Custom Field Template - Version 0.5.1

Version Description

Download this release

Release Info

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

Code changes from version 0.5.0 to 0.5.1

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-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"
@@ -18,9 +18,9 @@ msgstr ""
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
 
@@ -32,101 +32,107 @@ msgstr "設定"
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
 
2
  msgstr ""
3
  "Project-Id-Version: Custom Field Template\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2008-11-05 19:01+0900\n"
6
+ "PO-Revision-Date: 2008-11-05 19:02+0900\n"
7
  "Last-Translator: \n"
8
  "Language-Team: \n"
9
  "MIME-Version: 1.0\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:153
22
+ #: custom-field-template/custom-field-template.php:190
23
+ #: custom-field-template/custom-field-template.php:620
24
  msgid "Custom Field Template"
25
  msgstr "カスタムフィールドテンプレート"
26
 
32
  msgid "Default Template"
33
  msgstr "デフォルトテンプレート"
34
 
35
+ #: custom-field-template/custom-field-template.php:170
36
+ #: custom-field-template/custom-field-template.php:174
37
  msgid "Options updated."
38
  msgstr "オプションは更新されました。"
39
 
40
+ #: custom-field-template/custom-field-template.php:179
41
  msgid "Options resetted."
42
  msgstr "オプションはリセットされました。"
43
 
44
+ #: custom-field-template/custom-field-template.php:183
45
  msgid "Options deleted."
46
  msgstr "オプションは削除されました。"
47
 
48
+ #: custom-field-template/custom-field-template.php:195
49
  msgid "Custom Field Template Options"
50
  msgstr "カスタムフィールドテンプレートオプション"
51
 
52
+ #: custom-field-template/custom-field-template.php:204
53
  #, php-format
54
  msgid "Template Title %d"
55
  msgstr "テンプレートタイトル %d"
56
 
57
+ #: custom-field-template/custom-field-template.php:206
58
  #, php-format
59
  msgid "Template Content %d"
60
  msgstr "テンプレートコンテンツ %d"
61
 
62
+ #: custom-field-template/custom-field-template.php:213
63
  msgid "In case that you would like to insert multiple images at once in use of the custom field media buttons"
64
  msgstr "カスタムフィールへの画像挿入を一度に複数枚実行する場合"
65
 
66
+ #: custom-field-template/custom-field-template.php:214
67
  msgid "Use multiple image inset"
68
  msgstr "複数画像挿入を利用する"
69
 
70
+ #: custom-field-template/custom-field-template.php:214
71
  msgid "Caution:"
72
  msgstr "ご注意:"
73
 
74
+ #: custom-field-template/custom-field-template.php:214
75
  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."
76
  msgstr "`wp-admin/includes/media.php`を編集する必要があります。88-96行目の media_send_to_editor関数の中身を削除するかコメントアウトしてください。"
77
 
78
+ #: custom-field-template/custom-field-template.php:218
79
+ #: custom-field-template/custom-field-template.php:238
80
  msgid "Update Options »"
81
  msgstr "オプションを更新する »"
82
 
83
+ #: custom-field-template/custom-field-template.php:229
84
+ msgid "Admin CSS"
85
+ msgstr ""
86
+
87
+ #: custom-field-template/custom-field-template.php:249
88
  msgid "Option List"
89
  msgstr "オプションリスト"
90
 
91
+ #: custom-field-template/custom-field-template.php:303
92
  msgid "Reset Options"
93
  msgstr "オプションをリセットする"
94
 
95
+ #: custom-field-template/custom-field-template.php:305
96
  msgid "Are you sure to reset options? Options you set will be reset to the default settings."
97
  msgstr "本当にオプションをリセットしてもよろしいですか?設定したオプションはデフォルトの状態に戻ります。"
98
 
99
+ #: custom-field-template/custom-field-template.php:309
100
  msgid "Unset Options »"
101
  msgstr "オプションをリセットする »"
102
 
103
+ #: custom-field-template/custom-field-template.php:320
104
  msgid "Delete Options"
105
  msgstr "オプションを削除する"
106
 
