ID, self::DISMISSED_POINTERS, true ) ); $do_tour = ! in_array( 'oc_walthrough_pointer', $dismissed ); $welcome_modal_closed = false; $user_id = get_current_user_id(); if ( $user_id ) { // Retrieve the user meta $welcome_modal_closed = get_user_meta( $user_id, 'oc-welcome-modal-closed', true ); } // If not, we are good to continue if ( $do_tour && $welcome_modal_closed ) { // Enqueue WP pointer scripts and styles wp_enqueue_style( 'wp-pointer' ); wp_enqueue_script( 'wp-pointer' ); // Finish hooking to WP admin areas add_action( 'admin_print_footer_scripts', array( $this, 'walkthrough_footer_scripts', ) ); // Hook to admin footer scripts } add_action( 'admin_head', array( $this, 'css_admin_head' ) ); // Hook to admin head } // Used to add css of walkthrough public function css_admin_head() { ?> oc_generate_array(); // Determine the current page in query parameter $page = isset( $_GET['page'] ) ? $_GET['page'] . '-tour' : ''; $tab = isset( $_GET['tab'] ) ? $_GET['tab'] : ''; // Define other variables $function = ''; $button2 = ''; $id = ''; $options = array(); $show_pointer = false; if ( $page != '' && in_array( $page, array_keys( $tour ) ) && $tab == '' ) { $show_pointer = true; $parent = true; $screen = $page; if ( isset( $tour[ $page ]['id'] ) ) { $id = $tour[ $page ]['id']; } $options = array( self::CONTENT => $tour[ $page ][ self::CONTENT ], 'pointerWidth' => '342', 'position' => array( 'edge' => 'left', 'align' => 'left', ), ); $button2 = false; $function = ''; if ( isset( $tour[ $page ][ self::BUTTON_2 ] ) ) { $button2 = $tour[ $page ][ self::BUTTON_2 ]; } if ( isset( $tour[ $page ][ self::OC_FUNCTION ] ) ) { $function = $tour[ $page ][ self::OC_FUNCTION ]; } $parent = $tour[ $page ][ self::PARENT ]; } if ( $show_pointer && $id == '#onecom_themes' ) { $this->make_pointer_script( $id, $options, __( 'Got it!', 'onecom-wp' ), $button2, $function, $parent, $screen ); } elseif ( $show_pointer && $id == '#onecom_home' ) { $this->make_pointer_script( $id, $options, __( 'End tour', 'onecom-wp' ), $button2, $function, $parent, $screen ); } elseif ( $show_pointer ) { $this->make_pointer_script( $id, $options, __( 'Back', 'onecom-wp' ), $button2, $function, $parent, $screen ); } } /** * returns array which will be used for generating pointers(apart from default) */ public function oc_generate_array( $arr = array() ) { $home_page = $this->onecom_home_tour(); $themes_page = $this->onecom_theme_page_tour(); $plugins_page = $this->onecom_plugins_tour(); $staging_page = $this->onecom_staging_tour(); $health_monitor_page = $this->onecom_health_monitor_tour(); $cookie_banner_page = $this->onecom_utility_tour(); $error_page = $this->onecom_utility_tour(); $webshop = $this->onecom_utility_tour(); $one_photo = $this->onecom_utility_tour(); $maintenance_mode = $this->onecom_utility_tour(); $php_scanner = $this->onecom_utility_tour(); $performance_cache_page = $this->onecom_performance_cache_tour(); $wp_rocket_page = $this->onecom_performance_cache_tour(); // adding -tour to the page slug is required for generating the walkthrough $tours = array( 'onecom-home-tour' => $home_page, 'onecom-wp-themes-tour' => $themes_page, 'onecom-marketplace' => $plugins_page, 'onecom-wp-staging-tour' => $staging_page, 'onecom-wp-health-monitor-tour' => $health_monitor_page, 'onecom-wp-spam-protection-tour' => $health_monitor_page, 'onecom-wp-cookie-banner-tour' => $cookie_banner_page, 'onecom-wp-error-page-tour' => $error_page, 'onecom-php-compatibility-scanner-tour' => $php_scanner, 'onecom-wp-under-construction-tour' => $maintenance_mode, 'onecom-vcache-plugin-tour' => $performance_cache_page, 'onecom-wp-rocket-tour' => $wp_rocket_page, 'one-webshop-settings-tour' => $webshop, 'oc_onephoto-tour' => $one_photo, ); if ( isset( $arr ) && ! empty( $arr ) ) { return array_merge( $tours, $arr ); } return $tours; } /** * generates parameters array for landing page [i.e, home] */ public function onecom_home_tour() { $health_mn = array( 'id' => '#onecom_home', self::CONTENT => '
' . sprintf( __( 'Step %s of %s', 'onecom-wp' ), '1', '6' ) . '
' . '' . __( 'Here you find shortcuts to main features of our one.com plugin, such as performance and security tools.', 'onecom-wp' ) . __( 'Get inspired by our selected articles or browse the complete help centre.', 'onecom-wp' ) . __( "If you need support, you've also come to the right place.", 'onecom-wp' ) . '
', self::PARENT => true, ); $button2 = array( self::BUTTON_2 => __( 'Next', 'onecom-wp' ), self::OC_FUNCTION => 'window.location="' . menu_page_url( 'onecom-wp-health-monitor', false ) . '"', // We are relocating to "Settings" page with the 'site_title' query var ); $health_mn = array_merge( $health_mn, $button2 ); return $health_mn; } /** * generates parameters array for themes */ public function onecom_theme_page_tour() { return array( 'id' => '#onecom_themes', self::CONTENT => '' . sprintf( __( 'Step %s of %s', 'onecom-wp' ), '6', '6' ) . '
' . '' . __( 'Choose the perfect theme to suit your brand and give your site a professional appearance.', 'onecom-wp' ) . '
', //self::BUTTON_2 => __( 'Next', 'onecom-wp' ), //self::OC_FUNCTION => 'window.location="' . menu_page_url( 'onecom-marketplace', false ) . '"', self::PARENT => true, ); } /** * generates parameters array for plugins */ public function onecom_plugins_tour() { return array( 'id' => '#onecom_plugins', self::CONTENT => '' . sprintf( __( 'Step %s of %s', 'onecom-wp' ), '7', '7' ) . '
' . '' . __( 'Get a contact form, social media buttons, galleries and much more by adding plugins to your website.', 'onecom-wp' ) . '
', self::PARENT => true, ); } /** * generates parameters array for staging */ public function onecom_staging_tour() { $staging = array( 'id' => '#onecom_staging', self::CONTENT => '' . sprintf( __( 'Step %s of %s', 'onecom-wp' ), '4', '6' ) . '
' . '' . __( 'Create a copy fo your page to try out new plugins and themes without disturbing or breaking your existing website.', 'onecom-wp' ) . '
', self::PARENT => true, ); if ( is_plugin_active( self::WEBSHOP_PLUGIN ) ) { $button2 = array( self::BUTTON_2 => __( 'Next', 'onecom-wp' ), self::OC_FUNCTION => 'window.location="' . menu_page_url( 'one-webshop-settings', false ) . '"', ); $staging = array_merge( $staging, $button2 ); } else { $button2 = array( self::BUTTON_2 => __( 'Next', 'onecom-wp' ), self::OC_FUNCTION => 'window.location="' . menu_page_url( 'onecom-wp-error-page', false ) . '"', ); $staging = array_merge( $staging, $button2 ); } return $staging; } /** * generates parameters array for health & security category */ public function onecom_health_monitor_tour() { $health_mn = array( 'id' => '#onecom_health_security', self::CONTENT => '' . sprintf( __( 'Step %s of %s', 'onecom-wp' ), '2', '6' ) . '
' . '' . sprintf( __( '%1$s and %2$s keeps an eye on any issues, spammers, vulnerabilities and lets you fix most of them with just 1-click.', 'onecom-wp' ), 'Health Monitor', 'Spam Protection' ) . '
' . __( 'The tour can be restarted anytime from the dashboard.', 'onecom-wp' ) . '
', self::PARENT => true, ); if ( is_plugin_active( self::VCACHE_PLUGIN ) ) { $button2 = array( self::BUTTON_2 => __( 'Next', 'onecom-wp' ), self::OC_FUNCTION => 'window.location="' . menu_page_url( 'onecom-vcache-plugin', false ) . '"', // We are relocating to "Settings" page with the 'site_title' query var ); $health_mn = array_merge( $health_mn, $button2 ); } else { $button2 = array( self::BUTTON_2 => __( 'Next', 'onecom-wp' ), self::OC_FUNCTION => 'window.location="' . menu_page_url( 'onecom-wp-rocket', false ) . '"', ); $health_mn = array_merge( $health_mn, $button2 ); } return $health_mn; } /** * generates parameters array for performance tools */ public function onecom_performance_cache_tour() { // if ( ! is_plugin_active( self::VCACHE_PLUGIN ) ) { // return false; // } $performance_cache = array( 'id' => '#onecom-performance-tools', self::CONTENT => '' . sprintf( __( 'Step %s of %s', 'onecom-wp' ), '3', '6' ) . '
' . '' . sprintf( __( '%1$s, %2$s and %3$s will enhance the speed of your website and improve its overall performance.', 'onecom-wp' ), 'Performance Cache', 'CDN', 'WP Rocket' ) . '
', self::PARENT => true, ); $button2 = array( self::BUTTON_2 => __( 'Next', 'onecom-wp' ), self::OC_FUNCTION => 'window.location="' . menu_page_url( 'onecom-wp-staging', false ) . '"', // We are relocating to "Settings" page with the 'site_title' query var ); $performance_cache = array_merge( $performance_cache, $button2 ); return $performance_cache; } /** * generates parameters array for utility */ public function onecom_utility_tour() { $utility = array( 'id' => '#onecom-utility', self::CONTENT => '' . sprintf( __( 'Step %s of %s', 'onecom-wp' ), '5', '6' ) . '
' . '' . sprintf( __( 'Add features such as an %1$s, %2$s or a %3$s to increase the usability of your site.', 'onecom-wp' ), 'Error Page', 'Cookie Banner', 'Maintenance Mode' ) . '
', self::PARENT => true, ); $button2 = array( self::BUTTON_2 => __( 'Next', 'onecom-wp' ), self::OC_FUNCTION => 'window.location="' . menu_page_url( 'onecom-wp-themes', false ) . '"', ); $utility = array_merge( $utility, $button2 ); return $utility; } /** * generates Jquery script for the pointers */ public function make_pointer_script( $id, $options, $button1, $button2 = false, $function = '', $parent = false, $screen = '' ) { ?> false ) ) ); } elseif ( update_user_meta( get_current_user_id(), self::DISMISSED_POINTERS, $newpointers ) ) { wp_send_json_success( admin_url( 'admin.php?page=onecom-home' ) ); } } public function onecom_restart_tour() { $current_screen = get_current_screen(); if ( $current_screen->id === 'one-com_page_onecom-home' || $current_screen->id === 'dashboard' ) { ?>