Custom Field Template - Version 2.3.5

Version Description

  • Bugfix: WordPress 4.4.
Download this release

Release Info

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

Code changes from version 2.3.4 to 2.3.5

Files changed (2) hide show
  1. custom-field-template.php +62 -61
  2. readme.txt +5 -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.4
9
  Text Domain: custom-field-template
10
  Domain Path: /
11
  */
@@ -41,6 +41,7 @@ class custom_field_template {
41
  add_action( 'admin_print_scripts', array(&$this, 'custom_field_template_admin_scripts') );
42
  add_action( 'admin_head', array(&$this, 'custom_field_template_admin_head'), 100 );
43
  add_action( 'dbx_post_sidebar', array(&$this, 'custom_field_template_dbx_post_sidebar') );
 
44
 
45
  //add_action( 'edit_post', array(&$this, 'edit_meta_value'), 100 );
46
  add_action( 'save_post', array(&$this, 'edit_meta_value'), 100, 2 );
@@ -153,76 +154,75 @@ class custom_field_template {
153
  add_action( 'simple_edit_form', array(&$this, 'insert_custom_field'), 1 );
154
  add_action( 'edit_form_advanced', array(&$this, 'insert_custom_field'), 1 );
155
  add_action( 'edit_page_form', array(&$this, 'insert_custom_field'), 1 );
156
- } else {
157
- if ( substr($wp_version, 0, 3) >= '3.3' && file_exists(ABSPATH . 'wp-admin/includes/screen.php') ) :
158
- require_once(ABSPATH . 'wp-admin/includes/screen.php');
159
- endif;
160
- require_once(ABSPATH . 'wp-admin/includes/template.php');
161
 
162
- if ( function_exists('remove_meta_box') && !empty($options['custom_field_template_disable_default_custom_fields']) ) :
163
- remove_meta_box('postcustom', 'post', 'normal');
164
- remove_meta_box('postcustom', 'page', 'normal');
165
- remove_meta_box('pagecustomdiv', 'page', 'normal');
166
- endif;
 
 
 
167
 
168
- if ( !empty($options['custom_field_template_deploy_box']) ) :
169
- if ( !empty($options['custom_fields']) ) :
170
- $i = 0;
171
- foreach ( $options['custom_fields'] as $key => $val ) :
172
- if ( empty($options['custom_field_template_replace_the_title']) ) $title = __('Custom Field Template', 'custom-field-template');
173
- else $title = $options['custom_fields'][$key]['title'];
174
- if ( empty($options['custom_fields'][$key]['custom_post_type']) ) :
175
- if ( empty($options['custom_fields'][$key]['post_type']) ) :
176
- add_meta_box('cftdiv'.$i, $title, array(&$this, 'insert_custom_field'), 'post', 'normal', 'core', $key);
177
- add_meta_box('cftdiv'.$i, $title, array(&$this, 'insert_custom_field'), 'page', 'normal', 'core', $key);
178
- elseif ( $options['custom_fields'][$key]['post_type']=='post' ) :
179
- add_meta_box('cftdiv'.$i, $title, array(&$this, 'insert_custom_field'), 'post', 'normal', 'core', $key);
180
- elseif ( $options['custom_fields'][$key]['post_type']=='page' ) :
181
- add_meta_box('cftdiv'.$i, $title, array(&$this, 'insert_custom_field'), 'page', 'normal', 'core', $key);
182
- endif;
183
- else :
184
- $tmp_custom_post_type = explode(',', $options['custom_fields'][$key]['custom_post_type']);
185
- $tmp_custom_post_type = array_filter( $tmp_custom_post_type );
186
- $tmp_custom_post_type = array_unique(array_filter(array_map('trim', $tmp_custom_post_type)));
187
- foreach ( $tmp_custom_post_type as $type ) :
188
- add_meta_box('cftdiv'.$i, $title, array(&$this, 'insert_custom_field'), $type, 'normal', 'core', $key);
189
- endforeach;
190
  endif;
191
- $i++;
192
- endforeach;
193
- endif;
194
- else :
195
- add_meta_box('cftdiv', __('Custom Field Template', 'custom-field-template'), array(&$this, 'insert_custom_field'), 'post', 'normal', 'core');
196
- add_meta_box('cftdiv', __('Custom Field Template', 'custom-field-template'), array(&$this, 'insert_custom_field'), 'page', 'normal', 'core');
197
- endif;
198
-
199
- if ( empty($options['custom_field_template_deploy_box']) && is_array($options['custom_fields']) ) :
200
- $custom_post_type = array();
201
- foreach($options['custom_fields'] as $key => $val ) :
202
- if ( isset($options['custom_fields'][$key]['custom_post_type']) ) :
203
  $tmp_custom_post_type = explode(',', $options['custom_fields'][$key]['custom_post_type']);
204
  $tmp_custom_post_type = array_filter( $tmp_custom_post_type );
205
  $tmp_custom_post_type = array_unique(array_filter(array_map('trim', $tmp_custom_post_type)));
206
- $custom_post_type = array_merge($custom_post_type, $tmp_custom_post_type);
 
 
207
  endif;
 
208
  endforeach;
209
- if ( isset($custom_post_type) && is_array($custom_post_type) ) :
210
- foreach( $custom_post_type as $val ) :
211
- if ( function_exists('remove_meta_box') && !empty($options['custom_field_template_disable_default_custom_fields']) ) :
212
- remove_meta_box('postcustom', $val, 'normal');
213
- endif;
214
- add_meta_box('cftdiv', __('Custom Field Template', 'custom-field-template'), array(&$this, 'insert_custom_field'), $val, 'normal', 'core');
215
- if ( empty($options['custom_field_template_disable_custom_field_column']) ) :
216
- add_filter( 'manage_'.$val.'_posts_columns', array(&$this, 'add_manage_pages_columns') );
217
- endif;
218
- endforeach;
 
 
 
 
219
  endif;
 
 
 
 
 
 
 
 
 
 
 
220
  endif;
221
- }
222
-
223
- if( strstr($_SERVER['REQUEST_URI'], 'wp-admin/post-new.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/post.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/page-new.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/page.php') ) :
224
- add_action('admin_head', array(&$this, 'custom_field_template_admin_head_buffer') );
225
- add_action('admin_footer', array(&$this, 'custom_field_template_admin_footer_buffer') );
226
  endif;
227
  }
