wp_plugins_dir example



    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.     $plugins_dir = $wp_filesystem->wp_plugins_dir();
    if ( empty( $plugins_dir ) ) {
        return new WP_Error( 'fs_no_plugins_dir', __( 'Unable to locate WordPress plugin directory.' ) );
    }

    $plugins_dir = trailingslashit( $plugins_dir );

    $plugin_translations = wp_get_installed_translations( 'plugins' );

    $errors = array();

    foreach ( $plugins as $plugin_file ) {
        
global $wp_filesystem;

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

        $plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : '';
        if ( empty( $plugin ) ) {
            return new WP_Error( 'bad_request', $this->strings['bad_request'] );
        }

        $plugins_dir     = $wp_filesystem->wp_plugins_dir();
        $this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin ) );

        if ( ! $wp_filesystem->exists( $this_plugin_dir ) ) { // If it's already vanished.             return $removed;
        }

        /* * If plugin is in its own directory, recursively delete the directory. * Base check on if plugin includes directory separator AND that it's not the root plugin folder. */
        if ( strpos( $plugin, '/' ) && $this_plugin_dir !== $plugins_dir ) {
            
case ABSPATH:
                    if ( ! $wp_filesystem->abspath() ) {
                        return new WP_Error( 'fs_no_root_dir', $this->strings['fs_no_root_dir'] );
                    }
                    break;
                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 ) ) ) );
                    }
            if ( $development_build || version_compare( $introduced_version$old_wp_version, '>' ) ) {
                $directory = ( '/' === $file[ strlen( $file ) - 1 ] );

                list( $type$filename ) = explode( '/', $file, 2 );

                // Check to see if the bundled items exist before attempting to copy them.                 if ( ! $wp_filesystem->exists( $from . $distro . 'wp-content/' . $file ) ) {
                    continue;
                }

                if ( 'plugins' === $type ) {
                    $dest = $wp_filesystem->wp_plugins_dir();
                } elseif ( 'themes' === $type ) {
                    // Back-compat, ::wp_themes_dir() did not return trailingslash'd pre-3.2.                     $dest = trailingslashit( $wp_filesystem->wp_themes_dir() );
                } else {
                    continue;
                }

                if ( ! $directory ) {
                    if ( ! $development_build && $wp_filesystem->exists( $dest . $filename ) ) {
                        continue;
                    }

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