opt = Ivory_Search::load_options();
}
/**
* Gets the instance of this class.
*
* @return self
*/
public static function getInstance()
{
if ( !self::$_instance instanceof self ) {
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Displays settings sections having custom markup.
*/
public function is_do_settings_sections( $page, $sec )
{
global $wp_settings_sections, $wp_settings_fields ;
if ( !isset( $wp_settings_sections[$page] ) ) {
return;
}
$section = (array) $wp_settings_sections[$page][$sec];
if ( $section['title'] ) {
echo "
{$section['title']}
\n" ;
}
if ( $section['callback'] ) {
call_user_func( $section['callback'], $section );
}
if ( !isset( $wp_settings_fields ) || !isset( $wp_settings_fields[$page] ) || !isset( $wp_settings_fields[$page][$section['id']] ) ) {
return;
}
?>
is_do_settings_fields( $page, $section['id'] );
?>
=' ) ) {
$temp_oname = 'allowed_options';
}
if ( isset( $_POST['is_menu_search'] ) ) {
add_filter( $temp_oname, function ( $allowed_options ) {
$allowed_options['ivory_search'][0] = 'is_menu_search';
return $allowed_options;
} );
} else {
if ( isset( $_POST['is_analytics'] ) ) {
add_filter( $temp_oname, function ( $allowed_options ) {
$allowed_options['ivory_search'][0] = 'is_analytics';
return $allowed_options;
} );
}
}
}
$tab = 'settings';
if ( isset( $_GET['tab'] ) ) {
switch ( $_GET['tab'] ) {
case 'menu-search':
$tab = 'menu-search';
break;
case 'analytics':
$tab = 'analytics';
break;
}
}
if ( 'settings' === $tab ) {
add_settings_section(
'ivory_search_settings',
'',
array( $this, 'settings_section_desc' ),
'ivory_search'
);
add_settings_field(
'ivory_search_css',
__( 'Custom CSS', 'add-search-to-menu' ),
array( $this, 'custom_css' ),
'ivory_search',
'ivory_search_settings'
);
add_settings_field(
'ivory_search_stopwords',
__( 'Stopwords', 'add-search-to-menu' ),
array( $this, 'stopwords' ),
'ivory_search',
'ivory_search_settings'
);
add_settings_field(
'ivory_search_synonyms',
__( 'Synonyms', 'add-search-to-menu' ),
array( $this, 'synonyms' ),
'ivory_search',
'ivory_search_settings'
);
add_settings_field(
'ivory_search_header',
__( 'Header Search', 'add-search-to-menu' ),
array( $this, 'header' ),
'ivory_search',
'ivory_search_settings'
);
add_settings_field(
'ivory_search_footer',
__( 'Footer Search', 'add-search-to-menu' ),
array( $this, 'footer' ),
'ivory_search',
'ivory_search_settings'
);
add_settings_field(
'ivory_search_display_in_header',
__( 'Mobile Search', 'add-search-to-menu' ),
array( $this, 'menu_search_in_header' ),
'ivory_search',
'ivory_search_settings'
);
add_settings_field(
'not_load_files',
__( 'Plugin Files', 'add-search-to-menu' ),
array( $this, 'plugin_files' ),
'ivory_search',
'ivory_search_settings'
);
add_settings_field(
'ivory_search_extras',
__( 'Advanced', 'add-search-to-menu' ),
array( $this, 'advanced' ),
'ivory_search',
'ivory_search_settings'
);
register_setting( 'ivory_search', 'is_settings', array( $this, 'is_validate_setting' ) );
} else {
if ( 'menu-search' === $tab ) {
add_settings_section(
'ivory_search_section',
'',
array( $this, 'menu_search_section_desc' ),
'ivory_search'
);
add_settings_field(
'ivory_search_locations',
__( 'Menu Search Settings', 'add-search-to-menu' ),
array( $this, 'menu_settings' ),
'ivory_search',
'ivory_search_section'
);
register_setting( 'ivory_search', 'is_menu_search' );
} else {
if ( 'analytics' === $tab ) {
add_settings_section(
'ivory_search_analytics',
'',
array( $this, 'analytics_section_desc' ),
'ivory_search'
);
add_settings_field(
'ivory_search_analytics_fields',
__( 'Search Analytics', 'add-search-to-menu' ),
array( $this, 'analytics' ),
'ivory_search',
'ivory_search_analytics'
);
register_setting( 'ivory_search', 'is_analytics' );
}
}
}
}
function is_validate_setting( $args )
{
if ( isset( $args['custom_css'] ) && preg_match( '#?\\w+#', $args['custom_css'] ) ) {
add_settings_error(
'is_settings',
'invalid_is_css',
__( 'Invalid Custom CSS Code', 'add-search-to-menu' ),
'error'
);
$args['custom_css'] = $this->opt['custom_css'];
}
if ( isset( $args['custom_css'] ) && preg_match( '#?\\w+#', $args['stopwords'] ) ) {
add_settings_error(
'is_settings',
'invalid_is_stopwords',
__( 'Invalid Stopwords', 'add-search-to-menu' ),
'error'
);
$args['stopwords'] = $this->opt['stopwords'];
}
if ( isset( $args['custom_css'] ) && preg_match( '#?\\w+#', $args['synonyms'] ) ) {
add_settings_error(
'is_settings',
'invalid_is_synonyms',
__( 'Invalid Synonyms', 'add-search-to-menu' ),
'error'
);
$args['synonyms'] = $this->opt['synonyms'];
}
return $args;
}
/**
* Displays Search To Menu section description text.
*/
function menu_search_section_desc()
{
?>
$description ) {
if ( has_nav_menu( $location ) ) {
$check_value = ( isset( $this->opt['menus'][$location] ) ? $this->opt['menus'][$location] : 0 );
?>
', '' );
}
} else {
_e( 'Navigation menu location is not registered on the site.', 'add-search-to-menu' );
}
?>
opt['menu_name'][$value->slug] ) ? $this->opt['menu_name'][$value->slug] : 0 );
?>
', '' );
}
?>
opt['menus'] ) && !isset( $this->opt['menu_name'] ) || '' === $check_value ) {
return;
}
?>
>
", '' );
?>
", '' );
?>
' ;
$args = array(
'numberposts' => -1,
'post_type' => 'is_search_form',
);
$posts = get_posts( $args );
?>
opt['header_search'] ) ? $this->opt['header_search'] : 0 );
?>
-1,
'post_type' => 'is_search_form',
);
$posts = get_posts( $args );
if ( !empty($posts) ) {
$check_value = ( isset( $this->opt['footer_search'] ) ? $this->opt['footer_search'] : 0 );
?>
opt['header_menu_search'] ) ? $this->opt['header_menu_search'] : 0 );
$check_string = checked( 'header_menu_search', $check_value, false );
?>
opt['site_uses_cache'] ) ? $this->opt['site_uses_cache'] : 0 );
$check_string = checked( 'site_uses_cache', $check_value, false );
?>
opt['custom_css'] = ( isset( $this->opt['custom_css'] ) ? $this->opt['custom_css'] : '' );
?>
opt['stopwords'] = ( isset( $this->opt['stopwords'] ) ? $this->opt['stopwords'] : '' );
?>
opt['synonyms'] = ( isset( $this->opt['synonyms'] ) ? $this->opt['synonyms'] : '' );
?>
__( 'Do not load plugin CSS files', 'add-search-to-menu' ),
'js' => __( 'Do not load plugin JavaScript files', 'add-search-to-menu' ),
);
?>
' . __( 'Warning: Use with caution.', 'add-search-to-menu' ) . '';
IS_Help::help_info( $content );
$check_value = ( isset( $this->opt['default_search'] ) ? $this->opt['default_search'] : 0 );
?>
opt['disable'] ) ? $this->opt['disable'] : 0 );
?>
opt['easy_edit'] ) ? $this->opt['easy_edit'] : 0 );
?>