107
+ #: custom-field-template/custom-field-template.php:322
108
  msgid "Are you sure to delete options? Options you set will be deleted."
109
  msgstr "本当にオプションを削除してもよろしいですか?設定したオプションは削除されます。"
110
 
111
+ #: custom-field-template/custom-field-template.php:326
112
  msgid "Delete Options »"
113
  msgstr "オプションを削除する »"
114
 
115
+ #: custom-field-template/custom-field-template.php:443
116
  msgid "Clear"
117
  msgstr "解除"
118
 
119
+ #: custom-field-template/custom-field-template.php:527
120
  msgid "Add Media"
121
  msgstr ""
122
 
123
+ #: custom-field-template/custom-field-template.php:529
124
  msgid "Add an Image"
125
  msgstr ""
126
 
127
+ #: custom-field-template/custom-field-template.php:531
128
  msgid "Add Video"
129
  msgstr ""
130
 
131
+ #: custom-field-template/custom-field-template.php:533
132
  msgid "Add Audio"
133
  msgstr ""
134
 
135
+ #: custom-field-template/custom-field-template.php:544
136
  msgid "Toggle"
137
  msgstr "切り替え"
138
 
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.5.0
8
  Author URI: http://wordpressgogo.com/
9
  */
10
 
@@ -63,6 +63,7 @@ class custom_field_template {
63
  $options = $this->get_custom_field_template_data();
64
  if( !$options ) {
65
  $this->install_custom_field_template_data();
 
66
  }
67
  }
68
 
@@ -99,6 +100,7 @@ class custom_field_template {
99
  $options['custom_fields'][0]['content'] = '[Plan]
100
  type = textfield
101
  size = 35
 
102
 
103
  [Plan]
104
  type = textfield
@@ -110,21 +112,6 @@ type = checkbox
110
  value = apple # orange # banana # grape
111
  default = orange # grape
112
 
113
- [Favorite Animal]
114
- type = checkbox
115
- value = dog
116
- checked = true
117
-
118
- [Favorite Animal]
119
- type = checkbox
120
- value = cat
121
- hideKey = true
122
-
123
- [Favorite Animal]
124
- type = checkbox
125
- value = monkey
126
- hideKey = true
127
-
128
  [Miles Walked]
129
  type = radio
130
  value = 0-9 # 10-19 # 20+
@@ -145,6 +132,18 @@ mediaButton = true';
145
  update_option('custom_field_template_data', $options);
146
  }
147
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  function get_custom_field_template_data() {
149
  $options = get_option('custom_field_template_data');
150
  return $options;
@@ -169,8 +168,13 @@ mediaButton = true';
169
  }
170
  update_option('custom_field_template_data', $options);
171
  $message = __('Options updated.', 'custom-field-template');
 
 
 
 
172
  elseif ($_POST['custom_field_template_unset_options_submit']) :
173
  $this->install_custom_field_template_data();
 
174
  $options = $this->get_custom_field_template_data();
175
  $message = __('Options resetted.', 'custom-field-template');
176
  elseif ($_POST['custom_field_template_delete_options_submit']) :
@@ -220,6 +224,26 @@ mediaButton = true';
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>
@@ -241,6 +265,9 @@ hideKey = true<br />
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>
@@ -338,7 +365,7 @@ jQuery(this).addClass("closed");
338
  return $custom_fields;
339
  }
340
 
341
- function make_textfield( $name, $sid, $size = 25, $hideKey ) {
342
  $title = $name;
343
  $name = $this->sanitize_name( $name );
344
 
@@ -349,17 +376,20 @@ jQuery(this).addClass("closed");
349
  }
350
  }
351
 
352
- if( $hideKey == true ) $hide = ' style="visibility: hidden;"';
353
 
354
  $out .=
355
- '<tr>' .
356
- '<th scope="row"' . $hide . '>' . $title . ' </th>' .
357
- '<td> <input id="' . $name . '" name="' . $name . '[]" value="' . attribute_escape($value) . '" type="textfield" size="' . $size . '" /></td>' .
358
- '</tr>';
 
 
 
359
  return $out;
360
  }
361
 
