options = get_option( 'add_search_to_menu' ); $this->networkactive = ( is_multisite() && array_key_exists( plugin_basename( ASTM_PLUGIN_FILE ), (array) get_site_option( 'active_sitewide_plugins' ) ) ); } /** * PHP 4 Compatible Constructor. */ function ASTM_Admin() { $this->__construct(); } /** * Loads plugin javascript and stylesheet files in the admin area. */ function admin_script_style(){ wp_register_script( 'add-search-to-menu-scripts', plugins_url( '/admin/js/add-search-to-menu-admin.js', ASTM_PLUGIN_FILE ), array( 'jquery' ), ASTM_VERSION, true ); wp_localize_script( 'add-search-to-menu-scripts', 'add_search_to_menu', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) ); wp_enqueue_script( 'add-search-to-menu-scripts' ); } /** * Adds a link to the settings page in the plugins list. * * @param array $links array of links for the plugins, adapted when the current plugin is found. * @param string $file the filename for the current plugin, which the filter loops through. * * @return array $links */ function plugin_settings_link( $links, $file ) { if ( false !== strpos( $file, 'add-search-to-menu' ) ) { $mylinks = array( '' . esc_html__( 'Get Support', 'add-search-to-menu' ) . '', '' . esc_html__( 'Settings', 'add-search-to-menu' ) . '' ); $links = array_merge( $mylinks, $links ); } return $links; } /** * Displays plugin configuration notice in admin area. */ function setup_notice(){ if ( 0 === strpos( get_current_screen()->id, 'settings_page_add_search_to_menu' ) ) { return; } $hascaps = $this->networkactive ? is_network_admin() && current_user_can( 'manage_network_plugins' ) : current_user_can( 'manage_options' ); if ( $hascaps ) { $url = is_network_admin() ? network_site_url() : site_url( '/' ); echo '

' . sprintf( __( 'To configure Add Search To Menu plugin please visit its configuration page and to get plugin support contact us on plugin support forum or contact us page.', 'add-search-to-menu'), $url . 'wp-admin/options-general.php?page=add_search_to_menu', 'http://freewptp.com/forum/wordpress-plugins-forum/add-search-to-menu/', 'http://freewptp.com/contact/' ) . '

'; } } /** * Handles plugin notice dismiss functionality using AJAX. */ function dismiss_notice() { if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { $options = $this->options; $options['dismiss_admin_notices'] = 1; update_option( 'add_search_to_menu', $options ); } die(); } /** * Registers plugin admin menu item. */ function admin_menu_setup(){ add_submenu_page( 'options-general.php', __( 'Add Search To Menu Settings', 'add-search-to-menu' ), __( 'Add Search To Menu', 'add-search-to-menu' ), 'manage_options', 'add_search_to_menu', array( $this, 'admin_page_screen' ) ); } /** * Displays plugin admin page content. */ function admin_page_screen() { ?>
' . esc_html__( 'Configure the Add Search To Menu plugin settings here.', 'add-search-to-menu' ) . '

'; } /** * Displays choose menu locations field. */ function menu_locations() { $options = $this->options; $html = ''; $menus = get_registered_nav_menus(); if ( ! empty( $menus ) ){ foreach ( $menus as $location => $description ) { $check_value = isset( $options['add_search_to_menu_locations'][ $location ] ) ? $options['add_search_to_menu_locations'][ $location ] : 0; $html .= ''; $html .= '
'; } } else { $html = __( 'No navigation menu registered on your site.', 'add-search-to-menu' ); } echo $html; } /** * Displays choose post types field. */ function post_posts() { $options = $this->options; $html = ''; $args = array( 'exclude_from_search' => false ); $posts = get_post_types( $args ); if ( ! empty( $posts ) ){ foreach ( $posts as $key => $post ) { $check_value = isset( $options['add_search_to_menu_posts'][$key] ) ? $options['add_search_to_menu_posts'][ $key ] : 0; $html .= ''; $html .= '
'; } } else { $html = __( 'No post types registered on your site.', 'add-search-to-menu' ); } echo $html; } /** * Displays form style field. */ function form_style() { $options = $this->options; $styles = array( 'default' => __( 'Default', 'add-search-to-menu' ), 'dropdown' => __( 'Dropdown', 'add-search-to-menu' ), 'sliding' => __( 'Sliding', 'add-search-to-menu' ), 'full-width-menu' => __( 'Full Width', 'add-search-to-menu' ) ); if ( empty( $options ) || ! isset( $options['add_search_to_menu_style'] ) ) { $options['add_search_to_menu_style'] = 'default'; update_option( 'add_search_to_menu', $options ); } $html = ''; $check_value = isset( $options['add_search_to_menu_style'] ) ? $options['add_search_to_menu_style'] : 'default'; foreach ( $styles as $key => $style ) { $html .= ''; $html .= '
'; } echo $html; } /** * Displays search menu title field. */ function menu_title() { $options = $this->options; $options['add_search_to_menu_title'] = isset( $options['add_search_to_menu_title'] ) ? $options['add_search_to_menu_title'] : ''; $html = ''; $html .= '
'; echo $html; } /** * Displays search menu classes field. */ function menu_classes() { $options = $this->options; $options['add_search_to_menu_classes'] = isset( $options['add_search_to_menu_classes'] ) ? $options['add_search_to_menu_classes'] : 'astm-search-menu'; $html = ''; $html .= '
'; echo $html; } /** * Displays google cse field. */ function google_cse() { $options = $this->options; $options['add_search_to_menu_gcse'] = isset( $options['add_search_to_menu_gcse'] ) ? $options['add_search_to_menu_gcse'] : ''; $html = ''; $html .= '
'; echo $html; } /** * Displays display in header field. */ function display_in_header() { $options = $this->options; $check_value = isset( $options['add_search_to_menu_display_in_header'] ) ? $options['add_search_to_menu_display_in_header'] : 0; $html = ''; $html .= ''; $html .= '
'; echo $html; } /** * Displays search form close icon field. */ function close_icon() { $options = $this->options; $check_value = isset( $options['add_search_to_menu_close_icon'] ) ? $options['add_search_to_menu_close_icon'] : 0; $html = ''; $html .= ''; echo $html; } /** * Displays custom css field. */ function custom_css() { $options = $this->options; $options['add_search_to_menu_css'] = isset( $options['add_search_to_menu_css'] ) ? $options['add_search_to_menu_css'] : ''; $html = ''; $html .= '
'; echo $html; } /** * Displays do not load plugin files field. */ function plugin_files() { $options = $this->options; $styles = array( 'plugin-css-file' => __( 'Plugin CSS File', 'add-search-to-menu' ), 'plugin-js-file' => __( 'Plugin JavaScript File', 'add-search-to-menu' ) ); $html = ''; foreach ( $styles as $key => $file ) { $check_value = isset( $options['do_not_load_plugin_files'][ $key] ) ? $options['do_not_load_plugin_files'][ $key ] : 0; $html .= ''; $html .= ''; if ( 'plugin-css-file' == $key ) { $html .= '
'; $html .= '
' . plugins_url( '/public/css/add-search-to-menu.css', ASTM_PLUGIN_FILE ) . ''; $html .= '

'; } else { $html .= '
'; $html .= '
' . plugins_url( '/public/js/add-search-to-menu.js', ASTM_PLUGIN_FILE ) . ''; } } echo $html; } } }