Custom Field Template - Version 0.5.0

Version Description

Download this release

Release Info

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

Code changes from version 0.4.4 to 0.5.0

custom-field-template-ja.mo CHANGED
Binary file
custom-field-template-ja.po CHANGED
@@ -2,8 +2,8 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Custom Field Template\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2008-10-01 02:34+0900\n"
6
- "PO-Revision-Date: 2008-10-01 02:34+0900\n"
7
  "Last-Translator: \n"
8
  "Language-Team: \n"
9
  "MIME-Version: 1.0\n"
@@ -16,104 +16,117 @@ msgstr ""
16
  "X-Poedit-Basepath: ../\n"
17
  "X-Poedit-SearchPath-0: custom-field-template\n"
18
 
19
- #: custom-field-template/custom-field-template.php:81
20
- msgid "Default Template"
21
- msgstr "デフォルトテンプレート"
22
-
23
- #: custom-field-template/custom-field-template.php:120
24
- #: custom-field-template/custom-field-template.php:152
25
- #: custom-field-template/custom-field-template.php:431
26
- #: custom-field-template/custom-field-template.php:439
27
  msgid "Custom Field Template"
28
  msgstr "カスタムフィールドテンプレート"
29
 
30
- #: custom-field-template/custom-field-template.php:137
 
 
 
 
 
 
 
 
31
  msgid "Options updated."
32
  msgstr "オプションは更新されました。"
33
 
34
- #: custom-field-template/custom-field-template.php:141
35
  msgid "Options resetted."
36
  msgstr "オプションはリセットされました。"
37
 
38
- #: custom-field-template/custom-field-template.php:145
39
  msgid "Options deleted."
40
  msgstr "オプションは削除されました。"
41
 
42
- #: custom-field-template/custom-field-template.php:154
43
  msgid "Custom Field Template Options"
44
  msgstr "カスタムフィールドテンプレートオプション"
45
 
46
- #: custom-field-template/custom-field-template.php:162
47
  #, php-format
48
  msgid "Template Title %d"
49
  msgstr "テンプレートタイトル %d"
50
 
51
- #: custom-field-template/custom-field-template.php:164
52
  #, php-format
53
  msgid "Template Content %d"
54
  msgstr "テンプレートコンテンツ %d"
55
 
56
- #: custom-field-template/custom-field-template.php:171
57
  msgid "In case that you would like to insert multiple images at once in use of the custom field media buttons"
58
  msgstr "カスタムフィールへの画像挿入を一度に複数枚実行する場合"
59
 
60
- #: custom-field-template/custom-field-template.php:172
61
  msgid "Use multiple image inset"
62
  msgstr "複数画像挿入を利用する"
63
 
64
- #: custom-field-template/custom-field-template.php:172
65
  msgid "Caution:"
66
  msgstr "ご注意:"
67
 
68
- #: custom-field-template/custom-field-template.php:172
69
  msgid "You need to edit `wp-admin/includes/media.php`. Delete or comment out the code in the function media_send_to_editor at around line 88-96."
70
  msgstr "`wp-admin/includes/media.php`を編集する必要があります。88-96行目の media_send_to_editor関数の中身を削除するかコメントアウトしてください。"
71
 
72
- #: custom-field-template/custom-field-template.php:176
73
  msgid "Update Options »"
74
  msgstr "オプションを更新する »"
75
 
76
- #: custom-field-template/custom-field-template.php:182
 
 
 
 
77
  msgid "Reset Options"
78
  msgstr "オプションをリセットする"
79
 
80
- #: custom-field-template/custom-field-template.php:183
81
  msgid "Are you sure to reset options? Options you set will be reset to the default settings."
82
  msgstr "本当にオプションをリセットしてもよろしいですか?設定したオプションはデフォルトの状態に戻ります。"
83
 
84
- #: custom-field-template/custom-field-template.php:187
85
  msgid "Unset Options »"
86
  msgstr "オプションをリセットする »"
87
 
88
- #: custom-field-template/custom-field-template.php:193
89
  msgid "Delete Options"
90
  msgstr "オプションを削除する"
91
 
92
- #: custom-field-template/custom-field-template.php:194
93
  msgid "Are you sure to delete options? Options you set will be deleted."
94
  msgstr "本当にオプションを削除してもよろしいですか?設定したオプションは削除されます。"
95
 
96
- #: custom-field-template/custom-field-template.php:198
97
  msgid "Delete Options »"
98
  msgstr "オプションを削除する »"
99
 
100
- #: custom-field-template/custom-field-template.php:353
 
 
 
 
101
  msgid "Add Media"
102
  msgstr ""
103
 
104
- #: custom-field-template/custom-field-template.php:355
105
  msgid "Add an Image"
106
  msgstr ""
107
 
108
- #: custom-field-template/custom-field-template.php:357
109
  msgid "Add Video"
110
  msgstr ""
111
 
112
- #: custom-field-template/custom-field-template.php:359
113
  msgid "Add Audio"
114
  msgstr ""
115
 
116
- #: custom-field-template/custom-field-template.php:369
117
  msgid "Toggle"
118
  msgstr "切り替え"
119
 
2
  msgstr ""
3
  "Project-Id-Version: Custom Field Template\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2008-11-05 03:17+0900\n"
6
+ "PO-Revision-Date: 2008-11-05 03:17+0900\n"
7
  "Last-Translator: \n"
8
  "Language-Team: \n"
9
  "MIME-Version: 1.0\n"
16
  "X-Poedit-Basepath: ../\n"
17
  "X-Poedit-SearchPath-0: custom-field-template\n"
18
 
19
+ #: custom-field-template/custom-field-template.php:76
20
+ #: custom-field-template/custom-field-template.php:77
21
+ #: custom-field-template/custom-field-template.php:154
22
+ #: custom-field-template/custom-field-template.php:186
23
+ #: custom-field-template/custom-field-template.php:578
 
 
 
24
  msgid "Custom Field Template"
