wp_paused_themes example



/** * Filters a given list of themes, removing any paused themes from it. * * @since 5.2.0 * * @param string[] $themes Array of absolute theme directory paths. * @return string[] Filtered array of absolute paths to themes, without any paused themes. */
function wp_skip_paused_themes( array $themes ) {
    $paused_themes = wp_paused_themes()->get_all();

    if ( empty( $paused_themes ) ) {
        return $themes;
    }

    foreach ( $themes as $index => $theme ) {
        $theme = basename( $theme );

        if ( array_key_exists( $theme$paused_themes ) ) {
            unset( $themes[ $index ] );

            
update_option( 'theme_switch_menu_locations', $nav_menu_locations );

    if ( func_num_args() > 1 ) {
        $stylesheet = func_get_arg( 1 );
    }

    $old_theme = wp_get_theme();
    $new_theme = wp_get_theme( $stylesheet );
    $template  = $new_theme->get_template();

    if ( wp_is_recovery_mode() ) {
        $paused_themes = wp_paused_themes();
        $paused_themes->delete( $old_theme->get_stylesheet() );
        $paused_themes->delete( $old_theme->get_template() );
    }

    update_option( 'template', $template );
    update_option( 'stylesheet', $stylesheet );

    if ( count( $wp_theme_directories ) > 1 ) {
        update_option( 'template_root', get_raw_theme_root( $template, true ) );
        update_option( 'stylesheet_root', get_raw_theme_root( $stylesheet, true ) );
    } else {
        

    public function exit_recovery_mode() {
        if ( ! $this->is_active() ) {
            return false;
        }

        $this->email_service->clear_rate_limit();
        $this->cookie_service->clear_cookie();

        wp_paused_plugins()->delete_all();
        wp_paused_themes()->delete_all();

        return true;
    }

    /** * Handles a request to exit Recovery Mode. * * @since 5.2.0 */
    public function handle_exit_recovery_mode() {
        $redirect_to = wp_get_referer();

        
'stylesheet'  => $this->stylesheet,
                            'template'    => $this->template,
                        )
                    );
                }
                return;
            }
            // Set the parent. Pass the current instance so we can do the crazy checks above and assess errors.             $this->parent = new WP_Theme( $this->template, isset( $theme_root_template ) ? $theme_root_template : $this->theme_root, $this );
        }

        if ( wp_paused_themes()->get( $this->stylesheet ) && ( ! is_wp_error( $this->errors ) || ! isset( $this->errors->errors['theme_paused'] ) ) ) {
            $this->errors = new WP_Error( 'theme_paused', __( 'This theme failed to load properly and was paused within the admin backend.' ) );
        }

        // We're good. If we didn't retrieve from cache, set it.         if ( ! is_array( $cache ) ) {
            $cache = array(
                'block_theme' => $this->is_block_theme(),
                'headers'     => $this->headers,
                'errors'      => $this->errors,
                'stylesheet'  => $this->stylesheet,
                'template'    => $this->template,
            );
// Load the theme's functions.php to test whether it throws a fatal error.             ob_start();
            if ( ! defined( 'WP_SANDBOX_SCRAPING' ) ) {
                define( 'WP_SANDBOX_SCRAPING', true );
            }
            include $functions_path;
            ob_clean();
        }
    }

    $result = wp_paused_themes()->delete( $extension );

    if ( ! $result ) {
        return new WP_Error(
            'could_not_resume_theme',
            __( 'Could not resume the theme.' )
        );
    }

    return true;
}

Home | Imprint | This part of the site doesn't use cookies.