Version Description
Download this release
Release Info
Developer | miyauchi |
Plugin | TinyMCE Templates |
Version | 1.2.0 |
Comparing to | |
See all releases |
Code changes from version 1.1.2 to 1.2.0
- editor.css +1 -0
- includes/MceTemplatesAdmin.class.php +19 -15
- includes/TinyMCETemplate.class.php +3 -3
- readme.txt +1 -1
- screenshot-3.png +0 -0
- style.css +3 -7
- tinymce_templates.php +40 -5
editor.css
CHANGED
@@ -5,3 +5,4 @@ table {
|
|
5 |
th,td {
|
6 |
border: 1px dashed #cccccc;
|
7 |
}
|
|
5 |
th,td {
|
6 |
border: 1px dashed #cccccc;
|
7 |
}
|
8 |
+
|
includes/MceTemplatesAdmin.class.php
CHANGED
@@ -3,7 +3,6 @@
|
|
3 |
class MceTemplatesAdmin{
|
4 |
function __construct()
|
5 |
{
|
6 |
-
echo '<link rel="stylesheet" href="'.TINYMCE_TEMPLATES_PLUGIN_URL.'/style.css" type="text/css" media="all" />';
|
7 |
|
8 |
echo '<div class="wrap">';
|
9 |
|
@@ -20,7 +19,6 @@ class MceTemplatesAdmin{
|
|
20 |
echo '</div>';
|
21 |
}
|
22 |
|
23 |
-
|
24 |
public function editView()
|
25 |
{
|
26 |
global $wpdb;
|
@@ -55,7 +53,7 @@ class MceTemplatesAdmin{
|
|
55 |
echo '</tfoot>';
|
56 |
echo '<tbody>';
|
57 |
|
58 |
-
$sql = "select * from ".
|
59 |
where `author`={$current_user->ID} or `share`=1 order by `modified` desc";
|
60 |
$row = $wpdb->get_results($sql);
|
61 |
|
@@ -107,7 +105,7 @@ class MceTemplatesAdmin{
|
|
107 |
if ($this->validate() && $this->save()) {
|
108 |
echo "<div id=\"message\" class=\"updated fade\"><p><strong>".__("Template saved.", TINYMCE_TEMPLATES_DOMAIN)."</strong></p></div>";
|
109 |
global $wpdb;
|
110 |
-
$sql = $wpdb->prepare("select * from ".
|
111 |
where `id`=%s", $_POST['id']);
|
112 |
$r = $wpdb->get_row($sql);
|
113 |
$id = $r->ID;
|
@@ -120,14 +118,14 @@ class MceTemplatesAdmin{
|
|
120 |
$id = $_POST['id'];
|
121 |
$name = $_POST['name'];
|
122 |
$desc = $_POST['desc'];
|
123 |
-
$html = stripslashes($_POST['
|
124 |
$share = $_POST['share'];
|
125 |
}
|
126 |
} elseif (isset($_GET['page']) && $_GET['page'] == 'edittemplates'
|
127 |
&& isset($_GET['id']) && preg_match("/^[a-zA-Z0-9]{32}$/", $_GET['id'])) {
|
128 |
global $wpdb;
|
129 |
-
$sql = $wpdb->prepare("select * from ".
|
130 |
-
where `ID`=%s and author=%s",
|
131 |
$_GET['id'], $current_user->ID);
|
132 |
$r = $wpdb->get_row($sql);
|
133 |
if ($r) {
|
@@ -156,12 +154,18 @@ class MceTemplatesAdmin{
|
|
156 |
echo "<form action=\"{$_SERVER["REQUEST_URI"]}\" method=\"post\">";
|
157 |
echo "<input type=\"hidden\" name=\"save\" value=\"1\" />";
|
158 |
echo "<input type=\"hidden\" name=\"id\" value=\"{$id}\" />";
|
159 |
-
echo
|
160 |
-
echo
|
161 |
echo "<h3>".__("Template Description", TINYMCE_TEMPLATES_DOMAIN)."</h3>";
|
162 |
echo "<textarea id=\"desc\" name=\"desc\">{$desc}</textarea>";
|
163 |
echo "<h3>".__("Template Contents", TINYMCE_TEMPLATES_DOMAIN)." (HTML)</h3>";
|
164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
echo "<h3>".__("Share", TINYMCE_TEMPLATES_DOMAIN)."</h3>";
|
166 |
echo "<select name=\"share\" id=\"share\">";
|
167 |
if ($share == 1) {
|
@@ -187,7 +191,7 @@ class MceTemplatesAdmin{
|
|
187 |
return false;
|
188 |
}
|
189 |
|
190 |
-
$sql = "insert into ".
|
191 |
(`ID`, `name`, `desc`, `html`, `share`, `author`)
|
192 |
values
|
193 |
(%s, %s, %s, %s, %d, %d)
|
@@ -200,14 +204,14 @@ class MceTemplatesAdmin{
|
|
200 |
";
|
201 |
$sql = $wpdb->prepare($sql, $_POST['id'],
|
202 |
$_POST['name'], $_POST['desc'],
|
203 |
-
$_POST['
|
204 |
$wpdb->query($sql);
|
205 |
return true;
|
206 |
}
|
207 |
|
208 |
private function validate()
|
209 |
{
|
210 |
-
$pars = array('id', 'name', 'desc', '
|
211 |
foreach ($pars as $par):
|
212 |
$_POST[$par] = trim($_POST[$par]);
|
213 |
if (!isset($_POST[$par]) || !strlen($_POST[$par])) {
|
@@ -231,7 +235,7 @@ class MceTemplatesAdmin{
|
|
231 |
global $wpdb;
|
232 |
global $current_user;
|
233 |
|
234 |
-
$sql = $wpdb->prepare("select author from ".
|
235 |
$author = $wpdb->get_var($sql);
|
236 |
|
237 |
if (!$author || $author === $current_user->ID) {
|
@@ -247,7 +251,7 @@ class MceTemplatesAdmin{
|
|
247 |
global $current_user;
|
248 |
|
249 |
foreach ($_POST['templates'] as $tpl) {
|
250 |
-
$sql = "delete from ".
|
251 |
$sql = $wpdb->prepare($sql, $tpl, $current_user->ID);
|
252 |
$wpdb->query($sql);
|
253 |
}
|
3 |
class MceTemplatesAdmin{
|
4 |
function __construct()
|
5 |
{
|
|
|
6 |
|
7 |
echo '<div class="wrap">';
|
8 |
|
19 |
echo '</div>';
|
20 |
}
|
21 |
|
|
|
22 |
public function editView()
|
23 |
{
|
24 |
global $wpdb;
|
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 |
|
105 |
if ($this->validate() && $this->save()) {
|
106 |
echo "<div id=\"message\" class=\"updated fade\"><p><strong>".__("Template saved.", TINYMCE_TEMPLATES_DOMAIN)."</strong></p></div>";
|
107 |
global $wpdb;
|
108 |
+
$sql = $wpdb->prepare("select * from ".$wpdb->prefix."mce_template
|
109 |
where `id`=%s", $_POST['id']);
|
110 |
$r = $wpdb->get_row($sql);
|
111 |
$id = $r->ID;
|
118 |
$id = $_POST['id'];
|
119 |
$name = $_POST['name'];
|
120 |
$desc = $_POST['desc'];
|
121 |
+
$html = stripslashes($_POST['content']);
|
122 |
$share = $_POST['share'];
|
123 |
}
|
124 |
} elseif (isset($_GET['page']) && $_GET['page'] == 'edittemplates'
|
125 |
&& isset($_GET['id']) && preg_match("/^[a-zA-Z0-9]{32}$/", $_GET['id'])) {
|
126 |
global $wpdb;
|
127 |
+
$sql = $wpdb->prepare("select * from ".$wpdb->prefix."mce_template
|
128 |
+
where `ID`=%s and author=%s",
|
129 |
$_GET['id'], $current_user->ID);
|
130 |
$r = $wpdb->get_row($sql);
|
131 |
if ($r) {
|
154 |
echo "<form action=\"{$_SERVER["REQUEST_URI"]}\" method=\"post\">";
|
155 |
echo "<input type=\"hidden\" name=\"save\" value=\"1\" />";
|
156 |
echo "<input type=\"hidden\" name=\"id\" value=\"{$id}\" />";
|
157 |
+
echo '<h3>'.__("Template Name", TINYMCE_TEMPLATES_DOMAIN).'</h3>';
|
158 |
+
echo '<input type="text" id="name" name="name" value="'.$name.'" />';
|
159 |
echo "<h3>".__("Template Description", TINYMCE_TEMPLATES_DOMAIN)."</h3>";
|
160 |
echo "<textarea id=\"desc\" name=\"desc\">{$desc}</textarea>";
|
161 |
echo "<h3>".__("Template Contents", TINYMCE_TEMPLATES_DOMAIN)." (HTML)</h3>";
|
162 |
+
// new line by ANDREA BERSI
|
163 |
+
echo "<div id='poststuff'>";
|
164 |
+
echo "<div id=\"postdivrich\" class=\"postarea\">";
|
165 |
+
the_editor($html, "content", "desc", true, 3);
|
166 |
+
echo "</div><!--end #postdivrich-->";
|
167 |
+
echo "</div><!--end #poststuff-->";
|
168 |
+
//END NEW LINE
|
169 |
echo "<h3>".__("Share", TINYMCE_TEMPLATES_DOMAIN)."</h3>";
|
170 |
echo "<select name=\"share\" id=\"share\">";
|
171 |
if ($share == 1) {
|
191 |
return false;
|
192 |
}
|
193 |
|
194 |
+
$sql = "insert into ".$wpdb->prefix."mce_template
|
195 |
(`ID`, `name`, `desc`, `html`, `share`, `author`)
|
196 |
values
|
197 |
(%s, %s, %s, %s, %d, %d)
|
204 |
";
|
205 |
$sql = $wpdb->prepare($sql, $_POST['id'],
|
206 |
$_POST['name'], $_POST['desc'],
|
207 |
+
$_POST['content'], $_POST['share'], $current_user->ID);
|
208 |
$wpdb->query($sql);
|
209 |
return true;
|
210 |
}
|
211 |
|
212 |
private function validate()
|
213 |
{
|
214 |
+
$pars = array('id', 'name', 'desc', 'content', 'share');
|
215 |
foreach ($pars as $par):
|
216 |
$_POST[$par] = trim($_POST[$par]);
|
217 |
if (!isset($_POST[$par]) || !strlen($_POST[$par])) {
|
235 |
global $wpdb;
|
236 |
global $current_user;
|
237 |
|
238 |
+
$sql = $wpdb->prepare("select author from ".$wpdb->prefix."mce_template where ID=%s", $id);
|
239 |
$author = $wpdb->get_var($sql);
|
240 |
|
241 |
if (!$author || $author === $current_user->ID) {
|
251 |
global $current_user;
|
252 |
|
253 |
foreach ($_POST['templates'] as $tpl) {
|
254 |
+
$sql = "delete from ".$wpdb->prefix."mce_template where ID=%s and author=%s";
|
255 |
$sql = $wpdb->prepare($sql, $tpl, $current_user->ID);
|
256 |
$wpdb->query($sql);
|
257 |
}
|
includes/TinyMCETemplate.class.php
CHANGED
@@ -79,18 +79,18 @@ class TinyMCETemplate{
|
|
79 |
}
|
80 |
|
81 |
if( isset($_GET['id']) && strlen($_GET['id']) ){
|
82 |
-
$sql = "select html from ".
|
83 |
where (`ID`=%s) and (`author`={$current_user->ID} or `share`=1)
|
84 |
order by `modified` desc";
|
85 |
$sql = $wpdb->prepare($sql, $_GET['id']);
|
86 |
$template = $wpdb->get_var($sql);
|
87 |
if ($template) {
|
88 |
-
echo stripslashes($template);
|
89 |
}
|
90 |
exit;
|
91 |
}
|
92 |
|
93 |
-
$sql = "select * from ".
|
94 |
where `author`={$current_user->ID} or `share`=1
|
95 |
order by `modified` desc";
|
96 |
$row = $wpdb->get_results($sql);
|
79 |
}
|
80 |
|
81 |
if( isset($_GET['id']) && strlen($_GET['id']) ){
|
82 |
+
$sql = "select html from ".$wpdb->prefix."mce_template
|
83 |
where (`ID`=%s) and (`author`={$current_user->ID} or `share`=1)
|
84 |
order by `modified` desc";
|
85 |
$sql = $wpdb->prepare($sql, $_GET['id']);
|
86 |
$template = $wpdb->get_var($sql);
|
87 |
if ($template) {
|
88 |
+
echo wpautop(stripslashes($template));
|
89 |
}
|
90 |
exit;
|
91 |
}
|
92 |
|
93 |
+
$sql = "select * from ".$wpdb->prefix."mce_template
|
94 |
where `author`={$current_user->ID} or `share`=1
|
95 |
order by `modified` desc";
|
96 |
$row = $wpdb->get_results($sql);
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://firegoby.theta.ne.jp/
|
|
4 |
Tags: tinymce, Visual Editor, template
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.1
|
7 |
-
Stable tag: 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.1
|
7 |
+
Stable tag: 1.2.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.
|
screenshot-3.png
ADDED
Binary file
|
style.css
CHANGED
@@ -35,10 +35,10 @@
|
|
35 |
}
|
36 |
|
37 |
#name,
|
38 |
-
#desc
|
39 |
-
#html
|
40 |
{
|
41 |
width: 100%;
|
|
|
42 |
}
|
43 |
|
44 |
#desc
|
@@ -46,12 +46,8 @@
|
|
46 |
height: 3em;
|
47 |
}
|
48 |
|
49 |
-
#html
|
50 |
-
{
|
51 |
-
height: 10em;
|
52 |
-
}
|
53 |
-
|
54 |
#save
|
55 |
{
|
56 |
margin: 1em 0;
|
57 |
}
|
|
35 |
}
|
36 |
|
37 |
#name,
|
38 |
+
#desc
|
|
|
39 |
{
|
40 |
width: 100%;
|
41 |
+
font-size: 1.7em;
|
42 |
}
|
43 |
|
44 |
#desc
|
46 |
height: 3em;
|
47 |
}
|
48 |
|
|
|
|
|
|
|
|
|
|
|
49 |
#save
|
50 |
{
|
51 |
margin: 1em 0;
|
52 |
}
|
53 |
+
|
tinymce_templates.php
CHANGED
@@ -3,8 +3,8 @@
|
|
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.
|
8 |
Author URI: http://firegoby.theta.ne.jp/
|
9 |
*/
|
10 |
|
@@ -31,7 +31,6 @@ THE SOFTWARE.
|
|
31 |
*/
|
32 |
|
33 |
define('TINYMCE_TEMPLATES_PLUGIN_URL', WP_PLUGIN_URL.'/'.dirname(plugin_basename(__FILE__)));
|
34 |
-
define('TINYMCE_TEMPLATES_TABLE', $wpdb->prefix.'mce_template');
|
35 |
define('TINYMCE_TEMPLATES_DOMAIN', 'tinymce_templates');
|
36 |
|
37 |
require_once(dirname(__FILE__).'/includes/addrewriterules.class.php');
|
@@ -41,7 +40,7 @@ require_once(dirname(__FILE__).'/includes/MceTemplatesAdmin.class.php');
|
|
41 |
|
42 |
$MceTemplates = new MceTemplates();
|
43 |
register_activation_hook (__FILE__, array(&$MceTemplates, 'activation'));
|
44 |
-
register_deactivation_hook (__FILE__, array(&$MceTemplates, 'deactivation'));
|
45 |
|
46 |
class MceTemplates{
|
47 |
|
@@ -51,12 +50,38 @@ class MceTemplates{
|
|
51 |
function __construct()
|
52 |
{
|
53 |
add_action('admin_menu', array(&$this, 'loadAdmin'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
}
|
55 |
|
56 |
public function activation()
|
57 |
{
|
58 |
global $wpdb;
|
59 |
-
$sql = "CREATE TABLE {$wpdb->prefix}mce_template (
|
60 |
`ID` varchar(32) NOT NULL,
|
61 |
`name` varchar(50) NOT NULL,
|
62 |
`desc` varchar(100) NOT NULL,
|
@@ -124,5 +149,15 @@ class MceTemplates{
|
|
124 |
new MceTemplatesAdmin();
|
125 |
}
|
126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
}
|
128 |
?>
|
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.2.0
|
8 |
Author URI: http://firegoby.theta.ne.jp/
|
9 |
*/
|
10 |
|
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/addrewriterules.class.php');
|
40 |
|
41 |
$MceTemplates = new MceTemplates();
|
42 |
register_activation_hook (__FILE__, array(&$MceTemplates, 'activation'));
|
43 |
+
//register_deactivation_hook (__FILE__, array(&$MceTemplates, 'deactivation'));
|
44 |
|
45 |
class MceTemplates{
|
46 |
|
50 |
function __construct()
|
51 |
{
|
52 |
add_action('admin_menu', array(&$this, 'loadAdmin'));
|
53 |
+
add_action(
|
54 |
+
'admin_head-templates_page_addnewtemplates',
|
55 |
+
array(&$this, 'admin_head')
|
56 |
+
);
|
57 |
+
add_action(
|
58 |
+
'admin_head-toplevel_page_edittemplates',
|
59 |
+
array(&$this, 'admin_head')
|
60 |
+
);
|
61 |
+
add_filter('plugin_row_meta', array(&$this, 'plugin_row_meta'), 10, 2);
|
62 |
+
}
|
63 |
+
|
64 |
+
public function admin_head()
|
65 |
+
{
|
66 |
+
wp_enqueue_script( 'common' );
|
67 |
+
wp_enqueue_script( 'jquery-color' );
|
68 |
+
wp_print_scripts('editor');
|
69 |
+
if (function_exists('add_thickbox')) add_thickbox();
|
70 |
+
wp_print_scripts('media-upload');
|
71 |
+
if (function_exists('wp_tiny_mce')) wp_tiny_mce();
|
72 |
+
wp_admin_css();
|
73 |
+
wp_enqueue_script('utils');
|
74 |
+
do_action("admin_print_styles-post-php");
|
75 |
+
do_action('admin_print_styles');
|
76 |
+
$dir = WP_PLUGIN_URL.'/'.dirname(plugin_basename(__FILE__));
|
77 |
+
$html = '<link rel="stylesheet" href="%s/style.css" type="text/css" />';
|
78 |
+
printf($html, $dir);
|
79 |
}
|
80 |
|
81 |
public function activation()
|
82 |
{
|
83 |
global $wpdb;
|
84 |
+
$sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}mce_template (
|
85 |
`ID` varchar(32) NOT NULL,
|
86 |
`name` varchar(50) NOT NULL,
|
87 |
`desc` varchar(100) NOT NULL,
|
149 |
new MceTemplatesAdmin();
|
150 |
}
|
151 |
|
152 |
+
public function plugin_row_meta($links, $file)
|
153 |
+
{
|
154 |
+
$pname = plugin_basename(__FILE__);
|
155 |
+
if ($pname === $file) {
|
156 |
+
$url = "https://www.paypal.com/";
|
157 |
+
$url .= "cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=K8BY3GVRHSCHY";
|
158 |
+
$links[] = sprintf('<a href="%s">Donate</a>', $url);
|
159 |
+
}
|
160 |
+
return $links;
|
161 |
+
}
|
162 |
}
|
163 |
?>
|