| [ Index ] |
PHP Cross Reference of PageLines Framework |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * actions.admin.php 4 */ 5 6 /** 7 * Show Options Panel after theme activation 8 * 9 * @package PageLines Framework 10 * @subpackage Redirects 11 * @since 1.0.0 12 */ 13 if( is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php" ) 14 wp_redirect( admin_url( PL_DASH_URL.'&activated=true&pageaction=activated' ) ); 15 16 /** 17 * Add Javascript for Layout Controls from the Layout UI class 18 * 19 * @package PageLines Framework 20 * @subpackage LayoutUI 21 * @since 2.0.b3 22 */ 23 $layout_control_js = new PageLinesLayoutControl(); 24 add_action( 'pagelines_admin_head', array(&$layout_control_js, 'layout_control_javascript' ) ); 25 26 27 /** 28 * Admin Body Class 29 * 30 * Adds the 'pagelines_ui' class 31 * 32 * @package PageLines Framework 33 * @since ... 34 * 35 * @param $class 36 * 37 * @return string 38 */ 39 function pagelines_admin_body_class( $class ){ 40 41 $class = $class.'pagelines_ui'; 42 43 return $class; 44 } 45 /** 46 * Checks if PHP5 47 * 48 * Tests for installed version of PHP higher than 5.0 and prints message if version is found to be lower. 49 * 50 * @package PageLines Framework 51 * @subpackage Functions Library 52 * @since 4.0.0 53 */ 54 add_action( 'pagelines_before_optionUI', 'pagelines_check_php' ); 55 function pagelines_check_php(){ 56 if( floatval( phpversion() ) < 5.0 ){ 57 printf( __( "<div class='config-error'><h2>PHP Version Problem</h2>Looks like you are using PHP version: <strong>%s</strong>. To run this framework you will need PHP <strong>5.0</strong> or better...<br/><br/> Don't worry though! Just check with your host about a quick upgrade.</div>", 'pagelines' ), phpversion() ); 58 } 59 } 60 61 62 /** 63 * Ajax Callback 64 * 65 * AJAX OPTION SAVING 66 * Used to save via AJAX theme options and image uploads 67 * 68 * @package PageLines Framework 69 * @since 1.2.0 70 */ 71 add_action( 'wp_ajax_pagelines_ajax_post_action', 'pagelines_ajax_callback' ); 72 function pagelines_ajax_callback() { 73 /** This is how you get access to the database */ 74 global $wpdb; 75 76 $save_type = ( $_POST['type'] ) ? $_POST['type'] : null; 77 78 $setting = $_POST['setting']; 79 $button_id = $_POST['oid']; 80 81 $pieces = explode( 'OID', $_POST['oid'] ); 82 $oid = $pieces[0]; 83 $parent_oid = ( isset($pieces[1]) ) ? $pieces[1] : null; 84 85 // Uploads 86 if( $save_type == 'upload' ) { 87 88 89 $arr_file_type = wp_check_filetype( basename( $_FILES[$button_id]['name'] )); 90 91 $uploaded_file_type = $arr_file_type['type']; 92 93 // Set an array containing a list of acceptable formats 94 $allowed_file_types = array( 'image/jpg','image/jpeg','image/gif','image/png', 'image/x-icon'); 95 96 if( in_array( $uploaded_file_type, $allowed_file_types ) ) { 97 98 $filename = $_FILES[ $button_id ]; 99 $filename['name'] = preg_replace( '/[^a-zA-Z0-9._\-]/', '', $filename['name'] ); 100 101 $override['test_form'] = false; 102 $override['action'] = 'wp_handle_upload'; 103 104 $uploaded_file = wp_handle_upload( $filename, $override ); 105 106 $upload_tracking[] = $button_id; 107 108 plupop( $oid, $uploaded_file['url'], array( 'setting' => $setting, 'parent' => $parent_oid ) ); 109 110 $name = 'PageLines- ' . addslashes( $filename['name'] ); 111 112 $attachment = array( 113 'guid' => $uploaded_file['url'], 114 'post_mime_type' => $uploaded_file_type, 115 'post_title' => $name, 116 'post_content' => '', 117 'post_status' => 'inherit' 118 ); 119 120 $attach_id = wp_insert_attachment( $attachment, $uploaded_file['file'] ); 121 $attach_data = wp_generate_attachment_metadata( $attach_id, $uploaded_file['file'] ); 122 wp_update_attachment_metadata( $attach_id, $attach_data ); 123 124 } else 125 $uploaded_file['error'] = __( 'Unsupported file type!', 'pagelines' ); 126 127 if( !empty( $uploaded_file['error'] ) ) 128 echo sprintf( __('Upload Error: %s', 'pagelines' ) , $uploaded_file['error'] ); 129 else{ 130 //print_r($r); 131 echo $uploaded_file['url']; // Is the Response 132 133 } 134 } elseif( $save_type == 'image_reset' ){ 135 plupop( $oid, null, array( 'setting' => $setting, 'parent' => $parent_oid ) ); 136 } 137 138 die(); 139 } 140 141 /** 142 * (AJAX) Save Template Map 143 * 144 * Used to save via AJAX theme options and image uploads 145 * 146 * @package PageLines Framework 147 * @since ... 148 * 149 * @uses save_tempalte_map 150 */ 151 add_action( 'wp_ajax_pagelines_save_sortable', 'ajax_save_template_map' ); 152 function ajax_save_template_map() { 153 /** This is how you get access to the database */ 154 global $wpdb; 155 156 /** Full Template Map */ 157 $templatemap = get_option( PAGELINES_TEMPLATE_MAP ); 158 159 /** Order of the sections */ 160 $section_order = $_GET['orderdata']; 161 162 /** Get array / variable format */ 163 parse_str( $section_order ); 164 165 /** Selected Template */ 166 $selected_template = esc_attr( $_GET['template'] ); 167 168 /** Explode by hyphen to get heirarchy */ 169 $template_heirarchy = explode( '-', $selected_template ); 170 171 if( isset($template_heirarchy[1]) ) 172 $templatemap[$template_heirarchy[0]]['templates'][$template_heirarchy[1]]['sections'] = urlencode_deep( $section ); 173 else 174 $templatemap[$selected_template]['sections'] = $section; 175 176 save_template_map( $templatemap ); 177 178 PageLinesRenderCSS::flush_version( false ); 179 180 echo true; 181 182 die(); 183 } 184 185 /** 186 * Ajax Save Options Callback 187 * 188 * @package PageLines Framework 189 * @since ... 190 * 191 */ 192 add_action( 'wp_ajax_pagelines_ajax_save_option', 'pagelines_ajax_save_option_callback' ); 193 function pagelines_ajax_save_option_callback() { 194 /** This is how you get access to the database */ 195 global $wpdb; 196 197 $option_name = $_POST['option_name']; 198 $option_value = $_POST['option_value']; 199 200 update_option( $option_name, $option_value ); 201 202 die(); 203 } 204 205 /** 206 * Inline Help 207 * 208 * Load Inline help system. 209 * 210 * @package PageLines Framework 211 * @since ... 212 * 213 * @uses PageLines_Inline_Help 214 */ 215 add_action( 'admin_init', 'pagelines_inline_help' ); 216 function pagelines_inline_help() { 217 218 $pl_help = new PageLines_Inline_Help; 219 } 220 221 /** 222 * Page Columns 223 * 224 * Add custom columns to page/post views. 225 * 226 * @package PageLines Framework 227 * @since 2.1.3 228 * 229 * @param $columns 230 * @return array 231 */ 232 add_filter('manage_edit-page_columns', 'pl_page_columns'); 233 function pl_page_columns($columns) { 234 235 $columns['template'] = 'PageLines Template'; 236 237 return $columns; 238 } 239 240 /** 241 * Post Columns 242 * 243 * @package PageLines Framework 244 * @since 2.1.3 245 * 246 * @param $columns 247 * @return array 248 */ 249 add_filter('manage_edit-post_columns', 'pl_post_columns'); 250 function pl_post_columns($columns) { 251 252 $columns['feature'] = 'Featured Image'; 253 return $columns; 254 } 255 256 /** 257 * Posts Show Columns 258 * 259 * @package PageLines Framework 260 * @since ... 261 * 262 * @param $name 263 * 264 */ 265 add_action('manage_posts_custom_column', 'pl_posts_show_columns'); 266 function pl_posts_show_columns($name) { 267 global $post; 268 switch ($name) { 269 270 case 'feature': 271 if( has_post_thumbnail( $post->ID )) { 272 the_post_thumbnail( array(48,48) ); 273 } 274 275 break; 276 } 277 } 278 279 /** 280 * Page Show Columns 281 * 282 * @package PageLines Framework 283 * @since 2.1.3 284 * 285 * @param $name 286 * 287 * @uses pl_file_get_contents 288 */ 289 add_action( 'manage_pages_custom_column', 'pl_page_show_columns' ); 290 function pl_page_show_columns($name) { 291 global $post; 292 switch ($name) { 293 case 'template': 294 $template = get_post_meta( $post->ID, '_wp_page_template', true ); 295 296 if ( 'default' == $template ) { 297 _e( 'Default', 'pagelines' ); 298 break; 299 } 300 301 $file = sprintf( '%s/%s', PL_PARENT_DIR, $template ); 302 303 if ( !is_file( $file ) ) 304 $file = sprintf( '%s/%s', CHILD_DIR, $template ); 305 306 if ( !is_file( $file ) ) { 307 printf( '<a href="%s">%s</a>', admin_url( sprintf( 'post.php?post=%s&action=edit', $post->ID ) ), __( 'No Template Assigned', 'pagelines' ) ) ; 308 break; 309 } 310 311 $data = get_file_data( $file, array( 'name' => 'Template Name' ) ); 312 313 if ( is_array( $data ) && isset( $data['name'] ) ) 314 $template = $data['name']; 315 else 316 $template = __( 'Default', 'pagelines' ); 317 318 echo $template; 319 break; 320 321 case 'feature': 322 if( has_post_thumbnail( $post->ID )) { 323 the_post_thumbnail( array(48,48) ); 324 } 325 326 break; 327 } 328 } 329 330 /** 331 * Setup Versions and flush caches. 332 * 333 * @package PageLines Framework 334 * @since 2.2 335 */ 336 add_action( 'admin_init', 'pagelines_set_versions' ); 337 function pagelines_set_versions() { 338 if ( current_user_can( 'edit_themes' ) ) { 339 delete_transient( 'pagelines_sections_cache' ); 340 if( defined( 'PL_LESS_DEV' ) && PL_LESS_DEV ) 341 PageLinesRenderCSS::flush_version( false ); 342 } 343 set_theme_mod( 'pagelines_version', pl_get_theme_data( get_template_directory(), 'Version' ) ); 344 set_theme_mod( 'pagelines_child_version', pl_get_theme_data( get_stylesheet_directory(), 'Version' ) ); 345 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sat Apr 6 23:00:27 2013 | Cross-referenced by PHPXref 0.7.1 |