Custom Field Template - Version 1.9.9

Version Description

  • Code cleaning.
  • Bugfix: image insertion using the media button.
Download this release

Release Info

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

Code changes from version 1.9.8 to 1.9.9

Files changed (2) hide show
  1. custom-field-template.php +47 -18
  2. readme.txt +6 -2
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.9.8
8
  Author URI: http://wpgogo.com/
9
  */
10
 
@@ -13,7 +13,7 @@ This program is based on the rc:custom_field_gui plugin written by Joshua Sigar.
13
  I appreciate your efforts, Joshua.
14
  */
15
 
16
- /* Copyright 2008 -2011 Hiroaki Miyashita
17
 
18
  This program is free software; you can redistribute it and/or modify
19
  it under the terms of the GNU General Public License as published by
@@ -482,7 +482,7 @@ class custom_field_template {
482
  endif;
483
  endif;
484
 
485
- echo $output;
486
  }
487
 
488
  function add_manage_posts_columns($columns) {
@@ -699,7 +699,7 @@ type = file';
699
  if ( is_feed() && !$options['hook'][$i]['feed'] ) break;
700
  if ( !empty($options['hook'][$i]['category']) ) :
701
  if ( is_category() || is_single() || is_feed() ) :
702
- if ( $options['hook'][$i]['use_php'] ) :
703
  $options['hook'][$i]['content'] = $this->EvalBuffer(stripcslashes($options['hook'][$i]['content']));
704
  endif;
705
  $needle = explode(',', $options['hook'][$i]['category']);
@@ -719,7 +719,7 @@ type = file';
719
  endif;
720
  elseif ( $options['hook'][$i]['post_type']=='post' ) :
721
  if ( is_category() || is_single() ) :
722
- if ( $options['hook'][$i]['use_php'] ) :
723
  $options['hook'][$i]['content'] = $this->EvalBuffer(stripcslashes($options['hook'][$i]['content']));
724
  endif;
725
  if ( $options['hook'][$i]['position'] == 0 )
@@ -731,7 +731,7 @@ type = file';
731
  endif;
732
  elseif ( $options['hook'][$i]['post_type']=='page' ) :
733
  if ( is_page() ) :
734
- if ( $options['hook'][$i]['use_php'] ) :
735
  $options['hook'][$i]['content'] = $this->EvalBuffer(stripcslashes($options['hook'][$i]['content']));
736
  endif;
737
  if ( $options['hook'][$i]['position'] == 0 )
@@ -746,7 +746,7 @@ type = file';
746
  $custom_post_type = array_filter( $custom_post_type );
747
  array_walk( $custom_post_type, create_function('&$v', '$v = trim($v);') );
748
  if ( in_array($post->post_type, $custom_post_type) ) :
749
- if ( $options['hook'][$i]['use_php'] ) :
750
  $options['hook'][$i]['content'] = $this->EvalBuffer(stripcslashes($options['hook'][$i]['content']));
751
  endif;
752
  if ( $options['hook'][$i]['position'] == 0 )
@@ -757,7 +757,7 @@ type = file';
757
  $content = $options['hook'][$i]['content'] . $content;
758
  endif;
759
  else :
760
- if ( $options['hook'][$i]['use_php'] ) :
761
  $options['hook'][$i]['content'] = $this->EvalBuffer(stripcslashes($options['hook'][$i]['content']));
762
  endif;
763
  if ( $options['hook'][$i]['position'] == 0 )
@@ -1670,7 +1670,7 @@ jQuery(this).addClass("closed");
1670
  if ( !empty($class) ) $class = ' class="' . $class . '"';
1671
  if ( !empty($style) ) $style = ' style="' . $style . '"';
1672
 
1673
- if ( !empty($label) && $options['custom_field_template_replace_keys_by_labels'] )
1674
  $title = stripcslashes($label);
1675
 
1676
  $event = array('onclick' => $onclick, 'ondblclick' => $ondblclick, 'onkeydown' => $onkeydown, 'onkeypress' => $onkeypress, 'onkeyup' => $onkeyup, 'onmousedown' => $onmousedown, 'onmouseup' => $onmouseup, 'onmouseover' => $onmouseover, 'onmouseout' => $onmouseout, 'onmousemove' => $onmousemove, 'onfocus' => $onfocus, 'onblur' => $onblur, 'onchange' => $onchange, 'onselect' => $onselect);
@@ -1820,7 +1820,7 @@ jQuery(this).addClass("closed");
1820
  if ( !empty($class) ) $class = ' class="' . $class . '"';
1821
  if ( !empty($style) ) $style = ' style="' . $style . '"';
1822
 
1823
- if ( !empty($label) && $options['custom_field_template_replace_keys_by_labels'] )
1824
  $title = stripcslashes($label);
1825
 
1826
  $event = array('onclick' => $onclick, 'ondblclick' => $ondblclick, 'onkeydown' => $onkeydown, 'onkeypress' => $onkeypress, 'onkeyup' => $onkeyup, 'onmousedown' => $onmousedown, 'onmouseup' => $onmouseup, 'onmouseover' => $onmouseover, 'onmouseout' => $onmouseout, 'onmousemove' => $onmousemove, 'onfocus' => $onfocus, 'onblur' => $onblur, 'onchange' => $onchange, 'onselect' => $onselect);
@@ -1978,7 +1978,7 @@ jQuery(this).addClass("closed");
1978
  $content_class .= '"';
1979
  if ( !empty($style) ) $style = ' style="' . $style . '"';
1980
 
1981
- if ( !empty($label) && $options['custom_field_template_replace_keys_by_labels'] )
1982
  $title = stripcslashes($label);
1983
 
1984
  $event = array('onclick' => $onclick, 'ondblclick' => $ondblclick, 'onkeydown' => $onkeydown, 'onkeypress' => $onkeypress, 'onkeyup' => $onkeyup, 'onmousedown' => $onmousedown, 'onmouseup' => $onmouseup, 'onmouseover' => $onmouseover, 'onmouseout' => $onmouseout, 'onmousemove' => $onmousemove, 'onfocus' => $onfocus, 'onblur' => $onblur, 'onchange' => $onchange, 'onselect' => $onselect);
@@ -2020,7 +2020,7 @@ jQuery(this).addClass("closed");
2020
  '<dt><span' . $hide . '><label for="' . $name . $sid . '_' . $cftnum . '">' . $title . '</label></span><br />' . $addfield . $media . $switch . '</dt>' .
2021
  '<dd>';
2022
 
2023
- if ( !empty($label) && !$options['custom_field_template_replace_keys_by_labels'] )
2024
  $out .= '<p class="label">' . stripcslashes($label) . '</p>';
2025
 
2026
  $out .= trim($before);
@@ -2074,7 +2074,7 @@ jQuery(this).addClass("closed");
2074
  if ( !empty($class) ) $class = ' class="' . $class . '"';
2075
  if ( !empty($style) ) $style = ' style="' . $style . '"';
2076
 
2077
- if ( !empty($label) && $options['custom_field_template_replace_keys_by_labels'] )
2078
  $title = stripcslashes($label);
2079
 
2080
  if ( $multipleButton == true && $ct_value == $cftnum ) :
@@ -2363,6 +2363,35 @@ jQuery(this).addClass("closed");
2363
  $out .= '<script type="text/javascript">' . "\n" .
2364
  '// <![CDATA[' . "\n";
2365
  $out .= 'function qt_set(new_id) { eval("qt_"+new_id+" = new QTags(\'qt_"+new_id+"\', \'"+new_id+"\', \'editorcontainer_"+new_id+"\', \'more\');");}';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2366
  $out .= 'function send_to_custom_field(h) {' . "\n" .
2367
  ' if ( tmpFocus ) ed = tmpFocus;' . "\n" .
2368
  ' else if ( typeof tinyMCE == "undefined" ) ed = document.getElementById("content");' . "\n" .
@@ -2383,7 +2412,7 @@ jQuery(this).addClass("closed");
2383
  ' }' . "\n" .
2384
  ' ed.execCommand("mceInsertContent", false, h);' . "\n" .
2385
  ' } else {' . "\n" .
2386
- ' if ( tmpFocus ) edInsertContent(tmpFocus, h);' . "\n" .
2387
  ' else edInsertContent(edCanvas, h);' . "\n" .
2388
  ' }' . "\n";
2389
 
@@ -2492,7 +2521,7 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
2492
  endif;
2493
  endif;
2494
 
2495
- if ( $options['custom_fields'] ) :
2496
  if ( substr($wp_version, 0, 3) < '3.0' ) $taxonomy = 'categories';
2497
  else $taxonomy = 'category';
2498
 
@@ -2797,11 +2826,11 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
2797
  return;
2798
 
2799
  if ( substr($wp_version, 0, 3) >= '2.8' ) {
2800
- if ( !class_exists('SimpleTags') && $_POST['tax_input']['post_tag'] ) {
2801
  $tags_input = explode(",", $_POST['tax_input']['post_tag']);
2802
  }
2803
  } else {
2804
- if ( !class_exists('SimpleTags') && $_POST['tags_input'] ) {
2805
  $tags_input = explode(",", $_POST['tags_input']);
2806
  }
2807
  }
@@ -3503,7 +3532,7 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
3503
  foreach( $fields as $field_key => $field_val) :
3504
  foreach( $field_val as $key => $val) :
3505
  if ( $val['search'] == true ) :
3506
- if ( !empty($val['label']) && $options['custom_field_template_replace_keys_by_labels'] )
3507
  $key = stripcslashes($val['label']);
3508
  $output .= '<dl>' ."\n";
3509
  if ( $val['hideKey'] != true) :
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.9.9
8
  Author URI: http://wpgogo.com/
9
  */
