Version Description
Download this release
Release Info
Developer | Hiroaki Miyashita |
Plugin | Custom Field Template |
Version | 0.1.1 |
Comparing to | |
See all releases |
Version 0.1.1
- custom-field-template-ja.mo +0 -0
- custom-field-template-ja.po +112 -0
- custom-field-template.php +483 -0
- custom-field-template.pot +94 -0
- readme.txt +42 -0
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
custom-field-template-ja.mo
ADDED
Binary file
|
custom-field-template-ja.po
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# WordPress 用日本語リソース (UTF-8)
|
2 |
+
# Japanese (UTF-8) translation for WordPress
|
3 |
+
#
|
4 |
+
# Copyright (c) 2005-2008
|
5 |
+
# このファイルは WordPress 本体と同じライセンスのもと配布されています。
|
6 |
+
# This file is distributed under the same license as the WordPress package.
|
7 |
+
#
|
8 |
+
# WordPress 日本語版作成チーム / WP ja translation team
|
9 |
+
# <http://groups.google.com/group/wp-ja-pkg/web/members>
|
10 |
+
#
|
11 |
+
# 誤字脱字誤訳、あるいはよりよい訳などありましたら以下までぜひお知らせください。
|
12 |
+
# また、翻訳、校正、コミットをお手伝いしていただける方も随時募集中です。
|
13 |
+
# 連絡先 / Contact: wpja.team@gmail.com (件名か内容に「日本語リソース」と入れてください)
|
14 |
+
#
|
15 |
+
msgid ""
|
16 |
+
msgstr ""
|
17 |
+
"Project-Id-Version: Custom Field Template\n"
|
18 |
+
"Report-Msgid-Bugs-To: \n"
|
19 |
+
"POT-Creation-Date: 2008-08-29 18:20+0900\n"
|
20 |
+
"PO-Revision-Date: 2008-08-29 18:20+0900\n"
|
21 |
+
"Last-Translator: \n"
|
22 |
+
"Language-Team: \n"
|
23 |
+
"MIME-Version: 1.0\n"
|
24 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
25 |
+
"Content-Transfer-Encoding: 8bit\n"
|
26 |
+
"X-Poedit-Language: Japanese\n"
|
27 |
+
"X-Poedit-Country: JAPAN\n"
|
28 |
+
"X-Poedit-SourceCharset: utf-8\n"
|
29 |
+
"X-Poedit-KeywordsList: __;_e;_c\n"
|
30 |
+
"X-Poedit-Basepath: ../\n"
|
31 |
+
"X-Poedit-SearchPath-0: custom-field-template\n"
|
32 |
+
|
33 |
+
#: custom-field-template/custom-field-template.php:48
|
34 |
+
msgid "Default Template"
|
35 |
+
msgstr "デフォルトテンプレート"
|
36 |
+
|
37 |
+
#: custom-field-template/custom-field-template.php:81
|
38 |
+
#: custom-field-template/custom-field-template.php:112
|
39 |
+
#: custom-field-template/custom-field-template.php:349
|
40 |
+
#: custom-field-template/custom-field-template.php:357
|
41 |
+
msgid "Custom Field Template"
|
42 |
+
msgstr "カスタムフィールドテンプレート"
|
43 |
+
|
44 |
+
#: custom-field-template/custom-field-template.php:97
|
45 |
+
msgid "Options updated."
|
46 |
+
msgstr "オプションは更新されました。"
|
47 |
+
|
48 |
+
#: custom-field-template/custom-field-template.php:101
|
49 |
+
msgid "Options resetted."
|
50 |
+
msgstr "オプションはリセットされました。"
|
51 |
+
|
52 |
+
#: custom-field-template/custom-field-template.php:105
|
53 |
+
msgid "Options deleted."
|
54 |
+
msgstr "オプションは削除されました。"
|
55 |
+
|
56 |
+
#: custom-field-template/custom-field-template.php:114
|
57 |
+
msgid "Custom Field Template Options"
|
58 |
+
msgstr "カスタムフィールドテンプレートオプション"
|
59 |
+
|
60 |
+
#: custom-field-template/custom-field-template.php:122
|
61 |
+
#, php-format
|
62 |
+
msgid "Template Title %d"
|
63 |
+
msgstr "テンプレートタイトル %d"
|
64 |
+
|
65 |
+
#: custom-field-template/custom-field-template.php:124
|
66 |
+
#, php-format
|
67 |
+
msgid "Template Content %d"
|
68 |
+
msgstr "テンプレートコンテンツ %d"
|
69 |
+
|
70 |
+
#: custom-field-template/custom-field-template.php:131
|
71 |
+
msgid "Update Options »"
|
72 |
+
msgstr "オプションを更新する »"
|
73 |
+
|
74 |
+
#: custom-field-template/custom-field-template.php:137
|
75 |
+
msgid "Reset Options"
|
76 |
+
msgstr "オプションをリセットする"
|
77 |
+
|
78 |
+
#: custom-field-template/custom-field-template.php:138
|
79 |
+
msgid "Are you sure to reset options? Options you set will be reset to the default settings."
|
80 |
+
msgstr "本当にオプションをリセットしてもよろしいですか?設定したオプションはデフォルトの状態に戻ります。"
|
81 |
+
|
82 |
+
#: custom-field-template/custom-field-template.php:142
|
83 |
+
msgid "Unset Options »"
|
84 |
+
msgstr "オプションをリセットする »"
|
85 |
+
|
86 |
+
#: custom-field-template/custom-field-template.php:148
|
87 |
+
msgid "Delete Options"
|
88 |
+
msgstr "オプションを削除する"
|
89 |
+
|
90 |
+
#: custom-field-template/custom-field-template.php:149
|
91 |
+
msgid "Are you sure to delete options? Options you set will be deleted."
|
92 |
+
msgstr "本当にオプションを削除してもよろしいですか?設定したオプションは削除されます。"
|
93 |
+
|
94 |
+
#: custom-field-template/custom-field-template.php:153
|
95 |
+
msgid "Delete Options »"
|
96 |
+
msgstr "オプションを削除する »"
|
97 |
+
|
98 |
+
#~ msgid "Recent Posts Ext"
|
99 |
+
#~ msgstr "最近の投稿 Ext"
|
100 |
+
#~ msgid "camera"
|
101 |
+
#~ msgstr "機種"
|
102 |
+
#~ msgid "aperture"
|
103 |
+
#~ msgstr "絞り値"
|
104 |
+
#~ msgid "focal_length"
|
105 |
+
#~ msgstr "焦点距離"
|
106 |
+
#~ msgid "ISO"
|
107 |
+
#~ msgstr "ISO"
|
108 |
+
#~ msgid "shutter_speed"
|
109 |
+
#~ msgstr "シャッタースピード"
|
110 |
+
#~ msgid "created_timestamp"
|
111 |
+
#~ msgstr "撮影日時"
|
112 |
+
|
custom-field-template.php
ADDED
@@ -0,0 +1,483 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
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.1.1
|
8 |
+
Author URI: http://wordpressgogo.com/
|
9 |
+
*/
|
10 |
+
|
11 |
+
/*
|
12 |
+
This program is based on the rc:custom_field_gui plugin written by Joshua Sigar.
|
13 |
+
I appreciate your efforts, Joshua.
|
14 |
+
*/
|
15 |
+
|
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 |
+
|
33 |
+
function custom_field_template_init() {
|
34 |
+
if ( function_exists('load_plugin_textdomain') ) {
|
35 |
+
load_plugin_textdomain('custom-field-template', 'wp-content/plugins/custom-field-template');
|
36 |
+
}
|
37 |
+
|
38 |
+
if ( is_user_logged_in() && isset($_REQUEST['id']) && $_REQUEST['page'] == 'custom-field-template/custom-field-template.php' ) {
|
39 |
+
echo $this->load_custom_field( $_REQUEST['id'] );
|
40 |
+
exit();
|
41 |
+
}
|
42 |
+
|
43 |
+
if( strstr($_SERVER['REQUEST_URI'], 'wp-admin/plugins.php') && isset($_GET['activate']) && $_GET['activate'] == 'true' ) {
|
44 |
+
$options = $this->get_custom_field_template_data();
|
45 |
+
if( !$options ) {
|
46 |
+
$this->install_custom_field_template_data();
|
47 |
+
}
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
function custom_field_template_admin_scripts() {
|
52 |
+
wp_enqueue_script( 'jquery');
|
53 |
+
}
|
54 |
+
|
55 |
+
function install_custom_field_template_data() {
|
56 |
+
$options['custom_fields'][0]['title'] = __('Default Template', 'custom-field-template');
|
57 |
+
$options['custom_fields'][0]['content'] = '[Plan]
|
58 |
+
type = textfield
|
59 |
+
size = 35
|
60 |
+
|
61 |
+
[Favorite Post]
|
62 |
+
type = checkbox
|
63 |
+
default = checked
|
64 |
+
|
65 |
+
[Miles Walked]
|
66 |
+
type = radio
|
67 |
+
value = 0-9 # 10-19 # 20+
|
68 |
+
default = 10-19
|
69 |
+
|
70 |
+
[Temper Level]
|
71 |
+
type = select
|
72 |
+
value = High # Medium # Low
|
73 |
+
default = Low
|
74 |
+
|
75 |
+
[Hidden Thought]
|
76 |
+
type = textarea
|
77 |
+
rows = 4
|
78 |
+
cols = 40
|
79 |
+
';
|
80 |
+
update_option('custom_field_template_data', $options);
|
81 |
+
}
|
82 |
+
|
83 |
+
function get_custom_field_template_data() {
|
84 |
+
$options = get_option('custom_field_template_data');
|
85 |
+
return $options;
|
86 |
+
}
|
87 |
+
|
88 |
+
function custom_field_template_admin_menu() {
|
89 |
+
add_options_page(__('Custom Field Template', 'custom-field-template'), __('Custom Field Template', 'custom-field-template'), 8, basename(__FILE__), array(&$this, 'custom_field_template_admin'));
|
90 |
+
}
|
91 |
+
|
92 |
+
function custom_field_template_admin() {
|
93 |
+
$options = $this->get_custom_field_template_data();
|
94 |
+
if($_POST["custom_field_template_set_options_submit"]) :
|
95 |
+
unset($options['custom_fields']);
|
96 |
+
$j = 0;
|
97 |
+
for($i=0;$i<count($_POST["custom_field_template_content"]);$i++) {
|
98 |
+
if( $_POST["custom_field_template_content"][$i] ) {
|
99 |
+
$options['custom_fields'][$j]['title'] = $_POST["custom_field_template_title"][$i];
|
100 |
+
$options['custom_fields'][$j]['content'] = $_POST["custom_field_template_content"][$i];
|
101 |
+
$j++;
|
102 |
+
}
|
103 |
+
}
|
104 |
+
update_option('custom_field_template_data', $options);
|
105 |
+
$message = __('Options updated.', 'custom-field-template');
|
106 |
+
elseif ($_POST['custom_field_template_unset_options_submit']) :
|
107 |
+
$this->install_custom_field_template_data();
|
108 |
+
$options = $this->get_custom_field_template_data();
|
109 |
+
$message = __('Options resetted.', 'custom-field-template');
|
110 |
+
elseif ($_POST['custom_field_template_delete_options_submit']) :
|
111 |
+
delete_option('custom_field_template_data');
|
112 |
+
$options = $this->get_custom_field_template_data();
|
113 |
+
$message = __('Options deleted.', 'custom-field-template');
|
114 |
+
endif;
|
115 |
+
?>
|
116 |
+
<?php if ($message) : ?>
|
117 |
+
<div id="message" class="updated"><p><?php echo $message; ?></p></div>
|
118 |
+
<?php endif; ?>
|
119 |
+
<div class="wrap">
|
120 |
+
<h2><?php _e('Custom Field Template', 'custom-field-template'); ?></h2>
|
121 |
+
|
122 |
+
<h3><?php _e('Custom Field Template Options', 'custom-field-template'); ?></h3>
|
123 |
+
<form method="post">
|
124 |
+
<table class="form-table">
|
125 |
+
<tbody>
|
126 |
+
<?php
|
127 |
+
for ( $i = 0; $i < count($options['custom_fields'])+1; $i++ ) {
|
128 |
+
?>
|
129 |
+
<tr><td>
|
130 |
+
<p><label for="custom_field_template_title[<?= $i ?>]"><?php echo sprintf(__('Template Title %d', 'custom-field-template'), $i+1); ?></label>:<br />
|
131 |
+
<input name="custom_field_template_title[<?= $i ?>]" id="custom_field_template_title[<?= $i ?>]" class="input" value="<?= stripcslashes($options['custom_fields'][$i]['title']) ?>" size="60" /></p>
|
132 |
+
<p><label for="custom_field_template_content[<?= $i ?>]"><?php echo sprintf(__('Template Content %d', 'custom-field-template'), $i+1); ?></label>:<br />
|
133 |
+
<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>
|
134 |
+
</td></tr>
|
135 |
+
<?php
|
136 |
+
}
|
137 |
+
?>
|
138 |
+
<tr><td>
|
139 |
+
<p><input type="submit" name="custom_field_template_set_options_submit" value="<?php _e('Update Options »', 'custom-field-template'); ?>" /></p>
|
140 |
+
</td></tr>
|
141 |
+
</tbody>
|
142 |
+
</table>
|
143 |
+
</form>
|
144 |
+
|
145 |
+
<h3><?php _e('Reset Options', 'custom-field-template'); ?></h3>
|
146 |
+
<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'); ?>');">
|
147 |
+
<table class="form-table">
|
148 |
+
<tbody>
|
149 |
+
<tr><td>
|
150 |
+
<p><input type="submit" name="custom_field_template_unset_options_submit" value="<?php _e('Unset Options »', 'custom-field-template'); ?>" /></p>
|
151 |
+
</td></tr>
|
152 |
+
</tbody>
|
153 |
+
</table>
|
154 |
+
</form>
|
155 |
+
|
156 |
+
<h3><?php _e('Delete Options', 'custom-field-template'); ?></h3>
|
157 |
+
<form method="post" onsubmit="return confirm('<?php _e('Are you sure to delete options? Options you set will be deleted.', 'custom-field-template'); ?>');">
|
158 |
+
<table class="form-table">
|
159 |
+
<tbody>
|
160 |
+
<tr><td>
|
161 |
+
<p><input type="submit" name="custom_field_template_delete_options_submit" value="<?php _e('Delete Options »', 'custom-field-template'); ?>" /></p>
|
162 |
+
</td></tr>
|
163 |
+
</tbody>
|
164 |
+
</table>
|
165 |
+
</form>
|
166 |
+
|
167 |
+
</div>
|
168 |
+
<?php
|
169 |
+
}
|
170 |
+
|
171 |
+
function sanitize_name( $name ) {
|
172 |
+
$name = sanitize_title( $name );
|
173 |
+
$name = str_replace( '-', '_', $name );
|
174 |
+
|
175 |
+
return $name;
|
176 |
+
}
|
177 |
+
|
178 |
+
function get_custom_fields( $id ) {
|
179 |
+
$options = $this->get_custom_field_template_data();
|
180 |
+
if ( !$options['custom_fields'][$id] )
|
181 |
+
return null;
|
182 |
+
|
183 |
+
$custom_fields = $this->parse_ini_str( $options['custom_fields'][$id]['content'], true );
|
184 |
+
return $custom_fields;
|
185 |
+
}
|
186 |
+
|
187 |
+
function make_textfield( $name, $size = 25 ) {
|
188 |
+
$title = $name;
|
189 |
+
$name = $this->sanitize_name( $name );
|
190 |
+
|
191 |
+
if( isset( $_REQUEST[ 'post' ] ) ) {
|
192 |
+
$value = get_post_meta( $_REQUEST[ 'post' ], $title );
|
193 |
+
$value = $value[ 0 ];
|
194 |
+
}
|
195 |
+
|
196 |
+
$out =
|
197 |
+
'<tr>' .
|
198 |
+
'<th scope="row">' . $title . ' </th>' .
|
199 |
+
'<td> <input id="' . $name . '" name="' . $name . '" value="' . attribute_escape($value) . '" type="textfield" size="' . $size . '" /></td>' .
|
200 |
+
'</tr>';
|
201 |
+
return $out;
|
202 |
+
}
|
203 |
+
|
204 |
+
function make_checkbox( $name, $default ) {
|
205 |
+
$title = $name;
|
206 |
+
$name = $this->sanitize_name( $name );
|
207 |
+
|
208 |
+
if( isset( $_REQUEST[ 'post' ] ) ) {
|
209 |
+
$checked = get_post_meta( $_REQUEST[ 'post' ], $title );
|
210 |
+
$checked = $checked ? 'checked="checked"' : '';
|
211 |
+
}
|
212 |
+
else {
|
213 |
+
if ( isset( $default ) && trim( $default ) == 'checked' ) {
|
214 |
+
$checked = 'checked="checked"';
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
$out =
|
219 |
+
'<tr>' .
|
220 |
+
'<th scope="row" valign="top">' . $title. ' </th>' .
|
221 |
+
'<td>';
|
222 |
+
|
223 |
+
$out .=
|
224 |
+
'<input class="checkbox" name="' . $name . '" value="true" id="' . $name . '" ' . $checked . ' type="checkbox" />';
|
225 |
+
|
226 |
+
$out .= '</td>';
|
227 |
+
|
228 |
+
return $out;
|
229 |
+
}
|
230 |
+
|
231 |
+
function make_radio( $name, $values, $default ) {
|
232 |
+
$title = $name;
|
233 |
+
$name = $this->sanitize_name( $name );
|
234 |
+
|
235 |
+
if( isset( $_REQUEST[ 'post' ] ) ) {
|
236 |
+
$selected = get_post_meta( $_REQUEST[ 'post' ], $title );
|
237 |
+
$selected = $selected[ 0 ];
|
238 |
+
}
|
239 |
+
else {
|
240 |
+
$selected = $default;
|
241 |
+
}
|
242 |
+
|
243 |
+
$out =
|
244 |
+
'<tr>' .
|
245 |
+
'<th scope="row" valign="top">' . $title . ' </th>' .
|
246 |
+
'<td>';
|
247 |
+
|
248 |
+
foreach( $values as $val ) {
|
249 |
+
$id = $name . '_' . $this->sanitize_name( $val );
|
250 |
+
|
251 |
+
$checked = ( trim( $val ) == trim( $selected ) ) ? 'checked="checked"' : '';
|
252 |
+
|
253 |
+
$out .=
|
254 |
+
'<label for="' . $id . '" class="selectit"><input id="' . $id . '" name="' . $name . '" value="' . $val . '" ' . $checked . ' type="radio"> ' . $val . '</label><br>';
|
255 |
+
}
|
256 |
+
$out .= '</td>';
|
257 |
+
|
258 |
+
return $out;
|
259 |
+
}
|
260 |
+
|
261 |
+
function make_select( $name, $values, $default ) {
|
262 |
+
$title = $name;
|
263 |
+
$name = $this->sanitize_name( $name );
|
264 |
+
|
265 |
+
if( isset( $_REQUEST[ 'post' ] ) ) {
|
266 |
+
$selected = get_post_meta( $_REQUEST[ 'post' ], $title );
|
267 |
+
$selected = $selected[ 0 ];
|
268 |
+
}
|
269 |
+
else {
|
270 |
+
$selected = $default;
|
271 |
+
}
|
272 |
+
|
273 |
+
$out =
|
274 |
+
'<tr>' .
|
275 |
+
'<th scope="row">' . $title . ' </th>' .
|
276 |
+
'<td>' .
|
277 |
+
'<select name="' . $name . '">' .
|
278 |
+
'<option value="" >Select</option>';
|
279 |
+
|
280 |
+
foreach( $values as $val ) {
|
281 |
+
$checked = ( trim( $val ) == trim( $selected ) ) ? 'selected="selected"' : '';
|
282 |
+
|
283 |
+
$out .=
|
284 |
+
'<option value="' . $val . '" ' . $checked . ' > ' . $val. '</option>';
|
285 |
+
}
|
286 |
+
$out .= '</select></td>';
|
287 |
+
|
288 |
+
return $out;
|
289 |
+
}
|
290 |
+
|
291 |
+
function make_textarea( $name, $rows, $cols ) {
|
292 |
+
$title = $name;
|
293 |
+
$name = $this->sanitize_name( $name );
|
294 |
+
|
295 |
+
if( isset( $_REQUEST[ 'post' ] ) ) {
|
296 |
+
$value = get_post_meta( $_REQUEST[ 'post' ], $title );
|
297 |
+
$value = $value[ 0 ];
|
298 |
+
}
|
299 |
+
|
300 |
+
$out =
|
301 |
+
'<tr>' .
|
302 |
+
'<th scope="row" valign="top">' . $title . ' </th>' .
|
303 |
+
'<td> <textarea id="' . $name . '" name="' . $name . '" type="textfield" rows="' .$rows. '" cols="' .$cols. '">' .attribute_escape($value). '</textarea></td>' .
|
304 |
+
'</tr>';
|
305 |
+
return $out;
|
306 |
+
}
|
307 |
+
|
308 |
+
function load_custom_field( $id = 0 ) {
|
309 |
+
|
310 |
+
$fields = $this->get_custom_fields( $id );
|
311 |
+
|
312 |
+
if( $fields == null)
|
313 |
+
return;
|
314 |
+
|
315 |
+
$out .= '<input type="hidden" name="custom-field-template-id" id="custom-field-template-id" value="' . $id . '" />';
|
316 |
+
$out .= '<table class="editform">';
|
317 |
+
foreach( $fields as $title => $data ) {
|
318 |
+
if( $data[ 'type' ] == 'textfield' ) {
|
319 |
+
$out .= $this->make_textfield( $title, $data[ 'size' ] );
|
320 |
+
}
|
321 |
+
else if( $data[ 'type' ] == 'checkbox' ) {
|
322 |
+
$out .=
|
323 |
+
$this->make_checkbox( $title, $data[ 'default' ] );
|
324 |
+
}
|
325 |
+
else if( $data[ 'type' ] == 'radio' ) {
|
326 |
+
$out .=
|
327 |
+
$this->make_radio(
|
328 |
+
$title, explode( '#', $data[ 'value' ] ), $data[ 'default' ] );
|
329 |
+
}
|
330 |
+
else if( $data[ 'type' ] == 'select' ) {
|
331 |
+
$out .=
|
332 |
+
$this->make_select(
|
333 |
+
$title, explode( '#', $data[ 'value' ] ), $data[ 'default' ] );
|
334 |
+
}
|
335 |
+
else if( $data[ 'type' ] == 'textarea' ) {
|
336 |
+
$out .=
|
337 |
+
$this->make_textarea( $title, $data[ 'rows' ], $data[ 'cols' ] );
|
338 |
+
}
|
339 |
+
}
|
340 |
+
|
341 |
+
$out .= '</table>';
|
342 |
+
|
343 |
+
return $out;
|
344 |
+
}
|
345 |
+
|
346 |
+
function insert_custom_field() {
|
347 |
+
global $wp_version;
|
348 |
+
$options = $this->get_custom_field_template_data();
|
349 |
+
|
350 |
+
if( $options == null)
|
351 |
+
return;
|
352 |
+
|
353 |
+
if ( substr($wp_version, 0, 3) >= '2.5' ) {
|
354 |
+
$out .= '
|
355 |
+
<div id="postaiosp" class="postbox">
|
356 |
+
<h3>' . __('Custom Field Template', 'custom-field-template') . '</h3>
|
357 |
+
<div class="inside">
|
358 |
+
<div id="postaiosp">';
|
359 |
+
} else {
|
360 |
+
$out .= '
|
361 |
+
<div class="dbx-b-ox-wrapper">
|
362 |
+
<fieldset id="seodiv" class="dbx-box">
|
363 |
+
<div class="dbx-h-andle-wrapper">
|
364 |
+
<h3 class="dbx-handle">' . __('Custom Field Template', 'custom-field-template') . '</h3>
|
365 |
+
</div>
|
366 |
+
<div class="dbx-c-ontent-wrapper">
|
367 |
+
<div class="dbx-content">';
|
368 |
+
}
|
369 |
+
|
370 |
+
$body = $this->load_custom_field();
|
371 |
+
$out .= '<select id="custom_field_template_select" onchange="jQuery.ajax({type: \'GET\', url: \'?page=custom-field-template/custom-field-template.php&id=\'+jQuery(this).val()+\'&post=' . $_REQUEST['post'] . '\', success: function(html) {jQuery(\'#custom-field-template-box\').html(html);}});">';
|
372 |
+
for ( $i=0; $i < count($options['custom_fields']); $i++ ) {
|
373 |
+
if ( $i == $options['posts'][$_REQUEST['post']] ) {
|
374 |
+
$out .= '<option value="' . $i . '" selected="selected">' . stripcslashes($options['custom_fields'][$i]['title']) . '</option>';
|
375 |
+
$body = $this->load_custom_field($i);
|
376 |
+
} else
|
377 |
+
$out .= '<option value="' . $i . '">' . stripcslashes($options['custom_fields'][$i]['title']) . '</option>';
|
378 |
+
}
|
379 |
+
$out .= '</select>';
|
380 |
+
|
381 |
+
$out .= '<input type="hidden" name="custom-field-template-verify-key" id="custom-field-template-verify-key" value="' . wp_create_nonce('custom-field-template') . '" />';
|
382 |
+
$out .= '<div id="custom-field-template-box">';
|
383 |
+
|
384 |
+
$out .= $body;
|
385 |
+
|
386 |
+
$out .= '</div>';
|
387 |
+
|
388 |
+
if ( substr($wp_version, 0, 3) >= '2.5' ) {
|
389 |
+
$out .= '</div></div></div>';
|
390 |
+
} else {
|
391 |
+
$out .= '</div></fieldset></div>';
|
392 |
+
}
|
393 |
+
|
394 |
+
echo $out;
|
395 |
+
}
|
396 |
+
|
397 |
+
function edit_meta_value( $id ) {
|
398 |
+
global $wpdb;
|
399 |
+
$options = $this->get_custom_field_template_data();
|
400 |
+
|
401 |
+
if( !isset( $id ) )
|
402 |
+
$id = $_REQUEST[ 'post_ID' ];
|
403 |
+
|
404 |
+
if( !current_user_can('edit_post', $id) )
|
405 |
+
return $id;
|
406 |
+
|
407 |
+
if( !wp_verify_nonce($_REQUEST['custom-field-template-verify-key'], 'custom-field-template') )
|
408 |
+
return $id;
|
409 |
+
|
410 |
+
$fields = $this->get_custom_fields($_REQUEST['custom-field-template-id']);
|
411 |
+
|
412 |
+
if ( $fields == null )
|
413 |
+
return;
|
414 |
+
|
415 |
+
foreach( $fields as $title => $data) {
|
416 |
+
$name = $this->sanitize_name( $title );
|
417 |
+
$title = $wpdb->escape(stripslashes(trim($title)));
|
418 |
+
|
419 |
+
$meta_value = stripslashes(trim($_REQUEST[ "$name" ]));
|
420 |
+
if( isset( $meta_value ) && !empty( $meta_value ) ) {
|
421 |
+
delete_post_meta( $id, $title );
|
422 |
+
|
423 |
+
if( $data[ 'type' ] == 'textfield' ||
|
424 |
+
$data[ 'type' ] == 'radio' ||
|
425 |
+
$data[ 'type' ] == 'select' ||
|
426 |
+
$data[ 'type' ] == 'textarea' ) {
|
427 |
+
add_post_meta( $id, $title, $meta_value );
|
428 |
+
}
|
429 |
+
else if( $data[ 'type' ] == 'checkbox' )
|
430 |
+
add_post_meta( $id, $title, 'true' );
|
431 |
+
}
|
432 |
+
else {
|
433 |
+
delete_post_meta( $id, $title );
|
434 |
+
}
|
435 |
+
}
|
436 |
+
|
437 |
+
$options['posts'][$_REQUEST['post_ID']] = $_REQUEST['custom-field-template-id'];
|
438 |
+
update_option('custom_field_template_data', $options);
|
439 |
+
}
|
440 |
+
|
441 |
+
function parse_ini_str($Str,$ProcessSections = TRUE) {
|
442 |
+
$Section = NULL;
|
443 |
+
$Data = array();
|
444 |
+
if ($Temp = strtok($Str,"\r\n")) {
|
445 |
+
do {
|
446 |
+
switch ($Temp{0}) {
|
447 |
+
case ';':
|
448 |
+
case '#':
|
449 |
+
break;
|
450 |
+
case '[':
|
451 |
+
if (!$ProcessSections) {
|
452 |
+
break;
|
453 |
+
}
|
454 |
+
$Pos = strpos($Temp,'[');
|
455 |
+
$Section = substr($Temp,$Pos+1,strpos($Temp,']',$Pos)-1);
|
456 |
+
$Data[$Section] = array();
|
457 |
+
break;
|
458 |
+
default:
|
459 |
+
$Pos = strpos($Temp,'=');
|
460 |
+
if ($Pos === FALSE) {
|
461 |
+
break;
|
462 |
+
}
|
463 |
+
$Value = array();
|
464 |
+
$Value["NAME"] = trim(substr($Temp,0,$Pos));
|
465 |
+
$Value["VALUE"] = trim(substr($Temp,$Pos+1),' "');
|
466 |
+
|
467 |
+
if ($ProcessSections) {
|
468 |
+
$Data[$Section][$Value["NAME"]] = $Value["VALUE"];
|
469 |
+
}
|
470 |
+
else {
|
471 |
+
$Data[$Value["NAME"]] = $Value["VALUE"];
|
472 |
+
}
|
473 |
+
break;
|
474 |
+
}
|
475 |
+
} while ($Temp = strtok("\r\n"));
|
476 |
+
}
|
477 |
+
return $Data;
|
478 |
+
}
|
479 |
+
|
480 |
+
}
|
481 |
+
|
482 |
+
$custom_field_template = new custom_field_template();
|
483 |
+
?>
|
custom-field-template.pot
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# WordPress 用日本語リソース (UTF-8)
|
2 |
+
# Japanese (UTF-8) translation for WordPress
|
3 |
+
#
|
4 |
+
# Copyright (c) 2005-2008
|
5 |
+
# このファイルは WordPress 本体と同じライセンスのもと配布されています。
|
6 |
+
# This file is distributed under the same license as the WordPress package.
|
7 |
+
#
|
8 |
+
# WordPress 日本語版作成チーム / WP ja translation team
|
9 |
+
# <http://groups.google.com/group/wp-ja-pkg/web/members>
|
10 |
+
#
|
11 |
+
# 誤字脱字誤訳、あるいはよりよい訳などありましたら以下までぜひお知らせください。
|
12 |
+
# また、翻訳、校正、コミットをお手伝いしていただける方も随時募集中です。
|
13 |
+
# 連絡先 / Contact: wpja.team@gmail.com (件名か内容に「日本語リソース」と入れてください)
|
14 |
+
#
|
15 |
+
msgid ""
|
16 |
+
msgstr ""
|
17 |
+
"Project-Id-Version: Custom Field Template\n"
|
18 |
+
"Report-Msgid-Bugs-To: \n"
|
19 |
+
"POT-Creation-Date: 2008-08-29 18:28+0900\n"
|
20 |
+
"PO-Revision-Date: 2008-08-29 18:28+0900\n"
|
21 |
+
"Last-Translator: \n"
|
22 |
+
"Language-Team: \n"
|
23 |
+
"MIME-Version: 1.0\n"
|
24 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
25 |
+
"Content-Transfer-Encoding: 8bit\n"
|
26 |
+
"X-Poedit-KeywordsList: __;_e;_c\n"
|
27 |
+
"X-Poedit-Basepath: ../\n"
|
28 |
+
"X-Poedit-SearchPath-0: custom-field-template\n"
|
29 |
+
|
30 |
+
#: custom-field-template/custom-field-template.php:48
|
31 |
+
msgid "Default Template"
|
32 |
+
msgstr ""
|
33 |
+
|
34 |
+
#: custom-field-template/custom-field-template.php:81
|
35 |
+
#: custom-field-template/custom-field-template.php:112
|
36 |
+
#: custom-field-template/custom-field-template.php:349
|
37 |
+
#: custom-field-template/custom-field-template.php:357
|
38 |
+
msgid "Custom Field Template"
|
39 |
+
msgstr ""
|
40 |
+
|
41 |
+
#: custom-field-template/custom-field-template.php:97
|
42 |
+
msgid "Options updated."
|
43 |
+
msgstr ""
|
44 |
+
|
45 |
+
#: custom-field-template/custom-field-template.php:101
|
46 |
+
msgid "Options resetted."
|
47 |
+
msgstr ""
|
48 |
+
|
49 |
+
#: custom-field-template/custom-field-template.php:105
|
50 |
+
msgid "Options deleted."
|
51 |
+
msgstr ""
|
52 |
+
|
53 |
+
#: custom-field-template/custom-field-template.php:114
|
54 |
+
msgid "Custom Field Template Options"
|
55 |
+
msgstr ""
|
56 |
+
|
57 |
+
#: custom-field-template/custom-field-template.php:122
|
58 |
+
#, php-format
|
59 |
+
msgid "Template Title %d"
|
60 |
+
msgstr ""
|
61 |
+
|
62 |
+
#: custom-field-template/custom-field-template.php:124
|
63 |
+
#, php-format
|
64 |
+
msgid "Template Content %d"
|
65 |
+
msgstr ""
|
66 |
+
|
67 |
+
#: custom-field-template/custom-field-template.php:131
|
68 |
+
msgid "Update Options »"
|
69 |
+
msgstr ""
|
70 |
+
|
71 |
+
#: custom-field-template/custom-field-template.php:137
|
72 |
+
msgid "Reset Options"
|
73 |
+
msgstr ""
|
74 |
+
|
75 |
+
#: custom-field-template/custom-field-template.php:138
|
76 |
+
msgid "Are you sure to reset options? Options you set will be reset to the default settings."
|
77 |
+
msgstr ""
|
78 |
+
|
79 |
+
#: custom-field-template/custom-field-template.php:142
|
80 |
+
msgid "Unset Options »"
|
81 |
+
msgstr ""
|
82 |
+
|
83 |
+
#: custom-field-template/custom-field-template.php:148
|
84 |
+
msgid "Delete Options"
|
85 |
+
msgstr ""
|
86 |
+
|
87 |
+
#: custom-field-template/custom-field-template.php:149
|
88 |
+
msgid "Are you sure to delete options? Options you set will be deleted."
|
89 |
+
msgstr ""
|
90 |
+
|
91 |
+
#: custom-field-template/custom-field-template.php:153
|
92 |
+
msgid "Delete Options »"
|
93 |
+
msgstr ""
|
94 |
+
|
readme.txt
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
5 |
+
Requires at least: 1.5
|
6 |
+
Tested up to: 2.6.1
|
7 |
+
Stable tag: 0.1.1
|
8 |
+
|
9 |
+
This plugin adds the default custom fields on the Write Post/Page.
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
The Custom Field Template plugin adds the default custom fields on the Write Post/Page. The template format is almost same as the one of the rc:custom_field_gui plugin. The difference is following:
|
14 |
+
|
15 |
+
* You can set any number of the custom field templates and switch the templates when you write/edit the post/page.
|
16 |
+
* This plugin does not use the ini file for the template but set it in the option page of the plugin.
|
17 |
+
|
18 |
+
== Installation ==
|
19 |
+
|
20 |
+
1. Copy the `custom-field-template` directory into your `wp-content/plugins` directory
|
21 |
+
2. Activate the plugin through the `Plugins` menu in WordPress
|
22 |
+
3. Edit the options in `Settings` > `Custom Field Template`
|
23 |
+
4. That's it! :)
|
24 |
+
|
25 |
+
== Known Issues / Bugs ==
|
26 |
+
|
27 |
+
== Frequently Asked Questions ==
|
28 |
+
|
29 |
+
= How can I use this plugin? =
|
30 |
+
|
31 |
+
The template format is basically same as the one of the rc:custom_field_gui plugin.
|
32 |
+
See the default template of the plugin settings and modify it.
|
33 |
+
|
34 |
+
== Screenshots ==
|
35 |
+
|
36 |
+
1. Custom Field Template - Settings
|
37 |
+
2. Custom Field Template
|
38 |
+
|
39 |
+
== Uninstall ==
|
40 |
+
|
41 |
+
1. Deactivate the plugin
|
42 |
+
2. That's it! :)
|
screenshot-1.png
ADDED
Binary file
|
screenshot-2.png
ADDED
Binary file
|