25
  msgstr "カスタムフィールドテンプレート"
26
 
27
+ #: custom-field-template/custom-field-template.php:88
28
+ msgid "Settings"
29
+ msgstr "設定"
30
+
31
+ #: custom-field-template/custom-field-template.php:99
32
+ msgid "Default Template"
33
+ msgstr "デフォルトテンプレート"
34
+
35
+ #: custom-field-template/custom-field-template.php:171
36
  msgid "Options updated."
37
  msgstr "オプションは更新されました。"
38
 
39
+ #: custom-field-template/custom-field-template.php:175
40
  msgid "Options resetted."
41
  msgstr "オプションはリセットされました。"
42
 
43
+ #: custom-field-template/custom-field-template.php:179
44
  msgid "Options deleted."
45
  msgstr "オプションは削除されました。"
46
 
47
+ #: custom-field-template/custom-field-template.php:191
48
  msgid "Custom Field Template Options"
49
  msgstr "カスタムフィールドテンプレートオプション"
50
 
51
+ #: custom-field-template/custom-field-template.php:200
52
  #, php-format
53
  msgid "Template Title %d"
54
  msgstr "テンプレートタイトル %d"
55
 
56
+ #: custom-field-template/custom-field-template.php:202
57
  #, php-format
58
  msgid "Template Content %d"
59
  msgstr "テンプレートコンテンツ %d"
60
 
61
+ #: custom-field-template/custom-field-template.php:209
62
  msgid "In case that you would like to insert multiple images at once in use of the custom field media buttons"
63
  msgstr "カスタムフィールへの画像挿入を一度に複数枚実行する場合"
64
 
65
+ #: custom-field-template/custom-field-template.php:210
66
  msgid "Use multiple image inset"
67
  msgstr "複数画像挿入を利用する"
68
 
69
+ #: custom-field-template/custom-field-template.php:210
70
  msgid "Caution:"
71
  msgstr "ご注意:"
72
 
73
+ #: custom-field-template/custom-field-template.php:210
74
  msgid "You need to edit `wp-admin/includes/media.php`. Delete or comment out the code in the function media_send_to_editor at around line 88-96."
75
  msgstr "`wp-admin/includes/media.php`を編集する必要があります。88-96行目の media_send_to_editor関数の中身を削除するかコメントアウトしてください。"
76
 
77
+ #: custom-field-template/custom-field-template.php:214
78
  msgid "Update Options »"
79
  msgstr "オプションを更新する »"
80
 
81
+ #: custom-field-template/custom-field-template.php:225
82
+ msgid "Option List"
83
+ msgstr "オプションリスト"
84
+
85
+ #: custom-field-template/custom-field-template.php:276
86
  msgid "Reset Options"
87
  msgstr "オプションをリセットする"
88
 
89
+ #: custom-field-template/custom-field-template.php:278
90
  msgid "Are you sure to reset options? Options you set will be reset to the default settings."
91
  msgstr "本当にオプションをリセットしてもよろしいですか?設定したオプションはデフォルトの状態に戻ります。"
92
 
93
+ #: custom-field-template/custom-field-template.php:282
94
  msgid "Unset Options »"
95
  msgstr "オプションをリセットする »"
96
 
97
+ #: custom-field-template/custom-field-template.php:293
98
  msgid "Delete Options"
99
  msgstr "オプションを削除する"
100
 
101
+ #: custom-field-template/custom-field-template.php:295
102
  msgid "Are you sure to delete options? Options you set will be deleted."
103
  msgstr "本当にオプションを削除してもよろしいですか?設定したオプションは削除されます。"
104
 
105
+ #: custom-field-template/custom-field-template.php:299
106
  msgid "Delete Options »"
107
  msgstr "オプションを削除する »"
108
 
109
+ #: custom-field-template/custom-field-template.php:412
110
+ msgid "Clear"
111
+ msgstr "解除"
112
+
113
+ #: custom-field-template/custom-field-template.php:493
114
  msgid "Add Media"
115
  msgstr ""
116
 
117
+ #: custom-field-template/custom-field-template.php:495
118
  msgid "Add an Image"
119
  msgstr ""
120
 
121
+ #: custom-field-template/custom-field-template.php:497
122
  msgid "Add Video"
123
  msgstr ""
124
 
125
+ #: custom-field-template/custom-field-template.php:499
126
  msgid "Add Audio"
127
  msgstr ""
128
 
129
+ #: custom-field-template/custom-field-template.php:510
130
  msgid "Toggle"
131
  msgstr "切り替え"
132
 
custom-field-template.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Custom Field Template
4
  Plugin URI: http://wordpressgogo.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: 0.4.4
8
  Author URI: http://wordpressgogo.com/
9
  */
10
 
