Custom Field Template - Version 1.6.9

Version Description

  • Bugfix: template loading.
Download this release

Release Info

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

Code changes from version 1.6.8 to 1.6.9

Files changed (2) hide show
  1. custom-field-template.php +44 -14
  2. readme.txt +4 -1
custom-field-template.php CHANGED
@@ -4,7 +4,7 @@ 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
- Version: 1.6.8
8
  Author URI: http://wpgogo.com/
9
  */
10
 
@@ -152,6 +152,7 @@ class custom_field_template {
152
  foreach($options['custom_fields'] as $key => $val ) :
153
  $tmp_custom_post_type = explode(',', $options['custom_fields'][$key]['custom_post_type']);
154
  $tmp_custom_post_type = array_filter( $tmp_custom_post_type );
 
155
  $custom_post_type = array_merge($custom_post_type, $tmp_custom_post_type);
156
  endforeach;
157
  if ( is_array($custom_post_type) ) :
@@ -644,6 +645,8 @@ type = file';
644
  $options['hook'][$i]['content'] = preg_replace_callback("/(<\?php|<\?|< \?php)(.*?)\?>/si", array($this, 'EvalBuffer'), $options['hook'][$i]['content']);
645
  endif;
646
  $needle = explode(',', $options['hook'][$i]['category']);
 
 
647
  foreach ( $needle as $val ) :
648
  if ( in_array($val, $cats ) ) :
649
  if ( $options['hook'][$i]['position'] == 0 )
@@ -685,6 +688,7 @@ type = file';
685
  elseif ( $options['hook'][$i]['custom_post_type'] ) :
686
  $custom_post_type = explode(',', $options['hook'][$i]['custom_post_type']);
687
  $custom_post_type = array_filter( $custom_post_type );
 
688
  if ( in_array($post->post_type, $custom_post_type) ) :
689
  if ( $options['hook'][$i]['use_php'] ) :
690
  $options['hook'][$i]['content'] = stripcslashes($options['hook'][$i]['content']);
@@ -1909,21 +1913,40 @@ jQuery(this).addClass("closed");
1909
  $level = $userdata->user_level;
1910
 
1911
  $options = $this->get_custom_field_template_data();
1912
-
1913
- if ( $options['custom_fields'][$id]['disable'] )
1914
- return;
1915
-
1916
  if ( $_REQUEST['post'] ) $post = get_post($_REQUEST['post']);
1917
-
1918
- if ( $_REQUEST['page_template'] ) :
1919
- if ( count($options['custom_fields']) > 0 ) :
1920
- foreach ( $options['custom_fields'] as $key => $val ) :
1921
  $template_files = explode(',', $val['template_files']);
1922
  $template_files = array_filter( $template_files );
1923
- if ( in_array($_REQUEST['page_template'], $template_files) ) $id = $key;
1924
- endforeach;
1925
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1926
  endif;
 
 
 
1927
 
1928
  $fields = $this->get_custom_fields( $id );
1929
 
@@ -1953,6 +1976,8 @@ jQuery(this).addClass("closed");
1953
  if ( $options['custom_fields'][$id]['custom_post_type'] ) :
1954
  $custom_post_type = explode(',', $options['custom_fields'][$id]['custom_post_type']);
1955
  $custom_post_type = array_filter( $custom_post_type );
 
 
1956
  if ( !in_array($post->post_type, $custom_post_type) )
1957
  return;
1958
  endif;
@@ -1985,6 +2010,7 @@ jQuery(this).addClass("closed");
1985
  if ( $options['custom_fields'][$id]['post'] ) :
1986
  $post_ids = explode(',', $options['custom_fields'][$id]['post']);
1987
  $post_ids = array_filter( $post_ids );
 
1988
  if ( !in_array($_REQUEST['post'], $post_ids) )
1989
  return;
1990
  endif;
@@ -1992,6 +2018,7 @@ jQuery(this).addClass("closed");
1992
  if ( $options['custom_fields'][$id]['template_files'] && (isset($post->page_template) || $_REQUEST['page_template']) ) :
1993
  $template_files = explode(',', $options['custom_fields'][$id]['template_files']);
1994
  $template_files = array_filter( $template_files );
 
1995
  if ( $_REQUEST['page_template'] ) :
1996
  if ( !in_array($_REQUEST['page_template'], $template_files) ) :
1997
  return;
@@ -2217,6 +2244,7 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
2217
  $val['category'] = preg_replace('/\s/', '', $val['category']);
2218
  $categories = explode(',', $val['category']);
2219
  $categories = array_filter($categories);
 
2220
  foreach($categories as $cat_id) :
2221
  if ( is_numeric($cat_id) ) :
2222
  $out .= 'jQuery(\'#in-category-' . $cat_id . '\').click(function(){if(jQuery(\'#in-category-' . $cat_id . '\').attr(\'checked\') == true) { if(tinyMCEID.length) { for(i=0;i<tinyMCEID.length;i++) {tinyMCE.execCommand(\'mceRemoveControl\', false, tinyMCEID[i]);} tinyMCEID.length=0;}; jQuery.get(\'?page=custom-field-template/custom-field-template.php&cft_mode=selectbox&post=\'+jQuery(\'#post_ID\').val()+\'&\'+jQuery(\'#categories-all :input\').fieldSerialize(), function(html) { jQuery(\'#cft_selectbox\').html(html);';
@@ -2356,18 +2384,20 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
2356
  if ( $options['custom_fields'][$i]['custom_post_type'] ) :
2357
  $custom_post_type = explode(',', $options['custom_fields'][$i]['custom_post_type']);
2358
  $custom_post_type = array_filter( $custom_post_type );
 
2359
  if ( !in_array($post->post_type, $custom_post_type) )
2360
  continue;
2361
  endif;
2362
 
2363
- // Filter IDs and Pages
2364
  $cat_ids = explode(',', $options['custom_fields'][$i]['category']);
2365
  $template_files = explode(',', $options['custom_fields'][$i]['template_files']);
2366
  $post_ids = explode(',', $options['custom_fields'][$i]['post']);
2367
- // Send back empties
2368
  $cat_ids = array_filter( $cat_ids );
2369
  $template_files = array_filter( $template_files );
2370
  $post_ids = array_filter( $post_ids );
 
 
 
2371
 
2372
  if ( (strstr($_SERVER['REQUEST_URI'], 'wp-admin/page-new.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/page.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/edit-pages.php') || strstr($_SERVER['REQUEST_URI'], 'post_type=page') || $post->post_type=='page') ) :
2373
  // Check if there are page template files to filter by and there is a page 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
+ Version: 1.6.9
8
  Author URI: http://wpgogo.com/
9
  */
10
 
152
  foreach($options['custom_fields'] as $key => $val ) :
153
  $tmp_custom_post_type = explode(',', $options['custom_fields'][$key]['custom_post_type']);
154
  $tmp_custom_post_type = array_filter( $tmp_custom_post_type );
155
+ array_walk( $tmp_custom_post_type, create_function('&$v', '$v = trim($v);') );
156
  $custom_post_type = array_merge($custom_post_type, $tmp_custom_post_type);
157
  endforeach;
158
  if ( is_array($custom_post_type) ) :
645
  $options['hook'][$i]['content'] = preg_replace_callback("/(<\?php|<\?|< \?php)(.*?)\?>/si", array($this, 'EvalBuffer'), $options['hook'][$i]['content']);
646
  endif;
647
  $needle = explode(',', $options['hook'][$i]['category']);
648
+ $needle = array_filter($needle);
649
+ array_walk( $needle, create_function('&$v', '$v = trim($v);') );
650
  foreach ( $needle as $val ) :
651
  if ( in_array($val, $cats ) ) :
652
  if ( $options['hook'][$i]['position'] == 0 )
688
  elseif ( $options['hook'][$i]['custom_post_type'] ) :
689
  $custom_post_type = explode(',', $options['hook'][$i]['custom_post_type']);
690
  $custom_post_type = array_filter( $custom_post_type );
691
+ array_walk( $custom_post_type, create_function('&$v', '$v = trim($v);') );
692
  if ( in_array($post->post_type, $custom_post_type) ) :
693
  if ( $options['hook'][$i]['use_php'] ) :
694
  $options['hook'][$i]['content'] = stripcslashes($options['hook'][$i]['content']);
1913
  $level = $userdata->user_level;
1914
 
1915
  $options = $this->get_custom_field_template_data();
1916
+
 
 
 
1917
  if ( $_REQUEST['post'] ) $post = get_post($_REQUEST['post']);
1918
+
1919
+ if ( count($options['custom_fields']) > 0 && !isset($_REQUEST['id']) && !isset($options['posts'][$_REQUEST['post']]) ) :
1920
+ foreach ( $options['custom_fields'] as $key => $val ) :
1921
+ if ( !empty($val['template_files']) && !empty($_REQUEST['page_template']) ) :
1922
  $template_files = explode(',', $val['template_files']);
1923
  $template_files = array_filter( $template_files );
1924
+ array_walk( $template_files, create_function('&$v', '$v = trim($v);') );
1925
+ if ( in_array($_REQUEST['page_template'], $template_files) ) :
1926
+ $id = $key;
1927
+ break;
1928
+ endif;
1929
+ endif;
1930
+ if ( !empty($val['post_type']) ) :
1931
+ if ( $post->post_type == $val['post_type'] ) :
1932
+ $id = $key;
1933
+ break;
1934
+ endif;
1935
+ endif;
1936
+ if ( !empty($val['custom_post_type']) ) :
1937
+ $tmp_custom_post_type = explode(',', $val['custom_post_type']);
1938
+ $tmp_custom_post_type = array_filter( $tmp_custom_post_type );
1939
+ array_walk( $tmp_custom_post_type, create_function('&$v', '$v = trim($v);') );
1940
+ if ( in_array($post->post_type, $tmp_custom_post_type) ) :
1941
+ $id = $key;
1942
+ break;
1943
+ endif;
1944
+ endif;
1945
+ endforeach;
1946
  endif;
1947
+
1948
+ if ( $options['custom_fields'][$id]['disable'] )
1949
+ return;
1950
 
1951
  $fields = $this->get_custom_fields( $id );
1952
 
1976
  if ( $options['custom_fields'][$id]['custom_post_type'] ) :
1977
  $custom_post_type = explode(',', $options['custom_fields'][$id]['custom_post_type']);
1978
  $custom_post_type = array_filter( $custom_post_type );
1979
+ array_walk( $custom_post_type, create_function('&$v', '$v = trim($v);') );
1980
+
1981
  if ( !in_array($post->post_type, $custom_post_type) )
1982
  return;
1983
  endif;
2010
  if ( $options['custom_fields'][$id]['post'] ) :
2011
  $post_ids = explode(',', $options['custom_fields'][$id]['post']);
2012
  $post_ids = array_filter( $post_ids );
2013
+ array_walk( $post_ids, create_function('&$v', '$v = trim($v);') );
2014
  if ( !in_array($_REQUEST['post'], $post_ids) )
2015
  return;
2016
  endif;
2018
  if ( $options['custom_fields'][$id]['template_files'] && (isset($post->page_template) || $_REQUEST['page_template']) ) :
2019
  $template_files = explode(',', $options['custom_fields'][$id]['template_files']);
2020
  $template_files = array_filter( $template_files );
2021
+ array_walk( $template_files, create_function('&$v', '$v = trim($v);') );
2022
  if ( $_REQUEST['page_template'] ) :
2023
  if ( !in_array($_REQUEST['page_template'], $template_files) ) :
2024
  return;
2244
  $val['category'] = preg_replace('/\s/', '', $val['category']);
2245
  $categories = explode(',', $val['category']);
2246
  $categories = array_filter($categories);
2247
+ array_walk( $categories, create_function('&$v', '$v = trim($v);') );
2248
  foreach($categories as $cat_id) :
2249
  if ( is_numeric($cat_id) ) :
2250
  $out .= 'jQuery(\'#in-category-' . $cat_id . '\').click(function(){if(jQuery(\'#in-category-' . $cat_id . '\').attr(\'checked\') == true) { if(tinyMCEID.length) { for(i=0;i<tinyMCEID.length;i++) {tinyMCE.execCommand(\'mceRemoveControl\', false, tinyMCEID[i]);} tinyMCEID.length=0;}; jQuery.get(\'?page=custom-field-template/custom-field-template.php&cft_mode=selectbox&post=\'+jQuery(\'#post_ID\').val()+\'&\'+jQuery(\'#categories-all :input\').fieldSerialize(), function(html) { jQuery(\'#cft_selectbox\').html(html);';
2384
  if ( $options['custom_fields'][$i]['custom_post_type'] ) :
2385
  $custom_post_type = explode(',', $options['custom_fields'][$i]['custom_post_type']);
2386
  $custom_post_type = array_filter( $custom_post_type );
2387
+ array_walk( $custom_post_type, create_function('&$v', '$v = trim($v);') );
2388
  if ( !in_array($post->post_type, $custom_post_type) )
2389
  continue;
2390
  endif;
2391
 
 
2392
  $cat_ids = explode(',', $options['custom_fields'][$i]['category']);
2393
  $template_files = explode(',', $options['custom_fields'][$i]['template_files']);
2394
  $post_ids = explode(',', $options['custom_fields'][$i]['post']);
 
2395
  $cat_ids = array_filter( $cat_ids );
2396
  $template_files = array_filter( $template_files );
2397
  $post_ids = array_filter( $post_ids );
2398
+ array_walk( $cat_ids, create_function('&$v', '$v = trim($v);') );
2399
+ array_walk( $template_files, create_function('&$v', '$v = trim($v);') );
2400
+ array_walk( $post_ids, create_function('&$v', '$v = trim($v);') );
2401
 
2402
  if ( (strstr($_SERVER['REQUEST_URI'], 'wp-admin/page-new.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/page.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/edit-pages.php') || strstr($_SERVER['REQUEST_URI'], 'post_type=page') || $post->post_type=='page') ) :
2403
  // Check if there are page template files to filter by and there is a page template
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://wpgogo.com/development/custom-field-template.html
4
  Tags: custom, fields, field, template, meta, custom field, custom fields, custom field template
5
  Requires at least: 2.1
6
  Tested up to: 3.0
7
- Stable tag: 1.6.8
8
 
9
  This plugin adds the default custom fields on the Write Post/Page.
10
 
@@ -102,6 +102,9 @@ See the default template and modify it.
102
 
103
  == Changelog ==
104
 
 
 
 
105
  = 1.6.8 =
106
  * Bugfix: prepared statement of cft search sqls.
107
 
4
  Tags: custom, fields, field, template, meta, custom field, custom fields, custom field template
5
  Requires at least: 2.1
6
  Tested up to: 3.0
7
+ Stable tag: 1.6.9
8
 
9
  This plugin adds the default custom fields on the Write Post/Page.
10
 
102
 
103
  == Changelog ==
104
 
105
+ = 1.6.9 =
106
+ * Bugfix: template loading.
107
+
108
  = 1.6.8 =
109
  * Bugfix: prepared statement of cft search sqls.
110