Roel Meurders and Frank Bueltge Last Change: 21.08.2008 14:06:21 */ // SCRIPT INFO /////////////////////////////////////////////////////////////////////////// /* WP-AddQuicktag for WordPress is in originally by (C) 2005 Roel Meurders - GNU General Public License AddQuicktag is an newer version with more functions and worked in WP 2.1 (C) 2007 Frank Bueltge This Wordpress plugin is released under a GNU General Public License. A complete version of this license can be found here: http://www.gnu.org/licenses/gpl.txt This Wordpress plugin has been tested with Wordpress 2.0, 2.1 and Wordpress 2.3; This Wordpress plugin is released "as is". Without any warranty. The authors cannot be held responsible for any damage that this script might cause. */ // Pre-2.6 compatibility if ( !defined('WP_CONTENT_URL') ) define( 'WP_CONTENT_URL', get_option('url') . '/wp-content'); if ( !defined('WP_CONTENT_DIR') ) define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); function wpaq_textdomain() { if (function_exists('load_plugin_textdomain')) { if ( !defined('WP_PLUGIN_DIR') ) { load_plugin_textdomain('addquicktag', str_replace( ABSPATH, '', dirname(__FILE__) ) ); } else { load_plugin_textdomain('addquicktag', false, dirname(plugin_basename(__FILE__)) ); } } } // install options in table _options function wpaq_install() { global $wpdb; if (get_option('rmnlQuicktagSettings') == '') { $name = 'rmnlQuicktagSettings'; $value = 'a:1:{s:7:"buttons";a:1:{i:0;a:3:{s:4:"text";s:7:"Example";s:5:"start";s:9:"";s:3:"end";s:10:"";}}}'; $autoload = 'yes'; $wpdb->query("INSERT INTO $wpdb->options (option_name, option_value, autoload) VALUES ('$name', '$value', '$autoload')"); } } // options-page in wp-backend function wpaq_options_page() { global $wpdb; $wpaq_document_root = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['REQUEST_URI']; $wpaq_document_root = str_replace("/wp-admin/options-general.php?page=addquicktag.php", "/wp-content", $wpaq_document_root); $wpaq_link = $_SERVER['REQUEST_URI']; $wpaq_link = str_replace("\\", "/", $wpaq_link); if ($_POST['wpaq']) { if ( function_exists('current_user_can') && current_user_can('edit_plugins') ) { check_admin_referer('rmnl_nonce'); $buttons = array(); for ($i = 0; $i < count($_POST['wpaq']['buttons']); $i++){ $b = $_POST['wpaq']['buttons'][$i]; if ($b['text'] != '' && $b['start'] != '') { $b['text'] = ($b['text']); $b['start'] = stripslashes($b['start']); $b['end'] = stripslashes($b['end']); $buttons[] = $b; } } $_POST['wpaq']['buttons'] = $buttons; update_option('rmnlQuicktagSettings', $_POST['wpaq']); $message = '

' . __('Options saved.', 'addquicktag') . '

'; } else { wp_die('

'.__('You do not have sufficient permissions to edit plugins for this blog.').'

'); } } // Export sql-option if (($_POST['action'] == 'export')) { if ( function_exists('current_user_can') && current_user_can('edit_plugins') ) { check_admin_referer('rmnl_nonce'); $wpaq_data = mysql_query("SELECT option_value FROM $wpdb->options WHERE option_name = 'rmnlQuicktagSettings'"); $wpaq_data = mysql_result($wpaq_data, 0); $file_name = $wpaq_document_root . '/wpaq_export-' . date('Y-m-d_G-i-s') . '.wpaq'; $file_name = str_replace("//", "/", $file_name); $fh = @ fopen($file_name, 'w'); if ($fh == false) { $message_export = '

' . __('Can not open for write!', 'addquicktag') . '

'; } else { @flock($fh, LOCK_EXCLUSIVE); $err = @fputs($fh, $wpaq_data); @fclose($fh); if ($err === false) { $message_export = '

' . __('Can not write!', 'addquicktag') . '

'; } $message_export = '

' . __('AddQuicktag options saved!', 'addquicktag') . '
'; $message_export.= __('Saved in: ', 'addquicktag') . $file_name; $message_export.= '

'; } } else { wp_die('

'.__('You do not have sufficient permissions to edit plugins for this blog.').'

'); } } // Import the sql-file if (($_POST['action'] == 'import')) { if ( function_exists('current_user_can') && current_user_can('edit_plugins') ) { check_admin_referer('rmnl_nonce'); $message_export = '

'; // check file extension sql $str_file_name = $_FILES['datei']['name']; $str_file_ext = explode(".", $str_file_name); if ($str_file_ext[1] != 'wpaq') { $message_export.= __('Invalid file extension!', 'addquicktag'); } elseif (file_exists($_FILES['datei']['name'])) { $message_export.= __('File is exist!', 'addquicktag'); } else { // path for file $wpaq_document_root = str_replace("/wp-admin/options-general.php?page=addquicktag.php", "/wp-content/", $wpaq_document_root); $str_ziel = $wpaq_document_root . '/' . $_FILES['datei']['name']; $str_ziel = str_replace("//", "/", $str_ziel); // transfer move_uploaded_file($_FILES['datei']['tmp_name'], $str_ziel); // access authorisation chmod($str_ziel, 0644); // SQL import ini_set('default_socket_timeout', 120); $import_file = file_get_contents($str_ziel); $wpdb->query("UPDATE $wpdb->options SET `option_value` = '$import_file' WHERE `option_name` = 'rmnlQuicktagSettings'"); unlink($str_ziel); $message_export.= __('AddQuicktag options imported!', 'addquicktag'); } $message_export.= '