@@ -16,20 +16,16 @@ I appreciate your efforts, Joshua.
16
  class custom_field_template {
17
 
18
  function custom_field_template() {
19
- global $wp_version;
20
-
21
  add_action( 'init', array(&$this, 'custom_field_template_init') );
22
  add_action( 'admin_menu', array(&$this, 'custom_field_template_admin_menu') );
23
  add_action( 'admin_print_scripts', array(&$this, 'custom_field_template_admin_scripts') );
24
-
25
- add_action( 'simple_edit_form', array(&$this, 'insert_custome_field'), 1 );
26
- add_action( 'edit_form_advanced', array(&$this, 'insert_custom_field'), 1 );
27
- add_action( 'edit_page_form', array(&$this, 'insert_custom_field'), 1 );
28
  add_action( 'edit_post', array(&$this, 'edit_meta_value') );
29
  add_action( 'save_post', array(&$this, 'edit_meta_value') );
30
  add_action( 'publish_post', array(&$this, 'edit_meta_value') );
31
 
32
  add_filter( 'media_send_to_editor', array(&$this, 'media_send_to_custom_field'), 15 );
 
33
  }
34
 
35
  function media_send_to_custom_field($html) {
@@ -52,6 +48,8 @@ class custom_field_template {
52
  }
53
 
54
  function custom_field_template_init() {
 
 
55
  if ( function_exists('load_plugin_textdomain') ) {
56
  load_plugin_textdomain('custom-field-template', 'wp-content/plugins/custom-field-template');
57
  }
@@ -61,12 +59,35 @@ class custom_field_template {
61
  exit();
62
  }
63
 
64
- if( strstr($_SERVER['REQUEST_URI'], 'wp-admin/plugins.php') && isset($_GET['activate']) && $_GET['activate'] == 'true' ) {
65
  $options = $this->get_custom_field_template_data();
66
  if( !$options ) {
67
  $this->install_custom_field_template_data();
68
  }
69
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  }
71
 
72
  function custom_field_template_admin_scripts() {
@@ -108,6 +129,7 @@ hideKey = true
108
  type = radio
109
  value = 0-9 # 10-19 # 20+
110
  default = 10-19
 
111
 
112
  [Temper Level]
113
  type = select
@@ -162,19 +184,23 @@ mediaButton = true';
162
  <?php endif; ?>
163
  <div class="wrap">
164
  <h2><?php _e('Custom Field Template', 'custom-field-template'); ?></h2>
 
165
 
 
 
166
  <h3><?php _e('Custom Field Template Options', 'custom-field-template'); ?></h3>
 
167
  <form method="post">
168
- <table class="form-table">
169
  <tbody>
170
  <?php
171
  for ( $i = 0; $i < count($options['custom_fields'])+1; $i++ ) {
172
  ?>
173
  <tr><td>
174
  <p><label for="custom_field_template_title[<?= $i ?>]"><?php echo sprintf(__('Template Title %d', 'custom-field-template'), $i+1); ?></label>:<br />
175
- <input type="text" name="custom_field_template_title[<?= $i ?>]" id="custom_field_template_title[<?= $i ?>]" class="input" value="<?= stripcslashes($options['custom_fields'][$i]['title']) ?>" size="60" /></p>
176
  <p><label for="custom_field_template_content[<?= $i ?>]"><?php echo sprintf(__('Template Content %d', 'custom-field-template'), $i+1); ?></label>:<br />
177
- <textarea name="custom_field_template_content[<?= $i ?>]" id="custom_field_template_content[<?= $i ?>]" class="textarea" rows="10" cols="60"><?= stripcslashes($options['custom_fields'][$i]['content']) ?></textarea></p>
178
  </td></tr>
179
  <?php
180
  }
@@ -190,10 +216,67 @@ mediaButton = true';
190
  </tbody>
191
  </table>
192
  </form>
 
 
 
193
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  <h3><?php _e('Reset Options', 'custom-field-template'); ?></h3>
 
195
  <form method="post" onsubmit="return confirm('<?php _e('Are you sure to reset options? Options you set will be reset to the default settings.', 'custom-field-template'); ?>');">
196
- <table class="form-table">
197
  <tbody>
198
  <tr><td>
199
  <p><input type="submit" name="custom_field_template_unset_options_submit" value="<?php _e('Unset Options &raquo;', 'custom-field-template'); ?>" /></p>
@@ -201,10 +284,16 @@ mediaButton = true';
201
  </tbody>
202
  </table>
203
  </form>
 
 
 
204
 
 
 
205
  <h3><?php _e('Delete Options', 'custom-field-template'); ?></h3>
 
206
  <form method="post" onsubmit="return confirm('<?php _e('Are you sure to delete options? Options you set will be deleted.', 'custom-field-template'); ?>');">
207
- <table class="form-table">
208
  <tbody>
209
  <tr><td>
210
  <p><input type="submit" name="custom_field_template_delete_options_submit" value="<?php _e('Delete Options &raquo;', 'custom-field-template'); ?>" /></p>
@@ -212,6 +301,22 @@ mediaButton = true';
212
  </tbody>
213
  </table>
214
  </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
 
216
  </div>
217
  <?php
@@ -284,7 +389,7 @@ mediaButton = true';
284
  return $out;
285
  }
286
 
287
- function make_radio( $name, $sid, $values, $default, $hideKey ) {
288
  $title = $name;
289
  $name = $this->sanitize_name( $name );
290
 
@@ -297,10 +402,19 @@ mediaButton = true';
297
  }
298
 
299
  if( $hideKey == true ) $hide = ' style="visibility: hidden;"';
300
-
301
  $out .=
302
  '<tr>' .
303
- '<th scope="row" valign="top"' . $hide . '>' . $title . ' </th>' .
 
 
 
 
 
 
 
 
 
304
  '<td>';
305
 
306
  foreach( $values as $val ) {
@@ -367,7 +481,7 @@ mediaButton = true';
367
  $out = '<script type="text/javascript">' . "\n" .
368
  '// <![CDATA[' . "\n" .
369
  'if ( typeof tinyMCE != "undefined" )' . "\n" .
370
- 'jQuery(document).ready(function() {tinyMCE.execCommand("mceAddControl", false, "'. $name . $rand . '"); tinyMCEID.push("'. $name . $rand . '");});' . "\n" .
371
  '// ]]>' . "\n" .
372
  '</script>';
373
  }
@@ -399,18 +513,19 @@ EOF;
399
 
400
  }
401
 
402
- if( $hideKey == true ) $hide = ' style="visibility: hidden;"';
403
 
404
  $out .=
405
  '<tr>' .
406
  '<th scope="row" valign="top"><span' . $hide . '>' . $title . '</span><br />' . $media . $switch . '</th>' .
407
- '<td><textarea id="' . $name . $rand . '" name="' . $name . '[' . $sid . ']" type="textfield" rows="' .$rows. '" cols="' . $cols . '" style="color:#000000">' . attribute_escape($value) . '</textarea></td>' .
408
  '</tr>';
409
  return $out;
410
  }
411
 
412
  function load_custom_field( $id = 0 ) {
413
-
 
414
  $fields = $this->get_custom_fields( $id );
415
 
416
  if( $fields == null)
@@ -430,7 +545,7 @@ EOF;
430
  else if( $data[$i][ 'type' ] == 'radio' ) {
431
  $out .=
432
  $this->make_radio(
433
- $title, $i, explode( '#', $data[$i][ 'value' ] ), $data[$i][ 'default' ], $data[$i][ 'hideKey' ] );
434
  }
435
  else if( $data[$i][ 'type' ] == 'select' ) {
436
  $out .=
@@ -438,6 +553,7 @@ EOF;
438
  $title, $i, explode( '#', $data[$i][ 'value' ] ), $data[$i][ 'default' ], $data[$i][ 'hideKey' ] );
439
  }
440
  else if( $data[$i][ 'type' ] == 'textarea' ) {
 
441
  $out .=
442
  $this->make_textarea( $title, $i, $data[$i][ 'rows' ], $data[$i][ 'cols' ], $data[$i][ 'tinyMCE' ], $data[$i][ 'mediaButton' ], $data[$i][ 'hideKey' ] );
443
  }
@@ -456,13 +572,7 @@ EOF;
456
  if( $options == null)
457
  return;
458
 
459
- if ( substr($wp_version, 0, 3) >= '2.5' ) {
460
- $out .= '
461
- <div id="postaiosp" class="postbox">
462
- <h3>' . __('Custom Field Template', 'custom-field-template') . '</h3>
463
- <div class="inside">
464
- <div id="postaiosp">';
465
- } else {
466
  $out .= '
467
  <div class="dbx-b-ox-wrapper">
468
  <fieldset id="seodiv" class="dbx-box">
@@ -547,9 +657,14 @@ EOF;
547
  foreach( $fields as $title => $data ) {
548
  for($i = 0; $i<count($data); $i++) {
549
  if( $data[$i][ 'type' ] == 'textarea' && $data[$i][ 'tinyMCE' ] ) {
550
- $out .= 'jQuery(document).ready(function() {' . "\n" .
551
- ' if(wpTinyMCEConfig) if(wpTinyMCEConfig.defaultEditor == "html") { jQuery("#edButtonPreview").trigger("click"); }' . "\n" .
552
- '});' . "\n";
 
 
 
 
 
553
  break;
554
  }
555
  }
@@ -578,9 +693,7 @@ EOF;
578
 
579
  $out .= '</div>';
580
 
581
- if ( substr($wp_version, 0, 3) >= '2.5' ) {
582
- $out .= '</div></div></div>';
583
- } else {
584
  $out .= '</div></fieldset></div>';
585
  }
586
 
@@ -590,7 +703,7 @@ EOF;
590
  function edit_meta_value( $id ) {
591
  global $wpdb;
592
  $options = $this->get_custom_field_template_data();
593
-
594
  if( !isset( $id ) )
595
  $id = $_REQUEST[ 'post_ID' ];
596
 
@@ -618,20 +731,17 @@ EOF;
618
 
619
  $meta_value = stripslashes(trim($_REQUEST[ "$name" ][$i]));
620
  if( isset( $meta_value ) && !empty( $meta_value ) ) {
621
-
622
- /*if( $data[$i][ 'type' ] == 'textfield' ||
623
- $data[$i][ 'type' ] == 'radio' ||
624
- $data[$i][ 'type' ] == 'select' ||
625
- $data[$i][ 'type' ] == 'textarea' ) {*/
626
- add_post_meta( $id, $title, $meta_value );
627
- /*}
628
- else if( $data[$i][ 'type' ] == 'checkbox' )
629
- add_post_meta( $id, $title, 'true' );*/
630
  }
631
  }
632
  }
633
-
634
- $options['posts'][$_REQUEST['post_ID']] = $_REQUEST['custom-field-template-id'];
635
  update_option('custom_field_template_data', $options);
636
  }
637
 
4
  Plugin URI: http://wordpressgogo.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: 0.5.0
8
  Author URI: http://wordpressgogo.com/
9
  */
10
 
16
  class custom_field_template {
17
 
18
  function custom_field_template() {
 
 
19
  add_action( 'init', array(&$this, 'custom_field_template_init') );
20
  add_action( 'admin_menu', array(&$this, 'custom_field_template_admin_menu') );
21
  add_action( 'admin_print_scripts', array(&$this, 'custom_field_template_admin_scripts') );
22
+
 
 
 
23
  add_action( 'edit_post', array(&$this, 'edit_meta_value') );
24
  add_action( 'save_post', array(&$this, 'edit_meta_value') );
25
  add_action( 'publish_post', array(&$this, 'edit_meta_value') );
26
 
27
  add_filter( 'media_send_to_editor', array(&$this, 'media_send_to_custom_field'), 15 );
28
+ add_filter( 'plugin_action_links', array(&$this, 'wpaq_filter_plugin_actions',), 10, 2);
29
  }
30
 
31
  function media_send_to_custom_field($html) {
48
  }
49
 
50
  function custom_field_template_init() {
51
+ global $wp_version;
52
+
53
  if ( function_exists('load_plugin_textdomain') ) {
54
  load_plugin_textdomain('custom-field-template', 'wp-content/plugins/custom-field-template');
55
  }
59
  exit();
60
  }
61
 
62
+ if( strstr($_SERVER['REQUEST_URI'], 'wp-admin/plugins.php') && ((isset($_GET['activate']) && $_GET['activate'] == 'true') || (isset($_GET['activate-multi']) && $_GET['activate-multi'] == 'true') ) ) {
63
  $options = $this->get_custom_field_template_data();
64
  if( !$options ) {
65
  $this->install_custom_field_template_data();
66
  }
67
  }
68
+
69
+ if ( substr($wp_version, 0, 3) < '2.5' ) {
70
+ add_action( 'simple_edit_form', array(&$this, 'insert_custome_field'), 1 );
71
+ add_action( 'edit_form_advanced', array(&$this, 'insert_custom_field'), 1 );
72
+ add_action( 'edit_page_form', array(&$this, 'insert_custom_field'), 1 );
73
+ } else {
74
+ require_once(ABSPATH . 'wp-admin/includes/template.php');
75
+ add_meta_box('cftdiv', __('Custom Field Template', 'custom-field-template'), array(&$this, 'insert_custom_field'), 'post', 'normal', 'core');
76
+ add_meta_box('cftdiv', __('Custom Field Template', 'custom-field-template'), array(&$this, 'insert_custom_field'), 'page', 'normal', 'core');
77
+ }
78
+
79
+ }
80
+
81
+ function wpaq_filter_plugin_actions($links, $file){
82
+ static $this_plugin;
83
+
84
+ if( ! $this_plugin ) $this_plugin = plugin_basename(__FILE__);
85
+
86
+ if( $file == $this_plugin ){
87
+ $settings_link = '<a href="options-general.php?page=custom-field-template.php">' . __('Settings') . '</a>';
88
+ $links = array_merge( array($settings_link), $links);
89
+ }
90
+ return $links;
91
  }
92
 
93
  function custom_field_template_admin_scripts() {
129
  type = radio
130
  value = 0-9 # 10-19 # 20+
131
  default = 10-19
132
+ clearButton = true
133
 
134
  [Temper Level]
135
  type = select
184
  <?php endif; ?>
185
  <div class="wrap">
186
  <h2><?php _e('Custom Field Template', 'custom-field-template'); ?></h2>
187
+ <br class="clear"/>
188
 
189
+ <div id="poststuff" class="ui-sortable">
190
+ <div class="postbox">
191
  <h3><?php _e('Custom Field Template Options', 'custom-field-template'); ?></h3>
192
+ <div class="inside">
193
  <form method="post">
194
+ <table class="form-table" style="margin-bottom:5px;">
195
  <tbody>
196
  <?php
197
  for ( $i = 0; $i < count($options['custom_fields'])+1; $i++ ) {
198
  ?>
199
  <tr><td>
200
  <p><label for="custom_field_template_title[<?= $i ?>]"><?php echo sprintf(__('Template Title %d', 'custom-field-template'), $i+1); ?></label>:<br />
201
+ <input type="text" name="custom_field_template_title[<?= $i ?>]" id="custom_field_template_title[<?= $i ?>]" value="<?= stripcslashes($options['custom_fields'][$i]['title']) ?>" size="60" /></p>
202
  <p><label for="custom_field_template_content[<?= $i ?>]"><?php echo sprintf(__('Template Content %d', 'custom-field-template'), $i+1); ?></label>:<br />
203
+ <textarea name="custom_field_template_content[<?= $i ?>]" id="custom_field_template_content[<?= $i ?>]" rows="10" cols="60"><?= stripcslashes($options['custom_fields'][$i]['content']) ?></textarea></p>
204
  </td></tr>
205
  <?php
206
  }
216
  </tbody>
217
  </table>
218
  </form>
219
+ </div>
220
+ </div>
221
+ </div>
222
 
223
+ <div id="poststuff" class="ui-sortable">
224
+ <div class="postbox closed">
225
+ <h3><?php _e('Option List', 'custom-field-template'); ?></h3>
226
+ <div class="inside">
227
+ ex.<br />
228
+ [Plan]<br />
229
+ type = textfield<br />
230
+ size = 35<br />
231
+ hideKey = true<br />
232
+
233
+ <table class="form-table" style="margin-bottom:5px;">
234
+ <thead>
235
+ <tr>
236
+ <th>type</th><th>textfield</th><th>checkbox</th><th>radio</th><th>select</th><th>textarea</th>
237
+ </tr>
238
+ </thead>
239
+ <tbody>
240
+ <tr>
241
+ <th>hideKey</th><td>hideKey = true</td><td>hideKey = true</td><td>hideKey = true</td><td>hideKey = true</td><td>hideKey = true</td>
242
+ </tr>
243
+ <tr>
244
+ <th>size</th><td>size = 30</td><td></td><td></td><td></td><td></td>
245
+ </tr>
246
+ <tr>
247
+ <th>value</th><td></td><td>value = apple # orange # banana</td><td>value = apple # orange # banana</td><td>value = apple # orange # banana</td>
248
+ <td></td>
249
+ </tr>
250
+ <tr>
251
+ <th>default</th><td></td><td>default = orange # banana</td><td>default = orange</td><td>default = orange</td><td></td>
252
+ </tr>
253
+ <tr>
254
+ <th>clearButton</th><td></td><td></td><td>clearButton = true</td><td></td><td></td>
255
+ </tr>
256
+ <tr>
257
+ <th>rows</th><td></td><td></td><td></td><td></td><td>rows = 4</td>
258
+ </tr>
259
+ <tr>
260
+ <th>cols</th><td></td><td></td><td></td><td></td><td>cols = 40</td>
261
+ </tr>
262
+ <tr>
263
+ <th>tinyMCE</th><td></td><td></td><td></td><td></td><td>tinyMCE = true</td>
264
+ </tr>
265
+ <tr>
266
+ <th>mediaButton</th><td></td><td></td><td></td><td></td><td>mediaButton = true</td>
267
+ </tr>
268
+ </tbody>
269
+ </table>
270
+ </div>
271
+ </div>
272
+ </div>
273
+
274
+ <div id="poststuff" class="ui-sortable">
275
+ <div class="postbox closed">
276
  <h3><?php _e('Reset Options', 'custom-field-template'); ?></h3>
277
+ <div class="inside">
278
  <form method="post" onsubmit="return confirm('<?php _e('Are you sure to reset options? Options you set will be reset to the default settings.', 'custom-field-template'); ?>');">
279
+ <table class="form-table" style="margin-bottom:5px;">
280
  <tbody>
281
  <tr><td>
282
  <p><input type="submit" name="custom_field_template_unset_options_submit" value="<?php _e('Unset Options &raquo;', 'custom-field-template'); ?>" /></p>
284
  </tbody>
285
  </table>
286
  </form>
287
+ </div>
288
+ </div>
289
+ </div>
290
 
291
+ <div id="poststuff" class="ui-sortable">
292
+ <div class="postbox closed">
293
  <h3><?php _e('Delete Options', 'custom-field-template'); ?></h3>
294
+ <div class="inside">
295
  <form method="post" onsubmit="return confirm('<?php _e('Are you sure to delete options? Options you set will be deleted.', 'custom-field-template'); ?>');">
296
+ <table class="form-table" style="margin-bottom:5px;">
297
  <tbody>
298
  <tr><td>
299
  <p><input type="submit" name="custom_field_template_delete_options_submit" value="<?php _e('Delete Options &raquo;', 'custom-field-template'); ?>" /></p>
301
  </tbody>
302
  </table>
303
  </form>
304
+ </div>
305
+ </div>
306
+ </div>
307
+
308
+ <script type="text/javascript">
309
+ // <![CDATA[
310
+ <?php if ( version_compare( substr($wp_version, 0, 3), '2.7', '<' ) ) { ?>
311
+ jQuery('.postbox h3').prepend('<a class="togbox">+</a> ');
312
+ <?php } ?>
313
+ jQuery('.postbox h3').click( function() { jQuery(jQuery(this).parent().get(0)).toggleClass('closed'); } );
314
+ jQuery('.postbox.close-me').each(function(){
315
+ jQuery(this).addClass("closed");
316
+ });
317
+ //-->
318
+ </script>
319
+
320
 
321
  </div>
322
  <?php
389
  return $out;
390
  }
391
 
392
+ function make_radio( $name, $sid, $values, $clearButton, $default, $hideKey ) {
393
  $title = $name;
394
  $name = $this->sanitize_name( $name );
395
 
402
  }
403
 
404
  if( $hideKey == true ) $hide = ' style="visibility: hidden;"';
405
+
406
  $out .=
407
  '<tr>' .
408
+ '<th scope="row" valign="top"' . $hide . '>' . $title;
409
+
410
+ if( $clearButton == true ) {
411
+ $out .= '<div>';
412
+ $out .= '<a href="#clear" onclick="jQuery(this).parent().parent().parent().find(\'input\').attr(\'checked\', \'\'); return false;">' . __('Clear', 'custom-field-template') . '</a>';
413
+ $out .= '</div>';
414
+ }
415
+
416
+ $out .=
417
+ '</th>' .
418
  '<td>';
419
 
420
  foreach( $values as $val ) {
481
  $out = '<script type="text/javascript">' . "\n" .
482
  '// <![CDATA[' . "\n" .
483
  'if ( typeof tinyMCE != "undefined" )' . "\n" .
484
+ 'jQuery(document).ready(function() {tinyMCE.execCommand("mceAddControl", false, "'. $name . $rand . '"); tinyMCEID.push("'. $name . $rand . '");});' . "\n" .
485
  '// ]]>' . "\n" .
486
  '</script>';
487
  }
513
 
514
  }