362
- function make_checkbox( $name, $sid, $value, $checked, $hideKey ) {
363
  $title = $name;
364
  $name = $this->sanitize_name( $name );
365
 
@@ -375,21 +405,22 @@ jQuery(this).addClass("closed");
375
  if( $checked == true ) $checked = 'checked="checked"';
376
  }
377
 
378
- if( $hideKey == true ) $hide = ' style="visibility: hidden;"';
379
 
380
  $out .=
381
- '<tr>' .
382
- '<th scope="row" valign="top"' . $hide . '>' . $title . ' </th>' .
383
- '<td>';
384
-
385
- $out .= '<label for="' . $id . '" class="selectit"><input name="' . $name . '[' . $sid . ']" value="' . attribute_escape($value) . '" ' . $checked . ' type="checkbox" /> ' . stripcslashes($value) . '</label><br>';
 
386
 
387
- $out .= '</td>';
388
 
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
 
@@ -401,11 +432,11 @@ jQuery(this).addClass("closed");
401
  $selected = $default;
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>';
@@ -414,23 +445,24 @@ jQuery(this).addClass("closed");
414
  }
415
 
416
  $out .=
417
- '</th>' .
418
- '<td>';
419
-
 
420
  foreach( $values as $val ) {
421
  $id = $name . '_' . $this->sanitize_name( $val );
422
 
423
  $checked = ( trim( $val ) == trim( $selected ) ) ? 'checked="checked"' : '';
424
 
425
  $out .=
426
- '<label for="' . $id . '" class="selectit"><input id="' . $id . '" name="' . $name . '[' . $sid . ']" value="' . attribute_escape($val) . '" ' . $checked . ' type="radio" /> ' . stripcslashes($val) . '</label><br>';
427
  }
428
- $out .= '</td>';
429
 
430
  return $out;
431
  }
432
 
433
- function make_select( $name, $sid, $values, $default, $hideKey ) {
434
  $title = $name;
435
  $name = $this->sanitize_name( $name );
436
 
@@ -444,13 +476,15 @@ jQuery(this).addClass("closed");
444
  $selected = $default;
445
  }
446
 
447
- if( $hideKey == true ) $hide = ' style="visibility: hidden;"';
448
 
449
  $out .=
450
- '<tr>' .
451
- '<th scope="row" valign="top"' . $hide . '>' . $title . ' </th>' .
452
- '<td>' .
453
- '<select name="' . $name . '[]">' .
 
 
454
  '<option value="" >Select</option>';
455
 
456
  foreach( $values as $val ) {
@@ -459,12 +493,12 @@ jQuery(this).addClass("closed");
459
  $out .=
460
  '<option value="' . attribute_escape($val) . '" ' . $checked . ' > ' . $val. '</option>';
461
  }
462
- $out .= '</select></td>';
463
 
464
  return $out;
465
  }
466
 
467
- function make_textarea( $name, $sid, $rows, $cols, $tinyMCE, $mediaButton, $hideKey ) {
468
  global $wp_version;
469
 
470
  $title = $name;
@@ -509,17 +543,20 @@ EOF;
509
  if( $tinyMCE == true && user_can_richedit() ) {
510
  $switch .= '<a href="#toggle" onclick="switchMode(\''.$name.$rand.'\'); return false;">' . __('Toggle', 'custom-field-template') . '</a>';
511
  }
512
- $swicth .= '</div>';
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
 
@@ -532,35 +569,33 @@ EOF;
532
  return;
533
 
534
  $out .= '<input type="hidden" name="custom-field-template-id" id="custom-field-template-id" value="' . $id . '" />';
535
- $out .= '<table class="editform" style="width:100%;">';
536
  foreach( $fields as $title => $data ) {
537
  for($i = 0; $i<count($data); $i++) {
538
- if( $data[$i][ 'type' ] == 'textfield' ) {
539
- $out .= $this->make_textfield( $title, $i, $data[$i][ 'size' ], $data[$i][ 'hideKey' ] );
540
  }
541
- else if( $data[$i][ 'type' ] == 'checkbox' ) {
542
  $out .=
543
- $this->make_checkbox( $title, $i, $data[$i][ 'value' ], $data[$i][ 'checked' ], $data[$i][ 'hideKey' ] );
544
  }
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 .=
552
  $this->make_select(
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
  }
560
  }
561
  }
562
-
563
- $out .= '</table>';
564
 
565
  return $out;
566
  }
