Custom Field Template - Version 2.4.4

Version Description

  • Code cleaning.
  • Bugfix: media picker for pages.
  • Bugfix: quick edit for custom post types.
Download this release

Release Info

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

Code changes from version 2.4.3 to 2.4.4

Files changed (2) hide show
  1. custom-field-template.php +42 -28
  2. readme.txt +9 -4
custom-field-template.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
  /*
3
  Plugin Name: Custom Field Template
4
- 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.4.3
9
  Text Domain: custom-field-template
10
  Domain Path: /
11
  */
@@ -43,8 +43,9 @@ class custom_field_template {
43
  add_action( 'admin_menu', array(&$this, 'custom_field_template_admin_menu') );
44
  add_action( 'admin_print_scripts', array(&$this, 'custom_field_template_admin_scripts') );
45
  add_action( 'admin_head', array(&$this, 'custom_field_template_admin_head'), 100 );
46
- add_action( 'edit_form_advanced', array(&$this, 'custom_field_template_edit_form_advanced') );
47
  add_action( 'add_meta_boxes', array(&$this, 'custom_field_template_add_meta_boxes') );
 
 
48
 
49
  //add_action( 'edit_post', array(&$this, 'edit_meta_value'), 100 );
50
  add_action( 'save_post', array(&$this, 'edit_meta_value'), 100, 2 );
@@ -172,7 +173,7 @@ class custom_field_template {
172
  remove_meta_box('postcustom', 'page', 'normal');
173
  remove_meta_box('pagecustomdiv', 'page', 'normal');
174
  endif;
175
-
176
  if ( !empty($options['custom_field_template_deploy_box']) ) :
177
  if ( !empty($options['custom_fields']) ) :
178
  $i = 0;
@@ -326,7 +327,7 @@ class custom_field_template {
326
  $this->install_custom_field_template_css();
327
  $options = $this->get_custom_field_template_data();
328
  }
329
-
330
  $out = '';
331
  $out .= '<fieldset style="clear:both;">' . "\n";
332
  $out .= '<div class="inline-edit-group">';
@@ -645,7 +646,7 @@ class custom_field_template {
645
  $flag = 0;
646
  $content = $output = '';
647
  foreach($data as $key => $val) :
648
- if ( substr($key, 0, 1) == '_' || !$val[0] ) continue;
649
  $content .= '<p class="key">' . $key . '</p>' . "\n";
650
  foreach($val as $val2) :
651
  $val2 = htmlspecialchars($val2, ENT_QUOTES);
@@ -695,23 +696,27 @@ class custom_field_template {
695
  }
696
 
697
  function add_manage_posts_columns($columns) {
698
- $new_columns = array();
699
  foreach($columns as $key => $val) :
700
  $new_columns[$key] = $val;
701
  if ( $key == 'tags' )
702
  $new_columns['custom-fields'] = __('Custom Fields', 'custom-field-template');
703
- endforeach;
704
- return $new_columns;
 
 
705
  }
706
 
707
  function add_manage_pages_columns($columns) {
708
- $new_columns = array();
709
  foreach($columns as $key => $val) :
710
  $new_columns[$key] = $val;
711
  if ( $key == 'author' )
712
  $new_columns['custom-fields'] = __('Custom Fields', 'custom-field-template');
713
- endforeach;
714
- return $new_columns;
 
 
715
  }
716
 
717
  function media_send_to_custom_field($html) {
@@ -1759,7 +1764,7 @@ hideKey = true<br />
1759
  <h3><?php _e('CMS x WP', 'custom-field-template'); ?></h3>
1760
  <div class="inside">
1761
  <p><?php _e('There are much more plugins which are useful for developing business websites such as membership sites or ec sites. You could totally treat WordPress as CMS by use of CMS x WP plugins.', 'custom-field-template'); ?></p>
1762
- <p style="text-align:center"><a href="http://www.cmswp.jp/" target="_blank"><img src="<?php echo get_option('siteurl') . '/' . PLUGINDIR . '/' . $plugin_dir . '/js/'; ?>cmswp.jpg" width="125" height="125" alt="CMSxWP" /></a><br /><a href="http://www.cmswp.jp/" target="_blank"><?php _e('WordPress plugin sales site: CMS x WP', 'custom-field-template'); ?></a></p>
1763
  </div>
1764
  </div>
1765
  <?php
@@ -2475,27 +2480,33 @@ jQuery(this).addClass("closed");
2475
  endif;
2476
  endif;
2477
 
2478
- if ( (!isset($post_id) || $post_id<0) && !empty($options['custom_fields'][$id]['category']) && $_REQUEST['cft_mode'] != 'ajaxload' )
2479
  return;
2480
-
2481
- 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' )
2482
  return;
2483
-
2484
- if ( !isset($_REQUEST['id']) && !empty($options['custom_fields'][$id]['category']) && isset($_REQUEST['cft_mode']) && $_REQUEST['cft_mode'] == 'ajaxload' ) :
2485
  $category = explode(',', $options['custom_fields'][$id]['category']);
2486
  $category = array_filter( $category );
2487
  $category = array_unique(array_filter(array_map('trim', $category)));
2488
-
 
 
 
 
 
 
2489
  if ( !empty($_REQUEST['tax_input']) && is_array($_REQUEST['tax_input']) ) :
2490
  foreach($_REQUEST['tax_input'] as $key => $val) :
2491
  foreach($val as $key2 => $val2 ) :
2492
- if ( in_array($val2, $category) ) : $notreturn = 1; break; endif;;
2493
  endforeach;
2494
  endforeach;
2495
  else :
2496
  if ( !empty($_REQUEST['post_category']) && is_array($_REQUEST['post_category']) ) :
2497
  foreach($_REQUEST['post_category'] as $val) :
2498
- if ( in_array($val, $category) ) : $notreturn = 1; break; endif;;
2499
  endforeach;
2500
  endif;
2501
  endif;
@@ -2623,7 +2634,9 @@ jQuery(this).addClass("closed");
2623
  list($out_all,$out_key,$out_value) = $this->make_textarea( $title, $parentSN, $data, $post_id );
2624
  }
2625
  else if( $data['type'] == 'file' ) {
2626
- list($out_all,$out_key,$out_value) = $this->make_file( $title, $parentSN, $data, $post_id );
 
 
2627
  }
2628
  if ( isset($options['custom_fields'][$id]['format']) && is_numeric($options['custom_fields'][$id]['format']) ) :
2629
  $duplicator = '['.$title.']';
@@ -2802,7 +2815,7 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
2802
  else :
2803
  $out .= '<div>&nbsp;</div>';
2804
  endif;
2805
-
2806
  $out .= '<div id="cft'.$suffix.'" class="cft">';
2807
  $out .= $body;
2808
  $out .= '</div>';
@@ -3621,6 +3634,7 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
3621
  foreach( $replace as $rkey => $rval ) :
3622
  $replace_val[$rkey] = "";
3623
  $class = "";
 
3624
  $default = array();
3625
  switch ( $rval['type'] ) :
3626
  case 'text':
@@ -3664,7 +3678,7 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
3664
  endforeach;
3665
  $replace_val[$rkey] .= '</ul>';
3666
  else :
3667
- if ( $_REQUEST['cftsearch'][rawurlencode($key)][$rkey][0] == esc_attr(trim($values[0])) )
3668
  $checked = ' checked="checked"';
3669
  $replace_val[$rkey] .= '<label><input type="checkbox" name="cftsearch[' . rawurlencode($key) . '][' . $rkey . '][]" value="' . esc_attr(trim($values[0])) . '"' . $class . $checked . ' /> ';
3670
  if ( $valueLabel[0] ) $replace_val[$rkey] .= stripcslashes(trim($valueLabel[0]));
@@ -3702,7 +3716,7 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
3702
  endforeach;
3703
  $replace_val[$rkey] .= '</ul>';
3704
  else :
3705
- if ( $_REQUEST['cftsearch'][rawurlencode($key)][$rkey][0] == esc_attr(trim($values[0])) )
3706
  $checked = ' checked="checked"';
3707
  $replace_val[$rkey] .= '<label><input type="radio" name="cftsearch[' . rawurlencode($key) . '][]" value="' . esc_attr(trim($values[0])) . '"' . $class . $checked . ' /> ';
3708
  if ( $valueLabel[0] ) $replace_val[$rkey] .= stripcslashes(trim($valueLabel[0]));
@@ -3725,7 +3739,7 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
3725
  $j=0;
3726
  foreach ( $values as $metaval ) :
3727
  $metaval = trim($metaval);
3728
- if ( in_array($metavalue, $default) && !$_REQUEST['cftsearch'][rawurlencode($key)][$rkey] )
3729
  $checked = ' checked="checked"';
3730
 
3731
  if ( isset($_REQUEST['cftsearch']) && $_REQUEST['cftsearch'][rawurlencode($key)][$rkey][0] == $metaval ) $selected = ' selected="selected"';
@@ -3906,7 +3920,7 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
3906
  if ( $val3 ) :
3907
  if ( $ch == 0 ) : $where .= ' AND (';
3908
  else :
3909
- if ( $replace[$key][$key2]['type'] == 'checkbox' || !$replace[$key][$key2]['type'] ) $where .= ' OR ';
3910
  else $where .= ' AND ';
3911
  endif;
3912
  if ( !isset($replace[$key][$key2]['operator']) ) $replace[$key][$key2]['operator'] = '';
1
  <?php
2
  /*
3
  Plugin Name: Custom Field Template
4
+ Plugin URI: https://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: https://wpgogo.com/
8
+ Version: 2.4.4
9
  Text Domain: custom-field-template
10
  Domain Path: /
11
  */
43
  add_action( 'admin_menu', array(&$this, 'custom_field_template_admin_menu') );
44
  add_action( 'admin_print_scripts', array(&$this, 'custom_field_template_admin_scripts') );
45
  add_action( 'admin_head', array(&$this, 'custom_field_template_admin_head'), 100 );
 
46
  add_action( 'add_meta_boxes', array(&$this, 'custom_field_template_add_meta_boxes') );
47
+ add_action( 'edit_form_advanced', array(&$this, 'custom_field_template_edit_form_advanced') );
48
+ add_action( 'edit_page_form', array(&$this, 'custom_field_template_edit_form_advanced') );
49
 
50
  //add_action( 'edit_post', array(&$this, 'edit_meta_value'), 100 );
51
  add_action( 'save_post', array(&$this, 'edit_meta_value'), 100, 2 );
173
  remove_meta_box('postcustom', 'page', 'normal');
174
  remove_meta_box('pagecustomdiv', 'page', 'normal');
175
  endif;
176
+
177
  if ( !empty($options['custom_field_template_deploy_box']) ) :
178
  if ( !empty($options['custom_fields']) ) :
179
  $i = 0;
327
  $this->install_custom_field_template_css();
328
  $options = $this->get_custom_field_template_data();
329
  }
330
+
331
  $out = '';
332
  $out .= '<fieldset style="clear:both;">' . "\n";
333
  $out .= '<div class="inline-edit-group">';
646
  $flag = 0;
647
  $content = $output = '';
648
  foreach($data as $key => $val) :
649
+ if ( is_protected_meta($key) ) continue;
650
  $content .= '<p class="key">' . $key . '</p>' . "\n";
651
  foreach($val as $val2) :
652
  $val2 = htmlspecialchars($val2, ENT_QUOTES);
696
  }
697
 
698
  function add_manage_posts_columns($columns) {
699
+ /*$new_columns = array();
700
  foreach($columns as $key => $val) :
701
  $new_columns[$key] = $val;
702
  if ( $key == 'tags' )
703
  $new_columns['custom-fields'] = __('Custom Fields', 'custom-field-template');
704
+ endforeach;*/
705
+
706
+ $columns['custom-fields'] = __('Custom Fields', 'custom-field-template');
707
+ return $columns;
708
  }
709
 
710
  function add_manage_pages_columns($columns) {
711
+ /*$new_columns = array();
712
  foreach($columns as $key => $val) :
713
  $new_columns[$key] = $val;
714
  if ( $key == 'author' )
715
  $new_columns['custom-fields'] = __('Custom Fields', 'custom-field-template');
716
+ endforeach;*/
717
+
718
+ $columns['custom-fields'] = __('Custom Fields', 'custom-field-template');
719
+ return $columns;
720
  }
721
 
722
  function media_send_to_custom_field($html) {
1764
  <h3><?php _e('CMS x WP', 'custom-field-template'); ?></h3>
1765
  <div class="inside">
1766
  <p><?php _e('There are much more plugins which are useful for developing business websites such as membership sites or ec sites. You could totally treat WordPress as CMS by use of CMS x WP plugins.', 'custom-field-template'); ?></p>
1767
+ <p style="text-align:center"><a href="https://www.cmswp.jp/" target="_blank"><img src="<?php echo get_option('siteurl') . '/' . PLUGINDIR . '/' . $plugin_dir . '/js/'; ?>cmswp.jpg" width="125" height="125" alt="CMSxWP" /></a><br /><a href="https://www.cmswp.jp/" target="_blank"><?php _e('WordPress plugin sales site: CMS x WP', 'custom-field-template'); ?></a></p>
1768
  </div>
1769
  </div>
1770
  <?php
2480
  endif;
2481
  endif;
2482
 
2483
+ if ( (!isset($post_id) || $post_id<0) && !empty($options['custom_fields'][$id]['category']) && (isset($_REQUEST['cft_mode']) && $_REQUEST['cft_mode'] != 'ajaxload') )
2484
  return;
2485
+
2486
+ 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)) && ((isset($_REQUEST['cft_mode']) && $_REQUEST['cft_mode'] != 'ajaxload') || (!isset($_REQUEST['cft_mode']) && empty($options['custom_field_template_deploy_box']))) )
2487
  return;