515
 
516
+ if ( $hideKey == true ) $hide = ' style="visibility: hidden;"';
517
 
518
  $out .=
519
  '<tr>' .
520
  '<th scope="row" valign="top"><span' . $hide . '>' . $title . '</span><br />' . $media . $switch . '</th>' .
521
+ '<td><textarea id="' . $name . $rand . '" name="' . $name . '[' . $sid . ']" type="textfield" rows="' .$rows. '" cols="' . $cols . '" style="color:#000000">' . attribute_escape($value) . '</textarea><input type="hidden" name="'.$name.'_rand['.$sid.']" value="'.$rand.'" /></td>' .
522
  '</tr>';
523
  return $out;
524
  }
525
 
526
  function load_custom_field( $id = 0 ) {
527
+ $options = $this->get_custom_field_template_data();
528
+
529
  $fields = $this->get_custom_fields( $id );
530
 
531
  if( $fields == null)
545
  else if( $data[$i][ 'type' ] == 'radio' ) {
546
  $out .=
547
  $this->make_radio(
548
+ $title, $i, explode( '#', $data[$i][ 'value' ] ), $data[$i][ 'clearButton' ], $data[$i][ 'default' ], $data[$i][ 'hideKey' ] );
549
  }
550
  else if( $data[$i][ 'type' ] == 'select' ) {
551
  $out .=
553
  $title, $i, explode( '#', $data[$i][ 'value' ] ), $data[$i][ 'default' ], $data[$i][ 'hideKey' ] );
554
  }
