__( 'Next', 'admin-tour' ), 'prev_button' => __( 'Prev', 'admin-tour' ), 'finish_button' => __( 'Finish', 'admin-tour' ), 'go_to_button' => __( 'Go to', 'admin-tour' ), 'close_button_title' => __( 'Close', 'admin-tour' ), ) ); if ( ! is_admin() && is_user_logged_in() ) { $wat_screen_id = array( 'woocommerce' ); if ( function_exists( 'apt_current_dokan_page_id' ) ) { $wat_screen_id[] = apt_current_dokan_page_id(); } if ( in_array( $pointers['screen_id'], $wat_screen_id, true ) ) { $pointers['screen_id'] = $pointers['screen_id'] . '_' . get_current_user_id(); } } wp_localize_script( 'wat-pointer', 'WAT', array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'pointers' => $pointers['pointers'], 'security_nonce' => wp_create_nonce( 'wat_dismiss_pointer' ), 'i18n' => $i18n, 'current_screen' => $pointers['screen_id'], ) ); } } /** * Dismiss pointers. */ public function wat_dismiss_pointer() { check_ajax_referer( 'wat_dismiss_pointer', 'nonce' ); $screen = isset( $_POST['screen'] ) ? sanitize_title( wp_unslash( $_POST['screen'] ) ) : 'general'; $transient_key = 'wat_dismiss_pointers_' . $screen; set_transient( $transient_key, 1, apply_filters( 'wat_dismiss_expiration_time', 30 * DAY_IN_SECONDS ) ); wp_send_json_success(); } /** * Add admin bar. * * @param object $admin_bar Admin bar object. */ public function wat_admin_bar( $admin_bar ) { if ( function_exists( 'get_current_screen' ) && wat_allowed_roles() ) { $current_screen = get_current_screen(); if ( $current_screen && ! in_array( $current_screen->id, array( 'dashboard' ), true ) ) { if ( ! defined( 'WAT_SHOW_ADMIN_BAR_OPTION' ) || WAT_SHOW_ADMIN_BAR_OPTION ) { $args = array( 'id' => 'wat-screen-option-slug', // translators: %1$s to current screen ID. 'title' => wp_sprintf( __( 'Current Screen: %1$s', 'admin-tour' ), $current_screen->id ), 'href' => 'javascript:;', 'meta' => array( 'title' => __( 'Click to copy', 'admin-tour' ), ), ); $admin_bar->add_menu( $args ); } $pointers = wat_get_pointers( true ); if ( ! empty( $pointers ) && isset( $pointers[ $current_screen->id ] ) ) { $transient_key = 'wat_dismiss_pointers_' . $current_screen->id; if ( get_transient( $transient_key ) ) { $start_tour = array( 'id' => 'wat-start-tour', 'title' => __( 'Start Tour', 'admin-tour' ), 'href' => add_query_arg( 'wat_start_tour', 1 ), ); $admin_bar->add_menu( $start_tour ); } } } } } /** * Add click to copy script in admin footer. */ public function wat_admin_footer() { if ( wat_allowed_roles() ) { ?> $pointer ) { $s = 'general' === $s ? 'index.php' : $s; $screen = WP_Screen::get( $s ); $screen_name = $screen->id; $screen_name = explode( '-', $screen_name ); $screen_name = end( $screen_name ); $screen_name = preg_replace( '/[^A-Za-z0-9\-]/', ' ', $screen_name ); $screen_name = ucwords( $screen_name ); if ( isset( $pointer['screen_info'] ) && isset( $pointer['screen_info']['name'] ) ) { $screen_name = $pointer['screen_info']['name']; } $menu_url = '#'; if ( isset( $pointer['screen_info'] ) && isset( $pointer['screen_info']['url'] ) ) { $menu_url = add_query_arg( 'wat_start_tour', 1, $pointer['screen_info']['url'] ); } $extra_button_style = ''; if ( ! empty( $pointer_list ) ) { $extra_button_style = ' style="margin-top: 10px;"'; } $pointer_list .= '' . esc_html( $screen_name ) . '' . esc_html__( 'Start Tour', 'admin-tour' ) . ''; } ?>