Custom Field Template - Version 2.3.6

Version Description

  • Code cleaning.
  • Bugfix: Category ID and Page Template file name refinement.
Download this release

Release Info

Developer Hiroaki Miyashita
Plugin Icon 128x128 Custom Field Template
Version 2.3.6
Comparing to
See all releases

Code changes from version 2.3.5 to 2.3.6

Files changed (2) hide show
  1. custom-field-template.php +16 -16
  2. readme.txt +6 -2
custom-field-template.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://wpgogo.com/development/custom-field-template.html
5
  Description: This plugin adds the default custom fields on the Write Post/Page.
6
  Author: Hiroaki Miyashita
7
  Author URI: http://wpgogo.com/
8
- Version: 2.3.5
9
  Text Domain: custom-field-template
10
  Domain Path: /
11
  */
@@ -15,7 +15,7 @@ This program is based on the rc:custom_field_gui plugin written by Joshua Sigar.
15
  I appreciate your efforts, Joshua.
16
  */
17
 
18
- /* Copyright 2008 -2015 Hiroaki Miyashita
19
 
20
  This program is free software; you can redistribute it and/or modify
21
  it under the terms of the GNU General Public License as published by
@@ -35,7 +35,8 @@ I appreciate your efforts, Joshua.
35
  class custom_field_template {
36
  var $is_excerpt;
37
 
38
- function custom_field_template() {
 
39
  add_action( 'init', array(&$this, 'custom_field_template_init'), 100 );
40
  add_action( 'admin_menu', array(&$this, 'custom_field_template_admin_menu') );
41
  add_action( 'admin_print_scripts', array(&$this, 'custom_field_template_admin_scripts') );
@@ -75,18 +76,14 @@ class custom_field_template {
75
 
76
  add_filter( 'get_post_metadata', array(&$this, 'get_preview_postmeta'), 10, 4 );
77
  }
 
 
 
 
78
 
79
  function custom_field_template_init() {
80
  global $wp_version;
81
  $options = $this->get_custom_field_template_data();
82
-
83
- if ( function_exists('load_plugin_textdomain') ) {
84
- if ( !defined('WP_PLUGIN_DIR') ) {
85
- //load_plugin_textdomain('custom-field-template', str_replace( ABSPATH, '', dirname(__FILE__) ) );
86
- } else {
87
- load_plugin_textdomain('custom-field-template', false, dirname( plugin_basename(__FILE__) ) );
88
- }
89
- }
90
 
91
  if ( is_user_logged_in() && isset($_REQUEST['post']) && isset($_REQUEST['page']) && $_REQUEST['page'] == 'custom-field-template/custom-field-template.php' && $_REQUEST['cft_mode'] == 'selectbox' ) {
92
  echo $this->custom_field_template_selectbox();
@@ -2132,7 +2129,7 @@ jQuery(this).addClass("closed");
2132
 
2133
  function make_textarea( $name, $sid, $data, $post_id ) {
2134
  $cftnum = $rows = $cols = $tinyMCE = $htmlEditor = $mediaButton = $default = $hideKey = $label = $code = $class = $style = $wrap = $before = $after = $multipleButton = $mediaOffMedia = $mediaOffImage = $mediaOffVideo = $mediaOffAudio = $onclick = $ondblclick = $onkeydown = $onkeypress = $onkeyup = $onmousedown = $onmouseup = $onmouseover = $onmouseout = $onmousemove = $onfocus = $onblur = $onchange = $onselect = '';
2135
- $hide = $addfield = $out = $out_key = $out_value = $media = $editorcontainer_class = '';
2136
  extract($data);
2137
  $options = $this->get_custom_field_template_data();
2138
 
@@ -2465,7 +2462,7 @@ jQuery(this).addClass("closed");
2465
  return;
2466
  endif;
2467
  else :
2468
- if ( !empty($options['custom_fields'][$id]['category']) && ($_REQUEST['post_type']=='page' || $post->post_type=='page') && empty($options['custom_fields'][$id]['template_files']) ) :
2469
  return;
2470
  endif;
2471
  if ( !empty($options['custom_fields'][$id]['template_files']) && ($_REQUEST['post_type']!='page' && $post->post_type!='page') && empty($options['custom_fields'][$id]['category']) ) :
@@ -2476,10 +2473,10 @@ jQuery(this).addClass("closed");
2476
  if ( (!isset($post_id) || $post_id<0) && !empty($options['custom_fields'][$id]['category']) && $_REQUEST['cft_mode'] != 'ajaxload' )
2477
  return;
2478
 
2479
- if ( isset($post_id) && !empty($options['custom_fields'][$id]['category']) && !isset($options['posts'][$post_id]) && $options['posts'][$post_id] !== $id && $_REQUEST['cft_mode'] != 'ajaxload' )
2480
  return;
2481
 
2482
- if ( !isset($_REQUEST['id']) && !empty($options['custom_fields'][$id]['category']) && $_REQUEST['cft_mode'] == 'ajaxload' ) :
2483
  $category = explode(',', $options['custom_fields'][$id]['category']);
2484
  $category = array_filter( $category );
2485
  $category = array_unique(array_filter(array_map('trim', $category)));
@@ -2975,8 +2972,11 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
2975
  endforeach;
2976
  $out .= '</select> ';
2977
 
 
 
 
2978
  $out .= '<input type="button" class="button" value="' . __('Load', 'custom-field-template') . '" onclick="if(tinyMCEID.length) { for(i=0;i<tinyMCEID.length;i++) {tinyMCE.execCommand(\'mceRemoveControl\', false, tinyMCEID[i]);} tinyMCEID.length=0;};';
2979
- $out .= ' var cftloading_select = function() {jQuery.ajax({type: \'GET\', url: \'?page=custom-field-template/custom-field-template.php&cft_mode=ajaxload&id=\'+jQuery(\'#custom_field_template_select\').val()+\'&post=\'+jQuery(\'#post_ID\').val(), success: function(html) {';
2980
  if ( !empty($options['custom_field_template_replace_the_title']) ) :
2981
  $out .= 'jQuery(\'#cftdiv h3 span\').text(jQuery(\'#custom_field_template_select :selected\').text());';
2982
  endif;
5
  Description: This plugin adds the default custom fields on the Write Post/Page.
6
  Author: Hiroaki Miyashita
7
  Author URI: http://wpgogo.com/
8
+ Version: 2.3.6
9
  Text Domain: custom-field-template
10
  Domain Path: /
11
  */