555
  else if( $data[$i][ 'type' ] == 'textarea' ) {
556
+ if ( $options['tinyMCE'][$_REQUEST['post']][$this->sanitize_name($title)][$i] ) $data[$i][ 'rows' ] = $options['tinyMCE'][$_REQUEST['post']][$this->sanitize_name($title)][$i];
557
  $out .=
558
  $this->make_textarea( $title, $i, $data[$i][ 'rows' ], $data[$i][ 'cols' ], $data[$i][ 'tinyMCE' ], $data[$i][ 'mediaButton' ], $data[$i][ 'hideKey' ] );
559
  }
572
  if( $options == null)
573
  return;
574
 
575
+ if ( substr($wp_version, 0, 3) < '2.5' ) {
 
 
 
 
 
 
576
  $out .= '
577
  <div class="dbx-b-ox-wrapper">
578
  <fieldset id="seodiv" class="dbx-box">
657
  foreach( $fields as $title => $data ) {
658
  for($i = 0; $i<count($data); $i++) {
659
  if( $data[$i][ 'type' ] == 'textarea' && $data[$i][ 'tinyMCE' ] ) {
660
+ $out .= 'jQuery(document).ready(function() {' . "\n";
661
+ if ( substr($wp_version, 0, 3) >= '2.7' ) {
662
+ $out .= ' if ( getUserSetting( "editor" ) == "html" ) {
663
+ jQuery("#edButtonPreview").trigger("click"); }' . "\n";
664
+ } else {
665
+ $out .= ' if(wpTinyMCEConfig) if(wpTinyMCEConfig.defaultEditor == "html") { jQuery("#edButtonPreview").trigger("click"); }' . "\n";
666
+ }
667
+ $out .= '});' . "\n";
668
  break;
669
  }
670
  }
693
 
694
  $out .= '</div>';
695
 
696
+ if ( substr($wp_version, 0, 3) < '2.5' ) {
 
 
697
  $out .= '</div></fieldset></div>';
698
  }
699
 
703
  function edit_meta_value( $id ) {
704
  global $wpdb;
705
  $options = $this->get_custom_field_template_data();
706
+
707
  if( !isset( $id ) )
708
  $id = $_REQUEST[ 'post_ID' ];
709
 
731
 
732
  $meta_value = stripslashes(trim($_REQUEST[ "$name" ][$i]));
733
  if( isset( $meta_value ) && !empty( $meta_value ) ) {
734
+ add_post_meta( $id, $title, $meta_value );
735
+
736
+ if ( $_REQUEST['TinyMCE_' . $name . trim($_REQUEST[ $name."_rand" ][$i]) . '_size'] ) {
737
+ preg_match('/cw=[0-9]+&ch=([0-9]+)/', $_REQUEST['TinyMCE_' . $name . trim($_REQUEST[ $name."_rand" ][$i]) . '_size'], $matched);
738
+ $options['tinyMCE'][$id][$name][$i] = (int)($matched[1]/20);
739
+ }
 
 
 
740
  }
741
  }
742
  }
