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__( '%s info', 'storecommerce' ), $this->theme_name );
$this->page_name = isset( $this->config['page_name'] ) ? $this->config['page_name'] : sprintf( esc_html__( '%s info', 'storecommerce' ), $this->theme_name );
$this->tabs = isset( $this->config['tabs'] ) ? $this->config['tabs'] : array();
$this->page_slug = $this->theme_slug . '-details';
$this->page_url = admin_url( 'themes.php?page=' . $this->page_slug );
$this->notice = '
' . sprintf( esc_html__( 'Welcome! Thank you for choosing %1$s. To fully take advantage of the best our theme can offer please make sure you visit theme details page.', 'storecommerce' ), esc_html( $this->theme_name ) ) . '
' . sprintf( esc_html__( 'Get started with %1$s', 'storecommerce' ), $this->theme_name ) . '' . esc_html__( 'Dismiss this notice', 'storecommerce' ) . '
';
}
/**
* 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_storecommerce_dismiss', array( $this, 'dismiss_callback' ) );
add_action( 'wp_ajax_nopriv_storecommerce_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() {
?>
theme_name ); ?> - theme_version ); ?>
config['welcome-texts'] ) && ! empty( $this->config['welcome-texts'] ) ) : ?>
config['welcome-texts'] ); ?>
render_quick_links(); ?>
render_tabs(); ?>
render_current_tab_content(); ?>
config['tabs'] ) && ! empty( $this->config['tabs'] ) ) ? $this->config['tabs'] : array();
if ( empty( $tabs ) ) {
return;
}
$current_tab = isset( $_GET['tab'] ) ? wp_unslash( $_GET['tab'] ) : 'getting-started';
echo '';
foreach ( $tabs as $key => $tab ) {
if ( 'useful-plugins' === $key ) {
global $tgmpa;
if ( ! isset( $tgmpa ) ) {
continue;
}
}
$current_class = ' tab-' . $key;
$current_class .= ( $current_tab === $key ) ? ' nav-tab-active': '';
echo '' . esc_html( $tab ) . '';
}
echo '
';
}
/**
* Render current tab content.
*
* @since 1.0.0
*/
public function render_current_tab_content() {
$current_tab = isset( $_GET['tab'] ) ? wp_unslash( $_GET['tab'] ) : 'getting-started';
$method = str_replace( '-', '_', esc_attr( $current_tab ) );
if ( method_exists( $this, $method ) ) {
$this->{$method}();
} else {
printf( esc_html__( '%s() method does not exist.', 'storecommerce' ), $method );
}
}
/**
* Render getting started.
*
* @since 1.0.0
*/
public function getting_started() {
$content = ( isset( $this->config['getting_started'] ) ) ? $this->config['getting_started'] : array();
if ( empty( $content ) ) {
return;
}
?>
render_grid_item( $item ); ?>
config['support'] ) ) ? $this->config['support'] : array();
if ( empty( $content ) ) {
return;
}
?>
render_grid_item( $item ); ?>
config['useful_plugins'] ) ) ? $this->config['useful_plugins'] : array();
$tgmpa_url = $tgmpa->get_tgmpa_url();
$tgmpa_complete = $tgmpa->is_tgmpa_complete();
$plugins = $tgmpa->plugins;
?>
config['demo_content'] ) ) ? $this->config['demo_content'] : array();
if ( empty( $content ) ) {
return;
}
?>
get_tgmpa_url();
$tgmpa_complete = $tgmpa->is_tgmpa_complete();
if ( true !== $tgmpa_complete ) {
?>
config['free_vs_pro'] ) ) ? $this->config['free_vs_pro'] : array();
if ( empty( $content ) ) {
return;
}
?>
|
|
|
$value):
$class_1 = isset($value[2]) ? 'dashicons-before '.$value[2] : '';
$class_2 = isset($value[3]) ? 'dashicons-before '.$value[3] : '';
?>
|
|
|
config['upgrade_to_pro'] ) ) ? $this->config['upgrade_to_pro'] : array();
if ( empty( $content ) ) {
return;
}
?>
page_slug ), true ) ) {
wp_enqueue_style( 'storecommerce-info', get_template_directory_uri() . '/lib/info/css/info.css', array(), '1.0.0' );
wp_enqueue_script( 'storecommerce-info', get_template_directory_uri() . '/lib/info/js/info' . $min . '.js', array(), '1.0.0' );
}
}
/**
* Display admin notice.
*
* @since 1.0.0
*/
public function display_admin_notice() {
$screen_id = null;
$current_screen = get_current_screen();
if ( $current_screen ) {
$screen_id = $current_screen->id;
}
$user_id = get_current_user_id();
$dismiss_status = get_user_meta( $user_id, 'storecommerce_dismiss_status', true );
?>
render_notice(); ?>
array(
'href' => array(),
'class' => array(),
'data-userid' => array(),
'data-nonce' => array(),
),
'br' => array(),
'p' => array(),
'em' => array(),
'strong' => array(),
);
echo wp_kses( $this->notice, $allowed );
}
/**
* Render quick links.
*
* @since 1.0.0
*/
public function render_quick_links() {
$quick_links = ( isset( $this->config['quick_links'] ) ) ? $this->config['quick_links'] : array();
if ( ! empty( $quick_links ) ) {
echo '';
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, 'storecommerce_dismiss_nonce' ) ) {
wp_send_json( $output );
}
update_user_meta( $userid, 'storecommerce_dismiss_status', 1 );
$output['status'] = true;
wp_send_json( $output );
}
}
}