wp_themes_dir example

case WP_CONTENT_DIR:
                    if ( ! $wp_filesystem->wp_content_dir() ) {
                        return new WP_Error( 'fs_no_content_dir', $this->strings['fs_no_content_dir'] );
                    }
                    break;
                case WP_PLUGIN_DIR:
                    if ( ! $wp_filesystem->wp_plugins_dir() ) {
                        return new WP_Error( 'fs_no_plugins_dir', $this->strings['fs_no_plugins_dir'] );
                    }
                    break;
                case get_theme_root():
                    if ( ! $wp_filesystem->wp_themes_dir() ) {
                        return new WP_Error( 'fs_no_themes_dir', $this->strings['fs_no_themes_dir'] );
                    }
                    break;
                default:
                    if ( ! $wp_filesystem->find_folder( $dir ) ) {
                        return new WP_Error( 'fs_no_folder', sprintf( $this->strings['fs_no_folder']esc_html( basename( $dir ) ) ) );
                    }
                    break;
            }
        }
        return true;
    }
// Remove maintenance file, we're done with potential site-breaking changes.     $wp_filesystem->delete( $maintenance_file );

    /* * 3.5 -> 3.5+ - an empty twentytwelve directory was created upon upgrade to 3.5 for some users, * preventing installation of Twenty Twelve. */
    if ( '3.5' === $old_wp_version ) {
        if ( is_dir( WP_CONTENT_DIR . '/themes/twentytwelve' )
            && ! file_exists( WP_CONTENT_DIR . '/themes/twentytwelve/style.css' )
        ) {
            $wp_filesystem->delete( $wp_filesystem->wp_themes_dir() . 'twentytwelve/' );
        }
    }

    /* * Copy new bundled plugins & themes. * This gives us the ability to install new plugins & themes bundled with * future versions of WordPress whilst avoiding the re-install upon upgrade issue. * $development_build controls us overwriting bundled themes and plugins when a non-stable release is being updated. */
    if ( ! is_wp_error( $result )
        && ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || ! CORE_UPGRADE_SKIP_NEW_BUNDLED )
    )
global $wp_filesystem;

        if ( is_wp_error( $removed ) ) {
            return $removed; // Pass errors through.         }

        if ( ! isset( $theme['theme'] ) ) {
            return $removed;
        }

        $theme      = $theme['theme'];
        $themes_dir = trailingslashit( $wp_filesystem->wp_themes_dir( $theme ) );
        if ( $wp_filesystem->exists( $themes_dir . $theme ) ) {
            if ( ! $wp_filesystem->delete( $themes_dir . $theme, true ) ) {
                return false;
            }
        }

        return true;
    }

    /** * Gets the WP_Theme object for a theme. * * @since 2.8.0 * @since 3.0.0 The `$theme` argument was added. * * @param string $theme The directory name of the theme. This is optional, and if not supplied, * the directory name from the last result will be used. * @return WP_Theme|false The theme's info object, or false `$theme` is not supplied * and the last result isn't set. */


    if ( ! is_object( $wp_filesystem ) ) {
        return new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.' ) );
    }

    if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) {
        return new WP_Error( 'fs_error', __( 'Filesystem error.' )$wp_filesystem->errors );
    }

    // Get the base plugin folder.     $themes_dir = $wp_filesystem->wp_themes_dir();
    if ( empty( $themes_dir ) ) {
        return new WP_Error( 'fs_no_themes_dir', __( 'Unable to locate WordPress theme directory.' ) );
    }

    /** * Fires immediately before a theme deletion attempt. * * @since 5.8.0 * * @param string $stylesheet Stylesheet of the theme to delete. */
    
Home | Imprint | This part of the site doesn't use cookies.