743
+
744
+ $options['posts'][$id] = $_REQUEST['custom-field-template-id'];
745
  update_option('custom_field_template_data', $options);
746
  }
747
 
custom-field-template.pot CHANGED
@@ -2,8 +2,8 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Custom Field Template\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2008-10-01 02:34+0900\n"
6
- "PO-Revision-Date: 2008-10-01 02:34+0900\n"
7
  "Last-Translator: \n"
8
  "Language-Team: \n"
9
  "MIME-Version: 1.0\n"
@@ -13,104 +13,117 @@ msgstr ""
13
  "X-Poedit-Basepath: ../\n"
14
  "X-Poedit-SearchPath-0: custom-field-template\n"
15
 
16
- #: custom-field-template/custom-field-template.php:81
17
- msgid "Default Template"
 
 
 
 
18
  msgstr ""
19
 
20
- #: custom-field-template/custom-field-template.php:120
21
- #: custom-field-template/custom-field-template.php:152
22
- #: custom-field-template/custom-field-template.php:431
23
- #: custom-field-template/custom-field-template.php:439
24
- msgid "Custom Field Template"
 
25
  msgstr ""
26
 
27
- #: custom-field-template/custom-field-template.php:137
28
  msgid "Options updated."
29
  msgstr ""
30
 
