plugin = new stdClass(); $this->plugin->name = 'full-screen-morphing-search'; $this->plugin->folder = plugin_dir_path( __FILE__ ); $this->plugin->url = plugin_dir_url( __FILE__ ); // Add actions if we're not in the WordPress Administration to load CSS, JS and the Morphing Search HTML. if ( ! is_admin() ) { add_action( 'wp_head', array( $this, 'full_screen_morphing_search_enqueue_css_js' ) ); add_action( 'wp_footer', array( $this, 'full_screen_morphing_search_output_morphing_search' ) ); } } /** * Loads the CSS and JS used for this plugin. * * @since 1.1 */ public function full_screen_morphing_search_enqueue_css_js() { // Load CSS. wp_enqueue_style( $this->plugin->name, $this->plugin->url . 'assets/css/full-screen-morphing-search.css', array(), '1.0', false ); // Load Javascript. wp_enqueue_script( $this->plugin->name, $this->plugin->url . 'assets/js/full-screen-morphing-search.js', array( 'jquery' ), '1.0', true ); // Associative Array 'fsmsp_options'. $fsmsp_options = get_option( 'fsmsp_options' ); // Declare PHP Variables to be passed to JS. $fsmsp_options_does_not_exists = ( null === get_option( 'fsmsp_options', null ) ) ? true : false; // Localize full-screen-morphing-search.js ! wp_localize_script( $this->plugin->name, 'fsmsp_vars', array( 'fsmsp_is_customize_preview' => is_customize_preview(), 'fsmsp_options_does_not_exists' => $fsmsp_options_does_not_exists, 'fsmsp_main_background_color' => esc_attr( ( ! empty( $fsmsp_options['fsmsp_main_background_color'] ) ? $fsmsp_options['fsmsp_main_background_color'] : '#f1f1f1' ) ), 'fsmsp_close_icon_color' => esc_attr( ( ! empty( $fsmsp_options['fsmsp_close_icon_color'] ) ? $fsmsp_options['fsmsp_close_icon_color'] : '#000' ) ), 'fsmsp_search_text_color' => esc_attr( ( ! empty( $fsmsp_options['fsmsp_search_text_color'] ) ? $fsmsp_options['fsmsp_search_text_color'] : '#c2c2c2' ) ), 'fsmsp_input_text_color' => esc_attr( ( ! empty( $fsmsp_options['fsmsp_input_text_color'] ) ? $fsmsp_options['fsmsp_input_text_color'] : '#ec5a62' ) ), 'fsmsp_magnifier_submit_color' => esc_attr( ( ! empty( $fsmsp_options['fsmsp_magnifier_submit_color'] ) ? $fsmsp_options['fsmsp_magnifier_submit_color'] : '#ddd' ) ), 'fsmsp_headings_color' => esc_attr( ( ! empty( $fsmsp_options['fsmsp_headings_color'] ) ? $fsmsp_options['fsmsp_headings_color'] : '#c2c2c2' ) ), 'fsmsp_columns_background_color' => esc_attr( ( ! empty( $fsmsp_options['fsmsp_columns_background_color'] ) ? $fsmsp_options['fsmsp_columns_background_color'] : '#ebebeb' ) ), 'fsmsp_columns_hover_background_color' => esc_attr( ( ! empty( $fsmsp_options['fsmsp_columns_hover_background_color'] ) ? $fsmsp_options['fsmsp_columns_hover_background_color'] : '#e4e4e5' ) ), 'fsmsp_links_color' => esc_attr( ( ! empty( $fsmsp_options['fsmsp_links_color'] ) ? $fsmsp_options['fsmsp_links_color'] : '#b2b2b2' ) ), 'fsmsp_links_hover_color' => esc_attr( ( ! empty( $fsmsp_options['fsmsp_links_hover_color'] ) ? $fsmsp_options['fsmsp_links_hover_color'] : '#ec5a62' ) ), 'fsmsp_search_form_text' => esc_attr( ( ! empty( $fsmsp_options['fsmsp_search_form_text'] ) ? $fsmsp_options['fsmsp_search_form_text'] : 'Search…' ) ), ) ); } /** * Outputs the HTML markup for our Full Screen Morphing Search * CSS hides this by default, and Javascript displays it when the user * interacts with any WordPress search field * * @since 1.1 */ public function full_screen_morphing_search_output_morphing_search() { $fsmsp_options = get_option( 'fsmsp_options' ); // Associative Array 'fsmsp_options'. ?>

Recent Posts

'post', 'posts_per_page' => '5', 'ignore_sticky_posts' => 1, ); $fsmsprp = new WP_Query( $args ); while ( $fsmsprp->have_posts() ) : $fsmsprp->the_post(); ?>

Top Categories

name ] = $fsmspcat->count; $fsmspcat_links[ $fsmspcat->name ] = get_category_link( $fsmspcat->term_id ); } asort( $fsmsptc_counts ); $fsmsptc_counts = array_reverse( $fsmsptc_counts, true ); $i = 0; foreach ( $fsmsptc_counts as $fsmspcat => $fsmsptc_count ) { $i++; $fsmspcat_link = esc_url( $fsmspcat_links[ $fsmspcat ] ); $fsmspcat = str_replace( ' ', ' ', esc_html( $fsmspcat ) ); if ( $i < 6 ) { ?>
'; } else { full_screen_morphing_search_category_icon(); } ?> " . esc_html( $fsmspcat . ' (' . $fsmsptc_count . ')' ) . ''; ?>

Top Tags

name ] = $fsmsptag->count; $fsmsptag_links[ $fsmsptag->name ] = get_tag_link( $fsmsptag->term_id ); } asort( $fsmsptt_counts ); $fsmsptt_counts = array_reverse( $fsmsptt_counts, true ); $i = 0; foreach ( $fsmsptt_counts as $fsmsptag => $fsmsptt_count ) { $i++; $tag_link = esc_url( $fsmsptag_links[ $fsmsptag ] ); $fsmsptag = str_replace( ' ', ' ', esc_html( $fsmsptag ) ); if ( $i < 6 ) { ?>
'; } else { full_screen_morphing_search_tag_icon(); } ?> " . esc_html( $fsmsptag . ' (' . $fsmsptt_count . ')' ) . ''; ?>
array( 'post', 'page' ), 'post_status' => 'publish', 'posts_per_page' => -1, // all posts and pages. ); $posts = get_posts( $fsmsp_ac ); if ( $posts ) : foreach ( $posts as $k => $post ) { $source[ $k ]['ID'] = $post->ID; $source[ $k ]['label'] = $post->post_title; // The name of the post. $source[ $k ]['permalink'] = get_permalink( $post->ID ); } ?>