'; } else { wp_die('

'.__('You do not have sufficient permissions to edit plugins for this blog.').'

'); } } // Uninstall options if (($_POST['action'] == 'uninstall')) { if ( function_exists('current_user_can') && current_user_can('edit_plugins') ) { check_admin_referer('rmnl_nonce'); delete_option('rmnlQuicktagSettings', $_POST['wpaq']); $message_export = '

'; $message_export.= __('AddQuicktag options have been deleted!', 'addquicktag'); $message_export.= '

'; } else { wp_die('

'.__('You do not have sufficient permissions to edit plugins for this blog.').'

'); } } $string1 = __('Add or delete Quicktag buttons', 'addquicktag'); $string2 = __('Fill in the fields below to add or edit the quicktags. Fields with * are required. To delete a tag simply empty all fields.', 'addquicktag'); $field1 = __('Button Label*', 'addquicktag'); $field2 = __('Start Tag(s)*', 'addquicktag'); $field3 = __('End Tag(s)', 'addquicktag'); $button1 = __('Update Options »', 'addquicktag'); // Export strings $button2 = __('Export »', 'addquicktag'); $export1 = __('Export Quicktag buttons options', 'addquicktag'); $export2 = __('You can save a .wpaq file with your options in /wp-content/wpaq_export.wpaq', 'addquicktag'); // Import strings $button3 = __('Upload file and import »', 'addquicktag'); $import1 = __('Import Quicktag buttons options', 'addquicktag'); $import2 = __('Choose a Quicktag (.wpaq) file to upload, then click Upload file and import.', 'addquicktag'); $import3 = __('Choose a file from your computer: ', 'addquicktag'); // Uninstall strings $button4 = __('Uninstall Options »', 'addquicktag'); $uninstall1 = __('Uninstall options', 'addquicktag'); $uninstall2 = __('This button deletes all options of the WP-AddQuicktag plugin. Please use it before deactivating the plugin.
Attention: You cannot undo this!', 'addquicktag'); // Info $info1 = __('Further information: Visit the plugin homepage for further information or to grab the latest version of this plugin.', 'addquicktag'); $info2 = __('You want to thank me? Visit my wishlist.', 'addquicktag'); $o = get_option('rmnlQuicktagSettings'); echo '

WP-Quicktag Management

' . $message . $message_export . '
' . wp_nonce_field('rmnl_nonce') . '

' . $string1 . '

' . $string2 . '

'; for ($i = 0; $i < count($o['buttons']); $i++) { $b = $o['buttons'][$i]; $b['text'] = htmlentities(stripslashes($b['text']), ENT_COMPAT, get_option('blog_charset')); $b['start'] = htmlentities($b['start'], ENT_COMPAT, get_option('blog_charset')); $b['end'] = htmlentities($b['end'], ENT_COMPAT, get_option('blog_charset')); $nr = $i + 1; echo ' '; } echo '
' . $field1 . ' ' . $field2 . ' ' . $field3 . '

' . wp_nonce_field('rmnl_nonce') . '

' . $export1 . '

' . $export2 . '

' . wp_nonce_field('rmnl_nonce') . '

' . $import1 . '

' . $import2 . '

' . wp_nonce_field('rmnl_nonce') . '

' . $uninstall1 . '

' . $uninstall2 . '


' . $info1 . '
© Copyright 2007 - ' . date("Y") . ' Frank Bültge | ' . $info2 . '

'; } //End function wpaq_options_page // only for post.php, page.php, post-new.php, page-new.php, comment.php 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') || strpos($_SERVER['REQUEST_URI'], 'comment.php')) { add_action('admin_footer', 'wpaq_addsome'); function wpaq_addsome() { $o = get_option('rmnlQuicktagSettings'); if (count($o['buttons']) > 0) { echo ' '; } } //End wpaq_addsome } // End if // add to wp register_activation_hook(__FILE__, 'wpaq_install'); if ( is_admin() ) { add_action('init', 'wpaq_textdomain'); add_action('admin_menu', 'wpaq_add_settings_page'); add_action('in_admin_footer', 'wpaq_admin_footer'); } /** * Add action link(s) to plugins page * Thanks Dion Hulse -- http://dd32.id.au/wordpress-plugins/?configure-link */ function wpaq_filter_plugin_actions($links, $file){ static $this_plugin; if( ! $this_plugin ) $this_plugin = plugin_basename(__FILE__); if( $file == $this_plugin ){ $settings_link = '' . __('Settings') . ''; $links = array_merge( array($settings_link), $links); // before other links } return $links; } /** * settings in plugin-admin-page */ function wpaq_add_settings_page() { if( function_exists('current_user_can') && current_user_can('manage_options') ) { add_options_page('WP-Quicktag - Add Quicktags', 'Add Quicktags', 9, basename(__FILE__), 'wpaq_options_page'); add_filter('plugin_action_links', 'wpaq_filter_plugin_actions', 10, 2); } } /** * credit in wp-footer */ function wpaq_admin_footer() { if( basename($_SERVER['REQUEST_URI']) == 'options-general.php?page=addquicktag.php') { $plugin_data = get_plugin_data( __FILE__ ); printf('%1$s plugin | ' . __('Version') . ' %2$s | ' . __('Author') . ' %3$s
', $plugin_data['Title'], $plugin_data['Version'], $plugin_data['Author']); } } ?>