File: /home/rockyroadprintin/www/wp-content/themes/consulting/admin/classes/stm-theme-admin-pages.php
<?php
class STM_Theme_Admin_Pages extends STM_Theme_Admin_Templates {
public static function init() {
add_action( 'admin_enqueue_scripts', [ self::class, 'load_admin_styles' ] );
add_action( 'admin_notices', [ self::class, 'envato_notice' ] );
add_action( 'admin_menu', [ self::class, 'register_pages' ] );
add_action( 'admin_head', [ self::class, 'admin_head' ] );
}
public static function load_admin_styles() {
wp_enqueue_style('stm-startup_css', get_template_directory_uri() . '/admin/assets/css/style.css', null, STM_ADMIN_VERSION, 'all');
}
public static function admin_head() {
?>
<script type="text/javascript">
var stm_install_plugin = '<?php echo esc_js( wp_create_nonce('stm_install_plugin') ); ?>';
</script>
<?php
}
public static function register_pages() {
$theme = STM_Theme_Info::get_theme_info();
$theme_name = $theme['name'];
$theme_name_sanitized = 'stm-admin';
/**
* Item Registration
*/
add_menu_page(
$theme_name,
$theme_name,
'manage_options',
$theme_name_sanitized,
[ self::class, 'startup' ],
get_template_directory_uri() . '/assets/admin/images/icon.png',
'2.11'
);
/**
* Demo Import
*/
add_submenu_page(
$theme_name_sanitized,
'Demo import',
'Demo import',
'manage_options',
$theme_name_sanitized . '-demos',
[ self::class, 'install_demo' ]
);
/**
* Plugins
*/
add_submenu_page(
$theme_name_sanitized,
'Plugins',
'Plugins',
'manage_options',
$theme_name_sanitized . '-plugins',
[ self::class, 'plugins' ]
);
/**
* Support page
*/
add_submenu_page(
$theme_name_sanitized,
'Support',
'Support',
'manage_options',
$theme_name_sanitized . '-support',
[ self::class, 'support' ]
);
/**
* System status
*/
add_submenu_page(
$theme_name_sanitized,
'System status',
'System status',
'manage_options',
$theme_name_sanitized . '-system-status',
[ self::class, 'system_status' ]
);
}
public static function envato_notice() {
if ( ! STM_Theme_Activation::check_token() ) {
return;
}
if ( !defined( 'ENVATO_MARKET_VERSION' ) ) {
echo '<div class="notice notice-warning __envato-market"><p>';
echo '<span class="dashicons dashicons-warning"></span> To get automatic theme updates please install, activate and set Envato Market plugin.';
echo sprintf( ' <a href="%s" class="stm-button stm-button-sm">%s</a>', 'admin.php?page=stm-admin-plugins', 'Install & activate now' );
echo '</p></div>';
}
}
public static function get_admin_tabs( $screen = 'welcome' ) {
$theme_name_sanitized = 'stm-admin';
$screen = $screen ?: $theme_name_sanitized;
?>
<?php if ( $notice = get_site_transient( 'stm_auth_notice') ) : ?>
<div class="stm-admin-message"><strong>Activation alert:</strong> <?php echo sanitize_text_field($notice); ?></div><br>
<?php endif; ?>
<div class="stm-nav-tab-wrapper">
<a href="<?php echo ( 'welcome' === $screen ) ? '#' : esc_url_raw( admin_url( 'admin.php?page=' . $theme_name_sanitized ) ); ?>" class="<?php echo ( 'welcome' === $screen ) ? 'nav-tab-active' : ''; ?> nav-tab">Product Registration</a>
<a href="<?php echo ( 'demos' === $screen ) ? '#' : esc_url_raw( admin_url( 'admin.php?page=' . $theme_name_sanitized . '-demos' ) ); ?>" class="<?php echo ( 'demos' === $screen ) ? 'nav-tab-active' : ''; ?> nav-tab">Install Demos</a>
<a href="<?php echo ( 'plugins' === $screen ) ? '#' : esc_url_raw( admin_url( 'admin.php?page=' . $theme_name_sanitized . '-plugins' ) ); ?>" class="<?php echo ( 'plugins' === $screen ) ? 'nav-tab-active' : ''; ?> nav-tab">Plugins</a>
<a href="<?php echo ( 'support' === $screen ) ? '#' : esc_url_raw( admin_url( 'admin.php?page=' . $theme_name_sanitized . '-support' ) ); ?>" class="<?php echo ( 'support' === $screen ) ? 'nav-tab-active' : ''; ?> nav-tab">Support</a>
<a href="<?php echo ( 'system-status' === $screen ) ? '#' : esc_url_raw( admin_url( 'admin.php?page=' . $theme_name_sanitized . '-system-status' ) ); ?>" class="<?php echo ( 'system-status' === $screen ) ? 'nav-tab-active' : ''; ?> nav-tab">System Status</a>
<a href="<?php echo esc_url_raw( admin_url( 'admin.php?page=' . STM_THEME_SETTINGS_URL ) ); ?>" class="nav-tab">Theme Options</a>
</div>
<?php
}
}