@@ -572,6 +607,11 @@ EOF;
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">
@@ -674,23 +714,29 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";
674
  $out .= 'var tinyMCEID = new Array();' . "\n" .
675
  '// ]]>' . "\n" .
676
  '</script>';
677
-
 
 
 
 
678
  $body = $this->load_custom_field();
679
- $out .= '<select id="custom_field_template_select" onchange="if(tinyMCEID.length) { for(i=0;i<tinyMCEID.length;i++) {tinyMCE.execCommand(\'mceRemoveControl\', false, tinyMCEID[i]);} tinyMCEID = new Array();};jQuery.ajax({type: \'GET\', url: \'?page=custom-field-template/custom-field-template.php&id=\'+jQuery(this).val()+\'&post=\'+jQuery(\'#post_ID\').val(), success: function(html) {jQuery(\'#custom-field-template-box\').html(html);}});">';
680
- for ( $i=0; $i < count($options['custom_fields']); $i++ ) {
681
- if ( $i == $options['posts'][$_REQUEST['post']] ) {
682
- $out .= '<option value="' . $i . '" selected="selected">' . stripcslashes($options['custom_fields'][$i]['title']) . '</option>';
683
- $body = $this->load_custom_field($i);
684
- } else
685
- $out .= '<option value="' . $i . '">' . stripcslashes($options['custom_fields'][$i]['title']) . '</option>';
 
 
 
 
686
  }
687
- $out .= '</select>';
688
-
689
  $out .= '<input type="hidden" name="custom-field-template-verify-key" id="custom-field-template-verify-key" value="' . wp_create_nonce('custom-field-template') . '" />';
690
- $out .= '<div id="custom-field-template-box">';
691
 
692
  $out .= $body;
693
-
694
  $out .= '</div>';
695
 
696
  if ( substr($wp_version, 0, 3) < '2.5' ) {
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.1
8
  Author URI: http://wordpressgogo.com/
9
  */
10
 
63
  $options = $this->get_custom_field_template_data();
64
  if( !$options ) {
65
  $this->install_custom_field_template_data();
66
+ $this->install_custom_field_template_css();
67
  }
68
  }
69
 
100
  $options['custom_fields'][0]['content'] = '[Plan]
101
  type = textfield
102
  size = 35
103
+ label = Where are you going to go?
104
 
105
  [Plan]
106
  type = textfield
112
  value = apple # orange # banana # grape
113
  default = orange # grape
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  [Miles Walked]
116
  type = radio
117
  value = 0-9 # 10-19 # 20+
132
  update_option('custom_field_template_data', $options);
133
  }
134
 
135
+ function install_custom_field_template_css() {
136
+ $options = get_option('custom_field_template_data');
137
+ $options['css'] = '#cft dl { clear:both; margin:0; padding:0; width:100%; }
138
+ #cft dt { float:left; font-weight:bold; margin:0; text-align:center; width:20%; }
139
+ #cft dt .hideKey { visibility:hidden; }
140
+ #cft dd { float:left; margin:0; text-align:left; width:80%; }
141
+ #cft dd p.label { font-weight:bold; margin:0; }
142
+ ';
143
+ update_option('custom_field_template_data', $options);
144
+ }
145
+
146
+
147
  function get_custom_field_template_data() {
148
  $options = get_option('custom_field_template_data');
149
  return $options;
168
  }
169
  update_option('custom_field_template_data', $options);
170
  $message = __('Options updated.', 'custom-field-template');
171
+ elseif ($_POST['custom_field_template_css_submit']) :
172
+ $options['css'] = $_POST['custom_field_template_css'];
173
+ update_option('custom_field_template_data', $options);
174
+ $message = __('Options updated.', 'custom-field-template');
175
  elseif ($_POST['custom_field_template_unset_options_submit']) :
176
  $this->install_custom_field_template_data();
177
+ $this->install_custom_field_template_css();
178
  $options = $this->get_custom_field_template_data();