2488
+
2489
+ if ( !isset($_REQUEST['id']) && !empty($options['custom_fields'][$id]['category']) && ((isset($_REQUEST['cft_mode']) && $_REQUEST['cft_mode'] == 'ajaxload') || (!isset($_REQUEST['cft_mode']) && !empty($options['custom_field_template_deploy_box']))) ) :
2490
  $category = explode(',', $options['custom_fields'][$id]['category']);
2491
  $category = array_filter( $category );
2492
  $category = array_unique(array_filter(array_map('trim', $category)));
2493
+
2494
+ if ( !empty($options['custom_field_template_deploy_box']) ) :
2495
+ $categories = get_the_category($post_id);
2496
+ $cats = array();
2497
+ if ( is_array($categories) ) foreach($categories as $cat) $_REQUEST['post_category'][] = $cat->cat_ID;
2498
+ endif;
2499
+
2500
  if ( !empty($_REQUEST['tax_input']) && is_array($_REQUEST['tax_input']) ) :
2501
  foreach($_REQUEST['tax_input'] as $key => $val) :
2502
  foreach($val as $key2 => $val2 ) :
2503
+ if ( in_array($val2, $category) ) : $notreturn = 1; break; endif;
2504
  endforeach;
2505
  endforeach;
2506
  else :
