get( 'Name' ); add_theme_page( $page_menu_title, $page_menu_title, 'edit_theme_options', 'azera-shop-welcome', array( $this, 'azera_shop_welcome_screen' ) ); } /** * Adds an admin notice upon successful activation. */ public function azera_shop_activation_admin_notice() { global $pagenow; if ( is_admin() && ('themes.php' == $pagenow) && isset( $_GET['activated'] ) ) { add_action( 'admin_notices', array( $this, 'azera_shop_welcome_admin_notice' ), 99 ); } } /** * Display an admin notice linking to the welcome screen */ public function azera_shop_welcome_admin_notice() { ?>

', '' ); ?>

$nr_actions_required, 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'template_directory' => get_template_directory_uri(), 'no_required_actions_text' => __( 'Hooray! There are no required actions for you right now.', 'azera-shop' ), ) ); } } /** * Load scripts for customizer page */ public function azera_shop_welcome_scripts_for_customizer() { wp_enqueue_style( 'azera-shop-welcome-screen-customizer-css', get_template_directory_uri() . '/inc/admin/welcome-screen/css/welcome_customizer.css' ); wp_enqueue_script( 'azera-shop-welcome-screen-customizer-js', get_template_directory_uri() . '/inc/admin/welcome-screen/js/welcome_customizer.js', array( 'jquery' ), '20120206', true ); global $azera_shop_required_actions; $nr_actions_required = 0; /* get number of required actions */ if ( get_option( 'azera_shop_show_required_actions' ) ) : $azera_shop_show_required_actions = get_option( 'azera_shop_show_required_actions' ); else : $azera_shop_show_required_actions = array(); endif; if ( ! empty( $azera_shop_required_actions ) ) : foreach ( $azera_shop_required_actions as $azera_shop_required_action_value ) : if ( ( ! isset( $azera_shop_required_action_value['check'] ) || ( isset( $azera_shop_required_action_value['check'] ) && ( $azera_shop_required_action_value['check'] == false ) ) ) && ((isset( $azera_shop_show_required_actions[ $azera_shop_required_action_value['id'] ] ) && ($azera_shop_show_required_actions[ $azera_shop_required_action_value['id'] ] == true)) || ! isset( $azera_shop_show_required_actions[ $azera_shop_required_action_value['id'] ] ) ) ) : $nr_actions_required++; endif; endforeach; endif; wp_localize_script( 'azera-shop-welcome-screen-customizer-js', 'azeraShopWelcomeScreenCustomizerObject', array( 'nr_actions_required' => $nr_actions_required, 'aboutpage' => esc_url( admin_url( 'themes.php?page=azera-shop-welcome#actions_required' ) ), 'customizerpage' => esc_url( admin_url( 'customize.php#actions_required' ) ), ) ); } /** * Dismiss required actions */ public function azera_shop_dismiss_required_action_callback() { global $azera_shop_required_actions; $azera_shop_dismiss_id = (isset( $_GET['dismiss_id'] )) ? $_GET['dismiss_id'] : 0; echo $azera_shop_dismiss_id; /* this is needed and it's the id of the dismissable required action */ if ( ! empty( $azera_shop_dismiss_id ) ) : /* if the option exists, update the record for the specified id */ if ( get_option( 'azera_shop_show_required_actions' ) ) : $azera_shop_show_required_actions = get_option( 'azera_shop_show_required_actions' ); $azera_shop_show_required_actions[ $azera_shop_dismiss_id ] = false; update_option( 'azera_shop_show_required_actions',$azera_shop_show_required_actions ); /* create the new option,with false for the specified id */ else : $azera_shop_show_required_actions_new = array(); if ( ! empty( $azera_shop_required_actions ) ) : foreach ( $azera_shop_required_actions as $azera_shop_required_action ) : if ( $azera_shop_required_action['id'] == $azera_shop_dismiss_id ) : $azera_shop_show_required_actions_new[ $azera_shop_required_action['id'] ] = false; else : $azera_shop_show_required_actions_new[ $azera_shop_required_action['id'] ] = true; endif; endforeach; update_option( 'azera_shop_show_required_actions', $azera_shop_show_required_actions_new ); endif; endif; endif; die(); // this is required to return a proper result } /** * Welcome screen content */ public function azera_shop_welcome_screen() { require_once( ABSPATH . 'wp-load.php' ); require_once( ABSPATH . 'wp-admin/admin.php' ); require_once( ABSPATH . 'wp-admin/admin-header.php' ); ?>