Custom Field Template - Version 2.2

Version Description

  • Bugfix: tinyMCE editor.
Download this release

Release Info

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

Code changes from version 2.1.9 to 2.2

Files changed (2) hide show
  1. custom-field-template.php +19 -18
  2. readme.txt +4 -1
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.1.9
9
  Text Domain: custom-field-template
10
  Domain Path: /
11
  */
@@ -2172,6 +2172,7 @@ jQuery(this).addClass("closed");
2172
 
2173
  $rand = rand();
2174
  $switch = '';
 
2175
 
2176
  if( $tinyMCE == true ) {
2177
  $out_value = '<script type="text/javascript">' . "\n" .
@@ -2179,19 +2180,19 @@ jQuery(this).addClass("closed");
2179
  'jQuery(document).ready(function() {if ( typeof tinyMCE != "undefined" ) {' . "\n";
2180
 
2181
  if ( substr($wp_version, 0, 3) < '3.3' ) :
2182
- $load_tinyMCE = 'tinyMCE.execCommand("mceAddControl", false, "'. sha1($name . $rand) . '");';
2183
  $editorcontainer_class = ' class="editorcontainer"';
2184
  elseif ( substr($wp_version, 0, 3) < '3.9' ) :
2185
- $load_tinyMCE = 'var ed = new tinyMCE.Editor("'. sha1($name . $rand) . '", tinyMCEPreInit.mceInit["content"]); ed.render();';
2186
  $editorcontainer_class = ' class="wp-editor-container"';
2187
  else :
2188
- $load_tinyMCE = 'tinyMCE.execCommand("mceAddEditor", true, "'. sha1($name . $rand) . '");';
2189
  $editorcontainer_class = ' class="wp-editor-container"';
2190
  endif;
2191
  if ( !empty($options['custom_field_template_use_wpautop']) ) :
2192
- $out_value .= 'document.getElementById("'. sha1($name . $rand) . '").value = document.getElementById("'. sha1($name . $rand) . '").value; '.$load_tinyMCE.' tinyMCEID.push("'. sha1($name . $rand) . '");' . "\n";
2193
  else:
2194
- $out_value .= 'document.getElementById("'. sha1($name . $rand) . '").value = switchEditors.wpautop(document.getElementById("'. sha1($name . $rand) . '").value); '.$load_tinyMCE.' tinyMCEID.push("'. sha1($name . $rand) . '");' . "\n";
2195
  endif;
2196
  $out_value .= '}});' . "\n";
2197
  $out_value .= '// ]]>' . "\n" . '</script>';
@@ -2208,25 +2209,25 @@ jQuery(this).addClass("closed");
2208
  if ( !$mediaOffImage ) :
2209
  $image_upload_iframe_src = apply_filters('image_upload_iframe_src', "$media_upload_iframe_src?type=image");
2210
  $image_title = __('Add an Image');
2211
- $media .= "<a href=\"{$image_upload_iframe_src}&TB_iframe=true\" id=\"add_image{$rand}\" title='$image_title' onclick=\"focusTextArea('".sha1($name.$rand)."'); jQuery(this).attr('href',jQuery(this).attr('href').replace('\?','?post_id='+jQuery('#post_ID').val())); return thickbox(this);\"><img src='images/media-button-image.gif' alt='$image_title' /></a> ";
2212
  endif;
2213
  if ( !$mediaOffVideo ) :
2214
  $video_upload_iframe_src = apply_filters('video_upload_iframe_src', "$media_upload_iframe_src?type=video");
2215
  $video_title = __('Add Video');
2216
- $media .= "<a href=\"{$video_upload_iframe_src}&amp;TB_iframe=true\" id=\"add_video{$rand}\" title='$video_title' onclick=\"focusTextArea('".sha1($name.$rand)."'); jQuery(this).attr('href',jQuery(this).attr('href').replace('\?','?post_id='+jQuery('#post_ID').val())); return thickbox(this);\"><img src='images/media-button-video.gif' alt='$video_title' /></a> ";
2217
  endif;
2218
  if ( !$mediaOffAudio ) :
2219
  $audio_upload_iframe_src = apply_filters('audio_upload_iframe_src', "$media_upload_iframe_src?type=audio");
2220
  $audio_title = __('Add Audio');
2221
- $media .= "<a href=\"{$audio_upload_iframe_src}&amp;TB_iframe=true\" id=\"add_audio{$rand}\" title='$audio_title' onclick=\"focusTextArea('".sha1($name.$rand)."'); jQuery(this).attr('href',jQuery(this).attr('href').replace('\?','?post_id='+jQuery('#post_ID').val())); return thickbox(this);\"><img src='images/media-button-music.gif' alt='$audio_title' /></a> ";
2222
  endif;
2223
  if ( !$mediaOffMedia ) :
2224
  $media_title = __('Add Media');
2225
- $media .= "<a href=\"{$media_upload_iframe_src}?TB_iframe=true\" id=\"add_media{$rand}\" title='$media_title' onclick=\"focusTextArea('".sha1($name.$rand)."'); jQuery(this).attr('href',jQuery(this).attr('href').replace('\?','?post_id='+jQuery('#post_ID').val())); return thickbox(this);\"><img src='images/media-button-other.gif' alt='$media_title' /></a>";
2226
  endif;
2227
  else :
2228
  $media_title = __('Add Media');
2229
- $media .= "<a href=\"{$media_upload_iframe_src}?TB_iframe=true\" id=\"add_media{$rand}\" title='$media_title' onclick=\"focusTextArea('".sha1($name.$rand)."'); jQuery(this).attr('href',jQuery(this).attr('href').replace('\?','?post_id='+jQuery('#post_ID').val())); return thickbox(this);\"><img src='images/media-button.png' alt='$media_title' /></a>";
2230
  endif;
2231
  endif;
2232
 
@@ -2282,10 +2283,10 @@ jQuery(this).addClass("closed");
2282
  elseif ( substr($wp_version, 0, 3) < '3.9' ) :
2283
  $load_tinyMCE = 'var ed = new tinyMCE.Editor(original_id, tinyMCEPreInit.mceInit[\'content\']); ed.render(); var ed = new tinyMCE.Editor(new_id, tinyMCEPreInit.mceInit[\'content\']); ed.render();';
2284
  else :
2285
- $load_tinyMCE = 'tinyMCE.execCommand("mceAddEditor", true, original_id);tinyMCE.execCommand("mceAddEditor", true, new_id);';
2286
  endif;
2287
 
2288
- $addfield .= '<a href="#clear" onclick="var original_id; var new_id; jQuery(this).parent().parent().parent().find('."'textarea'".').each(function(){original_id = jQuery(this).attr('."'id'".');'.$load_htmlEditor1.'tinyMCE.execCommand(' . "'mceRemoveControl'" . ',false,jQuery(this).attr('."'id'".'));});var clone = jQuery(this).parent().parent().parent().clone().insertAfter(jQuery(this).parent().parent().parent()); clone.find('."'textarea'".').val('."''".');if(original_id.match(/([0-9]+)$/)) {var matchval = RegExp.$1;re = new RegExp(matchval, '."'ig'".');clone.html(clone.html().replace(re, parseInt(matchval)+1)); new_id = original_id.replace(/([0-9]+)$/, parseInt(matchval)+1);}if ( tinyMCE.get(jQuery(this).attr('."original_id".')) ) {'.$load_tinyMCE.'}jQuery(this).parent().css('."'visibility','hidden'".');'.$load_htmlEditor2.'jQuery(this).parent().prev().css('."'visibility','hidden'".'); return false;">' . __('Add New', 'custom-field-template') . '</a>';
2289
  else :
2290
  $addfield .= '<a href="#clear" onclick="var original_id; var new_id; jQuery(this).parent().parent().parent().find('."'textarea'".').each(function(){original_id = jQuery(this).attr('."'id'".');});'.$load_htmlEditor1.'var clone = jQuery(this).parent().parent().parent().clone().insertAfter(jQuery(this).parent().parent().parent()); clone.find('."'textarea'".').val('."''".');if(original_id.match(/([0-9]+)$/)) {var matchval = RegExp.$1;re = new RegExp(matchval, '."'ig'".');clone.html(clone.html().replace(re, parseInt(matchval)+1)); new_id = original_id.replace(/([0-9]+)$/, parseInt(matchval)+1);}'.$load_htmlEditor2.'jQuery(this).parent().css('."'visibility','hidden'".');jQuery(this).parent().prev().css('."'visibility','hidden'".'); return false;">' . __('Add New', 'custom-field-template') . '</a>';
2291
  endif;
@@ -2308,20 +2309,20 @@ jQuery(this).addClass("closed");
2308
 
2309
  if ( $htmlEditor == true ) :
2310
  if ( substr($wp_version, 0, 3) < '3.3' ) :
2311
- if( $tinyMCE == true ) $quicktags_hide = ' jQuery(\'#qt_' . sha1($name . $rand) . '_qtags\').hide();';
2312
  $out_value .= '<script type="text/javascript">' . "\n" . '// <![CDATA[' . '
2313
- jQuery(document).ready(function() { qt_' . sha1($name . $rand) . ' = new QTags(\'qt_' . sha1($name . $rand) . '\', \'' . sha1($name . $rand) . '\', \'editorcontainer_' . sha1($name . $rand) . '\', \'more\'); ' . $quicktags_hide . ' });' . "\n" . '// ]]>' . "\n" . '</script>';
2314
  $editorcontainer_class = ' class="editorcontainer"';
2315
  else :
2316
- if( $tinyMCE == true ) $quicktags_hide = ' jQuery(\'#qt_' . sha1($name . $rand) . '_toolbar\').hide();';
2317
  $out_value .= '<script type="text/javascript">' . "\n" . '// <![CDATA[' . '
2318
- jQuery(document).ready(function() { new QTags(\'' . sha1($name . $rand) . '\'); QTags._buttonsInit(); ' . $quicktags_hide . ' }); ' . "\n";
2319
  $out_value .= '// ]]>' . "\n" . '</script>';
2320
  $editorcontainer_class = ' class="wp-editor-container"';
2321
  endif;
2322
  endif;
2323
 
2324
- $out_value .= '<div' . $editorcontainer_class . ' id="editorcontainer_' . sha1($name . $rand) . '" style="clear:none;"><textarea id="' . sha1($name . $rand) . '" name="' . $name . '[' . $sid . '][]" rows="' .$rows. '" cols="' . $cols . '"' . $content_class . $style . $event_output . $wrap . '>' . htmlspecialchars(trim($value)) . '</textarea><input type="hidden" name="'.$name.'_rand['.$sid.']" value="'.$rand.'" /></div>';
2325
  if ( ($htmlEditor == true || $tinyMCE == true) && substr($wp_version, 0, 3) < '3.3' ) $out_value .= '</div>';
2326
  $out_value .= trim($after);
2327
  $out .= $out_value.'</dd></dl>'."\n";
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.2
9
  Text Domain: custom-field-template
10
  Domain Path: /
11
  */
2172
 
2173
  $rand = rand();
2174
  $switch = '';
2175
+ $textarea_id = sha1($name . $rand).rand(0,9);
2176
 
2177
  if( $tinyMCE == true ) {
2178
  $out_value = '<script type="text/javascript">' . "\n" .
2180
  'jQuery(document).ready(function() {if ( typeof tinyMCE != "undefined" ) {' . "\n";
2181
 
2182
  if ( substr($wp_version, 0, 3) < '3.3' ) :
2183
+ $load_tinyMCE = 'tinyMCE.execCommand("mceAddControl", false, "'. $textarea_id . '");';
2184
  $editorcontainer_class = ' class="editorcontainer"';
2185
  elseif ( substr($wp_version, 0, 3) < '3.9' ) :
2186
+ $load_tinyMCE = 'var ed = new tinyMCE.Editor("'. $textarea_id . '", tinyMCEPreInit.mceInit["content"]); ed.render();';
2187
  $editorcontainer_class = ' class="wp-editor-container"';
2188
  else :
2189
+ $load_tinyMCE = 'tinyMCE.execCommand("mceAddEditor", true, "'. $textarea_id . '");';
2190
  $editorcontainer_class = ' class="wp-editor-container"';
2191
  endif;
2192
  if ( !empty($options['custom_field_template_use_wpautop']) ) :
2193
+ $out_value .= 'document.getElementById("'. $textarea_id . '").value = document.getElementById("'. $textarea_id . '").value; '.$load_tinyMCE.' tinyMCEID.push("'. $textarea_id . '");' . "\n";
2194
  else:
2195
+ $out_value .= 'document.getElementById("'. $textarea_id . '").value = switchEditors.wpautop(document.getElementById("'. $textarea_id . '").value); '.$load_tinyMCE.' tinyMCEID.push("'. $textarea_id . '");' . "\n";
2196
  endif;
2197
  $out_value .= '}});' . "\n";
2198
  $out_value .= '// ]]>' . "\n" . '</script>';
2209
  if ( !$mediaOffImage ) :
2210
  $image_upload_iframe_src = apply_filters('image_upload_iframe_src', "$media_upload_iframe_src?type=image");
2211
  $image_title = __('Add an Image');
2212
+ $media .= "<a href=\"{$image_upload_iframe_src}&TB_iframe=true\" id=\"add_image{$rand}\" title='$image_title' onclick=\"focusTextArea('".$textarea_id."'); jQuery(this).attr('href',jQuery(this).attr('href').replace('\?','?post_id='+jQuery('#post_ID').val())); return thickbox(this);\"><img src='images/media-button-image.gif' alt='$image_title' /></a> ";
2213
  endif;
2214
  if ( !$mediaOffVideo ) :
2215
  $video_upload_iframe_src = apply_filters('video_upload_iframe_src', "$media_upload_iframe_src?type=video");
2216
  $video_title = __('Add Video');
2217
+ $media .= "<a href=\"{$video_upload_iframe_src}&amp;TB_iframe=true\" id=\"add_video{$rand}\" title='$video_title' onclick=\"focusTextArea('".$textarea_id."'); jQuery(this).attr('href',jQuery(this).attr('href').replace('\?','?post_id='+jQuery('#post_ID').val())); return thickbox(this);\"><img src='images/media-button-video.gif' alt='$video_title' /></a> ";
2218
  endif;
2219
  if ( !$mediaOffAudio ) :
2220
  $audio_upload_iframe_src = apply_filters('audio_upload_iframe_src', "$media_upload_iframe_src?type=audio");
2221
  $audio_title = __('Add Audio');
2222
+ $media .= "<a href=\"{$audio_upload_iframe_src}&amp;TB_iframe=true\" id=\"add_audio{$rand}\" title='$audio_title' onclick=\"focusTextArea('".$textarea_id."'); jQuery(this).attr('href',jQuery(this).attr('href').replace('\?','?post_id='+jQuery('#post_ID').val())); return thickbox(this);\"><img src='images/media-button-music.gif' alt='$audio_title' /></a> ";
2223
  endif;
2224
  if ( !$mediaOffMedia ) :
2225
  $media_title = __('Add Media');
2226
+ $media .= "<a href=\"{$media_upload_iframe_src}?TB_iframe=true\" id=\"add_media{$rand}\" title='$media_title' onclick=\"focusTextArea('".$textarea_id."'); jQuery(this).attr('href',jQuery(this).attr('href').replace('\?','?post_id='+jQuery('#post_ID').val())); return thickbox(this);\"><img src='images/media-button-other.gif' alt='$media_title' /></a>";
2227
  endif;
2228
  else :
2229
  $media_title = __('Add Media');
2230
+ $media .= "<a href=\"{$media_upload_iframe_src}?TB_iframe=true\" id=\"add_media{$rand}\" title='$media_title' onclick=\"focusTextArea('".$textarea_id."'); jQuery(this).attr('href',jQuery(this).attr('href').replace('\?','?post_id='+jQuery('#post_ID').val())); return thickbox(this);\"><img src='images/media-button.png' alt='$media_title' /></a>";
2231
  endif;
2232
  endif;
2233
 
2283
  elseif ( substr($wp_version, 0, 3) < '3.9' ) :
2284
  $load_tinyMCE = 'var ed = new tinyMCE.Editor(original_id, tinyMCEPreInit.mceInit[\'content\']); ed.render(); var ed = new tinyMCE.Editor(new_id, tinyMCEPreInit.mceInit[\'content\']); ed.render();';
2285
  else :
2286
+ $load_tinyMCE = 'tinyMCE.execCommand('."'mceAddEditor'".', true, original_id);tinyMCE.execCommand('."'mceAddEditor'".', true, new_id);';
2287
  endif;
2288
 
2289
+ $addfield .= '<a href="#clear" onclick="var original_id; var new_id; jQuery(this).parent().parent().parent().find('."'textarea'".').each(function(){original_id = jQuery(this).attr('."'id'".');'.$load_htmlEditor1.'tinyMCE.execCommand(' . "'mceRemoveControl'" . ',true,jQuery(this).attr('."'id'".'));});var clone = jQuery(this).parent().parent().parent().clone().insertAfter(jQuery(this).parent().parent().parent()); clone.find('."'textarea'".').val('."''".');if(original_id.match(/([0-9])$/)) {var matchval = RegExp.$1;re = new RegExp(matchval, '."'ig'".');clone.html(clone.html().replace(re, parseInt(matchval)+1)); new_id = original_id.replace(/([0-9])$/, parseInt(matchval)+1);}if ( tinyMCE.get(jQuery(this).attr('."original_id".')) ) {'.$load_tinyMCE.'}jQuery(this).parent().css('."'visibility','hidden'".');'.$load_htmlEditor2.'jQuery(this).parent().prev().css('."'visibility','hidden'".'); return false;">' . __('Add New', 'custom-field-template') . '</a>';
2290
  else :
2291
  $addfield .= '<a href="#clear" onclick="var original_id; var new_id; jQuery(this).parent().parent().parent().find('."'textarea'".').each(function(){original_id = jQuery(this).attr('."'id'".');});'.$load_htmlEditor1.'var clone = jQuery(this).parent().parent().parent().clone().insertAfter(jQuery(this).parent().parent().parent()); clone.find('."'textarea'".').val('."''".');if(original_id.match(/([0-9]+)$/)) {var matchval = RegExp.$1;re = new RegExp(matchval, '."'ig'".');clone.html(clone.html().replace(re, parseInt(matchval)+1)); new_id = original_id.replace(/([0-9]+)$/, parseInt(matchval)+1);}'.$load_htmlEditor2.'jQuery(this).parent().css('."'visibility','hidden'".');jQuery(this).parent().prev().css('."'visibility','hidden'".'); return false;">' . __('Add New', 'custom-field-template') . '</a>';
2292
  endif;
2309
 
2310
  if ( $htmlEditor == true ) :
2311
  if ( substr($wp_version, 0, 3) < '3.3' ) :
2312
+ if( $tinyMCE == true ) $quicktags_hide = ' jQuery(\'#qt_' . $textarea_id . '_qtags\').hide();';
2313
  $out_value .= '<script type="text/javascript">' . "\n" . '// <![CDATA[' . '
2314
+ jQuery(document).ready(function() { qt_' . $textarea_id . ' = new QTags(\'qt_' . $textarea_id . '\', \'' . $textarea_id . '\', \'editorcontainer_' . $textarea_id . '\', \'more\'); ' . $quicktags_hide . ' });' . "\n" . '// ]]>' . "\n" . '</script>';
2315
  $editorcontainer_class = ' class="editorcontainer"';
2316
  else :
2317
+ if( $tinyMCE == true ) $quicktags_hide = ' jQuery(\'#qt_' . $textarea_id . '_toolbar\').hide();';
2318
  $out_value .= '<script type="text/javascript">' . "\n" . '// <![CDATA[' . '
2319
+ jQuery(document).ready(function() { new QTags(\'' . $textarea_id . '\'); QTags._buttonsInit(); ' . $quicktags_hide . ' }); ' . "\n";
2320
  $out_value .= '// ]]>' . "\n" . '</script>';
2321
  $editorcontainer_class = ' class="wp-editor-container"';
2322
  endif;
2323
  endif;
2324
 
2325
+ $out_value .= '<div' . $editorcontainer_class . ' id="editorcontainer_' . $textarea_id . '" style="clear:none;"><textarea id="' . $textarea_id . '" name="' . $name . '[' . $sid . '][]" rows="' .$rows. '" cols="' . $cols . '"' . $content_class . $style . $event_output . $wrap . '>' . htmlspecialchars(trim($value)) . '</textarea><input type="hidden" name="'.$name.'_rand['.$sid.']" value="'.$rand.'" /></div>';
2326
  if ( ($htmlEditor == true || $tinyMCE == true) && substr($wp_version, 0, 3) < '3.3' ) $out_value .= '</div>';
2327
  $out_value .= trim($after);
2328
  $out .= $out_value.'</dd></dl>'."\n";
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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: 3.9
7
- Stable tag: 2.1.9
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.1.9 =
116
  * Bugfix: tinyMCE editor.
117
 
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: 3.9
7
+ Stable tag: 2.2
8
  License: GPLv2 or later
9
 
10
  The Custom Field Template plugin extends the functionality of custom fields.
112
 
113
  == Changelog ==
114
 
115
+ = 2.2 =
116
+ * Bugfix: tinyMCE editor.
117
+
118
  = 2.1.9 =
119
  * Bugfix: tinyMCE editor.
120