Version Description
Download this release
Release Info
Developer | artstorm |
Plugin | Post Snippets |
Version | 1.8.7 |
Comparing to | |
See all releases |
Code changes from version 1.8.6 to 1.8.7
- post-snippets.php +122 -13
- readme.txt +66 -24
- tinymce/editor_plugin.js +8 -5
- tinymce/tinymce.php +0 -50
- tinymce/window.php +0 -157
post-snippets.php
CHANGED
@@ -3,9 +3,9 @@
|
|
3 |
Plugin Name: Post Snippets
|
4 |
Plugin URI: http://wpstorm.net/wordpress-plugins/post-snippets/
|
5 |
Description: Stores snippets of HTML code or reoccurring text that you often use in your posts. You can use predefined variables to replace parts of the snippet on insert. All snippets are available in the post editor with a TinyMCE button or Quicktags.
|
6 |
-
Version: 1.8.
|
7 |
Author: Johan Steen
|
8 |
-
Author URI: http://
|
9 |
Text Domain: post-snippets
|
10 |
|
11 |
Copyright 2009-2011 Johan Steen (email : artstorm [at] gmail [dot] com)
|
@@ -26,26 +26,30 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
26 |
*/
|
27 |
|
28 |
class post_snippets {
|
|
|
29 |
var $plugin_options = "post_snippets_options";
|
30 |
|
31 |
/**
|
32 |
* Constructor
|
33 |
*
|
34 |
*/
|
35 |
-
function post_snippets() {
|
36 |
-
// define URL
|
37 |
-
define('post_snippets_ABSPATH', WP_PLUGIN_DIR.'/'.plugin_basename( dirname(__FILE__) ).'/' );
|
38 |
-
define('post_snippets_URLPATH', WP_PLUGIN_URL.'/'.plugin_basename( dirname(__FILE__) ).'/' );
|
39 |
-
|
40 |
// Define the domain for translations
|
41 |
-
load_plugin_textdomain( 'post-snippets', false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
-
|
|
|
44 |
global $wp_version;
|
45 |
if ( version_compare($wp_version, '2.7', '<') ) {
|
46 |
add_action( 'admin_notices', array(&$this, 'version_warning') );
|
47 |
} else {
|
48 |
-
include_once (dirname (__FILE__)."/tinymce/tinymce.php");
|
49 |
$this->init_hooks();
|
50 |
}
|
51 |
}
|
@@ -56,6 +60,10 @@ class post_snippets {
|
|
56 |
* @returns Nothing
|
57 |
*/
|
58 |
function init_hooks() {
|
|
|
|
|
|
|
|
|
59 |
# Settings link on plugins list
|
60 |
add_filter( 'plugin_action_links', array(&$this, 'plugin_action_links'), 10, 2 );
|
61 |
# Options Page
|
@@ -96,6 +104,24 @@ class post_snippets {
|
|
96 |
return $links;
|
97 |
}
|
98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
/**
|
100 |
* Displays a warning when installed in an old Wordpress Version
|
101 |
*
|
@@ -123,6 +149,81 @@ class post_snippets {
|
|
123 |
wp_enqueue_style( 'post-snippets');
|
124 |
}
|
125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
/**
|
127 |
* jQuery control for the dialog and Javascript needed to insert snippets into the editor
|
128 |
*
|
@@ -214,7 +315,13 @@ class post_snippets {
|
|
214 |
<?php
|
215 |
}
|
216 |
?>
|
217 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
}
|
219 |
},
|
220 |
width: 500,
|
@@ -222,12 +329,13 @@ class post_snippets {
|
|
222 |
});
|
223 |
});
|
224 |
|
225 |
-
|
226 |
var muppCanv;
|
|
|
227 |
|
228 |
-
|
229 |
function edOpenPostSnippets(myField) {
|
230 |
muppCanv = myField;
|
|
|
231 |
jQuery( "#post-snippets-dialog" ).dialog( "open" );
|
232 |
};
|
233 |
<?php
|
@@ -311,6 +419,7 @@ function edOpenPostSnippets(myField) {
|
|
311 |
<script type="text/javascript" charset="utf-8">
|
312 |
QTags.addButton( 'post_snippets_id', 'Post Snippets', qt_post_snippets );
|
313 |
function qt_post_snippets() {
|
|
|
314 |
jQuery( "#post-snippets-dialog" ).dialog( "open" );
|
315 |
}
|
316 |
</script>
|
3 |
Plugin Name: Post Snippets
|
4 |
Plugin URI: http://wpstorm.net/wordpress-plugins/post-snippets/
|
5 |
Description: Stores snippets of HTML code or reoccurring text that you often use in your posts. You can use predefined variables to replace parts of the snippet on insert. All snippets are available in the post editor with a TinyMCE button or Quicktags.
|
6 |
+
Version: 1.8.7
|
7 |
Author: Johan Steen
|
8 |
+
Author URI: http://johansteen.se/
|
9 |
Text Domain: post-snippets
|
10 |
|
11 |
Copyright 2009-2011 Johan Steen (email : artstorm [at] gmail [dot] com)
|
26 |
*/
|
27 |
|
28 |
class post_snippets {
|
29 |
+
private $tinymce_plugin_name = 'post_snippets';
|
30 |
var $plugin_options = "post_snippets_options";
|
31 |
|
32 |
/**
|
33 |
* Constructor
|
34 |
*
|
35 |
*/
|
36 |
+
public function post_snippets() {
|
|
|
|
|
|
|
|
|
37 |
// Define the domain for translations
|
38 |
+
load_plugin_textdomain( 'post-snippets', false,
|
39 |
+
dirname(plugin_basename(__FILE__)) . '/languages/');
|
40 |
+
|
41 |
+
|
42 |
+
// Add a warning if PHP is older than 5.2.4 (WP 3.3 requirements)
|
43 |
+
if (version_compare(PHP_VERSION, '5.2.4', '<')) {
|
44 |
+
add_action( 'admin_notices', array(&$this, 'php_warning') );
|
45 |
+
}
|
46 |
|
47 |
+
|
48 |
+
// Check that at least WordPress 3.0 is installed.
|
49 |
global $wp_version;
|
50 |
if ( version_compare($wp_version, '2.7', '<') ) {
|
51 |
add_action( 'admin_notices', array(&$this, 'version_warning') );
|
52 |
} else {
|
|
|
53 |
$this->init_hooks();
|
54 |
}
|
55 |
}
|
60 |
* @returns Nothing
|
61 |
*/
|
62 |
function init_hooks() {
|
63 |
+
|
64 |
+
// Add TinyMCE button
|
65 |
+
add_action('init', array(&$this, 'add_tinymce_button') );
|
66 |
+
|
67 |
# Settings link on plugins list
|
68 |
add_filter( 'plugin_action_links', array(&$this, 'plugin_action_links'), 10, 2 );
|
69 |
# Options Page
|
104 |
return $links;
|
105 |
}
|
106 |
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Displays a warning when installed on an old PHP version
|
110 |
+
*
|
111 |
+
* @returns Nothing
|
112 |
+
*/
|
113 |
+
function php_warning() {
|
114 |
+
echo '<div class="updated fade"><p><strong>'.__(
|
115 |
+
'Notice:<br/>
|
116 |
+
When Post Snippets v1.9 will be released, the minimum
|
117 |
+
required PHP Version will be 5.2.4 to be on par with WordPress 3.3.<br/>Please update your
|
118 |
+
PHP installation before updating Post Snippets to v1.9+, or
|
119 |
+
contact the plugin author to plead your case.<br/>
|
120 |
+
Your installed PHP version: '.PHP_VERSION
|
121 |
+
, 'post-snippets').'</strong></p></div>';
|
122 |
+
}
|
123 |
+
|
124 |
+
|
125 |
/**
|
126 |
* Displays a warning when installed in an old Wordpress Version
|
127 |
*
|
149 |
wp_enqueue_style( 'post-snippets');
|
150 |
}
|
151 |
|
152 |
+
|
153 |
+
// -------------------------------------------------------------------------
|
154 |
+
// WordPress Editor Buttons
|
155 |
+
// -------------------------------------------------------------------------
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Add TinyMCE button.
|
159 |
+
*
|
160 |
+
* Adds filters to add custom buttons to the TinyMCE editor (Visual Editor)
|
161 |
+
* in WordPress.
|
162 |
+
*
|
163 |
+
* @since Post Snippets 1.8.7
|
164 |
+
*/
|
165 |
+
public function add_tinymce_button()
|
166 |
+
{
|
167 |
+
// Don't bother doing this stuff if the current user lacks permissions
|
168 |
+
if ( !current_user_can('edit_posts') &&
|
169 |
+
!current_user_can('edit_pages') )
|
170 |
+
return;
|
171 |
+
|
172 |
+
// Add only in Rich Editor mode
|
173 |
+
if ( get_user_option('rich_editing') == 'true') {
|
174 |
+
add_filter('mce_external_plugins',
|
175 |
+
array(&$this, 'register_tinymce_plugin') );
|
176 |
+
add_filter('mce_buttons',
|
177 |
+
array(&$this, 'register_tinymce_button') );
|
178 |
+
}
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Register TinyMCE button.
|
183 |
+
*
|
184 |
+
* Pushes the custom TinyMCE button into the array of with button names.
|
185 |
+
* 'separator' or '|' can be pushed to the array as well. See the link
|
186 |
+
* for all available TinyMCE controls.
|
187 |
+
*
|
188 |
+
* @see wp-includes/class-wp-editor.php
|
189 |
+
* @link http://www.tinymce.com/wiki.php/Buttons/controls
|
190 |
+
* @since Post Snippets 1.8.7
|
191 |
+
*
|
192 |
+
* @param array $buttons Filter supplied array of buttons to modify
|
193 |
+
* @return array The modified array with buttons
|
194 |
+
*/
|
195 |
+
public function register_tinymce_button( $buttons )
|
196 |
+
{
|
197 |
+
array_push( $buttons, 'separator', $this->tinymce_plugin_name );
|
198 |
+
return $buttons;
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Register TinyMCE plugin.
|
203 |
+
*
|
204 |
+
* Adds the absolute URL for the TinyMCE plugin to the associative array of
|
205 |
+
* plugins. Array structure: 'plugin_name' => 'plugin_url'
|
206 |
+
*
|
207 |
+
* @see wp-includes/class-wp-editor.php
|
208 |
+
* @since Post Snippets 1.8.7
|
209 |
+
*
|
210 |
+
* @param array $plugins Filter supplied array of plugins to modify
|
211 |
+
* @return array The modified array with plugins
|
212 |
+
*/
|
213 |
+
public function register_tinymce_plugin( $plugins )
|
214 |
+
{
|
215 |
+
// Load the TinyMCE plugin, editor_plugin.js, into the array
|
216 |
+
$plugins[$this->tinymce_plugin_name] =
|
217 |
+
plugins_url('/tinymce/editor_plugin.js', __FILE__);
|
218 |
+
|
219 |
+
return $plugins;
|
220 |
+
}
|
221 |
+
|
222 |
+
|
223 |
+
// -------------------------------------------------------------------------
|
224 |
+
|
225 |
+
|
226 |
+
|
227 |
/**
|
228 |
* jQuery control for the dialog and Javascript needed to insert snippets into the editor
|
229 |
*
|
315 |
<?php
|
316 |
}
|
317 |
?>
|
318 |
+
|
319 |
+
if (caller == 'html') {
|
320 |
+
edInsertContent(muppCanv, insert_snippet);
|
321 |
+
} else {
|
322 |
+
muppCanv.execCommand('mceInsertContent', false, insert_snippet);
|
323 |
+
}
|
324 |
+
|
325 |
}
|
326 |
},
|
327 |
width: 500,
|
329 |
});
|
330 |
});
|
331 |
|
|
|
332 |
var muppCanv;
|
333 |
+
caller = '';
|
334 |
|
335 |
+
<!-- Deprecated -->
|
336 |
function edOpenPostSnippets(myField) {
|
337 |
muppCanv = myField;
|
338 |
+
caller = 'html';
|
339 |
jQuery( "#post-snippets-dialog" ).dialog( "open" );
|
340 |
};
|
341 |
<?php
|
419 |
<script type="text/javascript" charset="utf-8">
|
420 |
QTags.addButton( 'post_snippets_id', 'Post Snippets', qt_post_snippets );
|
421 |
function qt_post_snippets() {
|
422 |
+
caller = 'html';
|
423 |
jQuery( "#post-snippets-dialog" ).dialog( "open" );
|
424 |
}
|
425 |
</script>
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://wpstorm.net/wordpress-plugins/post-snippets/#donation
|
|
4 |
Tags: post, admin, snippet, html, custom, page, dynamic, editor, quicktag
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.3
|
7 |
-
Stable tag: 1.8.
|
8 |
|
9 |
Store snippets of HTML code or reoccurring text that you often use in your posts. Custom variables can be used.
|
10 |
|
@@ -66,6 +66,15 @@ Please visit the [Support Forum](http://wordpress.org/tags/post-snippets?forum_i
|
|
66 |
|
67 |
== Changelog ==
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
= Version 1.8.6 - 15 Dec 2011 =
|
70 |
* The Post Snippets HTML editor button is updated to be compatible with
|
71 |
WordPress 3.3 refactored QuickTags.
|
@@ -111,16 +120,27 @@ Please visit the [Support Forum](http://wordpress.org/tags/post-snippets?forum_i
|
|
111 |
* Updated the Spanish translation by Melvis E. Leon Lopez.
|
112 |
|
113 |
= Version 1.7.1 - 26 Feb 2011 =
|
114 |
-
* Added styling to the Tabs in the Quicktag jQuery dialog window to make them
|
115 |
-
|
116 |
-
*
|
|
|
|
|
|
|
|
|
117 |
* **Changed the required version of WordPress to 3.0**.
|
118 |
-
* Request by proximity2008: A snippet without anything entered in the snippet
|
|
|
119 |
|
120 |
= Version 1.7 - 26 Feb 2011 =
|
121 |
-
* Complete rewrite of the QuickTags insert functionality. It now uses jQuery UI
|
|
|
|
|
|
|
|
|
|
|
122 |
* Fixed QuickTags compability with WordPress 3.1.
|
123 |
-
* Added a link to the Post Snippets Settings directly from the entry on the
|
|
|
124 |
* Added get_post_snippet() function to retrieve snippets directly from PHP.
|
125 |
|
126 |
= Version 1.5.4 - 26 Jan 2011 =
|
@@ -154,46 +174,68 @@ Please visit the [Support Forum](http://wordpress.org/tags/post-snippets?forum_i
|
|
154 |
* Fixed a problem that didn't let a snippet contain a </script> tag.
|
155 |
|
156 |
= Version 1.4.7 - 27 Apr 2009 =
|
157 |
-
* Added a workaround for a bug in WordPress 2.7.x wp-includes/compat.php that
|
|
|
|
|
158 |
|
159 |
= Version 1.4.6 - 25 Apr 2009 =
|
160 |
-
* Updated all code to follow the WordPress Coding Standards for consistency, if
|
161 |
-
|
162 |
-
*
|
|
|
|
|
|
|
163 |
* Added additional proofing for the variables string.
|
164 |
|
165 |
= Version 1.4.5 - 24 Apr 2009 =
|
166 |
-
* Fixed a problem in the admin options that didn't allow a form with a textarea
|
167 |
-
|
|
|
|
|
168 |
|
169 |
= Version 1.4.4 - 19 Apr 2009 =
|
170 |
-
* Minor fix with quicktags and certain snippets that was left out in the last
|
|
|
171 |
|
172 |
= Version 1.4.3 - 16 Apr 2009 =
|
173 |
-
* Fixed an escaping problem with the recently implemented shortcode function,
|
174 |
-
|
|
|
|
|
175 |
|
176 |
= Version 1.4.2 - 11 Apr 2009 =
|
177 |
-
* Fixed some additional syntax for servers where the short_open_tag
|
|
|
178 |
|
179 |
= Version 1.4.1 - 10 Apr 2009 =
|
180 |
-
* Removed all short syntax commands and replaced them with the full versions so
|
|
|
|
|
181 |
|
182 |
= Version 1.4 - 10 Apr 2009 =
|
183 |
-
* Added a checkbox for Shortcodes (SC) in the admin panel. When checking this
|
184 |
-
|
|
|
|
|
|
|
|
|
|
|
185 |
|
186 |
= Version 1.3.5 - 9 Apr 2009 =
|
187 |
-
* Fixed so the TinyMCE window adds a scrollbar if there is more variables for a
|
188 |
-
|
|
|
|
|
189 |
|
190 |
= Version 1.3 - 2 Apr 2009 =
|
191 |
-
* Fixed a problem with the regular expressions that prohibited variables
|
|
|
192 |
* Updated the Help info in the admin page to take less space.
|
193 |
* Included a check so the plugin only runs in WP 2.7 or newer.
|
194 |
|
195 |
= Version 1.2 - 1 Apr 2009 =
|
196 |
-
* Added support for Quicktags so the snippets can be made available in the HTML
|
|
|
197 |
|
198 |
= Version 1.1 - 24 Mar 2009 =
|
199 |
* Included Swedish translation.
|
4 |
Tags: post, admin, snippet, html, custom, page, dynamic, editor, quicktag
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.3
|
7 |
+
Stable tag: 1.8.7
|
8 |
|
9 |
Store snippets of HTML code or reoccurring text that you often use in your posts. Custom variables can be used.
|
10 |
|
66 |
|
67 |
== Changelog ==
|
68 |
|
69 |
+
= Version 1.8.7 - 25 Dec 2011 =
|
70 |
+
* Updated the TinyMCE plugin for the Post Snippets button in WordPress Visual
|
71 |
+
Editor to use the same jQuery UI Dialog window that the HTML button have had
|
72 |
+
for some time. The consolidation of using the same window and code for the
|
73 |
+
different buttons will make Post Snippets easier to maintain and update.
|
74 |
+
* Added an admin notice when running on PHP versions below 5.2.4 to prepare
|
75 |
+
users that future Post Snippets requirements will be on par with WordPress
|
76 |
+
3.3.
|
77 |
+
|
78 |
= Version 1.8.6 - 15 Dec 2011 =
|
79 |
* The Post Snippets HTML editor button is updated to be compatible with
|
80 |
WordPress 3.3 refactored QuickTags.
|
120 |
* Updated the Spanish translation by Melvis E. Leon Lopez.
|
121 |
|
122 |
= Version 1.7.1 - 26 Feb 2011 =
|
123 |
+
* Added styling to the Tabs in the Quicktag jQuery dialog window to make them
|
124 |
+
more "tab-like".
|
125 |
+
* Added the possibility to use a description for each snippet to display for
|
126 |
+
the user when opening the Quicktag jQuery dialog window. Snippets without
|
127 |
+
description and variables, has a default information message.
|
128 |
+
* Moved the help text from below the snippets to the contextual help dropdown
|
129 |
+
menu at the top of the settings page.
|
130 |
* **Changed the required version of WordPress to 3.0**.
|
131 |
+
* Request by proximity2008: A snippet without anything entered in the snippet
|
132 |
+
field will not be registered as a shortcode.
|
133 |
|
134 |
= Version 1.7 - 26 Feb 2011 =
|
135 |
+
* Complete rewrite of the QuickTags insert functionality. It now uses jQuery UI
|
136 |
+
to display a similar tabbed window as the TinyMCE button does. There is now
|
137 |
+
one 'Post Snippets' button in the HTML editor instead of a separate button
|
138 |
+
for each snippet. As the QuickTags function is completely rewritten, and this
|
139 |
+
is the initial release of the new method, please report if you encounter any
|
140 |
+
problems with it.
|
141 |
* Fixed QuickTags compability with WordPress 3.1.
|
142 |
+
* Added a link to the Post Snippets Settings directly from the entry on the
|
143 |
+
'Plugins List' page.
|
144 |
* Added get_post_snippet() function to retrieve snippets directly from PHP.
|
145 |
|
146 |
= Version 1.5.4 - 26 Jan 2011 =
|
174 |
* Fixed a problem that didn't let a snippet contain a </script> tag.
|
175 |
|
176 |
= Version 1.4.7 - 27 Apr 2009 =
|
177 |
+
* Added a workaround for a bug in WordPress 2.7.x wp-includes/compat.php that
|
178 |
+
prevented the plugin to work correctly on webservers running with PHP below
|
179 |
+
version 5.1.0 together with WP 2.7.x. This bug is patched in WordPress 2.8.
|
180 |
|
181 |
= Version 1.4.6 - 25 Apr 2009 =
|
182 |
+
* Updated all code to follow the WordPress Coding Standards for consistency, if
|
183 |
+
someone wants to modify my code.
|
184 |
+
* Removed the nodechangehandler from the TinyMCE js, as it didn't fill any
|
185 |
+
purpose.
|
186 |
+
* Updated the save code to remove the PHP Notice messages, if using error
|
187 |
+
logging on the server.
|
188 |
* Added additional proofing for the variables string.
|
189 |
|
190 |
= Version 1.4.5 - 24 Apr 2009 =
|
191 |
+
* Fixed a problem in the admin options that didn't allow a form with a textarea
|
192 |
+
to be used as a snippet.
|
193 |
+
* Widened the columns for SC and QT slightly in the options panel so they
|
194 |
+
should look a bit better on the mac.
|
195 |
|
196 |
= Version 1.4.4 - 19 Apr 2009 =
|
197 |
+
* Minor fix with quicktags and certain snippets that was left out in the last
|
198 |
+
update.
|
199 |
|
200 |
= Version 1.4.3 - 16 Apr 2009 =
|
201 |
+
* Fixed an escaping problem with the recently implemented shortcode function,
|
202 |
+
that could cause problems on certain strings.
|
203 |
+
* Fixed an escaping problem with the quicktag javascript, that could cause
|
204 |
+
problems on certain strings.
|
205 |
|
206 |
= Version 1.4.2 - 11 Apr 2009 =
|
207 |
+
* Fixed some additional syntax for servers where the short_open_tag
|
208 |
+
configuration setting is disabled.
|
209 |
|
210 |
= Version 1.4.1 - 10 Apr 2009 =
|
211 |
+
* Removed all short syntax commands and replaced them with the full versions so
|
212 |
+
the plugin also works on servers with the short_open_tag configuration
|
213 |
+
setting disabled.
|
214 |
|
215 |
= Version 1.4 - 10 Apr 2009 =
|
216 |
+
* Added a checkbox for Shortcodes (SC) in the admin panel. When checking this
|
217 |
+
one a dynamic shortcode will be generated and inserted instead of the
|
218 |
+
snippet, which allows snippets to be updated later on for all posts it's been
|
219 |
+
inserted into when using this option.
|
220 |
+
* Added a checkbox for Quicktags (QT) in the admin panel, so Quicktags are
|
221 |
+
optional. Speeds up loading of the post editor if you don't need the quicktag
|
222 |
+
support, and only use the visual editor. Defaults to off.
|
223 |
|
224 |
= Version 1.3.5 - 9 Apr 2009 =
|
225 |
+
* Fixed so the TinyMCE window adds a scrollbar if there is more variables for a
|
226 |
+
snippet than fits in the window.
|
227 |
+
* Fixed a bug that snippets didn't get inserted when using the visual editor in
|
228 |
+
fullscreen mode.
|
229 |
|
230 |
= Version 1.3 - 2 Apr 2009 =
|
231 |
+
* Fixed a problem with the regular expressions that prohibited variables
|
232 |
+
consisting of just a single number to work.
|
233 |
* Updated the Help info in the admin page to take less space.
|
234 |
* Included a check so the plugin only runs in WP 2.7 or newer.
|
235 |
|
236 |
= Version 1.2 - 1 Apr 2009 =
|
237 |
+
* Added support for Quicktags so the snippets can be made available in the HTML
|
238 |
+
editor as well.
|
239 |
|
240 |
= Version 1.1 - 24 Mar 2009 =
|
241 |
* Included Swedish translation.
|
tinymce/editor_plugin.js
CHANGED
@@ -17,7 +17,10 @@
|
|
17 |
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
|
18 |
|
19 |
ed.addCommand('mcepost_snippets', function() {
|
20 |
-
ed
|
|
|
|
|
|
|
21 |
file : url + '/window.php',
|
22 |
width : 360 + ed.getLang('post_snippets.delta_width', 0),
|
23 |
height : 210 + ed.getLang('post_snippets.delta_height', 0),
|
@@ -25,7 +28,7 @@
|
|
25 |
}, {
|
26 |
plugin_url : url // Plugin absolute URL
|
27 |
});
|
28 |
-
});
|
29 |
|
30 |
// Register example button
|
31 |
ed.addButton('post_snippets', {
|
@@ -45,9 +48,9 @@
|
|
45 |
return {
|
46 |
longname : 'post_snippets',
|
47 |
author : 'Johan Steen',
|
48 |
-
authorurl : 'http://
|
49 |
-
infourl : 'http://
|
50 |
-
version : "1.
|
51 |
};
|
52 |
}
|
53 |
});
|
17 |
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
|
18 |
|
19 |
ed.addCommand('mcepost_snippets', function() {
|
20 |
+
muppCanv = ed;
|
21 |
+
caller = 'visual';
|
22 |
+
jQuery( "#post-snippets-dialog" ).dialog( "open" );
|
23 |
+
/* ed.windowManager.open({
|
24 |
file : url + '/window.php',
|
25 |
width : 360 + ed.getLang('post_snippets.delta_width', 0),
|
26 |
height : 210 + ed.getLang('post_snippets.delta_height', 0),
|
28 |
}, {
|
29 |
plugin_url : url // Plugin absolute URL
|
30 |
});
|
31 |
+
*/ });
|
32 |
|
33 |
// Register example button
|
34 |
ed.addButton('post_snippets', {
|
48 |
return {
|
49 |
longname : 'post_snippets',
|
50 |
author : 'Johan Steen',
|
51 |
+
authorurl : 'http://johansteen.se/',
|
52 |
+
infourl : 'http://wpstorm.net/wordpress-plugins/post-snippets/',
|
53 |
+
version : "1.1"
|
54 |
};
|
55 |
}
|
56 |
});
|
tinymce/tinymce.php
DELETED
@@ -1,50 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class that adds a TinyMCE button to the Post editor
|
4 |
-
*
|
5 |
-
*/
|
6 |
-
class add_post_snippets_button {
|
7 |
-
var $pluginname = "post_snippets";
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Constructor
|
11 |
-
*/
|
12 |
-
function add_post_snippets_button() {
|
13 |
-
// Modify the version when tinyMCE plugins are changed.
|
14 |
-
add_filter('tiny_mce_version', array (&$this, 'change_tinymce_version') );
|
15 |
-
|
16 |
-
// init process for button control
|
17 |
-
add_action('init', array (&$this, 'add_buttons') );
|
18 |
-
}
|
19 |
-
|
20 |
-
function add_buttons() {
|
21 |
-
// Don't bother doing this stuff if the current user lacks permissions
|
22 |
-
if ( !current_user_can('edit_posts') && !current_user_can('edit_pages') ) return;
|
23 |
-
|
24 |
-
// Add only in Rich Editor mode
|
25 |
-
if ( get_user_option('rich_editing') == 'true') {
|
26 |
-
// add the button for wp2.5 in a new way
|
27 |
-
add_filter("mce_external_plugins", array (&$this, "add_tinymce_plugin" ), 5);
|
28 |
-
add_filter('mce_buttons', array (&$this, 'register_button' ), 5);
|
29 |
-
}
|
30 |
-
}
|
31 |
-
|
32 |
-
// used to insert button in wordpress 2.5x editor
|
33 |
-
function register_button($buttons) {
|
34 |
-
array_push($buttons, "separator", $this->pluginname );
|
35 |
-
return $buttons;
|
36 |
-
}
|
37 |
-
|
38 |
-
// Load the TinyMCE plugin : editor_plugin.js (wp2.5)
|
39 |
-
function add_tinymce_plugin($plugin_array) {
|
40 |
-
$plugin_array[$this->pluginname] = post_snippets_URLPATH.'tinymce/editor_plugin.js';
|
41 |
-
return $plugin_array;
|
42 |
-
}
|
43 |
-
|
44 |
-
function change_tinymce_version($version) {
|
45 |
-
return ++$version;
|
46 |
-
}
|
47 |
-
}
|
48 |
-
|
49 |
-
$tinymce_button = new add_post_snippets_button();
|
50 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tinymce/window.php
DELETED
@@ -1,157 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/* Finding the path to the wp-admin folder */
|
3 |
-
$iswin = preg_match('/:\\\/', dirname(__file__));
|
4 |
-
$slash = ($iswin) ? "\\" : "/";
|
5 |
-
|
6 |
-
$wp_path = preg_split('/(?=((\\\|\/)wp-content)).*/', dirname(__file__));
|
7 |
-
$wp_path = (isset($wp_path[0]) && $wp_path[0] != "") ? $wp_path[0] : $_SERVER["DOCUMENT_ROOT"];
|
8 |
-
|
9 |
-
/** Load WordPress Administration Bootstrap */
|
10 |
-
require_once($wp_path . $slash . 'wp-load.php');
|
11 |
-
require_once($wp_path . $slash . 'wp-admin' . $slash . 'admin.php');
|
12 |
-
|
13 |
-
|
14 |
-
// check for rights
|
15 |
-
if ( !is_user_logged_in() || !current_user_can('edit_posts') )
|
16 |
-
wp_die(__( "You are not allowed to be here", 'post-snippets' ));
|
17 |
-
|
18 |
-
?>
|
19 |
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
20 |
-
<html xmlns="http://www.w3.org/1999/xhtml">
|
21 |
-
<head>
|
22 |
-
<title>Post Snippets</title>
|
23 |
-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
24 |
-
<script language="javascript" type="text/javascript" src="<?php echo get_option('siteurl') ?>/wp-includes/js/tinymce/tiny_mce_popup.js"></script>
|
25 |
-
<script language="javascript" type="text/javascript" src="<?php echo get_option('siteurl') ?>/wp-includes/js/tinymce/utils/mctabs.js"></script>
|
26 |
-
<script language="javascript" type="text/javascript" src="<?php echo get_option('siteurl') ?>/wp-includes/js/tinymce/utils/form_utils.js"></script>
|
27 |
-
<script language="javascript" type="text/javascript">
|
28 |
-
function init() {
|
29 |
-
tinyMCEPopup.resizeToInnerSize();
|
30 |
-
}
|
31 |
-
|
32 |
-
function createSnippet(theSnippet) {
|
33 |
-
}
|
34 |
-
|
35 |
-
function createShortcode(shortcodeTag, shortcodeAtts) {
|
36 |
-
theSnippet = "[" + shortcodeTag;
|
37 |
-
for (x in shortcodeAtts)
|
38 |
-
{
|
39 |
-
theSnippet += ' ' + shortcodeAtts[x] + '="{' + shortcodeAtts[x] + '}"';
|
40 |
-
}
|
41 |
-
theSnippet += "]";
|
42 |
-
return theSnippet;
|
43 |
-
}
|
44 |
-
|
45 |
-
function insertSnippet() {
|
46 |
-
|
47 |
-
var insertString;
|
48 |
-
|
49 |
-
<?php
|
50 |
-
$snippets = get_option($post_snippets->plugin_options);
|
51 |
-
for ($i = 0; $i < count($snippets); $i++) { ?>
|
52 |
-
var panel<?php echo $i; ?> = document.getElementById('ps_panel<?php echo $i; ?>');
|
53 |
-
<?php } ?>
|
54 |
-
|
55 |
-
var rss = document.getElementById('ps_panel0');
|
56 |
-
|
57 |
-
<?php
|
58 |
-
$snippets = get_option($post_snippets->plugin_options);
|
59 |
-
for ($i = 0; $i < count($snippets); $i++) {
|
60 |
-
// Make it js safe
|
61 |
-
$theString = str_replace('"','\"',str_replace(Chr(13), '', str_replace(Chr(10), '', str_replace('<', '\x3C', str_replace('>', '\x3E', $snippets[$i]['snippet'])))));
|
62 |
-
// \x3C and \x3E
|
63 |
-
?>
|
64 |
-
|
65 |
-
if (panel<?php echo $i; ?>.className.indexOf('current') != -1) {
|
66 |
-
<?php
|
67 |
-
if ($snippets[$i]['shortcode']) {
|
68 |
-
$var_arr = explode(",",$snippets[$i]['vars']);
|
69 |
-
$theVariables = "";
|
70 |
-
if (!empty($var_arr[0])) {
|
71 |
-
for ($j = 0; $j < count($var_arr); $j++) {
|
72 |
-
$theVariables = $theVariables . "'" . $var_arr[$j] . "'";
|
73 |
-
if ( $j < (count($var_arr) -1) )
|
74 |
-
$theVariables = $theVariables . ", ";
|
75 |
-
|
76 |
-
}
|
77 |
-
}
|
78 |
-
echo "var variables" . $i ." = new Array(".$theVariables.");"; ?>
|
79 |
-
insertString = createShortcode("<?php echo $snippets[$i]['title']; ?>", variables<?php echo $i; ?>);
|
80 |
-
<?php }else{ ?>
|
81 |
-
insertString = "<?php echo $theString; ?>";
|
82 |
-
<?php } ?>
|
83 |
-
<?php
|
84 |
-
$var_arr = explode(",",$snippets[$i]['vars']);
|
85 |
-
if (!empty($var_arr[0])) {
|
86 |
-
for ($j = 0; $j < count($var_arr); $j++) { ?>
|
87 |
-
var var_<?php echo $i; ?>_<?php echo $j; ?> = document.getElementById('var_<?php echo $i; ?>_<?php echo $j; ?>').value;
|
88 |
-
insertString = insertString.replace(/\{<?php echo $var_arr[$j]; ?>\}/g, var_<?php echo $i; ?>_<?php echo $j; ?>);
|
89 |
-
<?php } } ?>
|
90 |
-
}
|
91 |
-
<?php } ?>
|
92 |
-
|
93 |
-
|
94 |
-
if(window.tinyMCE) {
|
95 |
-
//window.tinyMCE.execInstanceCommand('content', 'mceInsertContent', false, insertString);
|
96 |
-
tinyMCEPopup.execCommand("mceBeginUndoLevel");
|
97 |
-
tinyMCEPopup.execCommand('mceInsertContent', false, insertString);
|
98 |
-
tinyMCEPopup.execCommand("mceEndUndoLevel");
|
99 |
-
//Peforms a clean up of the current editor HTML.
|
100 |
-
//tinyMCEPopup.editor.execCommand('mceCleanup');
|
101 |
-
//Repaints the editor. Sometimes the browser has graphic glitches.
|
102 |
-
tinyMCEPopup.editor.execCommand('mceRepaint');
|
103 |
-
tinyMCEPopup.close();
|
104 |
-
}
|
105 |
-
return;
|
106 |
-
}
|
107 |
-
</script>
|
108 |
-
<base target="_self" />
|
109 |
-
</head>
|
110 |
-
<body id="link" onload="tinyMCEPopup.executeOnLoad('init();');document.body.style.display='';" style="display: none">
|
111 |
-
<!-- <form onsubmit="insertLink();return false;" action="#"> -->
|
112 |
-
<form name="post_snippets" action="#">
|
113 |
-
|
114 |
-
<div class="tabs">
|
115 |
-
<ul>
|
116 |
-
<?php
|
117 |
-
$snippets = get_option($post_snippets->plugin_options);
|
118 |
-
for ($i = 0; $i < count($snippets); $i++) { ?>
|
119 |
-
<li id="ps_tab<?php echo $i; ?>"<?php if ($i == 0) {?> class="current"><?php } ?><span><a href="javascript:mcTabs.displayTab('ps_tab<?php echo $i; ?>','ps_panel<?php echo $i; ?>');" onmousedown="return false;"><?php echo $snippets[$i]['title']; ?></a></span></li>
|
120 |
-
<?php } ?>
|
121 |
-
</ul>
|
122 |
-
</div>
|
123 |
-
|
124 |
-
<div class="panel_wrapper" style="overflow:auto;">
|
125 |
-
<?php
|
126 |
-
$snippets = get_option($post_snippets->plugin_options);
|
127 |
-
for ($i = 0; $i < count($snippets); $i++) { ?>
|
128 |
-
<div id="ps_panel<?php echo $i; ?>" class="panel<?php if ($i == 0) {?> current<?php } ?>">
|
129 |
-
<br />
|
130 |
-
<table border="0" cellpadding="4" cellspacing="0">
|
131 |
-
<?php
|
132 |
-
$var_arr = explode(",",$snippets[$i]['vars']);
|
133 |
-
if (!empty($var_arr[0])) {
|
134 |
-
for ($j = 0; $j < count($var_arr); $j++) { ?>
|
135 |
-
<tr>
|
136 |
-
<td nowrap="nowrap"><label for="var_<?php echo $i; ?>_<?php echo $j; ?>"><?php echo($var_arr[$j]);?>:</label></td>
|
137 |
-
<td><input type="text" id="var_<?php echo $i; ?>_<?php echo $j; ?>" name="var_<?php echo $i; ?>_<?php echo $j; ?>" style="width: 190px" />
|
138 |
-
</td>
|
139 |
-
</tr>
|
140 |
-
<?php } } ?>
|
141 |
-
</table>
|
142 |
-
</div>
|
143 |
-
<?php } ?>
|
144 |
-
</div>
|
145 |
-
|
146 |
-
<div class="mceActionPanel">
|
147 |
-
<div style="float: left">
|
148 |
-
<input type="button" id="cancel" name="cancel" value="<?php _e( 'Cancel', 'post-snippets' ); ?>" onclick="tinyMCEPopup.close();" />
|
149 |
-
</div>
|
150 |
-
|
151 |
-
<div style="float: right">
|
152 |
-
<input type="submit" id="insert" name="insert" value="<?php _e( 'Insert', 'post-snippets' ); ?>" onclick="insertSnippet();" />
|
153 |
-
</div>
|
154 |
-
</div>
|
155 |
-
</form>
|
156 |
-
</body>
|
157 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|