179
  $message = __('Options resetted.', 'custom-field-template');
180
  elseif ($_POST['custom_field_template_delete_options_submit']) :
224
  </div>
225
  </div>
226
 
227
+ <div id="poststuff" class="ui-sortable">
228
+ <div class="postbox closed">
229
+ <h3><?php _e('Admin CSS', 'custom-field-template'); ?></h3>
230
+ <div class="inside">
231
+ <form method="post">
232
+ <table class="form-table" style="margin-bottom:5px;">
233
+ <tbody>
234
+ <tr><td>
235
+ <p><textarea name="custom_field_template_css" id="custom_field_template_css" rows="10" cols="60"><?= stripcslashes($options['css']) ?></textarea></p>
236
+ </td></tr>
237
+ <tr><td>
238
+ <p><input type="submit" name="custom_field_template_css_submit" value="<?php _e('Update Options &raquo;', 'custom-field-template'); ?>" /></p>
239
+ </td></tr>
240
+ </tbody>
241
+ </table>
242
+ </form>
243
+ </div>
244
+ </div>
245
+ </div>
246
+
247
  <div id="poststuff" class="ui-sortable">
248
  <div class="postbox closed">
249
  <h3><?php _e('Option List', 'custom-field-template'); ?></h3>
265
  <th>hideKey</th><td>hideKey = true</td><td>hideKey = true</td><td>hideKey = true</td><td>hideKey = true</td><td>hideKey = true</td>
266
  </tr>
267
  <tr>
268
+ <tr>
269
+ <th>label</th><td>label = ABC</td><td>label = DEF</td><td>label = GHI</td><td>label = JKL</td><td>label = MNO</td>
270
+ </tr>
271
  <th>size</th><td>size = 30</td><td></td><td></td><td></td><td></td>
272
  </tr>
273
  <tr>
365
  return $custom_fields;
366
  }
367
 
368
+ function make_textfield( $name, $sid, $size = 25, $hideKey, $label ) {
369
  $title = $name;
370
  $name = $this->sanitize_name( $name );
371
 
376
  }
377
  }
378
 
379
+ if ( $hideKey == true ) $hide = ' class="hideKey""';
380
 
381
  $out .=
382
+ '<dl>' .
383
+ '<dt><span' . $hide . '>' . $title . '</span></dt>' .
384
+ '<dd>';
385
+
386
+ if ( !empty($label) ) $out .= '<p class="label">' . $label . '</p>';
387
+ $out .= '<input id="' . $name . '" name="' . $name . '[]" value="' . attribute_escape($value) . '" type="textfield" size="' . $size . '" /></dd>' .
388
+ '</dl>';
389
  return $out;
390
  }
391
 
392
+ function make_checkbox( $name, $sid, $value, $checked, $hideKey, $label ) {
393
  $title = $name;
394
  $name = $this->sanitize_name( $name );
395
 
405
  if( $checked == true ) $checked = 'checked="checked"';
406
  }
407
 
408
+ if ( $hideKey == true ) $hide = ' class="hideKey""';
409
 
410
  $out .=
411
+ '<dl>' .
412
+ '<dt><span' . $hide . '>' . $title . '</span></dt>' .
413
+ '<dd>';
414
+
415
+ if ( !empty($label) ) $out .= '<p class="label">' . $label . '</p>';
416
+ $out .= '<label for="' . $id . '" class="selectit"><input name="' . $name . '[' . $sid . ']" value="' . attribute_escape($value) . '" ' . $checked . ' type="checkbox" /> ' . stripcslashes($value) . '</label><br />';
417
 
418
+ $out .= '</dd></dl>';
419
 
420
  return $out;
421
  }
422
 
423
+ function make_radio( $name, $sid, $values, $clearButton, $default, $hideKey, $label ) {
424
  $title = $name;
425
  $name = $this->sanitize_name( $name );
426
 
432
  $selected = $default;
433
  }
434
 
435
+ if ( $hideKey == true ) $hide = ' class="hideKey""';
436
 
437
  $out .=
438
+ '<dl>' .
439
+ '<dt><span' . $hide . '>' . $title . '</span>';
440
 
