array( array( 'text' => 'Example', 'start' => '', 'end' => '' ) ) ); add_option('rmnlQuicktagSettings', $rmnlQuicktagSettings); } /** * install options in table _options * * @package AddQuicktag */ function wpaq_reset() { $rmnlQuicktagSettings = array( 'buttons' => array( array( 'text' => 'Reset', 'start' => '', 'end' => '' ) ) ); update_option('rmnlQuicktagSettings', $rmnlQuicktagSettings); } /** * uninstall options in table _options * * @package AddQuicktag */ function wpaq_uninstall() { delete_option('rmnlQuicktagSettings'); } /** * export options in file * * @package AddQuicktag */ function wpaq_export() { global $wpdb; $filename = 'wpaq_export-' . date('Y-m-d_G-i-s') . '.wpaq'; header("Content-Description: File Transfer"); header("Content-Disposition: attachment; filename=" . urlencode($filename)); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header('Content-Type: text/wpaq; charset=' . get_option('blog_charset'), true); flush(); $wpaq_data = mysql_query("SELECT option_value FROM $wpdb->options WHERE option_name = 'rmnlQuicktagSettings'"); $wpaq_data = mysql_result($wpaq_data, 0); echo $wpaq_data; flush(); } /** * import options in table _options * * @package AddQuicktag */ function wpaq_import() { if ( !current_user_can('manage_options') ) wp_die( __('Options not update - you don‘t have the privilidges to do this!', 'secure_wp') ); //cross check the given referer check_admin_referer('rmnl_nonce'); // check file extension $str_file_name = $_FILES['datei']['name']; $str_file_ext = explode(".", $str_file_name); if ($str_file_ext[1] != 'wpaq') { $addreferer = 'notexist'; } elseif (file_exists($_FILES['datei']['name'])) { $addreferer = 'exist'; } else { // path for file $str_ziel = WP_CONTENT_DIR . '/' . $_FILES['datei']['name']; // 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); wpaq_reset(); $import_file = unserialize($import_file); update_option('rmnlQuicktagSettings', $import_file); unlink($str_ziel); $addreferer = 'true'; } $referer = str_replace('&update=true&update=true', '', $_POST['_wp_http_referer'] ); wp_redirect($referer . '&update=' . $addreferer ); } /** * options page in backend of WP * * @package AddQuicktag */ function wpaq_options_page() { global $wp_version; if ($_POST['wpaq']) { if ( 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.', 'addquicktag').'

'); } } // Uninstall options if ( ($_POST['action'] == 'uninstall') ) { if ( current_user_can('edit_plugins') ) { check_admin_referer('rmnl_nonce'); wpaq_uninstall(); $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.', 'addquicktag').'

'); } } $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/Import AddQuicktag buttons options', 'addquicktag'); $export2 = __('You can save a .wpaq file with your options.', 'addquicktag'); $export3 = __('Export', 'addquicktag'); // Import strings $button3 = __('Upload file and import »', 'addquicktag'); $import1 = __('Import', '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. Attention: You cannot undo this!', 'addquicktag'); // Info $info0 = __('About the plugin', 'addquicktag'); $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'); // message for import, after redirect if ( strpos($_SERVER['REQUEST_URI'], 'addquicktag.php') && $_GET['update'] && !$_POST['uninstall'] ) { $message_export = '

'; if ( $_GET['update'] == 'true' ) { $message_export .= __('AddQuicktag options imported!', 'addquicktag'); } elseif( $_GET['update'] == 'exist' ) { $message_export .= __('File is exist!', 'addquicktag'); } elseif( $_GET['update'] == 'notexist' ) { $message_export .= __('Invalid file extension!', 'addquicktag'); } $message_export .= '

'; } $o = get_option('rmnlQuicktagSettings'); ?>



'; } ?>


© Copyright 2007 - Frank Bültge |

0) { echo ' '; } } //End wpaq_addsome } // End if // add to wp if ( function_exists('register_activation_hook') ) register_activation_hook(__FILE__, 'wpaq_install'); if ( function_exists('register_uninstall_hook') ) register_uninstall_hook(__FILE__, 'wpaq_uninstall'); 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('admin_post_wpaq_import', 'wpaq_import' ); } /** * Add action link(s) to plugins page * Thanks Dion Hulse -- http://dd32.id.au/wordpress-plugins/?configure-link * * @package AddQuicktag */ 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; } /** * @version WP 2.7 * Add action link(s) to plugins page * * @package AddQuicktag */ function wpaq_filter_plugin_actions_new($links) { $settings_link = '' . __('Settings') . ''; array_unshift( $links, $settings_link ); return $links; } /** * Images/ Icons in base64-encoding * @use function wpag_get_resource_url() for display * * @package AddQuicktag */ if( isset($_GET['resource']) && !empty($_GET['resource'])) { # base64 encoding performed by base64img.php from http://php.holtsmark.no $resources = array( 'addquicktag.gif' => 'R0lGODlhCwAJALMPAPL19Y2cnLzNzZempsXV1VpfX6WysrS/v5'. '+trXmDg9Xh4drr66W5uay6urnHx////yH5BAEAAA8ALAAAAAAL'. 'AAkAAARA8D0gmBMESMUIK0XAVNzQOE6QCIJhIMOANMRCHG+MuI'. '5yG4PAzjDyORqyxKwh8AlUAEUiQVswqBINIHEIHCSPCAA7'. ''); if(array_key_exists($_GET['resource'], $resources)) { $content = base64_decode($resources[ $_GET['resource'] ]); $lastMod = filemtime(__FILE__); $client = ( isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false ); // Checking if the client is validating his cache and if it is current. if (isset($client) && (strtotime($client) == $lastMod)) { // Client's cache IS current, so we just respond '304 Not Modified'. header('Last-Modified: '.gmdate('D, d M Y H:i:s', $lastMod).' GMT', true, 304); exit; } else { // Image not cached or cache outdated, we respond '200 OK' and output the image. header('Last-Modified: '.gmdate('D, d M Y H:i:s', $lastMod).' GMT', true, 200); header('Content-Length: '.strlen($content)); header('Content-Type: image/' . substr(strrchr($_GET['resource'], '.'), 1) ); echo $content; exit; } } } /** * Display Images/ Icons in base64-encoding * @return $resourceID * * @package AddQuicktag */ function wpag_get_resource_url($resourceID) { return trailingslashit( get_bloginfo('url') ) . '?resource=' . $resourceID; } /** * settings in plugin-admin-page * * @package AddQuicktag */ function wpaq_add_settings_page() { global $wp_version; if ( function_exists('add_options_page') && current_user_can('manage_options') ) { $plugin = plugin_basename(__FILE__); $menutitle = ''; if ( version_compare( $wp_version, '2.6.999', '>' ) ) { $menutitle = '' . ' '; } $menutitle .= __('AddQuicktag', 'addquicktag'); add_options_page( __('WP-Quicktag – AddQuicktag', 'addquicktag'), $menutitle, 9, $plugin, 'wpaq_options_page'); if ( version_compare( $wp_version, '2.6.999', '<' ) ) { add_filter('plugin_action_links', 'wpaq_filter_plugin_actions', 10, 2); } else { add_filter( 'plugin_action_links_' . $plugin, 'wpaq_filter_plugin_actions_new' ); } } } /** * credit in wp-footer * * @package AddQuicktag */ function wpaq_admin_footer() { if( basename($_SERVER['REQUEST_URI']) == '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']); } } ?>