31
- #: custom-field-template/custom-field-template.php:141
32
  msgid "Options resetted."
33
  msgstr ""
34
 
35
- #: custom-field-template/custom-field-template.php:145
36
  msgid "Options deleted."
37
  msgstr ""
38
 
39
- #: custom-field-template/custom-field-template.php:154
40
  msgid "Custom Field Template Options"
41
  msgstr ""
42
 
43
- #: custom-field-template/custom-field-template.php:162
44
  #, php-format
45
  msgid "Template Title %d"
46
  msgstr ""
47
 
48
- #: custom-field-template/custom-field-template.php:164
49
  #, php-format
50
  msgid "Template Content %d"
51
  msgstr ""
52
 
53
- #: custom-field-template/custom-field-template.php:171
54
  msgid "In case that you would like to insert multiple images at once in use of the custom field media buttons"
55
  msgstr ""
56
 
57
- #: custom-field-template/custom-field-template.php:172
58
  msgid "Use multiple image inset"
59
  msgstr ""
60
 
61
- #: custom-field-template/custom-field-template.php:172
62
  msgid "Caution:"
63
  msgstr ""
64
 
65
- #: custom-field-template/custom-field-template.php:172
66
  msgid "You need to edit `wp-admin/includes/media.php`. Delete or comment out the code in the function media_send_to_editor at around line 88-96."
67
  msgstr ""
68
 
69
- #: custom-field-template/custom-field-template.php:176
70
  msgid "Update Options &raquo;"
71
  msgstr ""
72
 
73
- #: custom-field-template/custom-field-template.php:182
 
 
 
 
74
  msgid "Reset Options"
75
  msgstr ""
76
 
77
- #: custom-field-template/custom-field-template.php:183
78
  msgid "Are you sure to reset options? Options you set will be reset to the default settings."
79
  msgstr ""
80
 
81
- #: custom-field-template/custom-field-template.php:187
82
  msgid "Unset Options &raquo;"
83
  msgstr ""
84
 
85
- #: custom-field-template/custom-field-template.php:193
86
  msgid "Delete Options"
87
  msgstr ""
88
 
89
- #: custom-field-template/custom-field-template.php:194
90
  msgid "Are you sure to delete options? Options you set will be deleted."
91
  msgstr ""
92
 
93
- #: custom-field-template/custom-field-template.php:198
94
  msgid "Delete Options &raquo;"
95
  msgstr ""
96
 
97
- #: custom-field-template/custom-field-template.php:353
 
 
 
 
98
  msgid "Add Media"
99
  msgstr ""
100
 
101
- #: custom-field-template/custom-field-template.php:355
102
  msgid "Add an Image"
103
  msgstr ""
104
 
105
- #: custom-field-template/custom-field-template.php:357
106
  msgid "Add Video"
107
  msgstr ""
108
 
109
- #: custom-field-template/custom-field-template.php:359
110
  msgid "Add Audio"
111
  msgstr ""
112
 
