TinyMCE Templates - Version 2.9.0

Version Description

Download this release

Release Info

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

Code changes from version 2.8.0 to 2.9.0

Files changed (2) hide show
  1. readme.txt +3 -2
  2. tinymce-templates.php +27 -6
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: miyauchi
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CTUKCMFHF79K2
4
  Tags: tinymce, Visual Editor, template
5
  Requires at least: 3.2
6
- Tested up to: 3.3
7
- Stable tag: 2.8.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.
@@ -58,6 +58,7 @@ You can send your own language pack to me.
58
 
59
  == Changelog ==
60
 
 
61
  * [2.8.0](http://wpist.me/2012/05/24/tinymce-templates-2-8-0/)
62
  * [2.7.0](http://wpist.me/2012/05/19/tinymce-templates-2-7-0/)
63
  * [2.6.0](http://wpist.me/2011/11/14/tinymce-templates-2-6-0/)
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CTUKCMFHF79K2
4
  Tags: tinymce, Visual Editor, template
5
  Requires at least: 3.2
6
+ Tested up to: 3.4
7
+ Stable tag: 2.9.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.
58
 
59
  == Changelog ==
60
 
61
+ * [2.9.0](http://wpist.me/2012/06/14/tinymce-templates-2-9-0/)
62
  * [2.8.0](http://wpist.me/2012/05/24/tinymce-templates-2-8-0/)
63
  * [2.7.0](http://wpist.me/2012/05/19/tinymce-templates-2-7-0/)
64
  * [2.6.0](http://wpist.me/2011/11/14/tinymce-templates-2-6-0/)
tinymce-templates.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: TinyMCE Templates
4
  Plugin URI: http://wpist.me/wp/tinymce-templates/
5
  Description: TinyMCE Templates plugin will enable to use HTML template on WordPress Visual Editor.
6
  Author: Takayuki Miyauchi
7
- Version: 2.8.0
8
  Author URI: http://wpist.me/
9
  Domain Path: /languages
10
  Text Domain: tinymce_templates
@@ -38,6 +38,7 @@ new tinymceTemplates();
38
 
39
  class tinymceTemplates {
40
 
 
41
  private $db_version = '2';
42
  private $post_type = 'tinymcetemplates';
43
  private $meta_param = '_tinymcetemplates-share';
@@ -91,6 +92,7 @@ function __construct()
91
  add_action('post_submitbox_start', array(&$this, 'post_submitbox_start'));
92
  add_filter('post_row_actions', array(&$this, 'row_actions'),10,2);
93
  add_filter('page_row_actions', array(&$this, 'row_actions'),10,2);
 
94
  add_action(
95
  'wp_before_admin_bar_render',
96
  array(&$this, 'wp_before_admin_bar_render')
@@ -172,6 +174,15 @@ public function plugins_loaded()
172
  $this->addCustomPostType();
173
  }
174
 
 
 
 
 
 
 
 
 
 
175
  public function mce_css($css)
176
  {
177
  $files = preg_split("/,/", $css);
@@ -181,6 +192,11 @@ public function mce_css($css)
181
  }
182
 
183
  public function admin_head(){
 
 
 
 
 
184
  $plugin = $this->base_url.'/mce_plugins/plugins/template/editor_plugin.js';
185
 
186
  $url = admin_url('admin-ajax.php');
@@ -201,10 +217,6 @@ public function admin_head(){
201
  );
202
 
203
  if (get_post_type() === $this->post_type) {
204
- global $wp_roles;
205
- $me = wp_get_current_user();
206
- $role = array_shift($me->roles);
207
- $wp_roles->remove_cap($role, "edit_others_posts");
208
  if (get_option("tinymce_templates_db_version") != $this->db_version) {
209
  $this->activation();
210
  }
@@ -240,6 +252,10 @@ public function save_post($id)
240
 
241
  $p = get_post($id);
242
  if ($p->post_type === $this->post_type) {
 
 
 
 
243
  if (isset($_POST[$this->meta_param]) && $_POST[$this->meta_param]) {
244
  update_post_meta($id, $this->meta_param, 1);
245
  } else {
@@ -291,7 +307,6 @@ private function addCustomPostType()
291
  'author',
292
  )
293
  );
294
-
295
  register_post_type($this->post_type, $args);
296
  }
297
 
@@ -455,6 +470,12 @@ public function wp_ajax()
455
  exit;
456
  }
457
 
 
 
 
 
 
 
458
 
459
  private function get_copy_template_url($id)
460
  {
4
  Plugin URI: http://wpist.me/wp/tinymce-templates/
5
  Description: TinyMCE Templates plugin will enable to use HTML template on WordPress Visual Editor.
6
  Author: Takayuki Miyauchi
7
+ Version: 2.9.0
8
  Author URI: http://wpist.me/
9
  Domain Path: /languages
10
  Text Domain: tinymce_templates
38
 
39
  class tinymceTemplates {
40
 
41
+ private $version = '2.9.0';
42
  private $db_version = '2';
43
  private $post_type = 'tinymcetemplates';
44
  private $meta_param = '_tinymcetemplates-share';
92
  add_action('post_submitbox_start', array(&$this, 'post_submitbox_start'));
93
  add_filter('post_row_actions', array(&$this, 'row_actions'),10,2);
94
  add_filter('page_row_actions', array(&$this, 'row_actions'),10,2);
95
+ add_filter('parse_query', array(&$this, 'parse_query'));
96
  add_action(
97
  'wp_before_admin_bar_render',
98
  array(&$this, 'wp_before_admin_bar_render')
174
  $this->addCustomPostType();
175
  }
176
 
177
+ private function fixed_role_issue()
178
+ {
179
+ global $wp_roles;
180
+ $roles = array('administrator', 'editor');
181
+ foreach ($roles as $r) {
182
+ $wp_roles->add_cap($r, "edit_others_posts");
183
+ }
184
+ }
185
+
186
  public function mce_css($css)
187
  {
188
  $files = preg_split("/,/", $css);
192
  }
193
 
194
  public function admin_head(){
195
+ if (version_compare($this->version, get_option('tinymcetemplates-version', 0))) {
196
+ // bug recovery for 2.8.0
197
+ $this->fixed_role_issue();
198
+ update_option("tinymcetemplates-version", $this->version);
199
+ }
200
  $plugin = $this->base_url.'/mce_plugins/plugins/template/editor_plugin.js';
201
 
202
  $url = admin_url('admin-ajax.php');
217
  );
218
 
219
  if (get_post_type() === $this->post_type) {
 
 
 
 
220
  if (get_option("tinymce_templates_db_version") != $this->db_version) {
221
  $this->activation();
222
  }
252
 
253
  $p = get_post($id);
254
  if ($p->post_type === $this->post_type) {
255
+ $me = wp_get_current_user();
256
+ if ($p->post_author != $me->ID) {
257
+ wp_die('Permission denied.');
258
+ }
259
  if (isset($_POST[$this->meta_param]) && $_POST[$this->meta_param]) {
260
  update_post_meta($id, $this->meta_param, 1);
261
  } else {
307
  'author',
308
  )
309
  );
 
310
  register_post_type($this->post_type, $args);
311
  }
312
 
470
  exit;
471
  }
472
 
473
+ public function parse_query($q)
474
+ {
475
+ $me = wp_get_current_user();
476
+ $q->set('author', $me->ID);
477
+ return $q;
478
+ }
479
 
480
  private function get_copy_template_url($id)
481
  {