TinyMCE Templates - Version 2.0.0

Version Description

Download this release

Release Info

Developer miyauchi
Plugin Icon 128x128 TinyMCE Templates
Version 2.0.0
Comparing to
See all releases

Code changes from version 1.6.1 to 2.0.0

img/icon.png DELETED
Binary file
img/large.png DELETED
Binary file
includes/MceTemplatesAdmin.class.php DELETED
@@ -1,265 +0,0 @@
1
- <?php
2
-
3
- class MceTemplatesAdmin{
4
- function __construct()
5
- {
6
-
7
- echo '<div class="wrap">';
8
-
9
- if (isset($_GET['page']) && $_GET['page'] == 'edittemplates') {
10
- if (isset($_GET['id']) && preg_match("/^[a-zA-Z0-9]{32}$/", $_GET['id'])) {
11
- $this->addView();
12
- } else {
13
- $this->editView();
14
- }
15
- } elseif (isset($_GET['page']) && $_GET['page'] == 'addnewtemplates') {
16
- $this->addView();
17
- }
18
-
19
- echo '</div>';
20
- }
21
-
22
- public function editView()
23
- {
24
- global $wpdb;
25
- global $current_user;
26
-
27
- echo '<h2>'.__("Edit Templates", TINYMCE_TEMPLATES_DOMAIN).'</h2>';
28
-
29
- if (isset($_POST['templates']) && is_array($_POST['templates'])) {
30
- $this->delete();
31
- echo '<div id="message" class="updated fade"><p>'.$n.__("Templates permanently deleted.", TINYMCE_TEMPLATES_DOMAIN).'</p></div>';
32
- }
33
-
34
- echo "<form method=\"post\" action=\"{$_SERVER['REQUEST_URI']}\">";
35
- echo '<table class="widefat" cellspacing="0">';
36
- echo '<thead>';
37
- echo '<tr>';
38
- echo '<th scope="col" class="column-cb check-column"><input type="checkbox" /></th>';
39
- echo '<th scope="col">'.__('Name', TINYMCE_TEMPLATES_DOMAIN).'</th>';
40
- echo '<th scope="col">'.__('Description', TINYMCE_TEMPLATES_DOMAIN).'</th>';
41
- echo '<th scope="col">'.__('Author', TINYMCE_TEMPLATES_DOMAIN).'</th>';
42
- echo '<th scope="col">'.__('Share', TINYMCE_TEMPLATES_DOMAIN).'</th>';
43
- echo '</tr>';
44
- echo '</thead>';
45
- echo '<tfoot>';
46
- echo '<tr>';
47
- echo '<th scope="col" class="column-cb check-column"><input type="checkbox" /></th>';
48
- echo '<th scope="col">'.__('Name', TINYMCE_TEMPLATES_DOMAIN).'</th>';
49
- echo '<th scope="col">'.__('Description', TINYMCE_TEMPLATES_DOMAIN).'</th>';
50
- echo '<th scope="col">'.__('Author', TINYMCE_TEMPLATES_DOMAIN).'</th>';
51
- echo '<th scope="col">'.__('Share', TINYMCE_TEMPLATES_DOMAIN).'</th>';
52
- echo '</tr>';
53
- echo '</tfoot>';
54
- echo '<tbody>';
55
-
56
- $sql = "select * from ".$wpdb->prefix."mce_template
57
- where `author`={$current_user->ID} or `share`=1 order by `modified` desc";
58
- $row = $wpdb->get_results($sql);
59
-
60
- $i = 0;
61
- foreach ($row as $tpl) {
62
- if ($tpl->author === $current_user->ID) {
63
- $mine = true;
64
- } else {
65
- $mine = false;
66
- }
67
- if ($i % 2) {
68
- $class = 'alternate';
69
- } else {
70
- $class = '';
71
- }
72
- echo '<tr class="'.$class.'" valign="top">';
73
- if ($mine) {
74
- echo '<th scope="row" class="check-column">';
75
- echo "<input type=\"checkbox\" name=\"templates[]\"
76
- value=\"{$tpl->ID}\" />";
77
- echo '</th>';
78
- echo '<td><a href="?page=edittemplates&id='.$tpl->ID.'">'.esc_html($tpl->name).'</a></td>';
79
- } else {
80
- echo '<th scope="row" class="check-column">&nbsp;</th>';
81
- echo '<td>'.esc_html($tpl->name).'</td>';
82
- }
83
- echo '<td>'.esc_html($tpl->desc).'</td>';
84
- $author = get_userdata($tpl->author);
85
- echo '<td>'.esc_html($author->nickname).'</td>';
86
- if ($tpl->share) {
87
- echo '<td>'.__('Shared', TINYMCE_TEMPLATES_DOMAIN).'</td>';
88
- } else {
89
- echo '<td>'.__('Private', TINYMCE_TEMPLATES_DOMAIN).'</td>';
90
- }
91
- echo "</tr>";
92
- $i = $i + 1;
93
- }
94
- echo "</tbody>";
95
- echo "</table>";
96
- echo '<input type="submit" value="'.__("Delete checked items", TINYMCE_TEMPLATES_DOMAIN).'" class="button-secondary" />';
97
- echo "</form>";
98
- }
99
-
100
- public function addView()
101
- {
102
- global $current_user;
103
- global $wp_version;
104
-
105
- if (isset($_POST['save']) && $_POST['save']) {
106
- if ($this->validate() && $this->save()) {
107
- echo "<div id=\"message\" class=\"updated fade\"><p><strong>".__("Template saved.", TINYMCE_TEMPLATES_DOMAIN)."</strong></p></div>";
108
- global $wpdb;
109
- $sql = $wpdb->prepare("select * from ".$wpdb->prefix."mce_template
110
- where `id`=%s", $_POST['id']);
111
- $r = $wpdb->get_row($sql);
112
- $id = $r->ID;
113
- $name = $r->name;
114
- $desc = $r->desc;
115
- $html = stripslashes($r->html);
116
- $share = $r->share;
117
- } else {
118
- echo "<div id=\"message\" class=\"error fade\"><p><strong>".__("All entry must not be blank.", TINYMCE_TEMPLATES_DOMAIN)."</strong></p></div>";
119
- $id = $_POST['id'];
120
- $name = $_POST['name'];
121
- $desc = $_POST['desc'];
122
- $html = stripslashes($_POST['content']);
123
- $share = $_POST['share'];
124
- }
125
- } elseif (isset($_GET['page']) && $_GET['page'] == 'edittemplates'
126
- && isset($_GET['id']) && preg_match("/^[a-zA-Z0-9]{32}$/", $_GET['id'])) {
127
- global $wpdb;
128
- $sql = $wpdb->prepare("select * from ".$wpdb->prefix."mce_template
129
- where `ID`=%s and author=%s",
130
- $_GET['id'], $current_user->ID);
131
- $r = $wpdb->get_row($sql);
132
- if ($r) {
133
- $id = $r->ID;
134
- $name = $r->name;
135
- $desc = $r->desc;
136
- $html = stripslashes($r->html);
137
- $share = $r->share;
138
- } else {
139
- return;
140
- }
141
- } else {
142
- $id = md5(uniqid(rand(), true));
143
- $name = null;
144
- $desc = null;
145
- $html = null;
146
- $share = null;
147
- }
148
-
149
- if (isset($_GET['page']) && $_GET['page'] == 'edittemplates'
150
- && isset($_GET['id']) && preg_match("/^[a-zA-Z0-9]{32}$/", $_GET['id'])) {
151
- echo '<h2>'.__("Edit Templates", TINYMCE_TEMPLATES_DOMAIN).'</h2>';
152
- } else {
153
- echo '<h2>'.__("Add New Templates", TINYMCE_TEMPLATES_DOMAIN).'</h2>';
154
- }
155
- echo "<form action=\"{$_SERVER["REQUEST_URI"]}\" method=\"post\">";
156
- echo "<input type=\"hidden\" name=\"save\" value=\"1\" />";
157
- echo "<input type=\"hidden\" name=\"id\" value=\"{$id}\" />";
158
- echo '<h3>'.__("Template Name", TINYMCE_TEMPLATES_DOMAIN).'</h3>';
159
- echo '<input type="text" id="name" name="name" value="'.$name.'" />';
160
- echo "<h3>".__("Template Description", TINYMCE_TEMPLATES_DOMAIN)."</h3>";
161
- echo "<textarea id=\"desc\" name=\"desc\">{$desc}</textarea>";
162
- echo "<h3>".__("Template Contents", TINYMCE_TEMPLATES_DOMAIN)." (HTML)</h3>";
163
- // new line by ANDREA BERSI
164
- echo "<div id='poststuff'>";
165
- echo "<div id=\"postdivrich\" class=\"postarea\">";
166
- if (version_compare($wp_version, '3.2', '<')) {
167
- wp_tiny_mce();
168
- }
169
- the_editor($html, "content", "desc", true, 3);
170
- echo "</div><!--end #postdivrich-->";
171
- echo "</div><!--end #poststuff-->";
172
- //END NEW LINE
173
- echo "<h3>".__("Share", TINYMCE_TEMPLATES_DOMAIN)."</h3>";
174
- echo "<select name=\"share\" id=\"share\">";
175
- if ($share == 1) {
176
- echo "<option value=\"1\" selected=\"selected\">".__("Shared", TINYMCE_TEMPLATES_DOMAIN)."</option>";
177
- echo "<option value=\"0\">".__("Private", TINYMCE_TEMPLATES_DOMAIN)."</option>";
178
- } else {
179
- echo "<option value=\"1\">".__("Shared", TINYMCE_TEMPLATES_DOMAIN)."</option>";
180
- echo "<option value=\"0\" selected=\"selected\">".__("Private", TINYMCE_TEMPLATES_DOMAIN)."</option>";
181
- }
182
- echo "</select>";
183
- echo "<div id=\"save\">";
184
- echo "<input type=\"submit\" value=\"".__("Save Template", TINYMCE_TEMPLATES_DOMAIN)."\" class=\"button-primary\" />";
185
- echo "</div>";
186
- echo "</form>";
187
- }
188
-
189
- private function save()
190
- {
191
- global $wpdb;
192
- global $current_user;
193
-
194
- if (!$this->checkAuth($_POST['id'])) {
195
- return false;
196
- }
197
-
198
- $sql = "insert into ".$wpdb->prefix."mce_template
199
- (`ID`, `name`, `desc`, `html`, `share`, `author`)
200
- values
201
- (%s, %s, %s, %s, %d, %d)
202
- on duplicate key
203
- update
204
- `name`=values(`name`),
205
- `desc`=values(`desc`),
206
- `html`=values(`html`),
207
- `share`=values(`share`)
208
- ";
209
- $sql = $wpdb->prepare($sql, $_POST['id'],
210
- $_POST['name'], $_POST['desc'],
211
- $_POST['content'], $_POST['share'], $current_user->ID);
212
- $wpdb->query($sql);
213
- return true;
214
- }
215
-
216
- private function validate()
217
- {
218
- $pars = array('id', 'name', 'desc', 'content', 'share');
219
- foreach ($pars as $par):
220
- $_POST[$par] = trim($_POST[$par]);
221
- if (!isset($_POST[$par]) || !strlen($_POST[$par])) {
222
- return false;
223
- }
224
- endforeach;
225
-
226
- if (!preg_match("/^[a-zA-Z0-9]{32}$/", $_POST['id'])) {
227
- return false;
228
- }
229
-
230
- if ($_POST['share'] !== '1') {
231
- $_POST['share'] = '0';
232
- }
233
-
234
- return true;
235
- }
236
-
237
- private function checkAuth($id)
238
- {
239
- global $wpdb;
240
- global $current_user;
241
-
242
- $sql = $wpdb->prepare("select author from ".$wpdb->prefix."mce_template where ID=%s", $id);
243
- $author = $wpdb->get_var($sql);
244
-
245
- if (!$author || $author === $current_user->ID) {
246
- return true;
247
- } else {
248
- return false;
249
- }
250
- }
251
-
252
- private function delete()
253
- {
254
- global $wpdb;
255
- global $current_user;
256
-
257
- foreach ($_POST['templates'] as $tpl) {
258
- $sql = "delete from ".$wpdb->prefix."mce_template where ID=%s and author=%s";
259
- $sql = $wpdb->prepare($sql, $tpl, $current_user->ID);
260
- $wpdb->query($sql);
261
- }
262
- }
263
- }
264
-
265
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/TinyMCETemplate.class.php DELETED
@@ -1,123 +0,0 @@
1
- <?php
2
-
3
- new TinyMCETemplate();
4
-
5
- class TinyMCETemplate{
6
-
7
- private $list_url = null;
8
-
9
- function __construct()
10
- {
11
- new WP_AddRewriteRules(
12
- 'wp-admin/mce_templates.js$',
13
- 'mce_templates',
14
- array(&$this, 'get_templates')
15
- );
16
- add_filter('mce_css', array(&$this, 'addStyle'));
17
- add_action('init', array(&$this, 'loadTinyMCEPlugin'));
18
- }
19
-
20
- //
21
- // add css tinyMCE content
22
- //
23
- public function addStyle($css)
24
- {
25
- $files = preg_split("/,/", $css);
26
- $files[] = TINYMCE_TEMPLATES_PLUGIN_URL.'/editor.css';
27
- $files = array_map('trim', $files);
28
- return join(",", $files);
29
- }
30
-
31
- //
32
- // add button to tinyMCE editor
33
- //
34
- public function add_button($buttons = array())
35
- {
36
- array_unshift($buttons, '|');
37
- array_unshift($buttons, 'template');
38
- return $buttons;
39
- }
40
-
41
- //
42
- // load tinyMCE plugin
43
- //
44
- public function loadTinyMCEPlugin(){
45
- global $wp_rewrite;
46
- $plugin = TINYMCE_TEMPLATES_PLUGIN_URL.'/mce_plugins/plugins/template/editor_plugin.js';
47
- $path = dirname(__FILE__).'/../mce_plugins/plugins';
48
- $lang = $path.'/template/langs/langs.php';
49
- $inits = array();
50
- $url = home_url();
51
- if ($wp_rewrite->using_permalinks()) {
52
- $this->list_url = $url.'/wp-admin/mce_templates.js';
53
- } else {
54
- $this->list_url = $url.'/?mce_templates=1';
55
- }
56
- $inits['template_external_list_url'] = $this->list_url;
57
- new mcePlugins(
58
- 'template',
59
- $plugin,
60
- $lang,
61
- array(&$this, 'add_button'),
62
- $inits
63
- );
64
- }
65
-
66
- //
67
- // return display templates as JSON
68
- //
69
- public function get_templates(){
70
- if (get_query_var('mce_templates')) {
71
- $u = wp_get_current_user();
72
- if (!$u->ID) {
73
- header("HTTP/1.1 404 Not Found");
74
- echo "404 Not Found.";
75
- exit;
76
- }
77
- global $wp_rewrite;
78
- global $wpdb;
79
-
80
- if( isset($_GET['id']) && strlen($_GET['id']) ){
81
- $sql = "select html from ".$wpdb->prefix."mce_template
82
- where (`ID`=%s) and (`author`=%d or `share`=1)
83
- order by `modified` desc";
84
- $sql = $wpdb->prepare($sql, $_GET['id'], $u->ID);
85
- $template = $wpdb->get_var($sql);
86
- if ($template) {
87
- echo apply_filters(
88
- "tinymce_templates",
89
- wpautop(stripslashes($template)),
90
- stripslashes($template)
91
- );
92
- }
93
- exit;
94
- }
95
-
96
- $sql = "select * from ".$wpdb->prefix."mce_template
97
- where `author`=%d or `share`=1
98
- order by `modified` desc";
99
- $sql = $wpdb->prepare($sql, $u->ID);
100
- $row = $wpdb->get_results($sql);
101
-
102
- header( 'Content-Type: application/x-javascript; charset=UTF-8' );
103
- echo 'var tinyMCETemplateList = [';
104
- $arr = array();
105
- if ($wp_rewrite->using_permalinks()) {
106
- $list_url = $this->list_url.'?';
107
- } else {
108
- $list_url = $this->list_url.'&';
109
- }
110
- foreach ($row as $tpl) {
111
- $ID = esc_html($tpl->ID);
112
- $name = $tpl->name;
113
- $desc = esc_html($tpl->desc);
114
- $arr[] = "[\"{$name}\", \"{$list_url}id={$ID}\", \"{$desc}\"]";
115
- }
116
- echo join(',', $arr);
117
- echo ']';
118
- exit;
119
- }
120
- }
121
- }
122
-
123
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
langs/tinymce_templates-ja.mo DELETED
Binary file
langs/tinymce_templates-ja.po DELETED
@@ -1,108 +0,0 @@
1
- # SOME DESCRIPTIVE TITLE.
2
- # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
- # This file is distributed under the same license as the PACKAGE package.
4
- # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
- #
6
- #, fuzzy
7
- msgid ""
8
- msgstr ""
9
- "Project-Id-Version: PACKAGE VERSION\n"
10
- "Report-Msgid-Bugs-To: \n"
11
- "POT-Creation-Date: 2010-11-21 05:06+0900\n"
12
- "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
- "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
- "Language-Team: LANGUAGE <LL@li.org>\n"
15
- "Language: \n"
16
- "MIME-Version: 1.0\n"
17
- "Content-Type: text/plain; charset=UTF-8\n"
18
- "Content-Transfer-Encoding: 8bit\n"
19
-
20
- #: ..//includes/MceTemplatesAdmin.class.php:34
21
- #: ..//includes/MceTemplatesAdmin.class.php:156 ..//tinymce_templates.php:103
22
- msgid "Edit Templates"
23
- msgstr "テンプレートを編集"
24
-
25
- #: ..//includes/MceTemplatesAdmin.class.php:38
26
- msgid "Templates permanently deleted."
27
- msgstr "テンプレートを削除しました。"
28
-
29
- #: ..//includes/MceTemplatesAdmin.class.php:46
30
- #: ..//includes/MceTemplatesAdmin.class.php:55
31
- msgid "Name"
32
- msgstr "名前"
33
-
34
- #: ..//includes/MceTemplatesAdmin.class.php:47
35
- #: ..//includes/MceTemplatesAdmin.class.php:56
36
- msgid "Description"
37
- msgstr "説明"
38
-
39
- #: ..//includes/MceTemplatesAdmin.class.php:48
40
- #: ..//includes/MceTemplatesAdmin.class.php:57
41
- msgid "Author"
42
- msgstr "作成者"
43
-
44
- #: ..//includes/MceTemplatesAdmin.class.php:49
45
- #: ..//includes/MceTemplatesAdmin.class.php:58
46
- #: ..//includes/MceTemplatesAdmin.class.php:169
47
- #: ..//includes/MceTemplatesAdmin.class.php:172
48
- #: ..//includes/MceTemplatesAdmin.class.php:175
49
- msgid "Share"
50
- msgstr "共有"
51
-
52
- #: ..//includes/MceTemplatesAdmin.class.php:94
53
- msgid "Shared"
54
- msgstr "共有"
55
-
56
- #: ..//includes/MceTemplatesAdmin.class.php:96
57
- #: ..//includes/MceTemplatesAdmin.class.php:173
58
- #: ..//includes/MceTemplatesAdmin.class.php:176
59
- msgid "Private"
60
- msgstr "個人"
61
-
62
- #: ..//includes/MceTemplatesAdmin.class.php:103
63
- msgid "Delete checked items"
64
- msgstr "選択したアイテムを削除"
65
-
66
- #: ..//includes/MceTemplatesAdmin.class.php:113
67
- msgid "Template saved."
68
- msgstr "テンプレートを保存しました。"
69
-
70
- #: ..//includes/MceTemplatesAdmin.class.php:124
71
- msgid "All entry must not be blank."
72
- msgstr "すべての項目に入力してください。"
73
-
74
- #: ..//includes/MceTemplatesAdmin.class.php:158 ..//tinymce_templates.php:111
75
- msgid "Add New Templates"
76
- msgstr "テンプレートの新規登録"
77
-
78
- #: ..//includes/MceTemplatesAdmin.class.php:163
79
- msgid "Template Name"
80
- msgstr "テンプレート名"
81
-
82
- #: ..//includes/MceTemplatesAdmin.class.php:165
83
- msgid "Template Description"
84
- msgstr "テンプレートの説明"
85
-
86
- #: ..//includes/MceTemplatesAdmin.class.php:167
87
- msgid "Template Contents"
88
- msgstr "テンプレート"
89
-
90
- #: ..//includes/MceTemplatesAdmin.class.php:180
91
- msgid "Save Template"
92
- msgstr "テンプレートを保存"
93
-
94
- #: ..//tinymce_templates.php:94
95
- msgid "tinyMCE Templates"
96
- msgstr "テンプレートを編集"
97
-
98
- #: ..//tinymce_templates.php:95
99
- msgid "Templates"
100
- msgstr "テンプレート"
101
-
102
- #: ..//tinymce_templates.php:104
103
- msgid "Edit"
104
- msgstr "編集"
105
-
106
- #: ..//tinymce_templates.php:112
107
- msgid "Add New"
108
- msgstr "新規追加"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
langs/tinymce_templates.pot DELETED
@@ -1,108 +0,0 @@
1
- # SOME DESCRIPTIVE TITLE.
2
- # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
- # This file is distributed under the same license as the PACKAGE package.
4
- # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
- #
6
- #, fuzzy
7
- msgid ""
8
- msgstr ""
9
- "Project-Id-Version: PACKAGE VERSION\n"
10
- "Report-Msgid-Bugs-To: \n"
11
- "POT-Creation-Date: 2010-11-21 05:10+0900\n"
12
- "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
- "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
- "Language-Team: LANGUAGE <LL@li.org>\n"
15
- "Language: \n"
16
- "MIME-Version: 1.0\n"
17
- "Content-Type: text/plain; charset=CHARSET\n"
18
- "Content-Transfer-Encoding: 8bit\n"
19
-
20
- #: ../includes/MceTemplatesAdmin.class.php:34
21
- #: ../includes/MceTemplatesAdmin.class.php:156 ../tinymce_templates.php:103
22
- msgid "Edit Templates"
23
- msgstr ""
24
-
25
- #: ../includes/MceTemplatesAdmin.class.php:38
26
- msgid "Templates permanently deleted."
27
- msgstr ""
28
-
29
- #: ../includes/MceTemplatesAdmin.class.php:46
30
- #: ../includes/MceTemplatesAdmin.class.php:55
31
- msgid "Name"
32
- msgstr ""
33
-
34
- #: ../includes/MceTemplatesAdmin.class.php:47
35
- #: ../includes/MceTemplatesAdmin.class.php:56
36
- msgid "Description"
37
- msgstr ""
38
-
39
- #: ../includes/MceTemplatesAdmin.class.php:48
40
- #: ../includes/MceTemplatesAdmin.class.php:57
41
- msgid "Author"
42
- msgstr ""
43
-
44
- #: ../includes/MceTemplatesAdmin.class.php:49
45
- #: ../includes/MceTemplatesAdmin.class.php:58
46
- #: ../includes/MceTemplatesAdmin.class.php:169
47
- #: ../includes/MceTemplatesAdmin.class.php:172
48
- #: ../includes/MceTemplatesAdmin.class.php:175
49
- msgid "Share"
50
- msgstr ""
51
-
52
- #: ../includes/MceTemplatesAdmin.class.php:94
53
- msgid "Shared"
54
- msgstr ""
55
-
56
- #: ../includes/MceTemplatesAdmin.class.php:96
57
- #: ../includes/MceTemplatesAdmin.class.php:173
58
- #: ../includes/MceTemplatesAdmin.class.php:176
59
- msgid "Private"
60
- msgstr ""
61
-
62
- #: ../includes/MceTemplatesAdmin.class.php:103
63
- msgid "Delete checked items"
64
- msgstr ""
65
-
66
- #: ../includes/MceTemplatesAdmin.class.php:113
67
- msgid "Template saved."
68
- msgstr ""
69
-
70
- #: ../includes/MceTemplatesAdmin.class.php:124
71
- msgid "All entry must not be blank."
72
- msgstr ""
73
-
74
- #: ../includes/MceTemplatesAdmin.class.php:158 ../tinymce_templates.php:111
75
- msgid "Add New Templates"
76
- msgstr ""
77
-
78
- #: ../includes/MceTemplatesAdmin.class.php:163
79
- msgid "Template Name"
80
- msgstr ""
81
-
82
- #: ../includes/MceTemplatesAdmin.class.php:165
83
- msgid "Template Description"
84
- msgstr ""
85
-
86
- #: ../includes/MceTemplatesAdmin.class.php:167
87
- msgid "Template Contents"
88
- msgstr ""
89
-
90
- #: ../includes/MceTemplatesAdmin.class.php:180
91
- msgid "Save Template"
92
- msgstr ""
93
-
94
- #: ../tinymce_templates.php:94
95
- msgid "tinyMCE Templates"
96
- msgstr ""
97
-
98
- #: ../tinymce_templates.php:95
99
- msgid "Templates"
100
- msgstr ""
101
-
102
- #: ../tinymce_templates.php:104
103
- msgid "Edit"
104
- msgstr ""
105
-
106
- #: ../tinymce_templates.php:112
107
- msgid "Add New"
108
- msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
{langs → languages}/tinymce_templates-de_DE.mo RENAMED
File without changes
{langs → languages}/tinymce_templates-de_DE.po RENAMED
File without changes
{langs → languages}/tinymce_templates-es_ES.mo RENAMED
File without changes
{langs → languages}/tinymce_templates-es_ES.po RENAMED
File without changes
{langs → languages}/tinymce_templates-fr_FR.mo RENAMED
File without changes
{langs → languages}/tinymce_templates-fr_FR.po RENAMED
File without changes
{langs → languages}/tinymce_templates-it_IT.mo RENAMED
File without changes
{langs → languages}/tinymce_templates-it_IT.po RENAMED
File without changes
languages/tinymce_templates-ja.mo ADDED
Binary file
languages/tinymce_templates-ja.po ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: PACKAGE VERSION\n"
10
+ "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2011-11-11 20:30+0900\n"
12
+ "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "Language: \n"
16
+ "MIME-Version: 1.0\n"
17
+ "Content-Type: text/plain; charset=UTF-8\n"
18
+ "Content-Transfer-Encoding: 8bit\n"
19
+
20
+ #: ../tinymce-templates.php:157 ../tinymce-templates.php:159
21
+ msgid "Templates"
22
+ msgstr "テンプレート"
23
+
24
+ #: ../tinymce-templates.php:160
25
+ msgid "Add New Template"
26
+ msgstr "テンプレートの新規登録"
27
+
28
+ #: ../tinymce-templates.php:161
29
+ msgid "Edit Template"
30
+ msgstr "テンプレートを編集"
31
+
32
+ #: ../tinymce-templates.php:162
33
+ msgid "Add New"
34
+ msgstr "新規追加"
35
+
36
+ #: ../tinymce-templates.php:163
37
+ msgid "New Template"
38
+ msgstr "新しいテンプレート"
39
+
40
+ #: ../tinymce-templates.php:164
41
+ msgid "View Template"
42
+ msgstr "テンプレートを表示"
43
+
44
+ #: ../tinymce-templates.php:165
45
+ msgid "No templatess found."
46
+ msgstr "テンプレートが見つかりませんでした。"
47
+
48
+ #: ../tinymce-templates.php:167
49
+ msgid "No templates found in Trash."
50
+ msgstr "ゴミ箱内にテンプレートが見つかりませんでした。"
51
+
52
+ #: ../tinymce-templates.php:170
53
+ msgid "Search Templates"
54
+ msgstr "テンプレートを検索"
55
+
56
+ #: ../tinymce-templates.php:198
57
+ msgid "Share"
58
+ msgstr "共有"
59
+
60
+ #: ../tinymce-templates.php:210
61
+ msgid "Private"
62
+ msgstr "個人"
63
+
64
+ #: ../tinymce-templates.php:212 ../tinymce-templates.php:214
65
+ msgid "Shared"
66
+ msgstr "共有"
67
+
68
+ #~ msgid "Templates permanently deleted."
69
+ #~ msgstr "テンプレートを削除しました。"
70
+
71
+ #~ msgid "Name"
72
+ #~ msgstr "名前"
73
+
74
+ #~ msgid "Description"
75
+ #~ msgstr "説明"
76
+
77
+ #~ msgid "Author"
78
+ #~ msgstr "作成者"
79
+
80
+ #~ msgid "Delete checked items"
81
+ #~ msgstr "選択したアイテムを削除"
82
+
83
+ #~ msgid "Template saved."
84
+ #~ msgstr "テンプレートを保存しました。"
85
+
86
+ #~ msgid "All entry must not be blank."
87
+ #~ msgstr "すべての項目に入力してください。"
88
+
89
+ #~ msgid "Template Name"
90
+ #~ msgstr "テンプレート名"
91
+
92
+ #~ msgid "Template Description"
93
+ #~ msgstr "テンプレートの説明"
94
+
95
+ #~ msgid "Template Contents"
96
+ #~ msgstr "テンプレート"
97
+
98
+ #~ msgid "tinyMCE Templates"
99
+ #~ msgstr "テンプレートを編集"
100
+
101
+ #~ msgid "Edit"
102
+ #~ msgstr "編集"
{langs → languages}/tinymce_templates-nl_NL.mo RENAMED
File without changes
{langs → languages}/tinymce_templates-nl_NL.po RENAMED
File without changes
{langs → languages}/tinymce_templates-sv_SE.mo RENAMED
File without changes
{langs → languages}/tinymce_templates-sv_SE.po RENAMED
File without changes
languages/tinymce_templates.pot ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: PACKAGE VERSION\n"
10
+ "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2011-11-11 20:30+0900\n"
12
+ "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "Language: \n"
16
+ "MIME-Version: 1.0\n"
17
+ "Content-Type: text/plain; charset=CHARSET\n"
18
+ "Content-Transfer-Encoding: 8bit\n"
19
+
20
+ #: ../tinymce-templates.php:157 ../tinymce-templates.php:159
21
+ msgid "Templates"
22
+ msgstr ""
23
+
24
+ #: ../tinymce-templates.php:160
25
+ msgid "Add New Template"
26
+ msgstr ""
27
+
28
+ #: ../tinymce-templates.php:161
29
+ msgid "Edit Template"
30
+ msgstr ""
31
+
32
+ #: ../tinymce-templates.php:162
33
+ msgid "Add New"
34
+ msgstr ""
35
+
36
+ #: ../tinymce-templates.php:163
37
+ msgid "New Template"
38
+ msgstr ""
39
+
40
+ #: ../tinymce-templates.php:164
41
+ msgid "View Template"
42
+ msgstr ""
43
+
44
+ #: ../tinymce-templates.php:165
45
+ msgid "No templatess found."
46
+ msgstr ""
47
+
48
+ #: ../tinymce-templates.php:167
49
+ msgid "No templates found in Trash."
50
+ msgstr ""
51
+
52
+ #: ../tinymce-templates.php:170
53
+ msgid "Search Templates"
54
+ msgstr ""
55
+
56
+ #: ../tinymce-templates.php:198
57
+ msgid "Share"
58
+ msgstr ""
59
+
60
+ #: ../tinymce-templates.php:210
61
+ msgid "Private"
62
+ msgstr ""
63
+
64
+ #: ../tinymce-templates.php:212 ../tinymce-templates.php:214
65
+ msgid "Shared"
66
+ msgstr ""
mce_plugins/plugins/template/langs/es_dlg.js CHANGED
File without changes
mce_plugins/plugins/template/langs/ja_dlg.js CHANGED
File without changes
paypal.png ADDED
Binary file
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/jp/cgi-bin/webscr?cmd=_flow&SESSION=vVwWrw6V
4
  Tags: tinymce, Visual Editor, template
5
  Requires at least: 3.0
6
  Tested up to: 3.2
7
- Stable tag: 1.6.1
8
 
9
  TinyMCE Template plugin will enable to use HTML template on WordPress Visual Editor.
10
  You can edit and share this template with WordPress users.
4
  Tags: tinymce, Visual Editor, template
5
  Requires at least: 3.0
6
  Tested up to: 3.2
7
+ Stable tag: 2.0.0
8
 
9
  TinyMCE Template plugin will enable to use HTML template on WordPress Visual Editor.
10
  You can edit and share this template with WordPress users.
style.css DELETED
@@ -1,53 +0,0 @@
1
- .wrap h2
2
- {
3
- padding-left: 40px;
4
- margin-bottom: 1em;
5
- background-image: url(img/large.png);
6
- background-repeat: no-repeat;
7
- background-position: left center;
8
- line-height: 32px;
9
- height: 32px;
10
- }
11
-
12
- .ex
13
- {
14
- margin: 1em 0;
15
- background-color: #ffffff;
16
- font-family: monospace !important;
17
- border: 1px dashed #dedede;
18
- padding: 1em;
19
- font-size: 14px;
20
- }
21
-
22
- .button-secondary
23
- {
24
- margin: 0.5em 0;
25
- }
26
-
27
- .note
28
- {
29
- margin-top: 2em;
30
- }
31
-
32
- .widefat
33
- {
34
- margin: 8px 0;
35
- }
36
-
37
- #name,
38
- #desc
39
- {
40
- width: 100%;
41
- font-size: 1.7em;
42
- }
43
-
44
- #desc
45
- {
46
- height: 3em;
47
- }
48
-
49
- #save
50
- {
51
- margin: 1em 0;
52
- }
53
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tinymce-templates.php ADDED
@@ -0,0 +1,348 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: TinyMCE Templates
4
+ Plugin URI: http://firegoby.theta.ne.jp/wp/tinymce_templates
5
+ Description: Manage & Add Tiny MCE template.
6
+ Author: Takayuki Miyauchi
7
+ Version: 2.0.0
8
+ Author URI: http://firegoby.theta.ne.jp/
9
+ */
10
+
11
+ /*
12
+ Copyright (c) 2010 Takayuki Miyauchi (THETA NETWORKS Co,.Ltd).
13
+
14
+ Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ of this software and associated documentation files (the "Software"), to deal
16
+ in the Software without restriction, including without limitation the rights
17
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ copies of the Software, and to permit persons to whom the Software is
19
+ furnished to do so, subject to the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be included in
22
+ all copies or substantial portions of the Software.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30
+ THE SOFTWARE.
31
+ */
32
+
33
+ require_once(dirname(__FILE__).'/includes/class-addrewriterules.php');
34
+ require_once(dirname(__FILE__).'/includes/mceplugins.class.php');
35
+
36
+ define('TINYMCE_TEMPLATES_DOMAIN', 'tinymce_templates');
37
+
38
+ new tinymceTemplates();
39
+
40
+
41
+ class tinymceTemplates {
42
+
43
+ private $post_type = 'tinymcetemplates';
44
+ private $meta_param = '_tinymcetemplates-share';
45
+ private $table = 'mce_template';
46
+ private $base_url;
47
+ private $translators = array(
48
+ 'Takayuki Miyauchi' => array(
49
+ 'lang' => 'Japanese',
50
+ 'url' => 'http://twitter.com/#!/miya0001',
51
+ ),
52
+ 'Andrea Bersi' => array(
53
+ 'lang' => 'Italian',
54
+ 'url' => 'http://www.andreabersi.com/',
55
+ ),
56
+ 'Tobias Bergius' => array(
57
+ 'lang' => 'Swedish',
58
+ 'url' => '',
59
+ ),
60
+ 'Martin Lettner' => array(
61
+ 'lang' => 'German',
62
+ 'url' => 'http://www.martinlettner.info/',
63
+ ),
64
+ 'David Bravo' => array(
65
+ 'lang' => 'Spanish',
66
+ 'url' => 'http://www.dimensionmultimedia.com/',
67
+ ),
68
+ 'Frank Groeneveld' => array(
69
+ 'lang' => 'Dutch',
70
+ 'url' => 'http://ivaldi.nl/',
71
+ ),
72
+ 'HAROUY Jean-Michel' => array(
73
+ 'lang' => 'French',
74
+ 'url' => 'http://www.laposte.net/',
75
+ ),
76
+ );
77
+
78
+ function __construct()
79
+ {
80
+ register_activation_hook(__FILE__, array(&$this, 'activation'));
81
+ $this->base_url = WP_PLUGIN_URL.'/'.dirname(plugin_basename(__FILE__));
82
+ add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
83
+ add_action('admin_menu', array(&$this, 'admin_menu'));
84
+ add_action('save_post', array(&$this, 'save_post'));
85
+ add_filter('mce_css', array(&$this, 'mce_css'));
86
+ add_action('admin_head', array(&$this, 'admin_head'));
87
+ new WP_AddRewriteRules(
88
+ 'wp-admin/mce_templates.js$',
89
+ 'mce_templates',
90
+ array(&$this, 'get_templates')
91
+ );
92
+ }
93
+
94
+ public function activation()
95
+ {
96
+ global $wpdb;
97
+ // do update function
98
+ $sql = $wpdb->prepare('show tables like %s', $wpdb->prefix.$this->table);
99
+ if ($wpdb->get_var($sql)) {
100
+ $sql = "select * from ".mysql_real_escape_string($wpdb->prefix.$this->table);
101
+ $res = $wpdb->get_results($sql);
102
+ foreach ($res as $tpl) {
103
+ $post = array();
104
+ $post['post_title'] = $tpl->name;
105
+ $post['post_content'] = $tpl->html;
106
+ $post['post_excerpt'] = $tpl->desc;
107
+ $post['post_author'] = $tpl->author;
108
+ $post['post_date'] = $tpl->modified;
109
+ $post['post_type'] = $this->post_type;
110
+ $post['post_status'] = 'publish';
111
+ $id = wp_insert_post($post);
112
+ if ($id) {
113
+ update_post_meta($id, $this->meta_param, $tpl->share);
114
+ }
115
+ }
116
+ $sql = 'drop table '.$wpdb->prefix.$this->table;
117
+ $wpdb->query($sql);
118
+ }
119
+ // do flush rewrite rules
120
+ flush_rewrite_rules();
121
+ }
122
+
123
+ public function plugins_loaded()
124
+ {
125
+ load_plugin_textdomain(
126
+ TINYMCE_TEMPLATES_DOMAIN,
127
+ false,
128
+ dirname(plugin_basename(__FILE__)).'/languages'
129
+ );
130
+ $this->addCustomPostType();
131
+ }
132
+
133
+ public function mce_css($css)
134
+ {
135
+ $files = preg_split("/,/", $css);
136
+ $files[] = $this->base_url.'/editor.css';
137
+ $files = array_map('trim', $files);
138
+ return join(",", $files);
139
+ }
140
+
141
+ public function admin_head(){
142
+ $plugin = $this->base_url.'/mce_plugins/plugins/template/editor_plugin.js';
143
+ $lang = dirname(__FILE__).'/mce_plugins/plugins/template/langs/langs.php';
144
+ $url = home_url();
145
+ $list_url = add_query_arg('mce_templates', 1, home_url('/'));
146
+ $inits['template_external_list_url'] = $list_url;
147
+ new mcePlugins(
148
+ 'template',
149
+ $plugin,
150
+ $lang,
151
+ array(&$this, 'addButton'),
152
+ $inits
153
+ );
154
+ if (get_post_type() === $this->post_type) {
155
+ global $hook_suffix;
156
+ if ($hook_suffix === 'post.php' || $hook_suffix === 'post-new.php') {
157
+ echo '<style>#visibility{display:none;}</style>';
158
+ }
159
+ }
160
+ }
161
+
162
+ public function admin_menu()
163
+ {
164
+ remove_meta_box('slugdiv', $this->post_type, 'normal');
165
+ }
166
+
167
+ public function save_post($id)
168
+ {
169
+ if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
170
+ return $id;
171
+
172
+ if (isset($_POST['action']) && $_POST['action'] == 'inline-save')
173
+ return $id;
174
+
175
+ $p = get_post($id);
176
+ if ($p->post_type === $this->post_type) {
177
+ if (isset($_POST[$this->meta_param])) {
178
+ update_post_meta($id, $this->meta_param, 1);
179
+ }
180
+ }
181
+ }
182
+
183
+ public function addButton($buttons = array())
184
+ {
185
+ array_unshift($buttons, '|');
186
+ array_unshift($buttons, 'template');
187
+ return $buttons;
188
+ }
189
+
190
+ private function addCustomPostType()
191
+ {
192
+ $args = array(
193
+ 'label' => __('Templates', TINYMCE_TEMPLATES_DOMAIN),
194
+ 'labels' => array(
195
+ 'singular_name' => __('Templates', TINYMCE_TEMPLATES_DOMAIN),
196
+ 'add_new_item' => __('Add New Template', TINYMCE_TEMPLATES_DOMAIN),
197
+ 'edit_item' => __('Edit Template', TINYMCE_TEMPLATES_DOMAIN),
198
+ 'add_new' => __('Add New', TINYMCE_TEMPLATES_DOMAIN),
199
+ 'new_item' => __('New Template', TINYMCE_TEMPLATES_DOMAIN),
200
+ 'view_item' => __('View Template', TINYMCE_TEMPLATES_DOMAIN),
201
+ 'not_found' => __('No templatess found.', TINYMCE_TEMPLATES_DOMAIN),
202
+ 'not_found_in_trash' => __(
203
+ 'No templates found in Trash.',
204
+ TINYMCE_TEMPLATES_DOMAIN
205
+ ),
206
+ 'search_items' => __('Search Templates', TINYMCE_TEMPLATES_DOMAIN),
207
+ ),
208
+ 'public' => false,
209
+ 'publicly_queryable' => false,
210
+ 'exclude_from_search' => true,
211
+ 'show_ui' => true,
212
+ 'capability_type' => 'post',
213
+ 'hierarchical' => false,
214
+ 'menu_position' => 100,
215
+ 'rewrite' => false,
216
+ 'show_in_nav_menus' => false,
217
+ 'register_meta_box_cb' => array(&$this, 'addMetaBox'),
218
+ 'supports' => array(
219
+ 'title',
220
+ 'editor',
221
+ 'excerpt',
222
+ 'revisions',
223
+ 'author',
224
+ )
225
+ );
226
+
227
+ register_post_type($this->post_type, $args);
228
+ }
229
+
230
+ public function addMetaBox()
231
+ {
232
+ add_meta_box(
233
+ 'tinymce_templates-share',
234
+ __('Share', TINYMCE_TEMPLATES_DOMAIN),
235
+ array(&$this, 'sharedMetaBox'),
236
+ $this->post_type,
237
+ 'side',
238
+ 'low'
239
+ );
240
+ add_meta_box(
241
+ 'tinymce_templates-translators',
242
+ __('Translators', TINYMCE_TEMPLATES_DOMAIN),
243
+ array(&$this, 'translatorsMetaBox'),
244
+ $this->post_type,
245
+ 'side',
246
+ 'low'
247
+ );
248
+ }
249
+
250
+ public function translatorsMetaBox($post, $box)
251
+ {
252
+ echo '<ul>';
253
+ foreach ($this->translators as $u => $p) {
254
+ if ($p['url']) {
255
+ printf(
256
+ '<li><a href="%s">%s</a> (%s)</li>',
257
+ esc_attr($p['url']),
258
+ esc_html($u),
259
+ esc_html($p['lang'])
260
+ );
261
+ } else {
262
+ printf(
263
+ '<li>%s (%s)</li>',
264
+ esc_html($u),
265
+ esc_html($p['lang'])
266
+ );
267
+ }
268
+ }
269
+ echo '</ul>';
270
+ echo '<p>';
271
+ echo '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CU8N3N2Q9DA8U">';
272
+ echo '<img src="'.$this->base_url.'/paypal.png">';
273
+ echo '</a>';
274
+ echo '</p>';
275
+ }
276
+
277
+ public function sharedMetaBox($post, $box)
278
+ {
279
+ $share = get_post_meta($post->ID, $this->meta_param, true);
280
+ echo '<select name="'.$this->meta_param.'">';
281
+ echo '<option value="0">'.__('Private', TINYMCE_TEMPLATES_DOMAIN).'</option>';
282
+ if ($share) {
283
+ echo '<option value="1" selected="selected">'.__('Shared', TINYMCE_TEMPLATES_DOMAIN).'</option>';
284
+ } else {
285
+ echo '<option value="1">'.__('Shared', TINYMCE_TEMPLATES_DOMAIN).'</option>';
286
+ }
287
+ echo '</select>';
288
+ }
289
+
290
+ public function get_templates(){
291
+ if (is_user_logged_in() && get_query_var('mce_templates')) {
292
+ $u = wp_get_current_user();
293
+ header( 'Content-Type: application/x-javascript; charset=UTF-8' );
294
+ if (isset($_GET['template_id']) && intval($_GET['template_id'])) {
295
+ $p = get_post($_GET['template_id']);
296
+ if ($p->post_status === 'publish') {
297
+ if ($u->ID === $p->post_author) {
298
+ echo apply_filters(
299
+ "tinymce_templates",
300
+ wpautop($p->post_content),
301
+ stripslashes($p->post_content)
302
+ );
303
+ } else {
304
+ $share = get_post_meta($p->ID, $this->meta_param, true);
305
+ if ($share) {
306
+ echo apply_filters(
307
+ "tinymce_templates",
308
+ wpautop($p->post_content),
309
+ stripslashes($p->post_content)
310
+ );
311
+ }
312
+ }
313
+ }
314
+ exit;
315
+ }
316
+ $p = array(
317
+ 'post_status' => 'publish',
318
+ 'post_type' => $this->post_type,
319
+ 'orderby' => 'date',
320
+ 'order' => 'DESC',
321
+ );
322
+ $posts = get_posts($p);
323
+ echo 'var tinyMCETemplateList = [';
324
+ $arr = array();
325
+ $list_url = add_query_arg('mce_templates', 1, home_url('/'));
326
+ foreach ($posts as $p) {
327
+ if ($u->ID !== $p->post_author) {
328
+ $share = get_post_meta($p->ID, $this->meta_param, true);
329
+ if (!$share) {
330
+ continue;
331
+ }
332
+ }
333
+ $ID = esc_html($p->ID);
334
+ $name = esc_html($p->post_title);
335
+ $desc = esc_html($p->post_excerpt);
336
+ $url = add_query_arg('template_id', $ID, $list_url);
337
+ $arr[] = "[\"{$name}\", \"{$url}\", \"{$desc}\"]";
338
+ }
339
+ echo join(',', $arr);
340
+ echo ']';
341
+ exit;
342
+ }
343
+ }
344
+
345
+ } // end class tinymceTemplates
346
+
347
+
348
+ // eof
tinymce_templates.php DELETED
@@ -1,185 +0,0 @@
1
- <?php
2
- /*
3
- Plugin Name: TinyMCE Templates
4
- Plugin URI: http://firegoby.theta.ne.jp/wp/tinymce_templates
5
- Description: Manage & Add Tiny MCE template.
6
- Author: Takayuki Miyauchi
7
- Version: 1.6.1
8
- Author URI: http://firegoby.theta.ne.jp/
9
- */
10
-
11
- /*
12
- Copyright (c) 2010 Takayuki Miyauchi (THETA NETWORKS Co,.Ltd).
13
-
14
- Permission is hereby granted, free of charge, to any person obtaining a copy
15
- of this software and associated documentation files (the "Software"), to deal
16
- in the Software without restriction, including without limitation the rights
17
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
- copies of the Software, and to permit persons to whom the Software is
19
- furnished to do so, subject to the following conditions:
20
-
21
- The above copyright notice and this permission notice shall be included in
22
- all copies or substantial portions of the Software.
23
-
24
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30
- THE SOFTWARE.
31
- */
32
-
33
- define('TINYMCE_TEMPLATES_PLUGIN_URL', WP_PLUGIN_URL.'/'.dirname(plugin_basename(__FILE__)));
34
- define('TINYMCE_TEMPLATES_DOMAIN', 'tinymce_templates');
35
-
36
- require_once(dirname(__FILE__).'/includes/class-addrewriterules.php');
37
- require_once(dirname(__FILE__).'/includes/mceplugins.class.php');
38
- require_once(dirname(__FILE__).'/includes/TinyMCETemplate.class.php');
39
- require_once(dirname(__FILE__).'/includes/MceTemplatesAdmin.class.php');
40
-
41
- $MceTemplates = new MceTemplates();
42
- register_activation_hook(__FILE__, 'flush_rewrite_rules');
43
- register_activation_hook (__FILE__, array(&$MceTemplates, 'activation'));
44
- //register_deactivation_hook (__FILE__, array(&$MceTemplates, 'deactivation'));
45
-
46
- class MceTemplates{
47
-
48
- function __construct()
49
- {
50
- if (!is_admin()) {
51
- return;
52
- }
53
- add_action('admin_menu', array(&$this, 'loadAdmin'));
54
- add_filter('plugin_row_meta', array(&$this, 'plugin_row_meta'), 10, 2);
55
- }
56
-
57
- public function admin_head()
58
- {
59
- add_filter('tiny_mce_before_init', array(&$this, 'tiny_mce_before_init'), 999);
60
- wp_admin_css();
61
- do_action("admin_print_styles-post-php");
62
- do_action('admin_print_styles');
63
- $dir = WP_PLUGIN_URL.'/'.dirname(plugin_basename(__FILE__));
64
- $html = '<link rel="stylesheet" href="%s/style.css" type="text/css" />';
65
- printf($html, $dir);
66
- }
67
-
68
- public function tiny_mce_before_init($init)
69
- {
70
- $init['plugins'] = str_replace(
71
- array('wpfullscreen',',,'),
72
- array('', ','),
73
- $init['plugins']
74
- );
75
- return $init;
76
- }
77
-
78
- public function activation()
79
- {
80
- global $wpdb;
81
- $table = $wpdb->prefix.'mce_template';
82
- if ($wpdb->get_var("show tables like '$table'") != $table) {
83
- $sql = "CREATE TABLE ".$table." (
84
- `ID` varchar(32) NOT NULL,
85
- `name` varchar(50) NOT NULL,
86
- `desc` varchar(100) NOT NULL,
87
- `html` text NOT NULL,
88
- `share` tinyint(1) unsigned NOT NULL,
89
- `author` bigint(20) unsigned NOT NULL,
90
- `modified` timestamp NOT NULL,
91
- UNIQUE KEY ID (`ID`))
92
- ENGINE = MYISAM
93
- CHARACTER SET utf8
94
- COLLATE utf8_unicode_ci;
95
- ";
96
- require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
97
- dbDelta($sql);
98
- }
99
- }
100
-
101
- public function deactivation()
102
- {
103
- // nothing to do
104
- }
105
-
106
- public function loadAdmin()
107
- {
108
- load_plugin_textdomain(
109
- TINYMCE_TEMPLATES_DOMAIN,
110
- PLUGINDIR.'/'.dirname(plugin_basename(__FILE__)).'/langs',
111
- dirname(plugin_basename(__FILE__)).'/langs'
112
- );
113
-
114
- $this->edit_hook = add_menu_page(
115
- __('tinyMCE Templates', TINYMCE_TEMPLATES_DOMAIN),
116
- __('Templates', TINYMCE_TEMPLATES_DOMAIN),
117
- 'edit_pages',
118
- 'edittemplates',
119
- '',
120
- TINYMCE_TEMPLATES_PLUGIN_URL.'/img/icon.png'
121
- );
122
- add_submenu_page(
123
- 'edittemplates',
124
- __('Edit Templates', TINYMCE_TEMPLATES_DOMAIN),
125
- __('Edit', TINYMCE_TEMPLATES_DOMAIN),
126
- 'edit_pages',
127
- 'edittemplates',
128
- array(&$this, 'adminPage')
129
- );
130
- $this->add_hook = add_submenu_page(
131
- 'edittemplates',
132
- __('Add New Templates', TINYMCE_TEMPLATES_DOMAIN),
133
- __('Add New', TINYMCE_TEMPLATES_DOMAIN),
134
- 'edit_pages',
135
- 'addnewtemplates',
136
- array(&$this, 'adminPage')
137
- );
138
- add_action(
139
- 'admin_head-'.$this->edit_hook,
140
- array(&$this, 'admin_head')
141
- );
142
- add_action(
143
- 'admin_head-'.$this->add_hook,
144
- array(&$this, 'admin_head')
145
- );
146
- add_action(
147
- 'admin_print_scripts-'.$this->add_hook,
148
- array(&$this, 'admin_scripts')
149
- );
150
- add_action(
151
- 'admin_print_scripts-'.$this->edit_hook,
152
- array(&$this, 'admin_scripts')
153
- );
154
-
155
- }
156
-
157
- public function admin_scripts() {
158
- global $wp_version;
159
- wp_enqueue_script('jquery-ui-tabs');
160
- wp_enqueue_script('editor');
161
- add_thickbox();
162
- wp_enqueue_script('media-upload');
163
- if (version_compare($wp_version, '3.2', '<')) {
164
- add_action('admin_print_footer_scripts', 'wp_tiny_mce_preload_dialogs', 30);
165
- }
166
- }
167
-
168
- public function adminPage()
169
- {
170
- new MceTemplatesAdmin();
171
- }
172
-
173
- public function plugin_row_meta($links, $file)
174
- {
175
- $pname = plugin_basename(__FILE__);
176
- if ($pname === $file) {
177
- $url = "https://www.paypal.com/";
178
- $url .= "cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=K8BY3GVRHSCHY";
179
- $links[] = sprintf('<a href="%s">Donate</a>', $url);
180
- }
181
- return $links;
182
- }
183
- }
184
-
185
- ?>