2507
  if ( !empty($_REQUEST['post_category']) && is_array($_REQUEST['post_category']) ) :
2508
  foreach($_REQUEST['post_category'] as $val) :
2509
+ if ( in_array($val, $category) ) : $notreturn = 1; break; endif;
2510
  endforeach;
2511
  endif;
2512
  endif;
2634
  list($out_all,$out_key,$out_value) = $this->make_textarea( $title, $parentSN, $data, $post_id );
2635
  }
2636
  else if( $data['type'] == 'file' ) {
2637
+ if ( !strstr($_SERVER['REQUEST_URI'], 'wp-admin/edit.php') ) :
2638
+ list($out_all,$out_key,$out_value) = $this->make_file( $title, $parentSN, $data, $post_id );
2639
+ endif;
2640
  }
2641
  if ( isset($options['custom_fields'][$id]['format']) && is_numeric($options['custom_fields'][$id]['format']) ) :
2642
  $duplicator = '['.$title.']';
2815
  else :
2816
  $out .= '<div>&nbsp;</div>';
2817
  endif;
2818
+
2819
  $out .= '<div id="cft'.$suffix.'" class="cft">';
2820
  $out .= $body;
2821
  $out .= '</div>';
3634
  foreach( $replace as $rkey => $rval ) :
3635
  $replace_val[$rkey] = "";