228
 
@@ -1109,6 +1109,7 @@ type = file';
1109
  $plugin_dir = dirname( plugin_basename(__FILE__) );
1110
  ?>
1111
  <style type="text/css">
 
1112
  div.grippie {
1113
  background:#EEEEEE url(<?php echo '../' . PLUGINDIR . '/' . $plugin_dir . '/js/'; ?>grippie.png) no-repeat scroll center 2px;
1114
  border-color:#DDDDDD;
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
  */
41
  add_action( 'admin_print_scripts', array(&$this, 'custom_field_template_admin_scripts') );
42
  add_action( 'admin_head', array(&$this, 'custom_field_template_admin_head'), 100 );
43
  add_action( 'dbx_post_sidebar', array(&$this, 'custom_field_template_dbx_post_sidebar') );
44
+ add_action( 'add_meta_boxes', array(&$this, 'custom_field_template_add_meta_boxes') );
45
 
46
  //add_action( 'edit_post', array(&$this, 'edit_meta_value'), 100 );
47
  add_action( 'save_post', array(&$this, 'edit_meta_value'), 100, 2 );
154
  add_action( 'simple_edit_form', array(&$this, 'insert_custom_field'), 1 );
155
  add_action( 'edit_form_advanced', array(&$this, 'insert_custom_field'), 1 );
156
  add_action( 'edit_page_form', array(&$this, 'insert_custom_field'), 1 );
157
+ }
 
 
 
 
158
 