441
  if( $clearButton == true ) {
442
  $out .= '<div>';
445
  }
446
 
447
  $out .=
448
+ '</dt>' .
449
+ '<dd>';
450
+
451
+ if ( !empty($label) ) $out .= '<p class="label">' . $label . '</p>';
452
  foreach( $values as $val ) {
453
  $id = $name . '_' . $this->sanitize_name( $val );
454
 
455
  $checked = ( trim( $val ) == trim( $selected ) ) ? 'checked="checked"' : '';
456
 
457
  $out .=
458
+ '<label for="' . $id . '" class="selectit"><input id="' . $id . '" name="' . $name . '[' . $sid . ']" value="' . attribute_escape($val) . '" ' . $checked . ' type="radio" /> ' . stripcslashes($val) . '</label><br />';
459
  }
460
+ $out .= '</dd></dl>';
461
 
462
  return $out;
463
  }
464
 
465
+ function make_select( $name, $sid, $values, $default, $hideKey, $label ) {
466
  $title = $name;
467
  $name = $this->sanitize_name( $name );
468
 
476
  $selected = $default;
477
  }
478
 
479
+ if ( $hideKey == true ) $hide = ' class="hideKey""';
480
 
481
  $out .=
482
+ '<dl>' .
483
+ '<dt><span' . $hide . '>' . $title . '</span></dt>' .
484
+ '<dd>';
485
+
486
+ if ( !empty($label) ) $out .= '<p class="label">' . $label . '</p>';
487
+ $out .= '<select name="' . $name . '[]">' .
488
  '<option value="" >Select</option>';
489
 
490
  foreach( $values as $val ) {
493
  $out .=
494
  '<option value="' . attribute_escape($val) . '" ' . $checked . ' > ' . $val. '</option>';
495
  }
496
+ $out .= '</select></dd></dl>';
497
 
498
  return $out;
499
  }
500
 
501
+ function make_textarea( $name, $sid, $rows, $cols, $tinyMCE, $mediaButton, $hideKey, $label ) {
502
  global $wp_version;
503
 
504
  $title = $name;
543
  if( $tinyMCE == true && user_can_richedit() ) {
544
  $switch .= '<a href="#toggle" onclick="switchMode(\''.$name.$rand.'\'); return false;">' . __('Toggle', 'custom-field-template') . '</a>';
545
  }
546
+ $switch .= '</div>';
547
 
548
  }
549
 
550
+ if ( $hideKey == true ) $hide = ' class="hideKey""';
551
 
552
  $out .=
553
+ '<dl>' .
554
+ '<dt><span' . $hide . '>' . $title . '</span><br />' . $media . $switch . '</dt>' .
555
+ '<dd>';
556
+
557
+ if ( !empty($label) ) $out .= '<p class="label">' . $label . '</p>';
558
+ $out .= '<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.'" /></dd>' .
559
+ '</dl>';
560
  return $out;
561
  }
562
 
569
  return;
570
 
571
  $out .= '<input type="hidden" name="custom-field-template-id" id="custom-field-template-id" value="' . $id . '" />';
 
572
  foreach( $fields as $title => $data ) {
573
  for($i = 0; $i<count($data); $i++) {
574
+ if( $data[$i]['type'] == 'textfield' ) {
575
+ $out .= $this->make_textfield( $title, $i, $data[$i]['size'], $data[$i]['hideKey'], $data[$i]['label'] );
576
  }
577
+ else if( $data[$i]['type'] == 'checkbox' ) {
578
  $out .=
579
+ $this->make_checkbox( $title, $i, $data[$i]['value'], $data[$i]['checked'], $data[$i]['hideKey'], $data[$i]['label'] );
580
  }
581
+ else if( $data[$i]['type'] == 'radio' ) {
582
  $out .=
583
  $this->make_radio(
584
+ $title, $i, explode( '#', $data[$i]['value'] ), $data[$i]['clearButton'], $data[$i]['default'], $data[$i]['hideKey'], $data[$i]['label'] );
585
  }
586
+ else if( $data[$i]['type'] == 'select' ) {
587
  $out .=
588
  $this->make_select(
589
+ $title, $i, explode( '#', $data[$i]['value'] ), $data[$i]['default'], $data[$i]['hideKey'], $data[$i]['label'] );
590
  }
591
+ else if( $data[$i]['type'] == 'textarea' ) {
592
+ if ( $options['tinyMCE'][$_REQUEST['post']][$this->sanitize_name($title)][$i] ) $data[$i]['rows'] = $options['tinyMCE'][$_REQUEST['post']][$this->sanitize_name($title)][$i];
593
  $out .=
594
+ $this->make_textarea( $title, $i, $data[$i]['rows'], $data[$i]['cols'], $data[$i]['tinyMCE'], $data[$i]['mediaButton'], $data[$i]['hideKey'], $data[$i]['label'] );
595
  }
596
  }
597
  }
