/** * Start things up * * @since 1.6.3 */ public function __construct() { //set_theme_mod( 'theme_skin', 'agent' ); // for testing // Get current skin self::$current_skin = $this->get_current_skin(); $current_skin = self::$current_skin; // Enabled $this->enabled = $current_skin && 'base' != $current_skin ? true : false; $this->enabled = apply_filters('wpex_enable_skins', $this->enabled); // Return if disabled if (!$this->enabled) { return; } // Skins Paths define('WPEX_SKIN_DIR', WPEX_THEME_DIR . '/skins/'); define('WPEX_SKIN_DIR_URI', WPEX_THEME_URI . '/skins/'); // Admin if (is_admin()) { require_once WPEX_SKIN_DIR . 'skins-admin.php'; } // Load skin if needed if ($current_skin && 'base' != $current_skin) { $this->load_skin(); } }
/** * Settings page output */ public function create_admin_page() { ?> <div class="wrap wpex-skins-admin"> <h2>Theme Skins</h2> <?php // Check if admin is enabled $notice = apply_filters('wpex_skins_deprecated_notice', true); // Display notice if ($notice) { ?> <div class="notice error" style="display:block!important;padding:20px;"> <h4 style="margin:0 0 10px;font-size:16px;">Important Notice</h4> <p>Skins have been deprecated since Total 3.0.0. The theme has enough settings to allow you to create a design that fits your needs without loading extra bloat. If you select the "base" skin this admin panel will be removed and you will see an error message. To re-enable please visit the online snippets for this theme.</p> <p>We highly recommend you select the BASE skin and make all your edits via the Customizer to get the design you want or use a child theme (both are more optimized methods).</p> </div> <?php } // Get skins array $skins = WPEX_Skin_Loader::skins_array(); // Current skin from site_theme option $current_skin = wpex_active_skin(); // Get fallback from redux if (!$current_skin) { $data = get_option('wpex_options'); $current_skin = isset($data['site_theme']) ? $data['site_theme'] : 'base'; } ?> <form method="post" action="options.php"> <?php settings_fields('wpex_skins_options'); ?> <div class="wpex-skins-select theme-browser" id="theme_skin"> <?php // Loop through skins foreach ($skins as $key => $val) { $classes = 'wpex-skin theme'; $checked = $active = ''; if (!empty($current_skin) && $current_skin == $key) { $checked = 'checked'; $classes .= ' active'; } ?> <div class="<?php echo $classes; ?> "> <input type="radio" id="wpex-skin-<?php echo $key; ?> " name="theme_skin" value="<?php echo $key; ?> " <?php echo $checked; ?> class="wpex-skin-radio" /> <?php if (!empty($val['screenshot'])) { ?> <div class="theme-screenshot"> <img src="<?php echo esc_url($val['screenshot']); ?> " alt="Screenshot" /> </div> <?php } elseif (function_exists('wpex_placeholder_img_src')) { ?> <div class="theme-screenshot"> <img src="<?php echo wpex_placeholder_img_src(); ?> " /> </div> <?php } ?> <h3 class="theme-name"> <?php if ('active' == $active) { echo '<strong>Active:</strong> '; } ?> <?php echo $val['name']; ?> </h3> </div> <?php } ?> </div><!-- .wpex-skin --> <?php submit_button(); ?> </form> </div><!-- .wpex-skins-select --> <script type="text/javascript"> ( function($) { "use strict"; $( '.wpex-skin' ).click( function() { $( '.wpex-skin' ).removeClass( 'active' ); $( this ).addClass( 'active' ); var radio = $(this).find( '.wpex-skin-radio' ); radio.prop( 'checked', true ); event.preventDefault(); } ); } ) ( jQuery ); </script> <?php }