config = $config; self::$instance->configure(); self::$instance->hooks(); } } } /** * Configure data. * * @since 1.0.0 */ public function configure() { $theme = wp_get_theme(); if ( is_child_theme() ) { $this->theme_name = $theme->parent()->get( 'Name' ); $this->theme = $theme->parent(); } else { $this->theme_name = $theme->get( 'Name' ); $this->theme = $theme->parent(); } $this->theme_version = $theme->get( 'Version' ); $this->theme_slug = $theme->get_template(); $this->menu_name = isset( $this->config['menu_name'] ) ? $this->config['menu_name'] : sprintf( esc_html__( 'About %s', 'nexas' ), $this->theme_name ); $this->page_name = isset( $this->config['page_name'] ) ? $this->config['page_name'] : sprintf( esc_html__( 'About %s', 'nexas' ), $this->theme_name ); $this->tabs = isset( $this->config['tabs'] ) ? $this->config['tabs'] : array(); $this->page_slug = $this->theme_slug . '-about'; $this->page_url = admin_url( 'themes.php?page=' . $this->page_slug ); $this->notice = '
' . sprintf( esc_html__( 'Welcome! Thank you for choosing %1$s Theme. To take the advantage of our theme,Please make sure to visit theme info page.', 'nexas' ), esc_html( $this->theme_name ) ) . '
' . sprintf( esc_html__( 'Get started with %1$s', 'nexas' ), $this->theme_name ) . '' . esc_html__( 'Dismiss this notice', 'nexas' ) . '
'; } /** * Setup hooks. * * @since 1.0.0 */ public function hooks() { // Register menu. add_action( 'admin_menu', array( $this, 'register_info_page' ) ); // Admin notice. add_action( 'admin_notices', array( $this, 'admin_notice' ) ); // Load assets. add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) ); // Dismiss AJAX. add_action( 'wp_ajax_nexas_dismiss', array( $this, 'dismiss_callback' ) ); add_action( 'wp_ajax_nopriv_nexas_dismiss', array( $this, 'dismiss_callback' ) ); } /** * Register info page. * * @since 1.0.0 */ public function register_info_page() { // Add info page. add_theme_page( $this->menu_name, $this->page_name, 'activate_plugins', $this->page_slug, array( $this, 'render_page' ) ); } /** * Render page. * * @since 1.0.0 */ public function render_page() { ?>config['welcome_content'] ); ?>
render_quick_links(); ?> render_tabs(); ?> render_current_tab_content(); ?>'; foreach ( $quick_links as $link ) { $button_type = ''; if ( isset( $link['button'] ) ) { $button_type = 'button-' . esc_attr( $link['button'] ); } echo '' . esc_html( $link['text'] ) . ''; } echo '
'; } } /** * Callback for AJAX dismiss. * * @since 1.0.0 */ public function dismiss_callback() { $output = array(); $output['status'] = false; $userid = ( isset( $_GET['userid'] ) ) ? esc_attr( wp_unslash( $_GET['userid'] ) ) : ''; $wpnonce = ( isset( $_GET['_wpnonce'] ) ) ? esc_attr( wp_unslash( $_GET['_wpnonce'] ) ) : ''; if ( false === wp_verify_nonce( $wpnonce, 'nexas_dismiss_nonce' ) ) { wp_send_json( $output ); } update_user_meta( $userid, 'nexas_dismiss_status', 1 ); $output['status'] = true; wp_send_json( $output ); } } }