public static function check_roles() { if (current_user_can('edit_theme_options')) { if (!Wordless::theme_is_wordless_compatible()) { // Display a notice if options.php isn't present in the theme add_action('admin_notices', array('WordlessAdmin', 'add_notice')); } // If the user can edit theme options, let the fun begin! add_action('admin_menu', array('WordlessAdmin', 'add_page')); } }
public static function initialize() { if (Wordless::theme_is_wordless_compatible()) { self::load_i18n(); self::require_helpers(); self::require_theme_initializers(); self::register_activation(); self::register_preprocessors(); self::register_preprocessor_actions(); } self::load_admin_page(); }
public static function add_notice() { // Get a list of missing directories $dirs_missing = Wordless::theme_is_wordless_compatible(true); echo '<div class="error"><p>'; echo sprintf(__('Your current theme does not seem to be a Wordless-compatible theme! <a href="%2$s" target="_blank">%1$s</a> (or <a href="%4$s" target="_blank">%3$s</a>)', "wl"), __('Create a new Wordless theme', "wl"), admin_url('admin.php?page=wordless'), __('learn more about Wordless', "wl"), 'https://github.com/welaika/wordless#readme'); echo "</p>"; echo "<p><strong>Error found:</strong></p>"; echo "<ul>"; foreach ($dirs_missing as $dir) { echo "<li>Missing Directory: " . $dir . "</li>"; } echo "</ul>"; echo "</div>"; }
public static function start() { parent::initialize(); // Determine theme name foreach (scandir(self::$current_dir . '/wp-content/themes') as $theme_dir) { if (in_array($theme_dir, array('.', '..', 'index.php')) && !is_dir($theme_dir)) { continue; } $previous_theme_name = WordlessBridge::$theme_name; WordlessBridge::$theme_name = $theme_dir; if (Wordless::theme_is_wordless_compatible()) { if (basename(self::$current_dir) == $theme_dir) { // A theme with the same name as the site is Wordless-compatible, this is probably the one we want break; } } else { WordlessBridge::$theme_name = $previous_theme_name; } } require get_template_directory() . '/config/initializers/wordless_preferences.php'; Wordless::register_preprocessors(); Wordless::compile_assets(); }