= 3.3 and tested with PHP Interpreter >= 5.3 */ /** * */ class Add_Quicktag { static private $classobj; static private $option_string = 'rmnlQuicktagSettings'; static private $admin_pages_for_js = array( 'post.php', 'post-new.php', ); static private $admin_ids_for_js = array( 'post', 'page' ); static private $plugin; function __construct() { if ( ! is_admin() ) return; // get string of plugin self :: $plugin = plugin_basename( __FILE__ ); // on uninstall remove capability from roles register_uninstall_hook( __FILE__, array('Add_Quicktag', 'uninstall' ) ); // in deactivate delete all settings in database // register_deactivation_hook( __FILE__, array('Add_Quicktag', 'uninstall' ) ); // load translation files add_action( 'admin_init', array( $this, 'localize_plugin' ) ); // Include settings require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'inc/class-settings.php'; // Include solution for TinyMCe require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'inc/class-tinymce.php'; add_action( 'wp_print_scripts', array( $this, 'print_scripts' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts') ); } public function uninstall() { delete_option( self :: $option_string ); delete_site_option( self :: $option_string ); } public function print_scripts() { global $current_screen; if ( isset( $current_screen -> id ) && ! in_array( $current_screen -> id, self :: $admin_ids_for_js ) ) return; if ( is_multisite() && is_plugin_active_for_network( $this -> get_plugin_string() ) ) $options = get_site_option( self :: $option_string ); else $options = get_option( self :: $option_string ); if ( ! $options ) return; if ( 1 < count($options['buttons']) ) { // sort array by order value $tmp = array(); foreach( $options['buttons'] as $order ) { $tmp[] = $order['order']; } array_multisort( $tmp, SORT_ASC, $options['buttons'] ); } ?> =' ) ) { wp_enqueue_script( self :: get_textdomain() . '_script', plugins_url( '/js/add-quicktags' . $suffix. '.js', __FILE__ ), array( 'jquery', 'quicktags' ), '', TRUE ); } else { wp_enqueue_script( self :: get_textdomain() . '_script', plugins_url( '/js/add-quicktags_32' . $suffix. '.js', __FILE__ ), array( 'jquery', 'quicktags' ), '', TRUE ); } // Alternative to JSON function // wp_localize_script( self :: get_textdomain() . '_script', 'addquicktag_tags', get_option( self :: $option_string ) ); } /** * Handler for the action 'init'. Instantiates this class. * * @since 2.0.0 * @access public * @return $classobj */ public function get_object() { if ( NULL === self :: $classobj ) { self :: $classobj = new self; } return self :: $classobj; } /** * Localize_plugin function. * * @uses load_plugin_textdomain, plugin_basename * @access public * @since 2.0.0 * @return void */ public function localize_plugin() { load_plugin_textdomain( $this -> get_textdomain(), FALSE, dirname( plugin_basename(__FILE__) ) . '/languages' ); } /** * return plugin comment data * * @since 2.0.0 * @access public * @param $value string, default = 'TextDomain' * Name, PluginURI, Version, Description, Author, AuthorURI, TextDomain, DomainPath, Network, Title * @return string */ public function get_plugin_data( $value = 'TextDomain' ) { if ( ! function_exists( 'get_plugin_data' ) ) require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); $plugin_data = get_plugin_data( __FILE__ ); $plugin_value = $plugin_data[$value]; return $plugin_value; } public function get_plugin_string() { return self :: $plugin; } /** * Retrun textdomain string * * @since 2.0.0 * @access public * @return string */ public function get_textdomain() { return self :: get_plugin_data( 'TextDomain' ); } public function get_option_string() { return self :: $option_string; } } // end class if ( function_exists( 'add_action' ) && class_exists( 'Add_Quicktag' ) ) { add_action( 'plugins_loaded', array( 'Add_Quicktag', 'get_object' ) ); } else { header( 'Status: 403 Forbidden' ); header( 'HTTP/1.1 403 Forbidden' ); exit(); }