159
+ if( strstr($_SERVER['REQUEST_URI'], 'wp-admin/post-new.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/post.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/page-new.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/page.php') ) :
160
+ add_action('admin_head', array(&$this, 'custom_field_template_admin_head_buffer') );
161
+ add_action('admin_footer', array(&$this, 'custom_field_template_admin_footer_buffer') );
162
+ endif;
163
+ }
164
+
165
+ function custom_field_template_add_meta_boxes() {
166
+ $options = $this->get_custom_field_template_data();
167
 
168
+ if ( function_exists('remove_meta_box') && !empty($options['custom_field_template_disable_default_custom_fields']) ) :
169
+ remove_meta_box('postcustom', 'post', 'normal');
170
+ remove_meta_box('postcustom', 'page', 'normal');
171
+ remove_meta_box('pagecustomdiv', 'page', 'normal');
172
+ endif;
173
+
174
+ if ( !empty($options['custom_field_template_deploy_box']) ) :
175
+ if ( !empty($options['custom_fields']) ) :
176
+ $i = 0;
177
+ foreach ( $options['custom_fields'] as $key => $val ) :
178
+ if ( empty($options['custom_field_template_replace_the_title']) ) $title = __('Custom Field Template', 'custom-field-template');
179
+ else $title = $options['custom_fields'][$key]['title'];
180
+ if ( empty($options['custom_fields'][$key]['custom_post_type']) ) :
181
+ if ( empty($options['custom_fields'][$key]['post_type']) ) :
182
+ add_meta_box('cftdiv'.$i, $title, array(&$this, 'insert_custom_field'), 'post', 'normal', 'core', $key);
183
+ add_meta_box('cftdiv'.$i, $title, array(&$this, 'insert_custom_field'), 'page', 'normal', 'core', $key);
184
+ elseif ( $options['custom_fields'][$key]['post_type']=='post' ) :
185
+ add_meta_box('cftdiv'.$i, $title, array(&$this, 'insert_custom_field'), 'post', 'normal', 'core', $key);
186
+ elseif ( $options['custom_fields'][$key]['post_type']=='page' ) :
187
+ add_meta_box('cftdiv'.$i, $title, array(&$this, 'insert_custom_field'), 'page', 'normal', 'core', $key);
 
 
188
  endif;
189
+ else :
 
 
 
 
 
 
 
 
 
 
 
190
  $tmp_custom_post_type = explode(',', $options['custom_fields'][$key]['custom_post_type']);
191
  $tmp_custom_post_type = array_filter( $tmp_custom_post_type );
192
  $tmp_custom_post_type = array_unique(array_filter(array_map('trim', $tmp_custom_post_type)));
193
+ foreach ( $tmp_custom_post_type as $type ) :
194
+ add_meta_box('cftdiv'.$i, $title, array(&$this, 'insert_custom_field'), $type, 'normal', 'core', $key);
195
+ endforeach;
196
  endif;
197
+ $i++;
198
  endforeach;
199
+ endif;
200
+ else :
201
+ add_meta_box('cftdiv', __('Custom Field Template', 'custom-field-template'), array(&$this, 'insert_custom_field'), 'post', 'normal', 'core');
202
+ add_meta_box('cftdiv', __('Custom Field Template', 'custom-field-template'), array(&$this, 'insert_custom_field'), 'page', 'normal', 'core');
203
+ endif;
204
+
205
+ if ( empty($options['custom_field_template_deploy_box']) && is_array($options['custom_fields']) ) :
206
+ $custom_post_type = array();
207
+ foreach($options['custom_fields'] as $key => $val ) :
208
+ if ( isset($options['custom_fields'][$key]['custom_post_type']) ) :
209
+ $tmp_custom_post_type = explode(',', $options['custom_fields'][$key]['custom_post_type']);
210
+ $tmp_custom_post_type = array_filter( $tmp_custom_post_type );
211
+ $tmp_custom_post_type = array_unique(array_filter(array_map('trim', $tmp_custom_post_type)));
212
+ $custom_post_type = array_merge($custom_post_type, $tmp_custom_post_type);
213
  endif;
214
+ endforeach;
215
+ if ( isset($custom_post_type) && is_array($custom_post_type) ) :
216
+ foreach( $custom_post_type as $val ) :
217
+ if ( function_exists('remove_meta_box') && !empty($options['custom_field_template_disable_default_custom_fields']) ) :
218
+ remove_meta_box('postcustom', $val, 'normal');
219
+ endif;
220
+ add_meta_box('cftdiv', __('Custom Field Template', 'custom-field-template'), array(&$this, 'insert_custom_field'), $val, 'normal', 'core');
221
+ if ( empty($options['custom_field_template_disable_custom_field_column']) ) :
222
+ add_filter( 'manage_'.$val.'_posts_columns', array(&$this, 'add_manage_pages_columns') );
223
+ endif;
224
+ endforeach;
225
  endif;
 
 
 
 
 
226
  endif;
227
  }
228
 
1109
  $plugin_dir = dirname( plugin_basename(__FILE__) );
1110
  ?>
1111
  <style type="text/css">
1112
+ #poststuff h3 { font-size: 14px; line-height: 1.4; margin: 0; padding: 8px 12px; }
1113
  div.grippie {
1114
  background:#EEEEEE url(<?php echo '../' . PLUGINDIR . '/' . $plugin_dir . '/js/'; ?>grippie.png) no-repeat scroll center 2px;
1115
  border-color:#DDDDDD;
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.2
7
- Stable tag: 2.3.4
8
  License: GPLv2 or later
9
 
10
  The Custom Field Template plugin extends the functionality of custom fields.
@@ -112,6 +112,9 @@ See the default template and modify it.
112
 
113
  == Changelog ==
114
 
 
 
 
115
  = 2.3.4 =
116
  * Bugfix: tag save.
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.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
 
113
  == Changelog ==
114
 
115
+ = 2.3.5 =
116
+ * Bugfix: WordPress 4.4.
117
+
118
  = 2.3.4 =
119
  * Bugfix: tag save.
120