Version Description
Download this release
Release Info
| Developer | Bueltge |
| Plugin | |
| Version | 0.6 |
| Comparing to | |
| See all releases | |
Version 0.6
- addquicktag.php +261 -0
addquicktag.php
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/*
|
| 3 |
+
Plugin Name: AddQuicktag
|
| 4 |
+
Version: 0.6
|
| 5 |
+
Plugin URI: http://bueltge.de/wp-addquicktags-de-plugin/120
|
| 6 |
+
Description: This plugin make it easy, Quicktags add to the editor. It is possible to ex- and import your Quicktags. Use it <a href="options-general.php?page=addquicktag.php">Options --> Add Quicktags</a> by <a href="http://roel.meurders.nl/" >Roel Meurders</a> and <a href="http://bueltge.de" >Frank Bueltge</a>
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
// SCRIPT INFO ///////////////////////////////////////////////////////////////////////////
|
| 10 |
+
/*
|
| 11 |
+
WP-AddQuicktag for Wordpress is in originally by
|
| 12 |
+
(C) 2005 Roel Meurders - GNU General Public License
|
| 13 |
+
|
| 14 |
+
AddQuicktag is an newer version with more functions and worked in WP 2.1
|
| 15 |
+
(C) 2007 Frank Bueltge
|
| 16 |
+
|
| 17 |
+
This Wordpress plugin is released under a GNU General Public License. A complete version of this license
|
| 18 |
+
can be found here: http://www.gnu.org/licenses/gpl.txt
|
| 19 |
+
|
| 20 |
+
This Wordpress plugin has been tested with Wordpress 2.0, 2.1 and Wordpress 2.3;
|
| 21 |
+
|
| 22 |
+
This Wordpress plugin is released "as is". Without any warranty. The authors cannot
|
| 23 |
+
be held responsible for any damage that this script might cause.
|
| 24 |
+
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
// NO EDITING HERE!!!!! ////////////////////////////////////////////////////////////////
|
| 28 |
+
if(function_exists('load_plugin_textdomain'))
|
| 29 |
+
load_plugin_textdomain('addquicktag','wp-content/plugins');
|
| 30 |
+
|
| 31 |
+
function wpaq_install() {
|
| 32 |
+
global $wpdb;
|
| 33 |
+
|
| 34 |
+
if (!get_option('rmnlQuicktagSettings') != '') {
|
| 35 |
+
$name = 'rmnlQuicktagSettings';
|
| 36 |
+
$value = 'a:1:{s:7:"buttons";a:1:{i:0;a:3:{s:4:"text";s:7:"Example";s:5:"start";s:9:"<example>";s:3:"end";s:10:"</example>";}}}';
|
| 37 |
+
$description = '';
|
| 38 |
+
$autoload = 'yes';
|
| 39 |
+
$wpdb->query("INSERT INTO $wpdb->options (option_name, option_value, option_description, autoload) VALUES ('$name', '$value', '$description', '$autoload')");
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
return;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
if (function_exists('add_action')) {
|
| 46 |
+
add_action('admin_menu', 'wpaq_admin_menu');
|
| 47 |
+
|
| 48 |
+
if (strpos($_SERVER['REQUEST_URI'], 'addquicktag.php')) {
|
| 49 |
+
add_action('init', 'wpaq_install');
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
function wpaq_admin_menu(){
|
| 54 |
+
add_options_page('WP-Quicktag - Add Quicktags', 'Add Quicktags', 9, basename(__FILE__), 'wpaq_options_page');
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
function wpaq_options_page(){
|
| 58 |
+
global $wpdb;
|
| 59 |
+
$wpaq_document_root = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['REQUEST_URI'];
|
| 60 |
+
$wpaq_document_root = str_replace("/wp-admin/options-general.php?page=addquicktag.php", "/wp-content", $wpaq_document_root);
|
| 61 |
+
|
| 62 |
+
$wpaq_link = $_SERVER['REQUEST_URI'];
|
| 63 |
+
$wpaq_link = str_replace("\\", "/", $wpaq_link);
|
| 64 |
+
|
| 65 |
+
if ($_POST['wpaq']){
|
| 66 |
+
$buttons = array();
|
| 67 |
+
for ($i = 0; $i < count($_POST['wpaq']['buttons']); $i++){
|
| 68 |
+
$b = $_POST['wpaq']['buttons'][$i];
|
| 69 |
+
if ($b['text'] != '' && $b['start'] != ''){
|
| 70 |
+
$b['text'] = htmlentities($b['text']);
|
| 71 |
+
$b['start'] = stripslashes($b['start']);
|
| 72 |
+
$b['end'] = stripslashes($b['end']);
|
| 73 |
+
$buttons[] = $b;
|
| 74 |
+
}
|
| 75 |
+
}
|
| 76 |
+
$_POST['wpaq']['buttons'] = $buttons;
|
| 77 |
+
update_option('rmnlQuicktagSettings', $_POST['wpaq']);
|
| 78 |
+
$message = '<div class="updated"><p><strong>' . __('Options saved.', 'addquicktag') . '</strong></p></div>';
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
// Export in sql-file
|
| 82 |
+
if (($_POST['action'] == 'export')) {
|
| 83 |
+
if (file_exists(ABSPATH . '/wp-content/wpaq_export.wpaq')) {
|
| 84 |
+
$message_export = '<div class="error"><p><strong>' . __('wpaq_export.wpaq is exist!', 'addquicktag') . '</strong></p></div>';
|
| 85 |
+
} else {
|
| 86 |
+
$wpdb->query("SELECT option_value INTO OUTFILE '" . $wpaq_document_root . "/wpaq_export.wpaq' FROM $wpdb->options WHERE option_name = 'rmnlQuicktagSettings'");
|
| 87 |
+
$message_export = '<div class="updated"><p><strong>' . __('AddQuicktag options saved!', 'addquicktag') . '</strong><br />';
|
| 88 |
+
$message_export.= __('Saved in: ', 'addquicktag') . $wpaq_document_root . '/wpaq_export.wpaq';
|
| 89 |
+
$message_export.= '</p></div>';
|
| 90 |
+
}
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
// Import the sql-file
|
| 94 |
+
if (($_POST['action'] == 'import')) {
|
| 95 |
+
$message_export = '<div class="updated"><p><strong>';
|
| 96 |
+
|
| 97 |
+
// check file extension sql
|
| 98 |
+
$str_file_name = $_FILES['datei']['name'];
|
| 99 |
+
$str_file_ext = explode(".", $str_file_name);
|
| 100 |
+
|
| 101 |
+
if ($str_file_ext[1] != 'wpaq') {
|
| 102 |
+
$message_export.= __('Invalid file extension!', 'addquicktag');
|
| 103 |
+
} else {
|
| 104 |
+
// path for file
|
| 105 |
+
$wpaq_document_root = str_replace("/wp-admin/options-general.php?page=addquicktag.php", "/wp-content/", $wpaq_document_root);
|
| 106 |
+
$str_ziel = $wpaq_document_root . $_FILES['datei']['name'];
|
| 107 |
+
// transfer
|
| 108 |
+
move_uploaded_file($_FILES['datei']['tmp_name'], $str_ziel);
|
| 109 |
+
// access authorisation
|
| 110 |
+
chmod($str_ziel, 0644);
|
| 111 |
+
|
| 112 |
+
// SQL import
|
| 113 |
+
ini_set('default_socket_timeout', 120);
|
| 114 |
+
$import_file = file_get_contents($str_ziel);
|
| 115 |
+
$wpdb->query("UPDATE $wpdb->options SET `option_value` = '$import_file' WHERE `option_name` = 'rmnlQuicktagSettings'");
|
| 116 |
+
unlink($str_ziel);
|
| 117 |
+
$message_export.= __('AddQuicktag options imported!', 'addquicktag');
|
| 118 |
+
}
|
| 119 |
+
$message_export.= '</strong></p></div>';
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
$string1 = __('Adding or deleting Quicktag-buttons', 'addquicktag');
|
| 123 |
+
$string2 = __('Fill in the fields below to add or edit the quicktags. Fields with * are compulsary. To delete a tag simply empty all fields.', 'addquicktag');
|
| 124 |
+
$field1 = __('Buttonstring*', 'addquicktag');
|
| 125 |
+
$field2 = __('Start tag(s)*', 'addquicktag');
|
| 126 |
+
$field3 = __('End tag(s)', 'addquicktag');
|
| 127 |
+
$button1 = __('Update Options »', 'addquicktag');
|
| 128 |
+
|
| 129 |
+
// Export strings
|
| 130 |
+
$button2 = __('Export »', 'addquicktag');
|
| 131 |
+
$export1 = __('Export Quicktag-buttons options', 'addquicktag');
|
| 132 |
+
$export2 = __('You can save a wpaq-File with your options in <em>/wp-content/wpaq_export.wpaq</em>', 'addquicktag');
|
| 133 |
+
|
| 134 |
+
// Import strings
|
| 135 |
+
$button3 = __('Upload file and import »', 'addquicktag');
|
| 136 |
+
$import1 = __('Import Quicktag-buttons options', 'addquicktag');
|
| 137 |
+
$import2 = __('Choose a AddQuicktag (<em>wpaq</em>) file to upload, then click Upload file and import.', 'addquicktag');
|
| 138 |
+
$import3 = __('Choose a file from your computer: ', 'addquicktag');
|
| 139 |
+
|
| 140 |
+
// Info
|
| 141 |
+
$info1 = __('Further information: Visit the <a href=\'http://bueltge.de/wp-addquicktags-de-plugin/120\'>plugin homepage</a> for further information or to grab the latest version of this plugin.', 'addquicktag');
|
| 142 |
+
$info2 = __('You want to thank me? Visit my <a href=\'http://bueltge.de/wunschliste/\'>wishlist</a>.', 'addquicktag');
|
| 143 |
+
|
| 144 |
+
$o = get_option('rmnlQuicktagSettings');
|
| 145 |
+
|
| 146 |
+
echo <<<EOT
|
| 147 |
+
<div class="wrap">
|
| 148 |
+
<h2>WP-Quicktag Management</h2>
|
| 149 |
+
{$message}
|
| 150 |
+
{$message_export}
|
| 151 |
+
<form name="form1" method="post" action="options-general.php?page=addquicktag.php">
|
| 152 |
+
<fieldset class="options">
|
| 153 |
+
<legend>{$string1}</legend>
|
| 154 |
+
<p>{$string2}</p>
|
| 155 |
+
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
|
| 156 |
+
<tr>
|
| 157 |
+
<th style="text-align: center;">{$field1}</th>
|
| 158 |
+
<th style="text-align: center;">{$field2}</th>
|
| 159 |
+
<th style="text-align: center;">{$field3}</th>
|
| 160 |
+
</tr>
|
| 161 |
+
EOT;
|
| 162 |
+
for ($i = 0; $i < count($o['buttons']); $i++){
|
| 163 |
+
$b = $o['buttons'][$i];
|
| 164 |
+
$nr = $i + 1;
|
| 165 |
+
echo <<<EOT
|
| 166 |
+
<tr valign="top" style="text-align: center;">
|
| 167 |
+
<td><input type="text" name="wpaq[buttons][{$i}][text]" value="{$b['text']}" style="width: 95%;" /></td>
|
| 168 |
+
<td><textarea name="wpaq[buttons][{$i}][start]" rows="2" cols="25" style="width: 95%;">{$b['start']}</textarea></td>
|
| 169 |
+
<td><textarea name="wpaq[buttons][{$i}][end]" rows="2" cols="25" style="width: 95%;">{$b['end']}</textarea></td>
|
| 170 |
+
</tr>
|
| 171 |
+
EOT;
|
| 172 |
+
}
|
| 173 |
+
echo <<<EOT
|
| 174 |
+
<tr valign="top" style="text-align: center;">
|
| 175 |
+
<td><input type="text" name="wpaq[buttons][{$i}][text]" value="" style="width: 95%;" /></td>
|
| 176 |
+
<td><textarea name="wpaq[buttons][{$i}][start]" rows="2" cols="25" style="width: 95%;"></textarea></td>
|
| 177 |
+
<td><textarea name="wpaq[buttons][{$i}][end]" rows="2" cols="25" style="width: 95%;"></textarea></td>
|
| 178 |
+
</tr>
|
| 179 |
+
</table>
|
| 180 |
+
</fieldset>
|
| 181 |
+
<p class="submit">
|
| 182 |
+
<input type="submit" name="Submit" value="{$button1}" />
|
| 183 |
+
</p>
|
| 184 |
+
</form>
|
| 185 |
+
<form name="form2" method="post" action="options-general.php?page=addquicktag.php">
|
| 186 |
+
<fieldset class="options">
|
| 187 |
+
<legend>{$export1}</legend>
|
| 188 |
+
<p>{$export2}</p>
|
| 189 |
+
<p class="submit">
|
| 190 |
+
<input type="submit" name="Submit_export" value="{$button2}" />
|
| 191 |
+
<input type="hidden" name="action" value="export" />
|
| 192 |
+
</p>
|
| 193 |
+
</fieldset>
|
| 194 |
+
</form>
|
| 195 |
+
|
| 196 |
+
<form name="form3" enctype="multipart/form-data" method="post" action="options-general.php?page=addquicktag.php">
|
| 197 |
+
<fieldset class="options">
|
| 198 |
+
<legend>{$import1}</legend>
|
| 199 |
+
<p>{$import2}</p>
|
| 200 |
+
<p>
|
| 201 |
+
<label for="datei_id">{$import3}</label>
|
| 202 |
+
<input name="datei" id="datei_id" type="file" />
|
| 203 |
+
</p>
|
| 204 |
+
<p class="submit">
|
| 205 |
+
<input type="submit" name="Submit_import" value="{$button3}" />
|
| 206 |
+
<input type="hidden" name="action" value="import" />
|
| 207 |
+
</p>
|
| 208 |
+
</fieldset>
|
| 209 |
+
</form>
|
| 210 |
+
<hr />
|
| 211 |
+
<p><small>{$info1}<br />© Copyright 2007 <a href="http://bueltge.de">Frank Bültge</a> | {$info2}</small></p>
|
| 212 |
+
</div>
|
| 213 |
+
EOT;
|
| 214 |
+
} //End function wpaq_options_page
|
| 215 |
+
|
| 216 |
+
if (strpos($_SERVER['REQUEST_URI'], 'post.php') || strpos($_SERVER['REQUEST_URI'], 'post-new.php') || strpos($_SERVER['REQUEST_URI'], 'page-new.php') || strpos($_SERVER['REQUEST_URI'], 'page.php')) {
|
| 217 |
+
add_action('admin_footer', 'wpaq_addsome');
|
| 218 |
+
|
| 219 |
+
function wpaq_addsome(){
|
| 220 |
+
$o = get_option('rmnlQuicktagSettings');
|
| 221 |
+
if(count($o['buttons']) > 0){
|
| 222 |
+
echo <<<EOT
|
| 223 |
+
<script type="text/javascript">
|
| 224 |
+
<!--
|
| 225 |
+
if(wpaqToolbar = document.getElementById("ed_toolbar")){
|
| 226 |
+
var wpaqNr, wpaqBut, wpaqStart, wpaqEnd;
|
| 227 |
+
EOT;
|
| 228 |
+
for ($i = 0; $i < count($o['buttons']); $i++){
|
| 229 |
+
$b = $o['buttons'][$i];
|
| 230 |
+
$start = preg_replace('![\n\r]+!', "\\n", $b['start']);
|
| 231 |
+
$start = str_replace("'", "\'", $start);
|
| 232 |
+
$end = preg_replace('![\n\r]+!', "\\n", $b['end']);
|
| 233 |
+
$end = str_replace("'", "\'", $end);
|
| 234 |
+
echo <<<EOT
|
| 235 |
+
wpaqStart = '{$start}';
|
| 236 |
+
wpaqEnd = '{$end}';
|
| 237 |
+
wpaqNr = edButtons.length;
|
| 238 |
+
edButtons[wpaqNr] = new edButton('ed_wpaq{$i}','{$b['txt']}',wpaqStart, wpaqEnd,'');
|
| 239 |
+
var wpaqBut = wpaqToolbar.lastChild;
|
| 240 |
+
while (wpaqBut.nodeType != 1){
|
| 241 |
+
wpaqBut = wpaqBut.previousSibling;
|
| 242 |
+
}
|
| 243 |
+
wpaqBut = wpaqBut.cloneNode(true);
|
| 244 |
+
wpaqToolbar.appendChild(wpaqBut);
|
| 245 |
+
wpaqBut.value = '{$b['text']}';
|
| 246 |
+
wpaqBut.title = wpaqNr;
|
| 247 |
+
wpaqBut.onclick = function () {edInsertTag(edCanvas, parseInt(this.title));}
|
| 248 |
+
wpaqBut.id = "ed_wpaq{$i}";
|
| 249 |
+
EOT;
|
| 250 |
+
}
|
| 251 |
+
echo <<<EOT
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
//-->
|
| 255 |
+
</script>
|
| 256 |
+
EOT;
|
| 257 |
+
}
|
| 258 |
+
} //End wpaq_addsome
|
| 259 |
+
} // End if
|
| 260 |
+
|
| 261 |
+
?>
|