10
 
13
  I appreciate your efforts, Joshua.
14
  */
15
 
16
+ /* Copyright 2008 -2012 Hiroaki Miyashita
17
 
18
  This program is free software; you can redistribute it and/or modify
19
  it under the terms of the GNU General Public License as published by
482
  endif;
483
  endif;
484
 
485
+ if ( isset($output) ) echo $output;
486
  }
487
 
488
  function add_manage_posts_columns($columns) {
699
  if ( is_feed() && !$options['hook'][$i]['feed'] ) break;
700
  if ( !empty($options['hook'][$i]['category']) ) :
701
  if ( is_category() || is_single() || is_feed() ) :
702
+ if ( !empty($options['hook'][$i]['use_php']) ) :
703
  $options['hook'][$i]['content'] = $this->EvalBuffer(stripcslashes($options['hook'][$i]['content']));
704
  endif;
705
  $needle = explode(',', $options['hook'][$i]['category']);
719
  endif;
720
  elseif ( $options['hook'][$i]['post_type']=='post' ) :
721
  if ( is_category() || is_single() ) :
722
+ if ( !empty($options['hook'][$i]['use_php']) ) :
723
  $options['hook'][$i]['content'] = $this->EvalBuffer(stripcslashes($options['hook'][$i]['content']));
724
  endif;
725
  if ( $options['hook'][$i]['position'] == 0 )
731
  endif;
732
  elseif ( $options['hook'][$i]['post_type']=='page' ) :
733
  if ( is_page() ) :
734
+ if ( !empty($options['hook'][$i]['use_php']) ) :
735
  $options['hook'][$i]['content'] = $this->EvalBuffer(stripcslashes($options['hook'][$i]['content']));
736
  endif;
737
  if ( $options['hook'][$i]['position'] == 0 )
746
  $custom_post_type = array_filter( $custom_post_type );
747
  array_walk( $custom_post_type, create_function('&$v', '$v = trim($v);') );
748
  if ( in_array($post->post_type, $custom_post_type) ) :
749
+ if ( !empty($options['hook'][$i]['use_php']) ) :
750
  $options['hook'][$i]['content'] = $this->EvalBuffer(stripcslashes($options['hook'][$i]['content']));
751
  endif;
752
  if ( $options['hook'][$i]['position'] == 0 )
757
  $content = $options['hook'][$i]['content'] . $content;
758
  endif;
759
  else :
760
+ if ( !empty($options['hook'][$i]['use_php']) ) :
761
  $options['hook'][$i]['content'] = $this->EvalBuffer(stripcslashes($options['hook'][$i]['content']));
762
  endif;
763
  if ( $options['hook'][$i]['position'] == 0 )
1670
  if ( !empty($class) ) $class = ' class="' . $class . '"';
1671
  if ( !empty($style) ) $style = ' style="' . $style . '"';
1672
 
1673
+ if ( !empty($label) && !empty($options['custom_field_template_replace_keys_by_labels']) )
1674
  $title = stripcslashes($label);
1675
 
1676
  $event = array('onclick' => $onclick, 'ondblclick' => $ondblclick, 'onkeydown' => $onkeydown, 'onkeypress' => $onkeypress, 'onkeyup' => $onkeyup, 'onmousedown' => $onmousedown, 'onmouseup' => $onmouseup, 'onmouseover' => $onmouseover, 'onmouseout' => $onmouseout, 'onmousemove' => $onmousemove, 'onfocus' => $onfocus, 'onblur' => $onblur, 'onchange' => $onchange, 'onselect' => $onselect);
1820
  if ( !empty($class) ) $class = ' class="' . $class . '"';
1821
  if ( !empty($style) ) $style = ' style="' . $style . '"';
1822
 
1823
+ if ( !empty($label) && !empty($options['custom_field_template_replace_keys_by_labels']) )
1824
  $title = stripcslashes($label);
1825
 
1826
  $event = array('onclick' => $onclick, 'ondblclick' => $ondblclick, 'onkeydown' => $onkeydown, 'onkeypress' => $onkeypress, 'onkeyup' => $onkeyup, 'onmousedown' => $onmousedown, 'onmouseup' => $onmouseup, 'onmouseover' => $onmouseover, 'onmouseout' => $onmouseout, 'onmousemove' => $onmousemove, 'onfocus' => $onfocus, 'onblur' => $onblur, 'onchange' => $onchange, 'onselect' => $onselect);
1978
  $content_class .= '"';
1979
  if ( !empty($style) ) $style = ' style="' . $style . '"';
1980
 
1981
+ if ( !empty($label) && !empty($options['custom_field_template_replace_keys_by_labels']) )
1982
  $title = stripcslashes($label);
1983
 
1984
  $event = array('onclick' => $onclick, 'ondblclick' => $ondblclick, 'onkeydown' => $onkeydown, 'onkeypress' => $onkeypress, 'onkeyup' => $onkeyup, 'onmousedown' => $onmousedown, 'onmouseup' => $onmouseup, 'onmouseover' => $onmouseover, 'onmouseout' => $onmouseout, 'onmousemove' => $onmousemove, 'onfocus' => $onfocus, 'onblur' => $onblur, 'onchange' => $onchange, 'onselect' => $onselect);
2020
  '<dt><span' . $hide . '><label for="' . $name . $sid . '_' . $cftnum . '">' . $title . '</label></span><br />' . $addfield . $media . $switch . '</dt>' .
2021
  '<dd>';
2022
 
2023
+ if ( !empty($label) && empty($options['custom_field_template_replace_keys_by_labels']) )
2024
  $out .= '<p class="label">' . stripcslashes($label) . '</p>';
2025
 
2026
  $out .= trim($before);
2074
  if ( !empty($class) ) $class = ' class="' . $class . '"';
2075
  if ( !empty($style) ) $style = ' style="' . $style . '"';
2076
 
2077
+ if ( !empty($label) && !empty($options['custom_field_template_replace_keys_by_labels']) )
2078
  $title = stripcslashes($label);
2079
 
2080
  if ( $multipleButton == true && $ct_value == $cftnum ) :
2363
  $out .= '<script type="text/javascript">' . "\n" .
2364
  '// <![CDATA[' . "\n";
2365
  $out .= 'function qt_set(new_id) { eval("qt_"+new_id+" = new QTags(\'qt_"+new_id+"\', \'"+new_id+"\', \'editorcontainer_"+new_id+"\', \'more\');");}';
2366
+
2367
+ $out .= 'function _edInsertContent(myField, myValue) {
2368
+ var sel, startPos, endPos, scrollTop;
2369
+
2370
+ //IE support
2371
+ if (document.selection) {
2372
+ myField.focus();
2373
+ sel = document.selection.createRange();
2374
+ sel.text = myValue;
2375
+ myField.focus();
2376
+ }
2377
+ //MOZILLA/NETSCAPE support
2378
+ else if (myField.selectionStart || myField.selectionStart == "0") {
2379
+ startPos = myField.selectionStart;
2380
+ endPos = myField.selectionEnd;
2381
+ scrollTop = myField.scrollTop;
2382
+ myField.value = myField.value.substring(0, startPos)
2383
+ + myValue
2384
+ + myField.value.substring(endPos, myField.value.length);
2385
+ myField.focus();
2386
+ myField.selectionStart = startPos + myValue.length;
2387
+ myField.selectionEnd = startPos + myValue.length;
2388
+ myField.scrollTop = scrollTop;
2389
+ } else {
2390
+ myField.value += myValue;
2391
+ myField.focus();
2392
+ }
2393
+ }';
2394
+
2395
  $out .= 'function send_to_custom_field(h) {' . "\n" .
2396
  ' if ( tmpFocus ) ed = tmpFocus;' . "\n" .
2397
  ' else if ( typeof tinyMCE == "undefined" ) ed = document.getElementById("content");' . "\n" .
2412
  ' }' . "\n" .
2413
  ' ed.execCommand("mceInsertContent", false, h);' . "\n" .
2414
  ' } else {' . "\n" .
2415
+ ' if ( tmpFocus ) _edInsertContent(tmpFocus, h);' . "\n" .
2416
  ' else edInsertContent(edCanvas, h);' . "\n" .
2417
  ' }' . "\n";
2418
 
2521
  endif;
2522
  endif;
2523
 
2524
+ if ( !empty($options['custom_fields']) ) :
2525
  if ( substr($wp_version, 0, 3) < '3.0' ) $taxonomy = 'categories';
2526
  else $taxonomy = 'category';
2527
 
2826
  return;
2827
 
2828
  if ( substr($wp_version, 0, 3) >= '2.8' ) {
2829
+ if ( !class_exists('SimpleTags') && !empty($_POST['tax_input']['post_tag']) ) {
2830
  $tags_input = explode(",", $_POST['tax_input']['post_tag']);
2831
  }
2832
  } else {
2833
+ if ( !class_exists('SimpleTags') && !empty($_POST['tags_input']) ) {
2834
  $tags_input = explode(",", $_POST['tags_input']);
2835
  }
2836
  }
3532
  foreach( $fields as $field_key => $field_val) :
3533
  foreach( $field_val as $key => $val) :
3534
  if ( $val['search'] == true ) :
3535
+ if ( !empty($val['label']) && !empty($options['custom_field_template_replace_keys_by_labels']) )
3536
  $key = stripcslashes($val['label']);
3537
  $output .= '<dl>' ."\n";
3538
  if ( $val['hideKey'] != true) :
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: Hiroaki Miyashita
3
  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.3
7
- Stable tag: 1.9.8
8
 
9
  This plugin adds the default custom fields on the Write Post/Page.
10
 
@@ -106,6 +106,10 @@ See the default template and modify it.
106
 
107
  == Changelog ==
108
 
 
 
 
 
109
  = 1.9.8 =
110
  * tinyMCE and quicktags in custom post types without `editor`.
111
  * Upgrade of jQuery DatePicker plugin.
3
  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.3.1
7
+ Stable tag: 1.9.9
8
 
9
  This plugin adds the default custom fields on the Write Post/Page.
10
 
106
 
107
  == Changelog ==
108
 
109
+ = 1.9.9 =
110
+ * Code cleaning.
111
+ * Bugfix: image insertion using the media button.
112
+
113
  = 1.9.8 =
114
  * tinyMCE and quicktags in custom post types without `editor`.
115
  * Upgrade of jQuery DatePicker plugin.