add_section( 'bloghash_section_help', array( 'title' => esc_html__( 'Help', 'bloghash' ), 'priority' => 999, ) ); // Reset tour. $customizer->add_setting( 'bloghash_help_reset_tour', array( 'sanitize_callback' => 'bloghash_no_sanitize', ) ); $customizer->add_control( new Bloghash_Customizer_Control_Button( $customizer, 'bloghash_help_reset_tour', array( 'label' => esc_html__( 'Take a Tour', 'bloghash' ), 'section' => 'bloghash_section_help', 'ajax_action' => 'bloghash_start_customizer_tour', 'button_text' => esc_html__( 'Start Tour', 'bloghash' ), 'settings' => 'bloghash_help_reset_tour', 'priority' => 10, ) ) ); // Bloghash docs. $customizer->add_setting( 'bloghash_help_bloghash_docs', array( 'sanitize_callback' => 'bloghash_no_sanitize', ) ); $customizer->add_control( new Bloghash_Customizer_Control_Button( $customizer, 'bloghash_help_bloghash_docs', array( 'label' => esc_html__( 'BlogHash Theme Guide', 'bloghash' ), 'section' => 'bloghash_section_help', 'button_text' => esc_html__( 'Help Articles', 'bloghash' ), 'button_url' => 'http://docs.peregrine-themes.com/', 'settings' => 'bloghash_help_bloghash_docs', 'priority' => 20, ) ) ); // Customizer docs. $customizer->add_setting( 'bloghash_help_customizer_docs', array( 'sanitize_callback' => 'bloghash_no_sanitize', ) ); $customizer->add_control( new Bloghash_Customizer_Control_Button( $customizer, 'bloghash_help_customizer_docs', array( 'label' => esc_html__( 'WordPress Customizer Tutorial', 'bloghash' ), 'section' => 'bloghash_section_help', 'button_text' => esc_html__( 'Customizer Guide', 'bloghash' ), 'button_url' => 'http://docs.peregrine-themes.com/the-ultimate-guide-to-the-wordpress-customizer/', 'settings' => 'bloghash_help_customizer_docs', 'priority' => 30, ) ) ); } } /** * Create pointers for current screen. * * @since 1.0.0 */ public function add_pointers() { $current_screen = get_current_screen(); if ( ! $current_screen ) { return; } $pointers = array(); // Get all pointers. switch ( $current_screen->id ) { case 'customize': $pointers = $this->customizer_pointers(); break; default: break; } // Check if any pointers are to be displayed. if ( empty( $pointers ) ) { return; } // Filter out dismissed pointers. $dismissed = get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ); $dismissed = explode( ',', (string) $dismissed ); foreach ( $pointers as $pointer_id => $pointer ) { if ( in_array( $pointer_id, $dismissed, true ) ) { $this->pointers = array(); break; } if ( empty( $pointer ) || empty( $pointer_id ) || empty( $pointer['target'] ) || empty( $pointer['options'] ) ) { $this->pointers = array(); break; } $this->pointers[ $pointer_id ] = $pointer; } // Check if any pointers are to be displayed. if ( empty( $this->pointers ) ) { return; } // Enqueue pointer script. wp_enqueue_style( 'wp-pointer' ); wp_enqueue_script( 'wp-pointer' ); } /** * Customizer pointers. * * @since 1.0.0 */ public function customizer_pointers() { $pointers = array( 'bloghash-pointer-01' => array( 'id' => 'bloghash-pointer-01', 'target' => '#customize-info', 'next' => 'bloghash-pointer-02', 'options' => array( 'content' => '
' . esc_html__( 'Welcome to your WordPress Site! Let us give you a quick overview to help you customize your website’s design. Or, come back to this tour at any time in the “Help” tab.', 'bloghash' ) . '
', 'position' => array( 'edge' => 'left', 'align' => 'top', ), ), 'focus' => array( 'type' => 'root', ), 'arrow' => 'arrow-top', ), 'bloghash-pointer-02' => array( 'id' => 'bloghash-pointer-02', 'target' => '#accordion-section-themes', 'previous' => 'bloghash-pointer-01', 'next' => 'bloghash-pointer-03', 'options' => array( 'content' => '' . sprintf( wp_kses( 'To help you get building as fast as possible, we pre-installed our favorite theme, %3$sBloghash%4$s, but you can change this theme at any time. %1$sRead more about Bloghash.%2$s', bloghash_get_allowed_html_tags() ), '', '', '', '' ) . '
', 'position' => array( 'edge' => 'left', 'align' => 'middle', ), ), 'focus' => array( 'type' => 'root', ), ), 'bloghash-pointer-03' => array( 'id' => 'bloghash-pointer-03', 'target' => '#accordion-panel-bloghash_panel_general', 'previous' => 'bloghash-pointer-02', 'next' => 'bloghash-pointer-04', 'options' => array( 'content' => '' . esc_html__( 'Give your site a personalized look. Here you can change your site layout, colors, fonts and more.', 'bloghash' ) . '
', 'position' => array( 'edge' => 'left', 'align' => 'middle', ), ), 'focus' => array( 'type' => 'root', ), ), 'bloghash-pointer-04' => array( 'id' => 'bloghash-pointer-04', 'target' => '#accordion-panel-bloghash_panel_blog', 'previous' => 'bloghash-pointer-03', 'next' => 'bloghash-pointer-05', 'options' => array( 'content' => '' . esc_html__( 'Customize the look and feel of your blog and introduce yourself to your viewers, customers or the world.', 'bloghash' ) . '
', 'position' => array( 'edge' => 'left', 'align' => 'middle', ), ), 'focus' => array( 'type' => 'root', ), ), 'bloghash-pointer-05' => array( 'id' => 'bloghash-pointer-05', 'target' => '#customize-header-actions', 'previous' => 'bloghash-pointer-04', 'options' => array( 'content' => '' . esc_html__( 'Done for now? Save, preview, publish or schedule when you want to publish the latest edits to your site. Or, close the customizer to go to your WordPress dashboard to modify your website’s settings or preferences. ', 'bloghash' ) . '
', 'position' => array( 'edge' => 'top', 'align' => 'left', ), ), 'focus' => array( 'type' => 'root', ), ), ); return $pointers; } /** * Print JavaScript if pointers are available. * * @since 1.0.0 */ public function add_pointers_script() { if ( empty( $this->pointers ) ) { return; } $pointers = wp_json_encode( $this->pointers ); // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped echo " "; // phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped } /** * AJAX handler to reset WP Pointers for the customizer tour. * * @since 1.0.0 */ public function start_customizer_tour() { // Security check. check_ajax_referer( 'bloghash_customizer' ); $customizer_pointers = $this->customizer_pointers(); if ( ! empty( $customizer_pointers ) ) { $dismissed = array_filter( explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ) ); foreach ( $customizer_pointers as $pointer => $config ) { $key = array_search( $pointer, $dismissed, true ); if ( false !== $key ) { unset( $dismissed[ $key ] ); } } $dismissed = implode( ',', $dismissed ); update_user_meta( get_current_user_id(), 'dismissed_wp_pointers', $dismissed ); // Reload page and start the tour. wp_send_json_success( array( 'reload' => true ) ); } // Error. wp_send_json_error(); } /** * Modify recommended plugins for Endurance users. * * @since 1.0.0 * @param Array $plugins Array of recommended plugins. * @return Array Modified array of recommended plugins. */ public function recommended_plugins( $plugins ) { if ( is_array( $plugins ) && ! empty( $plugins ) ) { foreach ( $plugins as $slug => $plugin ) { if ( isset( $plugin['endurance'] ) && false === $plugin['endurance'] ) { unset( $plugins[ $slug ] ); } } } return $plugins; } } endif; /** * The function which returns the one Bloghash_Endurance instance. */ function bloghash_endurance() { return Bloghash_Endurance::instance(); } bloghash_endurance();