/** * Prevent switching to theme on old version of WordPress * * Switches to the previously activated theme or the default theme. * * @since 0.9 * @param string $theme_name Theme slug * @param object $theme Theme object */ function ctfw_old_wp_switch_theme($theme_name, $theme = false) { // Old theme still exists if (!$theme) { return; } // Is WordPress version too old for theme? if (ctfw_old_wp()) { if (CTFW_THEME_SLUG != $theme->get_template()) { switch_theme($theme->get_template(), $theme->get_stylesheet()); } elseif (CTFW_THEME_SLUG != WP_DEFAULT_THEME) { switch_theme(WP_DEFAULT_THEME); } unset($_GET['activated']); // Don't show regular notices (license activation, CTC plugin, etc.) ctfw_activation_remove_notices(); // Show notice saying to update WP then try again add_action('admin_notices', 'ctfw_old_wp_switch_theme_notice'); } }
/** * After Theme Activation * * Themes can request certain things to be done after activation: * * add_theme_support( 'ctfw-after-activation', array( * 'flush_rewrite_rules' => true, * 'replace_notice' => sprintf( __( 'Please follow the <a href="%s">Next Steps</a> now that the theme has been activated.', 'your-theme-textdomain' ), 'http://churchthemes.com/guides/user/getting-started/' ) * ) ); * * This does not affect the Customizer preview. * * @since 0.9 */ function ctfw_after_activation() { // Does theme support this? $support = get_theme_support('ctfw-after-activation'); if ($support) { // What to do $activation_tasks = isset($support[0]) ? $support[0] : array(); // Update .htaccess to make sure friendly URL's are in working order if (!empty($activation_tasks['flush_rewrite_rules'])) { flush_rewrite_rules(); } // Show notice to user if (!empty($activation_tasks['notice'])) { add_action('admin_notices', 'ctfw_activation_notice', 5); // show above other notices // Hide default notice if (!empty($activation_tasks['hide_default_notice'])) { add_action('admin_head', 'ctfw_hide_default_activation_notice'); } // Remove other notices when showing activation notice -- keep it simple ctfw_activation_remove_notices(); } } }