15
  I appreciate your efforts, Joshua.
16
  */
17
 
18
+ /* Copyright 2008 -2016 Hiroaki Miyashita
19
 
20
  This program is free software; you can redistribute it and/or modify
21
  it under the terms of the GNU General Public License as published by
35
  class custom_field_template {
36
  var $is_excerpt;
37
 
38
+ function __construct() {
39
+ add_action( 'plugins_loaded', array(&$this, 'custom_field_template_plugins_loaded') );
40
  add_action( 'init', array(&$this, 'custom_field_template_init'), 100 );
41
  add_action( 'admin_menu', array(&$this, 'custom_field_template_admin_menu') );
42
  add_action( 'admin_print_scripts', array(&$this, 'custom_field_template_admin_scripts') );
76
 
77
  add_filter( 'get_post_metadata', array(&$this, 'get_preview_postmeta'), 10, 4 );
78
  }
79
+
80
+ function custom_field_template_plugins_loaded() {
81
+ load_plugin_textdomain('custom-field-template', false, plugin_basename( dirname( __FILE__ ) ) );
82
+ }
83
 
84
  function custom_field_template_init() {
85
  global $wp_version;
86
  $options = $this->get_custom_field_template_data();
 
 
 
 
 
 
 
 
87
 
88
  if ( is_user_logged_in() && isset($_REQUEST['post']) && isset($_REQUEST['page']) && $_REQUEST['page'] == 'custom-field-template/custom-field-template.php' && $_REQUEST['cft_mode'] == 'selectbox' ) {
89
  echo $this->custom_field_template_selectbox();
2129
 
2130
  function make_textarea( $name, $sid, $data, $post_id ) {
2131
  $cftnum = $rows = $cols = $tinyMCE = $htmlEditor = $mediaButton = $default = $hideKey = $label = $code = $class = $style = $wrap = $before = $after = $multipleButton = $mediaOffMedia = $mediaOffImage = $mediaOffVideo = $mediaOffAudio = $onclick = $ondblclick = $onkeydown = $onkeypress = $onkeyup = $onmousedown = $onmouseup = $onmouseover = $onmouseout = $onmousemove = $onfocus = $onblur = $onchange = $onselect = '';
2132
+ $hide = $addfield = $out = $out_key = $out_value = $media = $editorcontainer_class = $quicktags_hide = '';
2133
  extract($data);
2134
  $options = $this->get_custom_field_template_data();
2135
 
2462
  return;
2463
  endif;
2464
  else :
2465
+ if ( !empty($options['custom_fields'][$id]['category']) && ((isset($_REQUEST['post_type']) && $_REQUEST['post_type']=='page') || $post->post_type=='page') && empty($options['custom_fields'][$id]['template_files']) ) :
2466
  return;
2467
  endif;
2468
  if ( !empty($options['custom_fields'][$id]['template_files']) && ($_REQUEST['post_type']!='page' && $post->post_type!='page') && empty($options['custom_fields'][$id]['category']) ) :
2473
  if ( (!isset($post_id) || $post_id<0) && !empty($options['custom_fields'][$id]['category']) && $_REQUEST['cft_mode'] != 'ajaxload' )
2474
  return;
2475
 
2476
+ if ( isset($post_id) && !empty($options['custom_fields'][$id]['category']) && (!isset($options['posts'][$post_id]) || (isset($options['posts'][$post_id]) && $options['posts'][$post_id] !== $id)) && $_REQUEST['cft_mode'] != 'ajaxload' )
2477
  return;
2478
 
2479
+ if ( !isset($_REQUEST['id']) && !empty($options['custom_fields'][$id]['category']) && isset($_REQUEST['cft_mode']) && $_REQUEST['cft_mode'] == 'ajaxload' ) :
2480
  $category = explode(',', $options['custom_fields'][$id]['category']);
2481
  $category = array_filter( $category );
2482
  $category = array_unique(array_filter(array_map('trim', $category)));
2972
  endforeach;
2973
  $out .= '</select> ';
2974
 
2975
+ $post_type = '';
2976
+ if ( !empty($_REQUEST['post_type']) ) $post_type = '+\'&post_type='.esc_attr($_REQUEST['post_type']).'\'';
2977
+
2978
  $out .= '<input type="button" class="button" value="' . __('Load', 'custom-field-template') . '" onclick="if(tinyMCEID.length) { for(i=0;i<tinyMCEID.length;i++) {tinyMCE.execCommand(\'mceRemoveControl\', false, tinyMCEID[i]);} tinyMCEID.length=0;};';
2979
+ $out .= ' var cftloading_select = function() {jQuery.ajax({type: \'GET\', url: \'?page=custom-field-template/custom-field-template.php&cft_mode=ajaxload&id=\'+jQuery(\'#custom_field_template_select\').val()+\'&post=\'+jQuery(\'#post_ID\').val()'.$post_type.'+\'&page_template=\'+jQuery(\'#page_template\').val(), success: function(html) {';
2980
  if ( !empty($options['custom_field_template_replace_the_title']) ) :
2981
  $out .= 'jQuery(\'#cftdiv h3 span\').text(jQuery(\'#custom_field_template_select :selected\').text());';
2982
  endif;
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: Hiroaki Miyashita
3
  Donate link: http://wpgogo.com/development/custom-field-template.html
4
  Tags: custom field, custom fields, custom, fields, field, template, meta, custom field template, custom post type
5
  Requires at least: 2.1
6
- Tested up to: 4.4
7
- Stable tag: 2.3.5
8
  License: GPLv2 or later
9
 
10
  The Custom Field Template plugin extends the functionality of custom fields.
@@ -112,6 +112,10 @@ See the default template and modify it.
112
 
113
  == Changelog ==
114
 
 
 
 
 
115
  = 2.3.5 =
116
  * Bugfix: WordPress 4.4.
117
 
3
  Donate link: http://wpgogo.com/development/custom-field-template.html
4
  Tags: custom field, custom fields, custom, fields, field, template, meta, custom field template, custom post type
5
  Requires at least: 2.1
6
+ Tested up to: 4.5
7
+ Stable tag: 2.3.6
8
  License: GPLv2 or later
9
 
10
  The Custom Field Template plugin extends the functionality of custom fields.
112
 
113
  == Changelog ==
114
 
115
+ = 2.3.6 =
116
+ * Code cleaning.
117
+ * Bugfix: Category ID and Page Template file name refinement.
118
+
119
  = 2.3.5 =
120
  * Bugfix: WordPress 4.4.
121