Version Description
Download this release
Release Info
Developer | artstorm |
Plugin | Post Snippets |
Version | 1.4.6 |
Comparing to | |
See all releases |
Code changes from version 1.4.5 to 1.4.6
- post-snippets.php +9 -9
- readme.txt +8 -2
- tinymce/editor_plugin.js +10 -15
- tinymce/langs/en.js +1 -1
- tinymce/langs/en_US.js +1 -1
- tinymce/langs/en_en.js +1 -1
- tinymce/tinymce.php +7 -7
- tinymce/window.php +5 -5
post-snippets.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Post Snippets
|
4 |
Plugin URI: http://coding.cglounge.com/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.4.
|
7 |
Author: Johan Steen
|
8 |
Author URI: http://coding.cglounge.com/
|
9 |
Text Domain: post-snippets
|
@@ -25,18 +25,18 @@ along with this program; if not, write to the Free Software
|
|
25 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
26 |
*/
|
27 |
|
28 |
-
class
|
29 |
var $plugin_options = "post_snippets_options";
|
30 |
|
31 |
/**
|
32 |
* Constructor
|
33 |
*
|
34 |
*/
|
35 |
-
function
|
36 |
{
|
37 |
// define URL
|
38 |
-
define('
|
39 |
-
define('
|
40 |
|
41 |
// Define the domain for translations
|
42 |
load_plugin_textdomain( 'post-snippets', false, dirname(plugin_basename(__FILE__)) . '/languages/');
|
@@ -240,9 +240,9 @@ JAVASCRIPT;
|
|
240 |
if (!empty($snippets)) {
|
241 |
for ($i=0; $i < count($snippets); $i++) {
|
242 |
$snippets[$i]['title'] = trim($_POST[$i.'_title']);
|
243 |
-
$snippets[$i]['vars'] = trim($_POST[$i.'_vars']);
|
244 |
-
$snippets[$i]['shortcode'] = $_POST[$i.'_shortcode']
|
245 |
-
$snippets[$i]['quicktag'] = $_POST[$i.'_quicktag']
|
246 |
$snippets[$i]['snippet'] = htmlspecialchars_decode( trim(stripslashes($_POST[$i.'_snippet'])), ENT_NOQUOTES);
|
247 |
}
|
248 |
update_option($this->plugin_options, $snippets);
|
@@ -362,5 +362,5 @@ JAVASCRIPT;
|
|
362 |
}
|
363 |
}
|
364 |
|
365 |
-
add_action( 'plugins_loaded', create_function( '', 'global $
|
366 |
?>
|
3 |
Plugin Name: Post Snippets
|
4 |
Plugin URI: http://coding.cglounge.com/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.4.6
|
7 |
Author: Johan Steen
|
8 |
Author URI: http://coding.cglounge.com/
|
9 |
Text Domain: post-snippets
|
25 |
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 |
{
|
37 |
// define URL
|
38 |
+
define('post_snippets_ABSPATH', WP_PLUGIN_DIR.'/'.plugin_basename( dirname(__FILE__) ).'/' );
|
39 |
+
define('post_snippets_URLPATH', WP_PLUGIN_URL.'/'.plugin_basename( dirname(__FILE__) ).'/' );
|
40 |
|
41 |
// Define the domain for translations
|
42 |
load_plugin_textdomain( 'post-snippets', false, dirname(plugin_basename(__FILE__)) . '/languages/');
|
240 |
if (!empty($snippets)) {
|
241 |
for ($i=0; $i < count($snippets); $i++) {
|
242 |
$snippets[$i]['title'] = trim($_POST[$i.'_title']);
|
243 |
+
$snippets[$i]['vars'] = str_replace(" ", "", trim($_POST[$i.'_vars']) );
|
244 |
+
$snippets[$i]['shortcode'] = isset($_POST[$i.'_shortcode']) ? true : false;
|
245 |
+
$snippets[$i]['quicktag'] = isset($_POST[$i.'_quicktag']) ? true : false;
|
246 |
$snippets[$i]['snippet'] = htmlspecialchars_decode( trim(stripslashes($_POST[$i.'_snippet'])), ENT_NOQUOTES);
|
247 |
}
|
248 |
update_option($this->plugin_options, $snippets);
|
362 |
}
|
363 |
}
|
364 |
|
365 |
+
add_action( 'plugins_loaded', create_function( '', 'global $post_snippets; $post_snippets = new post_snippets();' ) );
|
366 |
?>
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://coding.cglounge.com/wordpress-plugins/post-snippets/#pintwar
|
|
4 |
Tags: post, admin, snippet, html, custom, page, dynamic, editor, quicktag
|
5 |
Requires at least: 2.7
|
6 |
Tested up to: 2.7.1
|
7 |
-
Stable tag: 1.4.
|
8 |
|
9 |
Store snippets of HTML code or reoccurring text that you often use in your posts. Custom variables can be used.
|
10 |
|
@@ -47,9 +47,15 @@ Meditation.
|
|
47 |
|
48 |
== Changelog ==
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
= Version 1.4.5 - 24 Apr 2009 =
|
51 |
* Fixed a problem in the admin options that didn't allow a form with a textarea to be used as a snippet.
|
52 |
-
* Widened the columns for SC and QT
|
53 |
|
54 |
= Version 1.4.4 - 19 Apr 2009 =
|
55 |
* Minor fix with quicktags and certain snippets that was left out in the last update.
|
4 |
Tags: post, admin, snippet, html, custom, page, dynamic, editor, quicktag
|
5 |
Requires at least: 2.7
|
6 |
Tested up to: 2.7.1
|
7 |
+
Stable tag: 1.4.6
|
8 |
|
9 |
Store snippets of HTML code or reoccurring text that you often use in your posts. Custom variables can be used.
|
10 |
|
47 |
|
48 |
== Changelog ==
|
49 |
|
50 |
+
= Version 1.4.6 - 25 Apr 2009 =
|
51 |
+
* Updated all code to follow the WordPress Coding Standards for consistency, if someone wants to modify my code.
|
52 |
+
* Removed the nodechangehandler from the TinyMCE js, as it didn't fill any purpose.
|
53 |
+
* Updated the save code to remove the PHP Notice messages, if using error logging on the server.
|
54 |
+
* Added additional proofing for the variables string.
|
55 |
+
|
56 |
= Version 1.4.5 - 24 Apr 2009 =
|
57 |
* Fixed a problem in the admin options that didn't allow a form with a textarea to be used as a snippet.
|
58 |
+
* Widened the columns for SC and QT slightly in the options panel so they should look a bit better on the mac.
|
59 |
|
60 |
= Version 1.4.4 - 19 Apr 2009 =
|
61 |
* Minor fix with quicktags and certain snippets that was left out in the last update.
|
tinymce/editor_plugin.js
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
|
3 |
(function() {
|
4 |
// Load plugin specific language pack
|
5 |
-
tinymce.PluginManager.requireLangPack('
|
6 |
|
7 |
-
tinymce.create('tinymce.plugins.
|
8 |
/**
|
9 |
* Initializes the plugin, this will be executed after the plugin has been created.
|
10 |
* This call is done before the editor instance has finished it's initialization so use the onInit event
|
@@ -16,11 +16,11 @@
|
|
16 |
init : function(ed, url) {
|
17 |
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
|
18 |
|
19 |
-
ed.addCommand('
|
20 |
ed.windowManager.open({
|
21 |
file : url + '/window.php',
|
22 |
-
width : 360 + ed.getLang('
|
23 |
-
height : 210 + ed.getLang('
|
24 |
inline : 1
|
25 |
}, {
|
26 |
plugin_url : url // Plugin absolute URL
|
@@ -28,16 +28,11 @@
|
|
28 |
});
|
29 |
|
30 |
// Register example button
|
31 |
-
ed.addButton('
|
32 |
-
title : '
|
33 |
-
cmd : '
|
34 |
image : url + '/post-snippets.gif'
|
35 |
});
|
36 |
-
|
37 |
-
// Add a node change handler, selects the button in the UI when a image is selected
|
38 |
-
ed.onNodeChange.add(function(ed, cm, n) {
|
39 |
-
cm.setActive('postSnippets', n.nodeName == 'IMG');
|
40 |
-
});
|
41 |
},
|
42 |
|
43 |
/**
|
@@ -48,7 +43,7 @@
|
|
48 |
*/
|
49 |
getInfo : function() {
|
50 |
return {
|
51 |
-
longname : '
|
52 |
author : 'Johan Steen',
|
53 |
authorurl : 'http://coding.cglounge.com/',
|
54 |
infourl : 'http://coding.cglounge.com/',
|
@@ -58,7 +53,7 @@
|
|
58 |
});
|
59 |
|
60 |
// Register plugin
|
61 |
-
tinymce.PluginManager.add('
|
62 |
})();
|
63 |
|
64 |
|
2 |
|
3 |
(function() {
|
4 |
// Load plugin specific language pack
|
5 |
+
tinymce.PluginManager.requireLangPack('post_snippets');
|
6 |
|
7 |
+
tinymce.create('tinymce.plugins.post_snippets', {
|
8 |
/**
|
9 |
* Initializes the plugin, this will be executed after the plugin has been created.
|
10 |
* This call is done before the editor instance has finished it's initialization so use the onInit event
|
16 |
init : function(ed, url) {
|
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.windowManager.open({
|
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),
|
24 |
inline : 1
|
25 |
}, {
|
26 |
plugin_url : url // Plugin absolute URL
|
28 |
});
|
29 |
|
30 |
// Register example button
|
31 |
+
ed.addButton('post_snippets', {
|
32 |
+
title : 'post_snippets.desc',
|
33 |
+
cmd : 'mcepost_snippets',
|
34 |
image : url + '/post-snippets.gif'
|
35 |
});
|
|
|
|
|
|
|
|
|
|
|
36 |
},
|
37 |
|
38 |
/**
|
43 |
*/
|
44 |
getInfo : function() {
|
45 |
return {
|
46 |
+
longname : 'post_snippets',
|
47 |
author : 'Johan Steen',
|
48 |
authorurl : 'http://coding.cglounge.com/',
|
49 |
infourl : 'http://coding.cglounge.com/',
|
53 |
});
|
54 |
|
55 |
// Register plugin
|
56 |
+
tinymce.PluginManager.add('post_snippets', tinymce.plugins.post_snippets);
|
57 |
})();
|
58 |
|
59 |
|
tinymce/langs/en.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
tinyMCE.addI18n({en:{
|
2 |
-
|
3 |
desc : 'Insert a Post Snippet'
|
4 |
}}});
|
1 |
tinyMCE.addI18n({en:{
|
2 |
+
post_snippets:{
|
3 |
desc : 'Insert a Post Snippet'
|
4 |
}}});
|
tinymce/langs/en_US.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
tinyMCE.addI18n({en_US:{
|
2 |
-
|
3 |
desc : 'Insert a Post Snippet'
|
4 |
}}});
|
1 |
tinyMCE.addI18n({en_US:{
|
2 |
+
post_snippets:{
|
3 |
desc : 'Insert a Post Snippet'
|
4 |
}}});
|
tinymce/langs/en_en.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
tinyMCE.addI18n({en_US:{
|
2 |
-
|
3 |
desc : 'Insert a Post Snippet'
|
4 |
}}});
|
1 |
tinyMCE.addI18n({en_US:{
|
2 |
+
post_snippets:{
|
3 |
desc : 'Insert a Post Snippet'
|
4 |
}}});
|
tinymce/tinymce.php
CHANGED
@@ -3,21 +3,21 @@
|
|
3 |
* Class that adds a TinyMCE button to the Post editor
|
4 |
*
|
5 |
*/
|
6 |
-
class
|
7 |
-
var $pluginname = "
|
8 |
|
9 |
/**
|
10 |
* Constructor
|
11 |
*/
|
12 |
-
function
|
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, '
|
18 |
}
|
19 |
|
20 |
-
function
|
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 |
|
@@ -37,7 +37,7 @@ class add_postSnippets_button {
|
|
37 |
|
38 |
// Load the TinyMCE plugin : editor_plugin.js (wp2.5)
|
39 |
function add_tinymce_plugin($plugin_array) {
|
40 |
-
$plugin_array[$this->pluginname] =
|
41 |
return $plugin_array;
|
42 |
}
|
43 |
|
@@ -46,5 +46,5 @@ class add_postSnippets_button {
|
|
46 |
}
|
47 |
}
|
48 |
|
49 |
-
$tinymce_button = new
|
50 |
?>
|
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 |
|
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 |
|
46 |
}
|
47 |
}
|
48 |
|
49 |
+
$tinymce_button = new add_post_snippets_button();
|
50 |
?>
|
tinymce/window.php
CHANGED
@@ -40,7 +40,7 @@ if ( !is_user_logged_in() || !current_user_can('edit_posts') )
|
|
40 |
var insertString;
|
41 |
|
42 |
<?php
|
43 |
-
$snippets = get_option($
|
44 |
for ($i = 0; $i < count($snippets); $i++) { ?>
|
45 |
var panel<?php echo $i; ?> = document.getElementById('ps_panel<?php echo $i; ?>');
|
46 |
<?php } ?>
|
@@ -48,7 +48,7 @@ if ( !is_user_logged_in() || !current_user_can('edit_posts') )
|
|
48 |
var rss = document.getElementById('ps_panel0');
|
49 |
|
50 |
<?php
|
51 |
-
$snippets = get_option($
|
52 |
for ($i = 0; $i < count($snippets); $i++) {
|
53 |
// Make it js safe
|
54 |
$theString = str_replace('"','\"',str_replace(Chr(13), '', str_replace(Chr(10), '', $snippets[$i]['snippet'])))
|
@@ -101,12 +101,12 @@ if ( !is_user_logged_in() || !current_user_can('edit_posts') )
|
|
101 |
</head>
|
102 |
<body id="link" onload="tinyMCEPopup.executeOnLoad('init();');document.body.style.display='';" style="display: none">
|
103 |
<!-- <form onsubmit="insertLink();return false;" action="#"> -->
|
104 |
-
<form name="
|
105 |
|
106 |
<div class="tabs">
|
107 |
<ul>
|
108 |
<?php
|
109 |
-
$snippets = get_option($
|
110 |
for ($i = 0; $i < count($snippets); $i++) { ?>
|
111 |
<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>
|
112 |
<?php } ?>
|
@@ -115,7 +115,7 @@ if ( !is_user_logged_in() || !current_user_can('edit_posts') )
|
|
115 |
|
116 |
<div class="panel_wrapper" style="overflow:auto;">
|
117 |
<?php
|
118 |
-
$snippets = get_option($
|
119 |
for ($i = 0; $i < count($snippets); $i++) { ?>
|
120 |
<div id="ps_panel<?php echo $i; ?>" class="panel<?php if ($i == 0) {?> current<?php } ?>">
|
121 |
<br />
|
40 |
var insertString;
|
41 |
|
42 |
<?php
|
43 |
+
$snippets = get_option($post_snippets->plugin_options);
|
44 |
for ($i = 0; $i < count($snippets); $i++) { ?>
|
45 |
var panel<?php echo $i; ?> = document.getElementById('ps_panel<?php echo $i; ?>');
|
46 |
<?php } ?>
|
48 |
var rss = document.getElementById('ps_panel0');
|
49 |
|
50 |
<?php
|
51 |
+
$snippets = get_option($post_snippets->plugin_options);
|
52 |
for ($i = 0; $i < count($snippets); $i++) {
|
53 |
// Make it js safe
|
54 |
$theString = str_replace('"','\"',str_replace(Chr(13), '', str_replace(Chr(10), '', $snippets[$i]['snippet'])))
|
101 |
</head>
|
102 |
<body id="link" onload="tinyMCEPopup.executeOnLoad('init();');document.body.style.display='';" style="display: none">
|
103 |
<!-- <form onsubmit="insertLink();return false;" action="#"> -->
|
104 |
+
<form name="post_snippets" action="#">
|
105 |
|
106 |
<div class="tabs">
|
107 |
<ul>
|
108 |
<?php
|
109 |
+
$snippets = get_option($post_snippets->plugin_options);
|
110 |
for ($i = 0; $i < count($snippets); $i++) { ?>
|
111 |
<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>
|
112 |
<?php } ?>
|
115 |
|
116 |
<div class="panel_wrapper" style="overflow:auto;">
|
117 |
<?php
|
118 |
+
$snippets = get_option($post_snippets->plugin_options);
|
119 |
for ($i = 0; $i < count($snippets); $i++) { ?>
|
120 |
<div id="ps_panel<?php echo $i; ?>" class="panel<?php if ($i == 0) {?> current<?php } ?>">
|
121 |
<br />
|