'preloader_plus_setting_page', 'page_title' => esc_html__( 'Preloader Plus' , 'bie' ), 'menu_title' => esc_html__( 'Preloader Plus' , 'bie' ), 'capability' => 'import', 'menu_slug' => 'preloader_plus_setting_page', ); $this->plugin_page = add_submenu_page( $plugin_page_setup['parent_slug'], $plugin_page_setup['page_title'], $plugin_page_setup['menu_title'], $plugin_page_setup['capability'], $plugin_page_setup['menu_slug'], array( $this, 'display_plugin_page' ) ); } /** * Plugin page display. * Output (HTML) is in another file. */ public function display_plugin_page() { require_once PRELOADER_PLUS_PATH . 'views/plugin-page.php'; } public function enqueue_scripts() { if( $this->is_preloader_active() ) { $preloader_plus_settings = wp_parse_args( get_option( 'preloader_plus_settings', array() ), preloader_plus_get_default() ); if( ( false !== $preloader_plus_settings['show_on_front'] && ! is_front_page() ) || ( false !== $preloader_plus_settings['show_once'] && isset( $_COOKIE['show_preloader_once'] ) ) ) { return; } wp_enqueue_style( 'preloader-plus', PRELOADER_PLUS_URL . 'assets/css/preloader-plus.min.css', array() , PRELOADER_PLUS_VERSION ); if( is_customize_preview() ) { wp_enqueue_script( 'preloader-plus-preview', PRELOADER_PLUS_URL . '/assets/js/preloader-plus-preview.js', array( 'jquery' ), PRELOADER_PLUS_VERSION, false ); wp_localize_script( 'preloader-plus-preview', 'preloader_plus', array( 'animation_delay' => $preloader_plus_settings['animation_delay'], 'animation_duration' => $preloader_plus_settings['animation_duration'], )); } else { wp_enqueue_script( 'preloader-plus', PRELOADER_PLUS_URL . '/assets/js/preloader-plus.min.js', array( 'jquery' ), PRELOADER_PLUS_VERSION, false ); // Get preloader options. wp_localize_script( 'preloader-plus', 'preloader_plus', array( 'animation_delay' => $preloader_plus_settings['animation_delay'], 'animation_duration' => $preloader_plus_settings['animation_duration'], )); } } } public function enqueue_admin_scripts( $page ) { if( 'toplevel_page_preloader_plus_setting_page' == $page ) { wp_enqueue_style( 'preloader-plus-options', PRELOADER_PLUS_URL . 'assets/admin/css/preloader-plus-options.css', array() , PRELOADER_PLUS_VERSION ); } wp_enqueue_style( 'preloader-plus-admin', PRELOADER_PLUS_URL . 'assets/admin/css/preloader-plus-admin.css', array() , PRELOADER_PLUS_VERSION ); // Enqueue scripts to manage reminder wp_enqueue_script( 'preloader-plus-rate-reminder', PRELOADER_PLUS_URL . '/assets/admin/js/preloader-plus-rate-reminder.js', array( 'jquery' ), PRELOADER_PLUS_VERSION, false ); $preloader_plus_rate_reminder_nonce = wp_create_nonce( 'preloader_plus_rate_reminder_nonce' ); wp_localize_script( 'preloader-plus-rate-reminder', 'preloader_plus_rate_reminder', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'nonce' => $preloader_plus_rate_reminder_nonce, 'notice' => 'preloader-plus-reminder', )); } public function enqueue_control_scripts() { wp_enqueue_style( 'preloader-plus-customizer', PRELOADER_PLUS_URL . 'assets/admin/css/preloader-plus-customizer.css', array() , PRELOADER_PLUS_VERSION ); } /** * Get preloader options. * * @since 1.0 */ public function get_options() { // Get preloader options. $preloader_plus_settings = wp_parse_args( get_option( 'preloader_plus_settings', array() ), preloader_plus_get_default() ); return $preloader_plus_settings; } public function add_new_elements() { $new_choices = array( 'custom_image' => esc_html__( 'Custom image', 'preloader-plus' ), 'icon' => esc_html__( 'Built-in icon', 'preloader-plus' ), 'blog_name' => esc_html__( 'Blog name', 'preloader-plus' ), 'custom_content' => esc_html__( 'Custom content', 'preloader-plus' ), 'counter' => esc_html__( 'Percentage counter', 'preloader-plus' ), 'progress_bar' => esc_html__( 'Progress bar', 'preloader-plus' ), ); return $new_choices; } /** * Set a cookie to show the preloader once per session. * * @since 2.2 */ public function show_once() { $settings = $this->get_options(); if( false !== $settings['show_once'] ) { if ( !isset( $_COOKIE['show_preloader_once'] ) ) { setcookie("show_preloader_once", 'show preloader once'); } else { return; } } } /** * Display the preloader. * * @since 1.0 */ public function preloader_view() { if( !$this->is_preloader_active() ) { return; } // Get preloader options. $settings = $this->get_options(); if( false !== $settings['show_once'] ) { if ( isset( $_COOKIE['show_preloader_once'] ) ) { return; } } // Doesn't show the preloader if show on front is true and this is not the front page if( false !== $settings['show_on_front'] && ! is_front_page() ) { return; } ?>

0

get_options(); if( in_array( 'progress_bar', $settings['elements'] ) && 'middle' !== $settings['prog_bar_position'] ) { ?>
format( 'Y-m-d' ) ); } } /** * Set reminder transients on plugins update. * * @since 2.1 */ function set_update_rate_reminder( $upgrader_object, $options ) { if ( $options['action'] == 'update' && $options['type'] == 'plugin' ) { if( ! get_transient( 'preloader_plus_rate_reminder_deleted' ) && ! get_transient( 'preloader_plus_rate_reminder' ) ) { $date = new \DateTime(); set_transient( 'preloader_plus_rate_reminder', $date->format( 'Y-m-d' ) ); } } } /** * Show reminders. * * @since 2.1 */ function show_rate_reminder() { if( get_transient( 'preloader_plus_rate_reminder' ) ) { $start_date = new \DateTime( get_transient( 'preloader_plus_rate_reminder' ) ); $start_date->add( new \DateInterval( 'P7D' ) ); $actual_date = new \DateTime(); if( $actual_date >= $start_date ) { $img_msg = sprintf( esc_html( '%1$s' ), 'Preloader Plus Plugin Author' ); $message = sprintf( esc_html__( '%1$s Hey, I noticed you are using my plugin %2$s that%3$ss awesome! Could you please do me a BIG favor and give it a 5-star rating on WordPress? Just to help us spread the word and boost our motivation. %4$s - %5$ sMassimo Sanfelice %6$s %7$s', 'preloader-plus' ), '', '–', ''', '
', '', '', '
' ); $message .= sprintf( esc_html__( '%1$s %2$s YES, YOU DESERVE IT %3$s %4$s REMIND ME LATER %3$s %5$s I ALREADY DID %3$s %6$s', 'preloader-plus' ), '', '', '', '', '', '' ); printf( '
%1$s
%2$s
', wp_kses_post( $img_msg ), wp_kses_post( $message ) ); } } } /** * Delete or update the rate reminder admin notice. * * @since 2.1 */ function preloader_plus_update_rate_reminder() { check_ajax_referer( 'preloader_plus_rate_reminder_nonce' ); if( isset( $_POST['notice'] ) && isset( $_POST['update'] ) ) { $notice = sanitize_text_field( $_POST['notice'] ); if( $_POST['update'] === 'preloader_plus_delete_rate_reminder' ) { delete_transient( 'preloader_plus_rate_reminder' ); if( ! get_transient( 'preloader_plus_rate_reminder' ) && set_transient( 'preloader_plus_rate_reminder_deleted', 'No reminder to show' ) ) { $response = array( 'error' => false, ); } else { $response = array( 'error' => true, ); } } if( $_POST['update'] === 'preloader_plus_ask_later' ) { $date = new \DateTime(); $date->add( new \DateInterval( 'P7D' ) ); $date_format = $date->format( 'Y-m-d' ); delete_transient( 'preloader_plus_rate_reminder' ); if( set_transient( 'preloader_plus_rate_reminder', $date_format ) ) { $response = array( 'error' => false, ); } else { $response = array( 'error' => true, 'error_type' => set_transient( 'preloader_plus_rate_reminder', $date_format ), ); } } wp_send_json( $response ); } } }