opt = $is->opt;
} else {
$this->opt = Ivory_Search::load_options();
}
$this->networkactive = is_multisite() && array_key_exists( plugin_basename( IS_PLUGIN_FILE ), (array) get_site_option( 'active_sitewide_plugins' ) );
}
/**
* Gets the instance of this class.
*
* @return self
*/
public static function getInstance()
{
if ( !self::$_instance instanceof self ) {
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Loads plugin javascript and stylesheet files in the admin area.
*/
function admin_enqueue_scripts( $hook_suffix )
{
if ( false === strpos( $hook_suffix, 'ivory-search' ) ) {
return;
}
wp_enqueue_style(
'is-admin-styles',
plugins_url( '/admin/css/ivory-search-admin.css', IS_PLUGIN_FILE ),
array(),
IS_VERSION
);
wp_register_script(
'is-admin-scripts',
plugins_url( '/admin/js/ivory-search-admin.js', IS_PLUGIN_FILE ),
array( 'jquery', 'jquery-ui-tabs', 'jquery-ui-accordion' ),
IS_VERSION,
true
);
$args = array(
'saveAlert' => __( "The changes you made will be lost if you navigate away from this page.", 'ivory-search' ),
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
);
if ( $this->custom_admin_pointers_check() ) {
add_action( 'admin_print_footer_scripts', array( $this, 'custom_admin_pointers_footer' ) );
wp_enqueue_script( 'wp-pointer' );
wp_enqueue_style( 'wp-pointer' );
}
wp_localize_script( 'is-admin-scripts', 'ivory_search', $args );
wp_enqueue_script( 'is-admin-scripts' );
}
function custom_admin_pointers_check()
{
$admin_pointers = $this->custom_admin_pointers();
foreach ( $admin_pointers as $pointer => $array ) {
if ( $array['active'] ) {
return true;
}
}
}
function custom_admin_pointers_footer()
{
$admin_pointers = $this->custom_admin_pointers();
?>
' . __( 'Edit Search Form', 'ivory-search' ) . '';
$new_pointer_content .= '
' . __( 'Click on the search form link to edit it.', 'ivory-search' ) . '
';
$new_pointer_content .= '
' . __( 'Edit the Default Search Form to manage the default WordPress search.', 'ivory-search' ) . '
';
return array(
$prefix . 'is_pointers' => array(
'content' => $new_pointer_content,
'anchor_id' => '#the-list tr:first-child a.row-title',
'edge' => 'left',
'align' => 'left',
'active' => !in_array( $prefix . 'is_pointers', $dismissed ),
),
);
}
/**
* 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_action_links( $links, $file )
{
if ( false !== strpos( $file, 'add-search-to-menu' ) ) {
$mylinks = array( '' . esc_html__( 'Support', 'ivory-search' ) . '' );
$links = array_merge( $mylinks, $links );
}
return $links;
}
/**
* Change the admin footer text on Ivory Search admin pages.
*/
public function admin_footer_text( $footer_text )
{
$screen = get_current_screen();
$is_ivory = strpos( $screen->id, 'ivory-search' );
// Check to make sure we're on a Ivory Search admin page.
if ( FALSE !== $is_ivory ) {
// Change the footer text
$footer_text = sprintf( __( 'If you like %1$s please leave us a %2$s rating. A huge thanks in advance!', 'ivory-search' ), sprintf( '%s', esc_html__( 'Ivory Search', 'ivory-search' ) ), '★★★★★' );
}
return $footer_text;
}
/**
* Displays plugin configuration notice in admin area.
*/
function all_admin_notices()
{
$hascaps = ( $this->networkactive ? is_network_admin() && current_user_can( 'manage_network_plugins' ) : current_user_can( 'manage_options' ) );
if ( $hascaps ) {
$screen = get_current_screen();
$is_ivory = strpos( $screen->id, 'ivory-search' );
if ( 0 !== $is_ivory && FALSE === $is_ivory && (!isset( $_GET['is_dismiss'] ) || 'notice_config' !== $_GET['is_dismiss']) ) {
if ( !isset( $this->opt['is_notices']['config'] ) || !$this->opt['is_notices']['config'] ) {
$url = ( is_network_admin() ? network_site_url() : site_url( '/' ) );
echo '
' . sprintf(
__( 'Thank you for using Ivory Search plugin. Please configure its search form and get support on support forum or contact us.', 'ivory-search' ),
$url . 'wp-admin/admin.php?page=ivory-search',
'https://ivorysearch.com/support/',
'https://ivorysearch.com/contact/'
) ;
echo '' . __( 'Dismiss', 'iovry-search' ) . '
' . esc_html__( 'Have you found Ivory Search plugin useful?', 'iovry-search' ) . '
' ;
echo '
' . esc_html__( 'We poured a lot of hours into creating it, and we\'d love it if you could give us a nice rating on the official plugin directory.', 'iovry-search' ) . '
', esc_html( $updated_message ) ) ;
return;
}
if ( 'failed' == $_REQUEST['message'] ) {
$updated_message = __( "There was an error saving the search form.", 'ivory-search' );
echo sprintf( '
%s
', esc_html( $updated_message ) ) ;
return;
}
if ( 'invalid' == $_REQUEST['message'] ) {
$updated_message = __( "There was a validation error saving the search form.", 'ivory-search' );
$updated_message2 = sprintf( __( "Please make sure you have not selected similar %s fields in the search form Includes and Excludes sections.", 'ivory-search' ), $_REQUEST['data'] );
echo sprintf( '