113
- #: custom-field-template/custom-field-template.php:369
114
  msgid "Toggle"
115
  msgstr ""
116
 
2
  msgstr ""
3
  "Project-Id-Version: Custom Field Template\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2008-11-05 04:45+0900\n"
6
+ "PO-Revision-Date: 2008-11-05 04:45+0900\n"
7
  "Last-Translator: \n"
8
  "Language-Team: \n"
9
  "MIME-Version: 1.0\n"
13
  "X-Poedit-Basepath: ../\n"
14
  "X-Poedit-SearchPath-0: custom-field-template\n"
15
 
16
+ #: custom-field-template/custom-field-template.php:75
17
+ #: custom-field-template/custom-field-template.php:76
18
+ #: custom-field-template/custom-field-template.php:154
19
+ #: custom-field-template/custom-field-template.php:186
20
+ #: custom-field-template/custom-field-template.php:580
21
+ msgid "Custom Field Template"
22
  msgstr ""
23
 
24
+ #: custom-field-template/custom-field-template.php:87
25
+ msgid "Settings"
26
+ msgstr ""
27
+
28
+ #: custom-field-template/custom-field-template.php:98
29
+ msgid "Default Template"
30
  msgstr ""
31
 
32
+ #: custom-field-template/custom-field-template.php:171
33
  msgid "Options updated."
34
  msgstr ""
35
 
36
+ #: custom-field-template/custom-field-template.php:175
37
  msgid "Options resetted."
38
  msgstr ""
39
 
40
+ #: custom-field-template/custom-field-template.php:179
41
  msgid "Options deleted."
42
  msgstr ""
43
 
44
+ #: custom-field-template/custom-field-template.php:191
45
  msgid "Custom Field Template Options"
46
  msgstr ""
47
 
48
+ #: custom-field-template/custom-field-template.php:200
49
  #, php-format
50
  msgid "Template Title %d"
51
  msgstr ""
52
 
53
+ #: custom-field-template/custom-field-template.php:202
54
  #, php-format
55
  msgid "Template Content %d"
56
  msgstr ""
57
 
58
+ #: custom-field-template/custom-field-template.php:209
59
  msgid "In case that you would like to insert multiple images at once in use of the custom field media buttons"
60
  msgstr ""
61
 
62
+ #: custom-field-template/custom-field-template.php:210
63
  msgid "Use multiple image inset"
64
  msgstr ""
65
 
66
+ #: custom-field-template/custom-field-template.php:210
67
  msgid "Caution:"
68
  msgstr ""
69
 
70
+ #: custom-field-template/custom-field-template.php:210
71
  msgid "You need to edit `wp-admin/includes/media.php`. Delete or comment out the code in the function media_send_to_editor at around line 88-96."
72
  msgstr ""
73
 
74
+ #: custom-field-template/custom-field-template.php:214
75
  msgid "Update Options &raquo;"
76
  msgstr ""
77
 
78
+ #: custom-field-template/custom-field-template.php:225
79
+ msgid "Option List"
80
+ msgstr ""
81
+
82
+ #: custom-field-template/custom-field-template.php:276
83
  msgid "Reset Options"
84
  msgstr ""
85
 
86
+ #: custom-field-template/custom-field-template.php:278
87
  msgid "Are you sure to reset options? Options you set will be reset to the default settings."
88
  msgstr ""
89
 
90
+ #: custom-field-template/custom-field-template.php:282
91
  msgid "Unset Options &raquo;"
92
  msgstr ""
93
 
94
+ #: custom-field-template/custom-field-template.php:293
95
  msgid "Delete Options"
96
  msgstr ""
97
 
98
+ #: custom-field-template/custom-field-template.php:295
99
  msgid "Are you sure to delete options? Options you set will be deleted."
100
  msgstr ""
101
 
102
+ #: custom-field-template/custom-field-template.php:299
103
  msgid "Delete Options &raquo;"
104
  msgstr ""
105
 
106
+ #: custom-field-template/custom-field-template.php:412
107
+ msgid "Clear"
108
+ msgstr ""
109
+
110
+ #: custom-field-template/custom-field-template.php:493
111
  msgid "Add Media"
112
  msgstr ""
113
 
114
+ #: custom-field-template/custom-field-template.php:495
115
  msgid "Add an Image"
116
  msgstr ""
117
 
118
+ #: custom-field-template/custom-field-template.php:497
119
  msgid "Add Video"
120
  msgstr ""
121
 
122
+ #: custom-field-template/custom-field-template.php:499
123
  msgid "Add Audio"
124
  msgstr ""
125
 
126
+ #: custom-field-template/custom-field-template.php:510
127
  msgid "Toggle"
128
  msgstr ""
129
 
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Custom Field Template ===
2
  Contributors: Hiroaki Miyashita
3
  Donate link: http://wordpressgogo.com/development/custom-field-template.html
4
- Tags: custom, fields, field, template, meta
5
  Requires at least: 2.1
6
- Tested up to: 2.6.2
7
- Stable tag: 0.4.4
8
 
9
  This plugin adds the default custom fields on the Write Post/Page.
10
 
@@ -18,6 +18,7 @@ The Custom Field Template plugin adds the default custom fields on the Write Pos
18
  * Support for media buttons in the textarea. - requires at least 2.5.
19
  * Support for multiple fields with the same key.
20
  * Support for hideKey options.
 
21
 
22
  == Installation ==
23
 
1
  === Custom Field Template ===
2
  Contributors: Hiroaki Miyashita
3
  Donate link: http://wordpressgogo.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: 2.7 beta 1
7
+ Stable tag: 0.5.0
8
 
9
  This plugin adds the default custom fields on the Write Post/Page.
10
 
18
  * Support for media buttons in the textarea. - requires at least 2.5.
19
  * Support for multiple fields with the same key.
20
  * Support for hideKey options.
21
+ * You can see the full option list in the setting page of the plugin.
22
 
23
  == Installation ==
24