option_string = parent :: get_option_string(); $this -> plugin = parent :: get_plugin_string(); $this -> nonce_string = 'addquicktag_nonce'; register_uninstall_hook( __FILE__, array( 'Add_Quicktag_Settings', 'unregister_settings' ) ); // settings for an active multisite if ( is_multisite() && is_plugin_active_for_network( $this -> plugin ) ) { add_action( 'network_admin_menu', array( $this, 'add_settings_page' ) ); // add settings link add_filter( 'network_admin_plugin_action_links', array( $this, 'network_admin_plugin_action_links' ), 10, 2 ); // save settings on network add_action( 'network_admin_edit_' . $this -> option_string, array( $this, 'save_network_settings_page' ) ); // return message for update settings add_action( 'network_admin_notices', array( $this, 'get_network_admin_notices' ) ); } else { add_action( 'admin_menu', array( $this, 'add_settings_page' ) ); // add settings link add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 2 ); // use settings API add_action( 'admin_init', array( $this, 'register_settings' ) ); } // add meta boxes on settings pages add_action( 'addquicktag_settings_page_sidebar', array( $this, 'get_plugin_infos' ) ); add_action( 'addquicktag_settings_page_sidebar', array( $this, 'get_about_plugin' ) ); // include class for im/export require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'class-imexport.php'; } /** * Return Textdomain string * * @access public * @since 2.0.0 * @return string */ public function get_textdomain() { return self :: $textdomain; } /** * Add settings link on plugins.php in backend * * @uses * @access public * @param array $links, string $file * @since 2.0.0 * @return string $links */ public function plugin_action_links( $links, $file ) { if ( parent :: get_plugin_string() == $file ) $links[] = '' . __('Settings') . ''; return $links; } /** * Add settings link on plugins.php on network admin in backend * * @uses * @access public * @param array $links, string $file * @since 2.0.0 * @return string $links */ public function network_admin_plugin_action_links( $links, $file ) { if ( parent :: get_plugin_string() == $file ) $links[] = '' . __('Settings') . ''; return $links; } /** * Add settings page in WP backend * * @uses add_options_page * @access public * @since 2.0.0 * @return void */ public function add_settings_page () { if ( is_multisite() && is_plugin_active_for_network( $this -> plugin ) ) { add_submenu_page( 'settings.php', parent :: get_plugin_data( 'Name' ) . ' ' . __( 'Settings', $this -> get_textdomain() ), parent :: get_plugin_data( 'Name' ), 'manage_options', plugin_basename(__FILE__), array( $this, 'get_settings_page' ) ); } else { add_options_page( parent :: get_plugin_data( 'Name' ) . ' ' . __( 'Settings', $this -> get_textdomain() ), parent :: get_plugin_data( 'Name' ), 'manage_options', plugin_basename(__FILE__), array( $this, 'get_settings_page' ) ); add_action( 'contextual_help', array( $this, 'contextual_help' ), 10, 3 ); } } /** * Return form and markup on settings page * * @uses settings_fields, normalize_whitespace, is_plugin_active_for_network, get_site_option, get_option * @access public * @since 0.0.2 * @return void */ public function get_settings_page() { ?>

get_textdomain() ); ?>

plugin ) ) $action = 'edit.php?action=' . $this -> option_string; else $action = 'options.php'; ?>
option_string . '_group' ); if ( is_multisite() && is_plugin_active_for_network( $this -> plugin ) ) $options = get_site_option( $this -> option_string ); else $options = get_option( $this -> option_string ); if ( ! $options ) $options['buttons'] = array(); if ( 1 < count($options['buttons']) ) { // sort array by order value $tmp = array(); foreach( $options['buttons'] as $order ) { if ( isset( $order['order'] ) ) $tmp[] = $order['order']; else $tmp[] = 0; } array_multisort( $tmp, SORT_ASC, $options['buttons'] ); } ?> '; } ?>
get_textdomain() ); ?> get_textdomain() ); ?> get_textdomain() ); ?> get_textdomain() ); ?> get_textdomain() ); ?> get_textdomain() ); ?> get_textdomain() ); ?>

get_textdomain() ); ?>

get_textdomain() ); ?>

get_textdomain() ); ?>

get_textdomain() ); ?>

get_textdomain() ); ?>

get_textdomain() ); ?>

validate_settings( $_POST[$this -> option_string] ); // update options update_site_option( $this -> option_string, $value ); // redirect to settings page in network wp_redirect( add_query_arg( array('page' => 'addquicktag/inc/class-settings.php', 'updated' => 'true'), network_admin_url( 'settings.php' ) ) ); exit(); } /* * Retrun string vor update message * * @uses * @access public * @since 2.0.0 * @return string $notice */ public function get_network_admin_notices() { // if updated and the right page if ( isset( $_GET['updated'] ) && 'settings_page_addquicktag/inc/class-settings-network' === $GLOBALS['current_screen'] -> id ) { $message = __( 'Options saved.', $this -> get_textdomain() ); $notice = '

' .$message . '

'; echo $notice; } } /** * Validate settings for options * * @uses normalize_whitespace * @access public * @param array $value * @since 2.0.0 * @return string $value */ public function validate_settings( $value ) { $buttons = array(); for ( $i = 0; $i < count( $value['buttons']); $i++ ) { $b = $value['buttons'][$i]; if ($b['text'] != '' && $b['start'] != '') { $b['text'] = esc_html( $b['text'] ); $b['title'] = esc_html( $b['title'] ); $b['start'] = stripslashes( $b['start'] ); $b['end'] = stripslashes( $b['end'] ); if ( isset( $b['access'] ) ) $b['access'] = esc_html( $b['access'] ); if ( isset( $b['order'] ) ) $b['order'] = intval( $b['order'] ); if ( isset( $b['visual'] ) ) $b['visual'] = intval( $b['visual'] ); else $b['visual'] = 0; $buttons[] = $b; } } $value['buttons'] = $buttons; return $value; } /** * Register settings for options * * @uses register_setting * @access public * @since 2.0.0 * @return void */ public function register_settings() { register_setting( $this -> option_string . '_group', $this -> option_string, array( $this, 'validate_settings' ) ); } /** * Unregister and delete settings; clean database * * @uses unregister_setting, delete_option * @access public * @since 0.0.2 * @return void */ public function unregister_settings() { unregister_setting( $this -> option_string . '_group', $this -> option_string ); delete_option( $this -> option_string ); } /** * Add help text * * @uses normalize_whitespace * @param string $contextual_help * @param string $screen_id * @param string $screen * @since 2.0.0 * @return string $contextual_help */ public function contextual_help( $contextual_help, $screen_id, $screen ) { if ( 'settings_page_' . $this -> option_string . '_group' !== $screen_id ) return $contextual_help; $contextual_help = '

' . __( '' ) . '

'; return normalize_whitespace( $contextual_help ); } } $add_quicktag_settings = Add_Quicktag_Settings :: get_object();