598
+ $out .= '<br style="clear:both;" />';
 
599
 
600
  return $out;
601
  }
607
  if( $options == null)
608
  return;
609
 
610
+ if ( !$options['css'] ) {
611
+ $this->install_custom_field_template_css();
612
+ $options = $this->get_custom_field_template_data();
613
+ }
614
+
615
  if ( substr($wp_version, 0, 3) < '2.5' ) {
616
  $out .= '
617
  <div class="dbx-b-ox-wrapper">
714
  $out .= 'var tinyMCEID = new Array();' . "\n" .
715
  '// ]]>' . "\n" .
716
  '</script>';
717
+ $out .= '<style type="text/css">' . "\n" .
718
+ '<!--' . "\n";
719
+ $out .= $options['css'] . "\n";
720
+ $out .= '-->' . "\n" .
721
+ '</style>';
722
  $body = $this->load_custom_field();
723
+
724
+ if ( count($options['custom_fields'])>1 ) {
725
+ $out .= '<select id="custom_field_template_select" onchange="if(tinyMCEID.length) { for(i=0;i<tinyMCEID.length;i++) {tinyMCE.execCommand(\'mceRemoveControl\', false, tinyMCEID[i]);} tinyMCEID = new Array();};jQuery.ajax({type: \'GET\', url: \'?page=custom-field-template/custom-field-template.php&id=\'+jQuery(this).val()+\'&post=\'+jQuery(\'#post_ID\').val(), success: function(html) {jQuery(\'#cft\').html(html);}});">';
726
+ for ( $i=0; $i < count($options['custom_fields']); $i++ ) {
727
+ if ( $i == $options['posts'][$_REQUEST['post']] ) {
728
+ $out .= '<option value="' . $i . '" selected="selected">' . stripcslashes($options['custom_fields'][$i]['title']) . '</option>';
729
+ $body = $this->load_custom_field($i);
730
+ } else
731
+ $out .= '<option value="' . $i . '">' . stripcslashes($options['custom_fields'][$i]['title']) . '</option>';
732
+ }
733
+ $out .= '</select>';
734
  }
735
+
736
+ $out .= '<div id="cft">';
737
  $out .= '<input type="hidden" name="custom-field-template-verify-key" id="custom-field-template-verify-key" value="' . wp_create_nonce('custom-field-template') . '" />';
 
738
 
739
  $out .= $body;
 
740
  $out .= '</div>';
741
 
742
  if ( substr($wp_version, 0, 3) < '2.5' ) {
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-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,117 +13,123 @@ msgstr ""
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
 
2
  msgstr ""
3
  "Project-Id-Version: Custom Field Template\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2008-11-05 19:03+0900\n"
6
+ "PO-Revision-Date: 2008-11-05 19:03+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:76
17
+ #: custom-field-template/custom-field-template.php:77
18
+ #: custom-field-template/custom-field-template.php:153
19
+ #: custom-field-template/custom-field-template.php:190
20
+ #: custom-field-template/custom-field-template.php:620
21
  msgid "Custom Field Template"
22
  msgstr ""
23
 
24
+ #: custom-field-template/custom-field-template.php:88
25
  msgid "Settings"
26
  msgstr ""
27
 
28
+ #: custom-field-template/custom-field-template.php:99
29
  msgid "Default Template"
30
  msgstr ""
31
 
32
+ #: custom-field-template/custom-field-template.php:170
33
+ #: custom-field-template/custom-field-template.php:174
34
  msgid "Options updated."
35
  msgstr ""
36
 
37
+ #: custom-field-template/custom-field-template.php:179
38
  msgid "Options resetted."
39
  msgstr ""
40
 
41
+ #: custom-field-template/custom-field-template.php:183
42
  msgid "Options deleted."
43
  msgstr ""
44
 
45
+ #: custom-field-template/custom-field-template.php:195
46
  msgid "Custom Field Template Options"
47
  msgstr ""
48
 
49
+ #: custom-field-template/custom-field-template.php:204
50
  #, php-format
51
  msgid "Template Title %d"
52
  msgstr ""
53
 
54
+ #: custom-field-template/custom-field-template.php:206
55
  #, php-format
56
  msgid "Template Content %d"
57
  msgstr ""
58
 
59
+ #: custom-field-template/custom-field-template.php:213
60
  msgid "In case that you would like to insert multiple images at once in use of the custom field media buttons"
61
  msgstr ""
62
 
63
+ #: custom-field-template/custom-field-template.php:214
64
  msgid "Use multiple image inset"
65
  msgstr ""
66
 
67
+ #: custom-field-template/custom-field-template.php:214
68
  msgid "Caution:"
69
  msgstr ""
70
 
71
+ #: custom-field-template/custom-field-template.php:214
72
  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."
73
  msgstr ""
74
 
75
+ #: custom-field-template/custom-field-template.php:218
76
+ #: custom-field-template/custom-field-template.php:238
77
  msgid "Update Options &raquo;"
78
  msgstr ""
79
 
80
+ #: custom-field-template/custom-field-template.php:229
81
+ msgid "Admin CSS"
82
+ msgstr ""
83
+
84
+ #: custom-field-template/custom-field-template.php:249
85
  msgid "Option List"
86
  msgstr ""
87
 
88
+ #: custom-field-template/custom-field-template.php:303
89
  msgid "Reset Options"
90
  msgstr ""
91
 
92
+ #: custom-field-template/custom-field-template.php:305
93
  msgid "Are you sure to reset options? Options you set will be reset to the default settings."
94
  msgstr ""
95
 
96
+ #: custom-field-template/custom-field-template.php:309
97
  msgid "Unset Options &raquo;"
98
  msgstr ""
99
 
100
+ #: custom-field-template/custom-field-template.php:320
101
  msgid "Delete Options"
102
  msgstr ""
103
 
104
+ #: custom-field-template/custom-field-template.php:322
105
  msgid "Are you sure to delete options? Options you set will be deleted."
106
  msgstr ""
107
 
108
+ #: custom-field-template/custom-field-template.php:326
109
  msgid "Delete Options &raquo;"
110
  msgstr ""
111
 
112
+ #: custom-field-template/custom-field-template.php:443
113
  msgid "Clear"
114
  msgstr ""
115
 
116
+ #: custom-field-template/custom-field-template.php:527
117
  msgid "Add Media"
118
  msgstr ""
119
 
120
+ #: custom-field-template/custom-field-template.php:529
121
  msgid "Add an Image"
122
  msgstr ""
123
 
124
+ #: custom-field-template/custom-field-template.php:531
125
  msgid "Add Video"
126
  msgstr ""
127
 
128
+ #: custom-field-template/custom-field-template.php:533
129
  msgid "Add Audio"
130
  msgstr ""
131
 
132
+ #: custom-field-template/custom-field-template.php:544
133
  msgid "Toggle"
134
  msgstr ""
135
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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
 
@@ -17,8 +17,9 @@ The Custom Field Template plugin adds the default custom fields on the Write Pos
17
  * Support for TinyMCE in the textarea.
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
 
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.1
8
 
9
  This plugin adds the default custom fields on the Write Post/Page.
10
 
17
  * Support for TinyMCE in the textarea.
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 and label options.
21
+ * You can see the full option list in the setting page of the plugin.
22
+ * You can customize the design of custom field template with css.
23
 
24
  == Installation ==
25