Changeset 3402937
- Timestamp:
- 11/26/2025 01:12:56 AM (3 weeks ago)
- Location:
- simple-post-template
- Files:
-
- 62 added
- 13 edited
-
tags/2.2.7 (added)
-
tags/2.2.7/admin (added)
-
tags/2.2.7/admin/class-advanced-content-templates-admin.php (added)
-
tags/2.2.7/admin/index.php (added)
-
tags/2.2.7/admin/partials (added)
-
tags/2.2.7/admin/partials/advanced-content-templates-admin-display.php (added)
-
tags/2.2.7/admin/partials/advanced-content-templates-admin-sidecar.php (added)
-
tags/2.2.7/admin/partials/advanced-content-templates-admin-upgrade.php (added)
-
tags/2.2.7/composer.json (added)
-
tags/2.2.7/composer.lock (added)
-
tags/2.2.7/includes (added)
-
tags/2.2.7/includes/class-advanced-content-templates-i18n.php (added)
-
tags/2.2.7/includes/class-advanced-content-templates-loader.php (added)
-
tags/2.2.7/includes/class-advanced-content-templates.php (added)
-
tags/2.2.7/includes/index.php (added)
-
tags/2.2.7/index.php (added)
-
tags/2.2.7/languages (added)
-
tags/2.2.7/languages/advanced-content-templates.pot (added)
-
tags/2.2.7/lib (added)
-
tags/2.2.7/lib/wordpress-simple-settings.php (added)
-
tags/2.2.7/license.txt (added)
-
tags/2.2.7/public (added)
-
tags/2.2.7/public/class-advanced-content-templates-public.php (added)
-
tags/2.2.7/public/index.php (added)
-
tags/2.2.7/readme.txt (added)
-
tags/2.2.7/simple-content-template.php (added)
-
tags/2.2.7/uninstall.php (added)
-
tags/2.2.7/vendor (added)
-
tags/2.2.7/vendor/autoload.php (added)
-
tags/2.2.7/vendor/composer (added)
-
tags/2.2.7/vendor/composer/ClassLoader.php (added)
-
tags/2.2.7/vendor/composer/InstalledVersions.php (added)
-
tags/2.2.7/vendor/composer/LICENSE (added)
-
tags/2.2.7/vendor/composer/autoload_classmap.php (added)
-
tags/2.2.7/vendor/composer/autoload_namespaces.php (added)
-
tags/2.2.7/vendor/composer/autoload_psr4.php (added)
-
tags/2.2.7/vendor/composer/autoload_real.php (added)
-
tags/2.2.7/vendor/composer/autoload_static.php (added)
-
tags/2.2.7/vendor/composer/installed.json (added)
-
tags/2.2.7/vendor/composer/installed.php (added)
-
tags/2.2.7/vendor/composer/platform_check.php (added)
-
tags/2.2.7/vendor/objectivco (added)
-
tags/2.2.7/vendor/objectivco/wordpress-simple-settings (added)
-
tags/2.2.7/vendor/objectivco/wordpress-simple-settings/.gitignore (added)
-
tags/2.2.7/vendor/objectivco/wordpress-simple-settings/LICENSE (added)
-
tags/2.2.7/vendor/objectivco/wordpress-simple-settings/README.md (added)
-
tags/2.2.7/vendor/objectivco/wordpress-simple-settings/composer.json (added)
-
tags/2.2.7/vendor/objectivco/wordpress-simple-settings/examples (added)
-
tags/2.2.7/vendor/objectivco/wordpress-simple-settings/examples/awesome-plugin (added)
-
tags/2.2.7/vendor/objectivco/wordpress-simple-settings/examples/awesome-plugin/awesome-plugin-admin.php (added)
-
tags/2.2.7/vendor/objectivco/wordpress-simple-settings/examples/awesome-plugin/awesome-plugin.php (added)
-
tags/2.2.7/vendor/objectivco/wordpress-simple-settings/examples/awesome-plugin/inc (added)
-
tags/2.2.7/vendor/objectivco/wordpress-simple-settings/examples/awesome-plugin/inc/wordpress-simple-settings.php (added)
-
tags/2.2.7/vendor/objectivco/wordpress-simple-settings/src (added)
-
tags/2.2.7/vendor/objectivco/wordpress-simple-settings/src/wordpress-simple-settings.php (added)
-
tags/2.2.7/vendor/objectivco/wp_tabbed_navigation (added)
-
tags/2.2.7/vendor/objectivco/wp_tabbed_navigation/.gitignore (added)
-
tags/2.2.7/vendor/objectivco/wp_tabbed_navigation/LICENSE (added)
-
tags/2.2.7/vendor/objectivco/wp_tabbed_navigation/README.md (added)
-
tags/2.2.7/vendor/objectivco/wp_tabbed_navigation/composer.json (added)
-
tags/2.2.7/vendor/objectivco/wp_tabbed_navigation/src (added)
-
tags/2.2.7/vendor/objectivco/wp_tabbed_navigation/src/class-wp-tabbed-navigation.php (added)
-
trunk/admin/class-advanced-content-templates-admin.php (modified) (15 diffs)
-
trunk/admin/partials/advanced-content-templates-admin-display.php (modified) (3 diffs)
-
trunk/admin/partials/advanced-content-templates-admin-sidecar.php (modified) (3 diffs)
-
trunk/admin/partials/advanced-content-templates-admin-upgrade.php (modified) (1 diff)
-
trunk/includes/class-advanced-content-templates-i18n.php (modified) (1 diff)
-
trunk/includes/class-advanced-content-templates-loader.php (modified) (6 diffs)
-
trunk/includes/class-advanced-content-templates.php (modified) (17 diffs)
-
trunk/lib/wordpress-simple-settings.php (modified) (9 diffs)
-
trunk/public/class-advanced-content-templates-public.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/simple-content-template.php (modified) (3 diffs)
-
trunk/vendor/composer/installed.php (modified) (2 diffs)
-
trunk/vendor/composer/platform_check.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
simple-post-template/trunk/admin/class-advanced-content-templates-admin.php
r2806059 r3402937 1 1 <?php 2 3 // Prevent direct access 4 if ( ! defined( 'ABSPATH' ) ) { 5 exit; 6 } 2 7 3 8 /** … … 54 59 * 55 60 * @since 1.0.0 56 * @param string $plugin_name The name of this plugin.57 * @param string $version The version of this plugin.61 * @param string $plugin_name The name of this plugin. 62 * @param string $version The version of this plugin. 58 63 */ 59 64 public function __construct( $plugin_name, $version, $plugin ) { 60 65 61 $this->plugin_name = $plugin_name; 62 $this->version = $version; 63 $this->plugin = $plugin; 64 66 $this->plugin_name = $plugin_name; 67 $this->version = $version; 68 $this->plugin = $plugin; 65 69 } 66 70 … … 84 88 */ 85 89 86 //wp_enqueue_style( $this->plugin_name , plugin_dir_url( __FILE__ ) . 'css/advanced-content-templates-admin.css', array(), $this->version, 'all' ); 87 90 // wp_enqueue_style( $this->plugin_name , plugin_dir_url( __FILE__ ) . 'css/advanced-content-templates-admin.css', array(), $this->version, 'all' ); 88 91 } 89 92 … … 107 110 */ 108 111 109 //wp_enqueue_script( $this->plugin_name , plugin_dir_url( __FILE__ ) . 'js/advanced-content-templates-admin.js', array( 'jquery' ), $this->version, false ); 110 112 // wp_enqueue_script( $this->plugin_name , plugin_dir_url( __FILE__ ) . 'js/advanced-content-templates-admin.js', array( 'jquery' ), $this->version, false ); 111 113 } 112 114 … … 121 123 global $wp_tabbed_navigation; 122 124 123 add_submenu_page( "edit.php?post_type={$this->plugin->post_type}", "Simple Content Templates Settings", "Settings", "manage_options", "sct-settings", array($this, 'admin_settings_page') );124 add_submenu_page( "edit.php?post_type={$this->plugin->post_type}", "Simple Content Templates Upgrade", "Upgrade", "manage_options", "sct-upgrade", array($this, 'admin_upgrade_page') );125 126 $wp_tabbed_navigation = new WP_Tabbed_Navigation( 'Simple Content Templates Settings');127 128 $wp_tabbed_navigation->add_tab( 'Settings', menu_page_url('sct-settings', false) );129 $wp_tabbed_navigation->add_tab( 'Upgrade', menu_page_url('sct-upgrade', false ) );125 add_submenu_page( 'edit.php?post_type=' . sanitize_key( $this->plugin->post_type ), 'Simple Content Templates Settings', 'Settings', 'manage_options', 'sct-settings', array( $this, 'admin_settings_page' ) ); 126 add_submenu_page( 'edit.php?post_type=' . sanitize_key( $this->plugin->post_type ), 'Simple Content Templates Upgrade', 'Upgrade', 'manage_options', 'sct-upgrade', array( $this, 'admin_upgrade_page' ) ); 127 128 $wp_tabbed_navigation = new WP_Tabbed_Navigation( 'Simple Content Templates Settings' ); 129 130 $wp_tabbed_navigation->add_tab( 'Settings', menu_page_url( 'sct-settings', false ) ); 131 $wp_tabbed_navigation->add_tab( 'Upgrade', menu_page_url( 'sct-upgrade', false ) ); 130 132 } 131 133 … … 137 139 */ 138 140 function admin_settings_page() { 139 include_once ('partials/advanced-content-templates-admin-display.php');141 include_once 'partials/advanced-content-templates-admin-display.php'; 140 142 } 141 143 142 144 /** 143 145 * admin_upgrade_page function 146 * 144 147 * @return void 145 148 */ 146 149 function admin_upgrade_page() { 147 include_once ('partials/advanced-content-templates-admin-upgrade.php');150 include_once 'partials/advanced-content-templates-admin-upgrade.php'; 148 151 } 149 152 … … 155 158 */ 156 159 function boxes() { 157 $settings = $this->plugin->get_setting('act_post_type_settings'); 158 159 if ( empty($settings) || ! is_array($settings) ) return; 160 161 foreach($settings as $post_type => $s) { 162 if( isset($s['show_ui']) && $s['show_ui'] == "true") { 163 add_meta_box( 'act_side_car_' . $post_type, 'Simple Content Templates', array($this, 'render_side_car'), $post_type, 'side', 'high'); 160 $settings = $this->plugin->get_setting( 'act_post_type_settings' ); 161 162 if ( empty( $settings ) || ! is_array( $settings ) ) { 163 return; 164 } 165 166 foreach ( $settings as $post_type => $s ) { 167 if ( isset( $s['show_ui'] ) && $s['show_ui'] == 'true' ) { 168 add_meta_box( 'act_side_car_' . sanitize_key( $post_type ), 'Simple Content Templates', array( $this, 'render_side_car' ), sanitize_key( $post_type ), 'side', 'high' ); 164 169 } 165 170 } … … 173 178 */ 174 179 function render_side_car() { 175 include_once ('partials/advanced-content-templates-admin-sidecar.php');180 include_once 'partials/advanced-content-templates-admin-sidecar.php'; 176 181 } 177 182 … … 182 187 * @return void 183 188 */ 184 function page_template_box() {189 function page_template_box() { 185 190 global $post; 186 191 187 if($post->post_type == $this->plugin->post_type) 188 add_meta_box( 'act_template_side_car', 'Template', array($this, 'render_template_side_car'), $this->plugin->post_type, 'side', 'high'); 192 if ( $post->post_type == $this->plugin->post_type ) { 193 add_meta_box( 'act_template_side_car', 'Template', array( $this, 'render_template_side_car' ), sanitize_key( $this->plugin->post_type ), 'side', 'high' ); 194 } 189 195 } 190 196 … … 198 204 global $post; 199 205 200 if ( 0 != count( get_page_templates() ) ): 201 $template = get_post_meta($post->ID, '_wp_page_template', true); 202 if( empty($template) ) $template = false; 203 ?> 206 if ( 0 != count( get_page_templates() ) ) : 207 $template = get_post_meta( $post->ID, '_wp_page_template', true ); 208 if ( empty( $template ) ) { 209 $template = false; 210 } 211 ?> 204 212 205 213 <select name="page_template" id="page_template"> 206 <option value= 'default'><?php _e('Default Template'); ?></option>207 <?php page_template_dropdown( $template); ?>214 <option value="default"><?php esc_html_e( 'Default Template', 'simple-post-template' ); ?></option> 215 <?php page_template_dropdown( $template ); ?> 208 216 </select> 209 217 … … 220 228 * @return void 221 229 */ 222 function save_template( $post_id) {223 if ( $parent_id = wp_is_post_revision($post_id))230 function save_template( $post_id ) { 231 if ( $parent_id = wp_is_post_revision( $post_id ) ) { 224 232 $post_id = $parent_id; 225 226 $template = get_post($parent_id); 227 228 if ( !is_object($template) ) return; 229 230 if( $template->post_type == $this->plugin->post_type && isset($_REQUEST['page_template']) ) { 231 232 if($_REQUEST['page_template'] !== 'default' ) { 233 update_post_meta($parent_id, '_wp_page_template', $_REQUEST['page_template']); 234 } else { 235 delete_post_meta($parent_id, '_wp_page_template'); 236 } 233 } 234 235 $template = get_post( $parent_id ); 236 237 if ( ! is_object( $template ) ) { 238 return; 239 } 240 241 // Check if we should process page template (use POST consistently) 242 if ( $template->post_type != $this->plugin->post_type || ! isset( $_POST['page_template'] ) ) { 243 return; 244 } 245 246 // Verify nonce before saving page template 247 if ( ! isset( $_POST['act_page_template_nonce'] ) || 248 ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['act_page_template_nonce'] ) ), 'act_save_page_template' ) ) { 249 return; // Silently fail to maintain compatibility 250 } 251 252 // Sanitize and process page template 253 $page_template = sanitize_text_field( wp_unslash( $_POST['page_template'] ) ); 254 255 if ( $page_template !== 'default' ) { 256 update_post_meta( $parent_id, '_wp_page_template', $page_template ); 257 } else { 258 delete_post_meta( $parent_id, '_wp_page_template' ); 259 } 260 } 261 262 /** 263 * Add nonce field for page template saving 264 * 265 * @access public 266 * @return void 267 */ 268 public function add_template_nonce_field() { 269 global $post; 270 if ( $post && $post->post_type == $this->plugin->post_type ) { 271 wp_nonce_field( 'act_save_page_template', 'act_page_template_nonce' ); 237 272 } 238 273 } … … 246 281 */ 247 282 function redirect_on_first_activate() { 248 if ( $this->plugin->get_setting('act_first_activate', false) ) {249 $this->plugin->delete_setting( 'act_first_activate');250 wp_ redirect( admin_url("edit.php?post_type={$this->plugin->post_type}&page=sct-settings") );283 if ( $this->plugin->get_setting( 'act_first_activate', false ) ) { 284 $this->plugin->delete_setting( 'act_first_activate' ); 285 wp_safe_redirect( admin_url( 'edit.php?post_type=' . sanitize_key( $this->plugin->post_type ) . '&page=sct-settings' ) ); 251 286 exit; 252 287 } … … 262 297 * @return void 263 298 */ 264 function template_load( $excerpt, $post) {299 function template_load( $excerpt, $post ) { 265 300 global $editing; 266 if( ! current_user_can('edit_posts') || $editing !== true ) return $excerpt; 301 if ( ! current_user_can( 'edit_posts' ) || $editing !== true ) { 302 return $excerpt; 303 } 304 305 // Verify nonce for manual template loading 306 if ( isset( $_REQUEST['act_template_load'] ) && 307 ( ! isset( $_REQUEST['act_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['act_nonce'] ) ), 'act_load_template' ) ) ) { 308 wp_die( 'Security check failed. Please try again.', 'Security Error', array( 'response' => 403 ) ); 309 } 267 310 268 311 $post_type = $post->post_type; 269 $settings = $this->plugin->get_setting('act_post_type_settings');312 $settings = $this->plugin->get_setting( 'act_post_type_settings' ); 270 313 271 314 // If there are no configured post types, bail 272 if ( empty($settings) ) return; 315 if ( empty( $settings ) ) { 316 return; 317 } 273 318 274 319 // Load the template 275 320 $template = false; 276 if ( ! empty($settings[$post_type]['auto_load']) && is_numeric($settings[$post_type]['auto_load']) ) {277 $template = get_post( $settings[ $post_type]['auto_load'] );278 } elseif ( isset($_REQUEST['act_template_load']) && is_numeric($_REQUEST['act_template_load']) ) {279 $template = get_post( $_REQUEST['act_template_load']);321 if ( ! empty( $settings[ $post_type ]['auto_load'] ) && is_numeric( $settings[ $post_type ]['auto_load'] ) ) { 322 $template = get_post( $settings[ $post_type ]['auto_load'] ); 323 } elseif ( isset( $_REQUEST['act_template_load'] ) && is_numeric( $_REQUEST['act_template_load'] ) ) { 324 $template = get_post( absint( wp_unslash( $_REQUEST['act_template_load'] ) ) ); 280 325 } 281 326 282 327 // Only proceed if we have a template 283 if ( $template !== false) {328 if ( $template !== false ) { 284 329 ob_start(); 285 330 286 if( isset($_REQUEST['post_id']) ) { 287 $post_id = $_REQUEST['post_id']; 288 } else $post_id = $post->ID; 331 // Get and sanitize post_id 332 $post_id = isset( $_REQUEST['post_id'] ) ? absint( wp_unslash( $_REQUEST['post_id'] ) ) : $post->ID; 333 334 // Verify edit permissions if using custom post_id 335 if ( isset( $_REQUEST['post_id'] ) && ! current_user_can( 'edit_post', $post_id ) ) { 336 wp_die( 'You do not have permission to edit this post.', 'Permission Error', array( 'response' => 403 ) ); 337 } 289 338 290 339 if ( $post_id > 0 ) { 291 $target_post = get_post( $post_id);340 $target_post = get_post( $post_id ); 292 341 } 293 342 294 $properties = get_object_vars($template);343 $properties = get_object_vars( $template ); 295 344 $excluded_properties = array( 296 345 'ID', … … 307 356 ); 308 357 309 $temp_post = array(); 310 $temp_post['ID'] = $post_id; 311 $temp_post['post_status'] = "draft"; 312 $empty_only_properties = apply_filters('act_protected_properties', array() ); 313 314 foreach($properties as $property => $value) { 315 if ( ! in_array($property, $excluded_properties) ) { 316 // Exclude post_title, if title already set on target post 317 if ( ( in_array($property, $empty_only_properties) && ! empty($target_post) && ! empty($target_post->$property) ) && $target_post->$property != "Auto Draft" ) continue; 318 319 /** 320 * act_template_property 321 * 322 * Filter template property before it is loaded. 323 * 324 * @since 2.0.0 325 * 326 * @param string $value The template property value 327 * @param string $property The template property being filtered 328 */ 329 $value = apply_filters('act_template_property', $value, $property); 330 331 $temp_post[$property] = iconv( mb_detect_encoding($value), "UTF-8//IGNORE", $value ); 358 $temp_post = array(); 359 $temp_post['ID'] = $post_id; 360 $temp_post['post_status'] = 'draft'; 361 $empty_only_properties = apply_filters( 'act_protected_properties', array() ); 362 363 foreach ( $properties as $property => $value ) { 364 // Skip excluded properties 365 if ( in_array( $property, $excluded_properties ) ) { 366 continue; 332 367 } 368 369 // Skip if property should be empty-only and already has value 370 if ( ( in_array( $property, $empty_only_properties ) && ! empty( $target_post ) && ! empty( $target_post->$property ) ) && $target_post->$property != 'Auto Draft' ) { 371 continue; 372 } 373 374 /** 375 * act_template_property 376 * 377 * Filter template property before it is loaded. 378 * 379 * @since 2.0.0 380 * 381 * @param string $value The template property value 382 * @param string $property The template property being filtered 383 */ 384 $value = apply_filters( 'act_template_property', $value, $property ); 385 386 $temp_post[ $property ] = iconv( mb_detect_encoding( $value ), 'UTF-8//IGNORE', $value ); 333 387 } 334 388 335 // Dynamic Fields 336 if( $this->plugin->get_php_enabled() == "true" ) { 337 $dynamic_fields = array('post_title','post_content','post_excerpt'); 338 339 foreach($dynamic_fields as $df) { 340 // Exclude post_title, if title already set on target post 341 if ( ( in_array($df, $empty_only_properties) && ! empty($target_post) && ! empty($target_post->$df) ) && $target_post->$df != "Auto Draft" ) continue; 342 343 ob_start(); 344 eval('?>'. html_entity_decode($temp_post[$df])); 345 $new = ob_get_clean(); 346 $temp_post[$df] = iconv( mb_detect_encoding($new), "UTF-8//IGNORE", $new ); 347 } 348 } 349 350 $temp_post = apply_filters('act_load_template', $temp_post); 351 352 wp_update_post($temp_post); 389 $temp_post = apply_filters( 'act_load_template', $temp_post ); 390 391 wp_update_post( $temp_post ); 353 392 354 393 ob_end_clean(); 355 394 356 do_action_ref_array( 'act_template_loaded', $post_id);357 358 wp_ redirect( get_edit_post_link($post_id, '') );395 do_action_ref_array( 'act_template_loaded', $post_id ); 396 397 wp_safe_redirect( get_edit_post_link( $post_id, '' ) ); 359 398 exit(); 360 399 } … … 364 403 365 404 function get_templates() { 366 return get_posts( array( 367 'posts_per_page' => -1, 368 'post_type' => $this->plugin->post_type, 369 'orderby' => 'post_title', 370 'order' => 'ASC', 371 'post_status' => array( 405 return get_posts( 406 array( 407 'posts_per_page' => -1, 408 'post_type' => $this->plugin->post_type, 409 'orderby' => 'post_title', 410 'order' => 'ASC', 411 'post_status' => array( 372 412 'publish', 373 413 'pending', 374 414 'future', 375 415 'private', 376 ) 416 ), 377 417 ) 378 418 ); -
simple-post-template/trunk/admin/partials/advanced-content-templates-admin-display.php
r2970365 r3402937 13 13 */ 14 14 15 $post_type_objects = $this->plugin->get_post_types();16 $templates = $this->get_templates();17 $act_post_type_settings = $this->plugin->get_setting( 'act_post_type_settings');15 $post_type_objects = $this->plugin->get_post_types(); 16 $templates = $this->get_templates(); 17 $act_post_type_settings = $this->plugin->get_setting( 'act_post_type_settings' ); 18 18 ?> 19 19 <div class="wrap"> … … 22 22 <?php $wp_tabbed_navigation->display_tabs(); ?> 23 23 24 <h3><?php _e('Settings'); ?></h3>24 <h3><?php esc_html_e( 'Settings', 'simple-post-template' ); ?></h3> 25 25 <p>Do you like Simple Content Templates? Help us out by <a target="_blank" href="https://wordpress.org/plugins/simple-post-template/">leaving us a review</a>!</p> 26 26 27 <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">27 <form method="post" action="<?php echo esc_url( isset( $_SERVER['REQUEST_URI'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '' ); ?>"> 28 28 <?php $this->plugin->the_nonce(); ?> 29 29 30 30 <table class="form-table"> 31 31 <tbody> 32 <?php foreach($post_type_objects as $pto): if ( ! in_array( $pto->name, array( 'post','page' ) ) ) continue; ?> 32 <?php 33 foreach ( $post_type_objects as $pto ) : 34 if ( ! in_array( $pto->name, array( 'post', 'page' ) ) ) { 35 continue;} 36 ?> 33 37 <tr> 34 <th scope="row" valign="top"><?php echo $pto->labels->name; ?></th>38 <th scope="row" valign="top"><?php echo esc_html( $pto->labels->name ); ?></th> 35 39 <td> 36 <label><input type="checkbox" name="<?php echo $this->plugin->get_field_name('act_post_type_settings'); ?>[<?php echo $pto->name; ?>][show_ui]" value="true" <?php if( isset($act_post_type_settings[$pto->name]['show_ui']) && $act_post_type_settings[$pto->name]['show_ui'] == "true" ) echo 'checked="checked"'; ?> /> Show UI</label><br /> 40 <label><input type="checkbox" name="<?php echo esc_attr( $this->plugin->get_field_name( 'act_post_type_settings' ) ); ?>[<?php echo esc_attr( $pto->name ); ?>][show_ui]" value="true" 41 <?php 42 if ( isset( $act_post_type_settings[ $pto->name ]['show_ui'] ) && $act_post_type_settings[ $pto->name ]['show_ui'] == 'true' ) { 43 checked( $act_post_type_settings[ $pto->name ]['show_ui'], 'true' ); 44 } 45 ?> 46 /> Show UI</label><br /> 37 47 <label>Auto Load Template: 38 <select name="<?php echo $this->plugin->get_field_name('act_post_type_settings'); ?>[<?php echo $pto->name; ?>][auto_load]">48 <select name="<?php echo esc_attr( $this->plugin->get_field_name( 'act_post_type_settings' ) ); ?>[<?php echo esc_attr( $pto->name ); ?>][auto_load]"> 39 49 <option value="false">None</option> 40 <?php foreach ($templates as $t): ?>41 <?php42 $key_exists = $act_post_type_settings[$pto->name] ?? false;43 $auto_load_id = $act_post_type_settings[$pto->name]['auto_load'] ?? false;44 $auto_load_current = $auto_load_id == $t->ID;50 <?php foreach ( $templates as $t ) : ?> 51 <?php 52 $key_exists = $act_post_type_settings[ $pto->name ] ?? false; 53 $auto_load_id = $act_post_type_settings[ $pto->name ]['auto_load'] ?? false; 54 $auto_load_current = $auto_load_id == $t->ID; 45 55 46 $selected_text = "";47 if ($key_exists && $auto_load_id && $auto_load_current) {48 $selected_text = "selected";49 }50 ?>51 <option value="<?php echo $t->ID; ?>" <?php echo $selected_text ?>><?php echo $t->post_title; ?></option>56 $selected_text = ''; 57 if ( $key_exists && $auto_load_id && $auto_load_current ) { 58 $selected_text = 'selected'; 59 } 60 ?> 61 <option value="<?php echo esc_attr( $t->ID ); ?>" <?php echo esc_attr( $selected_text ); ?>><?php echo esc_html( $t->post_title ); ?></option> 52 62 <?php endforeach; ?> 53 63 </select> … … 57 67 <?php endforeach; ?> 58 68 59 <?php do_action_ref_array( 'act_admin_page_after_row', array($this->plugin) ); ?>69 <?php do_action_ref_array( 'act_admin_page_after_row', array( $this->plugin ) ); ?> 60 70 </tbody> 61 71 </table> 62 72 63 <p class="submit"><input type="submit" class="button-primary" name="save" value="<?php _e('Save Changes','act_templates'); ?>" /></p>73 <p class="submit"><input type="submit" class="button-primary" name="save" value="<?php esc_attr_e( 'Save Changes', 'simple-post-template' ); ?>" /></p> 64 74 <div style="clear:both"></div> 65 75 </form> -
simple-post-template/trunk/admin/partials/advanced-content-templates-admin-sidecar.php
r2970365 r3402937 4 4 5 5 if ( empty( $templates ) ) { 6 echo "You don't have any content templates.";6 echo esc_html( "You don't have any content templates." ); 7 7 return; 8 } ;8 } 9 9 ?> 10 10 <div> … … 13 13 <option disabled selected value="nada">Choose one</option> 14 14 <?php foreach ( $templates as $template ) : ?> 15 <option value="<?php echo $template->ID; ?>"><?php echo $template->post_title; ?></option>15 <option value="<?php echo esc_attr( $template->ID ); ?>"><?php echo esc_html( $template->post_title ); ?></option> 16 16 <?php endforeach; ?> 17 17 </select> 18 18 19 19 <input class="button-primary" style="margin-top: 10px;" name="act_load_template" id="act_load_template" type="button" value="Load Template" /> 20 <input type="hidden" id="act_template_nonce_value" value="<?php echo esc_attr( wp_create_nonce('act_load_template') ); ?>" /> 21 <input type="hidden" id="act_post_id" value="<?php echo esc_attr($post->ID); ?>" /> 20 22 </div> 21 23 22 24 <div class="" style="padding: 12px; border-radius: 4px; background-color:#ffe01a; margin-top: 12px;"> 23 <h4 style="margin-bottom: 4px; margin-top: 0px;">Advanced Content Templates</h4>24 <p>Want more powerful features like custom fields, featured images, and taxonomies? Upgrade today!</p>25 <p style="font-style: italic;">P.S. You can save 25% on your pro upgrade with code <b>LITE25</b></p>26 <a class="button-secondary" target="_blank" href="https://www.advancedcontenttemplates.com/?utm_campaign=free&utm_source=wprepo">Check Out ACT</a>25 <h4 style="margin-bottom: 4px; margin-top: 0px;">Advanced Content Templates</h4> 26 <p>Want more powerful features like custom fields, featured images, and taxonomies? Upgrade today!</p> 27 <p style="font-style: italic;">P.S. You can save 25% on your pro upgrade with code <b>LITE25</b></p> 28 <a class="button-secondary" target="_blank" href="https://www.advancedcontenttemplates.com/?utm_campaign=free&utm_source=wprepo">Check Out ACT</a> 27 29 </div> 28 30 … … 33 35 34 36 var template = jQuery("#act_template option:selected").val(); 37 var nonce = jQuery('#act_template_nonce_value').val(); 38 var post_id = jQuery('#act_post_id').val(); 35 39 36 40 if ( 'nada' === template ) { 37 alert( "You need to actually select a content template to load, otherwise we would just be guessing!") 38 } else { 39 if( confirm('Are you sure? Loading this template may wipe out existing changes.') ) { 40 window.location = 'post-new.php?post_id=<?php echo $post->ID; ?>&act_template_load=' + template; 41 } 41 alert( "You need to actually select a content template to load, otherwise we would just be guessing!"); 42 return; 43 } 44 45 if ( confirm('Are you sure? Loading this template may wipe out existing changes.') ) { 46 window.location = 'post-new.php?post_id=' + post_id + '&act_template_load=' + template + '&act_nonce=' + encodeURIComponent(nonce); 42 47 } 43 48 -
simple-post-template/trunk/admin/partials/advanced-content-templates-admin-upgrade.php
r2970365 r3402937 13 13 */ 14 14 15 $post_type_objects = $this->plugin->get_post_types();16 $templates = $this->get_templates();17 $act_post_type_settings = $this->plugin->get_setting( 'act_post_type_settings');15 $post_type_objects = $this->plugin->get_post_types(); 16 $templates = $this->get_templates(); 17 $act_post_type_settings = $this->plugin->get_setting( 'act_post_type_settings' ); 18 18 ?> 19 19 <div class="wrap"> 20 <?php global $wp_tabbed_navigation; ?>21 <?php $wp_tabbed_navigation->display_tabs(); ?>20 <?php global $wp_tabbed_navigation; ?> 21 <?php $wp_tabbed_navigation->display_tabs(); ?> 22 22 23 <div class="" style="padding: 20px; border-radius: 4px; background-color:#ffe01a; margin-top: 20px; max-width: 500px;">24 <h2 style="font-size: 22px; margin-top: 0px;">You're missing out!</h2>25 <p style="font-size: 18px;">Advanced Content Templates has tons of bonus features, and it's growing all the time. Join over 600 other pro users and receive:</p>26 <ol style="font-size: 18px;">27 <li>Premium Support</li>28 <li>Featured Images</li>29 <li>Categories, Tags, and Custom Taxonomies</li>30 <li>Custom Fields</li>31 <li>Custom Post Type Support</li>32 <li>And much more!</li>33 </ol>34 35 <p style="font-size: 18px; font-style: italic;">P.S. You can save 25% on your pro upgrade with code <b>LITE25</b></p>23 <div class="" style="padding: 20px; border-radius: 4px; background-color:#ffe01a; margin-top: 20px; max-width: 500px;"> 24 <h2 style="font-size: 22px; margin-top: 0px;">You're missing out!</h2> 25 <p style="font-size: 18px;">Advanced Content Templates has tons of bonus features, and it's growing all the time. Join over 600 other pro users and receive:</p> 26 <ol style="font-size: 18px;"> 27 <li>Premium Support</li> 28 <li>Featured Images</li> 29 <li>Categories, Tags, and Custom Taxonomies</li> 30 <li>Custom Fields</li> 31 <li>Custom Post Type Support</li> 32 <li>And much more!</li> 33 </ol> 34 35 <p style="font-size: 18px; font-style: italic;">P.S. You can save 25% on your pro upgrade with code <b>LITE25</b></p> 36 36 37 <a class="button-secondary" style="font-size: 18px;" target="_blank" href="https://www.advancedcontenttemplates.com/?utm_campaign=free&utm_source=wprepo">Check Out Advanced Content Templates!</a>38 </div>37 <a class="button-secondary" style="font-size: 18px;" target="_blank" href="https://www.advancedcontenttemplates.com/?utm_campaign=free&utm_source=wprepo">Check Out Advanced Content Templates!</a> 38 </div> 39 39 </div> -
simple-post-template/trunk/includes/class-advanced-content-templates-i18n.php
r1620485 r3402937 44 44 45 45 load_plugin_textdomain( 46 ' advanced-content-templates',46 'simple-post-template', 47 47 false, 48 48 dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' 49 49 ); 50 51 50 } 52 51 } -
simple-post-template/trunk/includes/class-advanced-content-templates-loader.php
r1620485 r3402937 51 51 $this->actions = array(); 52 52 $this->filters = array(); 53 54 53 } 55 54 … … 58 57 * 59 58 * @since 1.0.0 60 * @param string $hook The name of the WordPress action that is being registered.61 * @param object $component A reference to the instance of the object on which the action is defined.62 * @param string $callback The name of the function definition on the $component.63 * @param int Optional $priority The priority at which the function should be fired.64 * @param int Optional $accepted_args The number of arguments that should be passed to the $callback.59 * @param string $hook The name of the WordPress action that is being registered. 60 * @param object $component A reference to the instance of the object on which the action is defined. 61 * @param string $callback The name of the function definition on the $component. 62 * @param int Optional $priority The priority at which the function should be fired. 63 * @param int Optional $accepted_args The number of arguments that should be passed to the $callback. 65 64 */ 66 65 public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { … … 72 71 * 73 72 * @since 1.0.0 74 * @param string $hook The name of the WordPress filter that is being registered.75 * @param object $component A reference to the instance of the object on which the filter is defined.76 * @param string $callback The name of the function definition on the $component.77 * @param int Optional $priority The priority at which the function should be fired.78 * @param int Optional $accepted_args The number of arguments that should be passed to the $callback.73 * @param string $hook The name of the WordPress filter that is being registered. 74 * @param object $component A reference to the instance of the object on which the filter is defined. 75 * @param string $callback The name of the function definition on the $component. 76 * @param int Optional $priority The priority at which the function should be fired. 77 * @param int Optional $accepted_args The number of arguments that should be passed to the $callback. 79 78 */ 80 79 public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { … … 88 87 * @since 1.0.0 89 88 * @access private 90 * @param array $hooks The collection of hooks that is being registered (that is, actions or filters).91 * @param string $hook The name of the WordPress filter that is being registered.92 * @param object $component A reference to the instance of the object on which the filter is defined.93 * @param string $callback The name of the function definition on the $component.94 * @param int Optional $priority The priority at which the function should be fired.95 * @param int Optional $accepted_args The number of arguments that should be passed to the $callback.89 * @param array $hooks The collection of hooks that is being registered (that is, actions or filters). 90 * @param string $hook The name of the WordPress filter that is being registered. 91 * @param object $component A reference to the instance of the object on which the filter is defined. 92 * @param string $callback The name of the function definition on the $component. 93 * @param int Optional $priority The priority at which the function should be fired. 94 * @param int Optional $accepted_args The number of arguments that should be passed to the $callback. 96 95 * @return type The collection of actions and filters registered with WordPress. 97 96 */ … … 103 102 'callback' => $callback, 104 103 'priority' => $priority, 105 'accepted_args' => $accepted_args 104 'accepted_args' => $accepted_args, 106 105 ); 107 106 108 107 return $hooks; 109 110 108 } 111 109 … … 124 122 add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); 125 123 } 126 127 124 } 128 129 125 } -
simple-post-template/trunk/includes/class-advanced-content-templates.php
r1746168 r3402937 39 39 * @access public 40 40 */ 41 var $post_type = "act_template";41 var $post_type = 'act_template'; 42 42 43 43 … … 50 50 * @access public 51 51 */ 52 var $prefix = "Simple_Content_Templates";52 var $prefix = 'Simple_Content_Templates'; 53 53 54 54 … … 61 61 * @access public 62 62 */ 63 var $short_prefix = "act_";63 var $short_prefix = 'act_'; 64 64 65 65 /** … … 103 103 104 104 parent::__construct(); 105 $this->plugin_name = 'advanced-content-templates';106 $this->version = CGD_SCT_VERSION;105 $this->plugin_name = 'advanced-content-templates'; 106 $this->version = CGD_SCT_VERSION; 107 107 108 108 $this->load_dependencies(); … … 134 134 * core plugin. 135 135 */ 136 require_once plugin_dir_path( dirname( __FILE__ )) . 'includes/class-advanced-content-templates-loader.php';136 require_once plugin_dir_path( __DIR__ ) . 'includes/class-advanced-content-templates-loader.php'; 137 137 138 138 /** … … 140 140 * of the plugin. 141 141 */ 142 require_once plugin_dir_path( dirname( __FILE__ )) . 'includes/class-advanced-content-templates-i18n.php';142 require_once plugin_dir_path( __DIR__ ) . 'includes/class-advanced-content-templates-i18n.php'; 143 143 144 144 /** 145 145 * The class responsible for defining all actions that occur in the Dashboard. 146 146 */ 147 require_once plugin_dir_path( dirname( __FILE__ )) . 'admin/class-advanced-content-templates-admin.php';147 require_once plugin_dir_path( __DIR__ ) . 'admin/class-advanced-content-templates-admin.php'; 148 148 149 149 /** … … 151 151 * side of the site. 152 152 */ 153 require_once plugin_dir_path( dirname( __FILE__ )) . 'public/class-advanced-content-templates-public.php';153 require_once plugin_dir_path( __DIR__ ) . 'public/class-advanced-content-templates-public.php'; 154 154 155 155 $this->loader = new Simple_Content_Templates_Loader(); … … 170 170 171 171 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); 172 173 172 } 174 173 … … 188 187 189 188 // The admin menus 190 $this->loader->add_action( 'admin_menu', $act_plugin_admin, 'admin_menus', 11);189 $this->loader->add_action( 'admin_menu', $act_plugin_admin, 'admin_menus', 11 ); 191 190 192 191 // Template Selector Metabox 193 $this->loader->add_action( 'add_meta_boxes', $act_plugin_admin, 'boxes' );192 $this->loader->add_action( 'add_meta_boxes', $act_plugin_admin, 'boxes' ); 194 193 195 194 // Save page template on template save (confusing wording I know) 196 $this->loader->add_action('save_post', $act_plugin_admin, 'save_template', 10, 1 ); 195 $this->loader->add_action( 'save_post', $act_plugin_admin, 'save_template', 10, 1 ); 196 197 // Add nonce field for page template saving 198 $this->loader->add_action( 'post_submitbox_misc_actions', $act_plugin_admin, 'add_template_nonce_field' ); 197 199 198 200 // Redirect to settings on first activate 199 $this->loader->add_action( 'admin_init', $act_plugin_admin, 'redirect_on_first_activate' );201 $this->loader->add_action( 'admin_init', $act_plugin_admin, 'redirect_on_first_activate' ); 200 202 201 203 // Actually load templates, yo 202 $this->loader->add_filter( 'default_excerpt', $act_plugin_admin, 'template_load', 1, 2);203 204 $this->loader->add_action( 'admin_init', $this, 'sct_upgrade', 1, 1);204 $this->loader->add_filter( 'default_excerpt', $act_plugin_admin, 'template_load', 1, 2 ); 205 206 $this->loader->add_action( 'admin_init', $this, 'sct_upgrade', 1, 1 ); 205 207 } 206 208 … … 217 219 218 220 // Register Post Type 219 $this->loader->add_action('init', $plugin_public, 'register_post_type', 0 ); 220 221 $this->loader->add_action( 'init', $plugin_public, 'register_post_type', 0 ); 221 222 } 222 223 … … 229 230 $this->loader->run(); 230 231 231 do_action( 'act_loaded');232 do_action( 'act_loaded' ); 232 233 } 233 234 … … 271 272 */ 272 273 function activate() { 273 if ( get_option('spt_version', false) === false ) {274 $this->update_setting( 'act_first_activate', true);274 if ( get_option( 'spt_version', false ) === false ) { 275 $this->update_setting( 'act_first_activate', true ); 275 276 276 277 // Default Post Setting 277 $this->add_setting('act_post_type_settings', array( 278 'post' => array( 279 'show_ui' => true, 278 $this->add_setting( 279 'act_post_type_settings', 280 array( 281 'post' => array( 282 'show_ui' => true, 283 ), 280 284 ) 281 ) );282 } 283 284 update_option( 'spt_version', CGD_SCT_VERSION);285 ); 286 } 287 288 update_option( 'spt_version', CGD_SCT_VERSION ); 285 289 } 286 290 … … 295 299 296 300 // Make sure we have a table from the old version 297 if ( $wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}simple_post_templates'") !== "{$wpdb->prefix}simple_post_templates" ) return; 298 299 // Make sure user is an admin 300 if ( isset($_GET['force_act_convert']) && ! current_user_can('manage_options') ) return; 301 302 $old_templates = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}simple_post_templates"); 303 304 foreach($old_templates as $ot) { 305 $post = array(); 306 $post['post_type'] = $this->post_type; 307 $post['post_status'] = 'publish'; 308 $post['post_title'] = $ot->title; 301 if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}simple_post_templates'" ) !== "{$wpdb->prefix}simple_post_templates" ) { 302 return; 303 } 304 305 $old_templates = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}simple_post_templates" ); 306 307 foreach ( $old_templates as $ot ) { 308 $post = array(); 309 $post['post_type'] = $this->post_type; 310 $post['post_status'] = 'publish'; 311 $post['post_title'] = $ot->title; 309 312 $post['post_content'] = $ot->content; 310 313 $post['post_excerpt'] = $ot->excerpt; 311 314 312 $result = wp_insert_post( $post);313 } 314 315 $this->update_setting( 'act_converted_spt', true);315 $result = wp_insert_post( $post ); 316 } 317 318 $this->update_setting( 'act_converted_spt', true ); 316 319 } 317 320 … … 333 336 */ 334 337 public function get_php_enabled() { 335 return apply_filters( 'act_enable_php_in_templates', false);338 return apply_filters( 'act_enable_php_in_templates', false ); 336 339 } 337 340 … … 344 347 public function get_post_types() { 345 348 $post_type_objects = array(); 346 $post_types = get_post_types( array('show_ui' => true) ); 347 unset($post_types['attachment']); 348 349 foreach($post_types as $pt) { 350 if ( $pt == $this->post_type ) continue; 351 $post_type_objects[] = get_post_type_object($pt); 349 $post_types = get_post_types( array( 'show_ui' => true ) ); 350 unset( $post_types['attachment'] ); 351 352 foreach ( $post_types as $pt ) { 353 if ( $pt == $this->post_type ) { 354 continue; 355 } 356 $post_type_objects[] = get_post_type_object( $pt ); 352 357 } 353 358 … … 357 362 /** 358 363 * Upgrade SCT <= 2.0.x to 2.1.x 364 * 359 365 * @return void 360 366 */ … … 363 369 364 370 // If table doesn't exist, bail 365 if ( $wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}simple_post_templates'") !== "{$wpdb->prefix}simple_post_templates" ) return; 366 367 // Force ACT convert 368 if ( isset($_GET['force_act_convert']) ) { 369 $this->convert_sct_to_act(); 370 } 371 372 if( $this->get_setting('act_converted_spt') === false && get_option('spt_version', false) !== false ) { 373 $old_templates = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}simple_post_templates"); 374 375 if ( ! empty($old_templates) ) { 376 $this->convert_sct_to_act(); 371 if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}simple_post_templates'" ) !== "{$wpdb->prefix}simple_post_templates" ) { 372 return; 373 } 374 375 // Check if force conversion not requested - handle automatic conversion 376 if ( ! isset( $_GET['force_act_convert'] ) ) { 377 // Automatic conversion check 378 if ( $this->get_setting( 'act_converted_spt' ) === false && get_option( 'spt_version', false ) !== false ) { 379 $old_templates = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}simple_post_templates" ); 380 381 if ( ! empty( $old_templates ) ) { 382 $this->convert_sct_to_act(); 383 } 377 384 } 378 } 385 return; 386 } 387 388 // Force ACT convert requested - verify nonce and admin permissions 389 if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['_wpnonce'] ) ), 'force_act_convert' ) ) { 390 wp_die( 'Security check failed. Please try again.', 'Security Error', array( 'response' => 403 ) ); 391 } 392 393 if ( ! current_user_can( 'manage_options' ) ) { 394 wp_die( 'You do not have permission to perform this action. Admin access required.', 'Permission Error', array( 'response' => 403 ) ); 395 } 396 397 // Perform conversion 398 $this->convert_sct_to_act(); 399 400 // Redirect after conversion to prevent re-triggering 401 wp_safe_redirect( admin_url( 'edit.php?post_type=act_template&converted=1' ) ); 402 exit; 379 403 } 380 404 } -
simple-post-template/trunk/lib/wordpress-simple-settings.php
r1620485 r3402937 24 24 public function __construct() { 25 25 // Set a default prefix 26 if( function_exists('get_called_class') && empty($this->prefix) ) $this->prefix = get_called_class(); 26 if ( function_exists( 'get_called_class' ) && empty( $this->prefix ) ) { 27 $this->prefix = get_called_class(); 28 } 27 29 28 30 $this->settings = $this->get_settings_obj( $this->prefix ); 29 add_action( 'admin_init', array($this, 'save_settings') );31 add_action( 'admin_init', array( $this, 'save_settings' ) ); 30 32 } 31 33 … … 40 42 * @return boolean True if successful, false otherwise 41 43 **/ 42 public function add_setting ( $setting = false, $value ) { 43 if($setting === false ) return false; 44 45 if ( ! isset($this->settings[$setting]) ) { 46 return $this->update_setting($setting, $value); 47 } else return false; 44 public function add_setting( $setting = false, $value ) { 45 if ( $setting === false ) { 46 return false; 47 } 48 49 if ( ! isset( $this->settings[ $setting ] ) ) { 50 return $this->update_setting( $setting, $value ); 51 } else { 52 return false; 53 } 48 54 } 49 55 … … 58 64 * @return boolean True if successful, false if not 59 65 **/ 60 public function update_setting ( $setting = false, $value ) { 61 if( $setting === false ) return false; 62 63 $this->settings = $this->get_settings_obj($this->prefix); 64 $this->settings[$setting] = $value; 65 66 return $this->set_settings_obj($this->settings); 66 public function update_setting( $setting = false, $value ) { 67 if ( $setting === false ) { 68 return false; 69 } 70 71 $this->settings = $this->get_settings_obj( $this->prefix ); 72 $this->settings[ $setting ] = $value; 73 74 return $this->set_settings_obj( $this->settings ); 67 75 } 68 76 … … 76 84 * @return boolean True if successful, false if not 77 85 **/ 78 public function delete_setting ( $setting = false ) { 79 if( $setting === false ) return false; 80 81 $this->settings = $this->get_settings_obj($this->prefix); 82 unset($this->settings[$setting]); 83 84 return $this->set_settings_obj($this->settings); 86 public function delete_setting( $setting = false ) { 87 if ( $setting === false ) { 88 return false; 89 } 90 91 $this->settings = $this->get_settings_obj( $this->prefix ); 92 unset( $this->settings[ $setting ] ); 93 94 return $this->set_settings_obj( $this->settings ); 85 95 } 86 96 … … 95 105 * @return mixed The value of the setting 96 106 **/ 97 public function get_setting ( $setting = false, $type = 'string' ) { 98 if($setting === false || ! isset($this->settings[$setting]) ) return false; 99 100 $value = $this->settings[$setting]; 101 102 if( strtolower($type) == 'array' && ! empty($value) ) { 103 $value = (array)explode(";", $value); 104 } 105 106 return apply_filters($this->prefix . '_get_setting', $value, $setting); 107 public function get_setting( $setting = false, $type = 'string' ) { 108 if ( $setting === false || ! isset( $this->settings[ $setting ] ) ) { 109 return false; 110 } 111 112 $value = $this->settings[ $setting ]; 113 114 if ( strtolower( $type ) == 'array' && ! empty( $value ) ) { 115 $value = (array) explode( ';', $value ); 116 } 117 118 return apply_filters( $this->prefix . '_get_setting', $value, $setting ); 107 119 } 108 120 … … 117 129 * @return string The name of the field 118 130 **/ 119 public function get_field_name( $setting, $type = 'string') {131 public function get_field_name( $setting, $type = 'string' ) { 120 132 return "{$this->prefix}_setting[$setting][$type]"; 121 133 } … … 142 154 **/ 143 155 public function save_settings() { 144 if( isset($_REQUEST["{$this->prefix}_setting"]) && check_admin_referer("save_{$this->prefix}_settings","{$this->prefix}_save") ) { 145 $new_settings = $_REQUEST["{$this->prefix}_setting"]; 146 147 foreach( $new_settings as $setting_name => $setting_value ) { 148 foreach( $setting_value as $type => $value ) { 149 if( $type == "array" ) { 150 if ( ! is_array($value) && ! empty($value) ) $value = (array)explode(";", $value); 151 152 $this->update_setting($setting_name, $value); 156 if ( isset( $_REQUEST[ "{$this->prefix}_setting" ] ) && check_admin_referer( "save_{$this->prefix}_settings", "{$this->prefix}_save" ) ) { 157 $new_settings = map_deep( wp_unslash( $_REQUEST[ "{$this->prefix}_setting" ] ), 'sanitize_text_field' ); 158 159 foreach ( $new_settings as $setting_name => $setting_value ) { 160 foreach ( $setting_value as $type => $value ) { 161 if ( $type == 'array' ) { 162 if ( ! is_array( $value ) && ! empty( $value ) ) { 163 $value = (array) explode( ';', $value ); 164 } 165 166 $this->update_setting( $setting_name, $value ); 153 167 } else { 154 $this->update_setting( $setting_name, $value);168 $this->update_setting( $setting_name, $value ); 155 169 } 156 170 } 157 171 } 158 172 159 do_action( "{$this->prefix}_settings_saved");173 do_action( "{$this->prefix}_settings_saved" ); 160 174 } 161 175 } … … 169 183 * @return void 170 184 **/ 171 public function get_settings_obj () {172 return get_option( "{$this->prefix}_settings", false);185 public function get_settings_obj() { 186 return get_option( "{$this->prefix}_settings", false ); 173 187 } 174 188 … … 182 196 * @return boolean True if successful, false otherwise 183 197 **/ 184 public function set_settings_obj ( $newobj ) {185 return update_option( "{$this->prefix}_settings", $newobj);198 public function set_settings_obj( $newobj ) { 199 return update_option( "{$this->prefix}_settings", $newobj ); 186 200 } 187 201 } -
simple-post-template/trunk/public/class-advanced-content-templates-public.php
r2970366 r3402937 21 21 * @author Clifton Griffin <[email protected]> 22 22 */ 23 class Simple_Content_Templates_Public 24 { 23 class Simple_Content_Templates_Public { 25 24 26 /**27 * The ID of this plugin.28 *29 * @since 1.0.030 * @access private31 * @var string $Simple_Content_Templates The ID of this plugin.32 */33 private $plugin_name;34 25 35 /**36 * The versionof this plugin.37 *38 * @since 1.0.039 * @access private40 * @var string $version The current versionof this plugin.41 */42 private $version;26 /** 27 * The ID of this plugin. 28 * 29 * @since 1.0.0 30 * @access private 31 * @var string $Simple_Content_Templates The ID of this plugin. 32 */ 33 private $plugin_name; 43 34 44 /**45 * Main instanceof this plugin.46 *47 * @since 1.0.048 * @access private49 * @var string $plugin_name The IDof this plugin.50 */51 private $plugin;35 /** 36 * The version of this plugin. 37 * 38 * @since 1.0.0 39 * @access private 40 * @var string $version The current version of this plugin. 41 */ 42 private $version; 52 43 53 /** 54 * Initialize the class and set its properties. 55 * 56 * @since 1.0.0 57 * @param string $Simple_Content_Templates The name of the plugin. 58 * @param string $version The version of this plugin. 59 */ 60 public function __construct($Simple_Content_Templates, $version, $plugin) 61 { 44 /** 45 * Main instance of this plugin. 46 * 47 * @since 1.0.0 48 * @access private 49 * @var string $plugin_name The ID of this plugin. 50 */ 51 private $plugin; 62 52 63 $this->plugin_name = $Simple_Content_Templates; 64 $this->version = $version; 65 $this->plugin = $plugin; 66 } 53 /** 54 * Initialize the class and set its properties. 55 * 56 * @since 1.0.0 57 * @param string $Simple_Content_Templates The name of the plugin. 58 * @param string $version The version of this plugin. 59 */ 60 public function __construct( $Simple_Content_Templates, $version, $plugin ) { 67 61 68 /** 69 * Registers the post type 70 * 71 * @access public 72 * @return void 73 */ 74 function register_post_type() 75 { 62 $this->plugin_name = $Simple_Content_Templates; 63 $this->version = $version; 64 $this->plugin = $plugin; 65 } 76 66 77 // Register Post Type 78 $menu_icon = "dashicons-welcome-write-blog"; 67 /** 68 * Registers the post type 69 * 70 * @access public 71 * @return void 72 */ 73 function register_post_type() { 79 74 80 register_post_type( 81 $this->plugin->post_type, 82 array( 83 'label' => 'Simple Content Templates', 84 'description' => '', 85 'public' => false, 86 'publicly_queryable' => false, 87 'has_archive' => false, 88 'show_ui' => true, 89 'show_in_menu' => true, 90 'capability_type' => 'post', 91 'menu_icon' => $menu_icon, 92 'hierarchical' => false, 93 'rewrite' => array('slug' => ''), 94 'query_var' => true, 95 'exclude_from_search' => true, 96 'show_in_nav_menus' => false, 97 'supports' => 98 array( 99 'title', 100 'editor', 101 'excerpt', 102 'comments', 103 'revisions' 104 ), 105 'labels' => 106 array ( 107 'name' => 'Simple Content Templates', 108 'singular_name' => 'Content Template', 109 'menu_name' => 'Content Templates', 110 'add_new' => 'Add Template', 111 'add_new_item' => 'Add New Template', 112 'edit' => 'Edit', 113 'edit_item' => 'Edit Template', 114 'new_item' => 'New Template', 115 'view' => 'View Template', 116 'view_item' => 'View Template', 117 'search_items' => 'Search Templates', 118 'not_found' => 'No Templates Found', 119 'not_found_in_trash' => 'No Templates Found in Trash', 120 'parent' => 'Parent Template', 121 ), 122 ) 123 ); 124 } 75 // Register Post Type 76 $menu_icon = 'dashicons-welcome-write-blog'; 77 78 register_post_type( 79 $this->plugin->post_type, 80 array( 81 'label' => 'Simple Content Templates', 82 'description' => '', 83 'public' => false, 84 'publicly_queryable' => false, 85 'has_archive' => false, 86 'show_ui' => true, 87 'show_in_menu' => true, 88 'capability_type' => 'post', 89 'menu_icon' => $menu_icon, 90 'hierarchical' => false, 91 'rewrite' => array( 'slug' => '' ), 92 'query_var' => true, 93 'exclude_from_search' => true, 94 'show_in_nav_menus' => false, 95 'supports' => 96 array( 97 'title', 98 'editor', 99 'excerpt', 100 'comments', 101 'revisions', 102 ), 103 'labels' => 104 array( 105 'name' => 'Simple Content Templates', 106 'singular_name' => 'Content Template', 107 'menu_name' => 'Content Templates', 108 'add_new' => 'Add Template', 109 'add_new_item' => 'Add New Template', 110 'edit' => 'Edit', 111 'edit_item' => 'Edit Template', 112 'new_item' => 'New Template', 113 'view' => 'View Template', 114 'view_item' => 'View Template', 115 'search_items' => 'Search Templates', 116 'not_found' => 'No Templates Found', 117 'not_found_in_trash' => 'No Templates Found in Trash', 118 'parent' => 'Parent Template', 119 ), 120 ) 121 ); 122 } 125 123 } -
simple-post-template/trunk/readme.txt
r3279407 r3402937 1 1 === Simple Content Templates for Blog Posts & Pages === 2 2 Contributors: clifgriffin, nodleredoy 3 Tags: post template, content template, post from template, templates, copy, clone, duplicate3 Tags: post template, template, copy, clone, duplicate post 4 4 Requires at least: 3.6 5 5 Tested up to: 6.8 6 Stable tag: 2.2.61 6 Stable tag: 2.2.7 7 License: GPL-2.0+ 8 License URI: http://www.gnu.org/licenses/gpl-2.0.txt 7 9 8 10 Create content templates for your posts and pages. When creating a new post or page use one of your content templates as the starting point! … … 37 39 == Changelog == 38 40 41 **Version 2.2.7** 42 43 * Fixes a possible - though highly unlikely CSRF security issue 44 * Fixes a couple small warnings that were showing up with the plugin-check 45 * Bump version 46 * Update dependencies 47 39 48 **Version 2.2.61** 40 49 -
simple-post-template/trunk/simple-content-template.php
r3279405 r3402937 17 17 * Plugin URI: https://www.advancedcontenttemplates.com/ 18 18 * Description: A simple to use content template system. Create similarly structured posts & pages with ease. 19 * Version: 2.2. 6119 * Version: 2.2.7 20 20 * Author: Clifton Griffin 21 21 * Author URI: https://objectiv.co 22 22 * License: GPL-2.0+ 23 23 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt 24 * Text Domain: advanced-content-templates24 * Text Domain: simple-post-template 25 25 * Domain Path: /languages 26 26 * Tested up to: 6.8 … … 28 28 29 29 // If this file is called directly, abort. 30 if ( ! defined('WPINC')) {31 die;30 if ( ! defined( 'WPINC' ) ) { 31 die; 32 32 } 33 33 34 define( 'CGD_SCT_VERSION', '2.2.61');35 define( 'CGD_SCT_NAME', 'Simple Content Templates');34 define( 'CGD_SCT_VERSION', '2.2.7' ); 35 define( 'CGD_SCT_NAME', 'Simple Content Templates' ); 36 36 37 37 /** 38 38 * Composer Include 39 39 */ 40 require dirname(__FILE__). '/vendor/autoload.php';40 require __DIR__ . '/vendor/autoload.php'; 41 41 42 42 /** … … 44 44 * dashboard-specific hooks, and public-facing site hooks. 45 45 */ 46 require plugin_dir_path( __FILE__) . 'includes/class-advanced-content-templates.php';46 require plugin_dir_path( __FILE__ ) . 'includes/class-advanced-content-templates.php'; 47 47 48 48 $Simple_Content_Templates = new Simple_Content_Templates(); 49 49 $Simple_Content_Templates->run(); 50 50 51 register_activation_hook( __FILE__, array( $Simple_Content_Templates, 'activate' ));52 register_deactivation_hook( __FILE__, array( $Simple_Content_Templates, 'deactivate' ));51 register_activation_hook( __FILE__, array( $Simple_Content_Templates, 'activate' ) ); 52 register_deactivation_hook( __FILE__, array( $Simple_Content_Templates, 'deactivate' ) ); -
simple-post-template/trunk/vendor/composer/installed.php
r3279405 r3402937 2 2 'root' => array( 3 3 'name' => '__root__', 4 'pretty_version' => 'dev- master',5 'version' => 'dev- master',6 'reference' => ' 0e563f6f3ef30738836d5debf315112a080163fc',4 'pretty_version' => 'dev-develop', 5 'version' => 'dev-develop', 6 'reference' => '8471f3bd401852fdef19f93344449d5f5e2f4e5b', 7 7 'type' => 'library', 8 8 'install_path' => __DIR__ . '/../../', … … 12 12 'versions' => array( 13 13 '__root__' => array( 14 'pretty_version' => 'dev- master',15 'version' => 'dev- master',16 'reference' => ' 0e563f6f3ef30738836d5debf315112a080163fc',14 'pretty_version' => 'dev-develop', 15 'version' => 'dev-develop', 16 'reference' => '8471f3bd401852fdef19f93344449d5f5e2f4e5b', 17 17 'type' => 'library', 18 18 'install_path' => __DIR__ . '/../../', -
simple-post-template/trunk/vendor/composer/platform_check.php
r2970365 r3402937 20 20 } 21 21 } 22 trigger_error( 23 'Composer detected issues in your platform: ' . implode(' ', $issues), 24 E_USER_ERROR 22 throw new \RuntimeException( 23 'Composer detected issues in your platform: ' . implode(' ', $issues) 25 24 ); 26 25 }
Note: See TracChangeset
for help on using the changeset viewer.