3636
  $class = "";
3637
+ $checked = "";
3638
  $default = array();
3639
  switch ( $rval['type'] ) :
3640
  case 'text':
3678
  endforeach;
3679
  $replace_val[$rkey] .= '</ul>';
3680
  else :
3681
+ if ( isset($_REQUEST['cftsearch']) && $_REQUEST['cftsearch'][rawurlencode($key)][$rkey][0] == esc_attr(trim($values[0])) )
3682
  $checked = ' checked="checked"';
3683
  $replace_val[$rkey] .= '<label><input type="checkbox" name="cftsearch[' . rawurlencode($key) . '][' . $rkey . '][]" value="' . esc_attr(trim($values[0])) . '"' . $class . $checked . ' /> ';
3684
  if ( $valueLabel[0] ) $replace_val[$rkey] .= stripcslashes(trim($valueLabel[0]));
3716
  endforeach;
3717
  $replace_val[$rkey] .= '</ul>';
3718
  else :
3719
+ if ( isset($_REQUEST['cftsearch']) && $_REQUEST['cftsearch'][rawurlencode($key)][$rkey][0] == esc_attr(trim($values[0])) )
3720
  $checked = ' checked="checked"';
3721
  $replace_val[$rkey] .= '<label><input type="radio" name="cftsearch[' . rawurlencode($key) . '][]" value="' . esc_attr(trim($values[0])) . '"' . $class . $checked . ' /> ';
3722
  if ( $valueLabel[0] ) $replace_val[$rkey] .= stripcslashes(trim($valueLabel[0]));
3739
  $j=0;
3740
  foreach ( $values as $metaval ) :
3741
  $metaval = trim($metaval);
3742
+ if ( in_array($metaval, $default) && !isset($_REQUEST['cftsearch'][rawurlencode($key)][$rkey]) )
3743
  $checked = ' checked="checked"';
3744
 
3745
  if ( isset($_REQUEST['cftsearch']) && $_REQUEST['cftsearch'][rawurlencode($key)][$rkey][0] == $metaval ) $selected = ' selected="selected"';
3920
  if ( $val3 ) :
3921
  if ( $ch == 0 ) : $where .= ' AND (';
3922
  else :
3923
+ if ( empty($replace[$key][$key2]['type']) || $replace[$key][$key2]['type'] == 'checkbox' ) $where .= ' OR ';
3924
  else $where .= ' AND ';
3925
  endif;
3926
  if ( !isset($replace[$key][$key2]['operator']) ) $replace[$key][$key2]['operator'] = '';
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Custom Field Template ===
2
  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.9.8
7
- Stable tag: 2.4.3
8
  License: GPLv2 or later
9
 
10
  The Custom Field Template plugin extends the functionality of custom fields.
@@ -114,6 +114,11 @@ See the default template and modify it.
114
 
115
  == Changelog ==
116
 
 
 
 
 
 
117
  = 2.4.3 =
118
  * Bugfix: deployment of templates.
119
 
1
  === Custom Field Template ===
2
  Contributors: Hiroaki Miyashita
3
+ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WN7Y2442JPRU6
4
+ Tags: custom field, custom fields, custom, fields, field, template, meta, custom field template, custom post type, acf, advanced
5
  Requires at least: 2.1
6
+ Tested up to: 5.0
7
+ Stable tag: 2.4.4
8
  License: GPLv2 or later
9
 
10
  The Custom Field Template plugin extends the functionality of custom fields.
114
 
115
  == Changelog ==
116
 
117
+ = 2.4.4 =
118
+ * Code cleaning.
119
+ * Bugfix: media picker for pages.
120
+ * Bugfix: quick edit for custom post types.
121
+
122
  = 2.4.3 =
123
  * Bugfix: deployment of templates.
124