Making WordPress.org

Changeset 12533


Ignore:
Timestamp:
04/12/2023 05:24:19 AM (20 months ago)
Author:
dd32
Message:

Plugin Directory: Store required plugins as an array, and an additional flag for when dependencies are not met by published WordPress.org-hosted plugins.

See #6921, [12532].

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin.php

    r12157 r12533  
    113113        }
    114114
    115         $result['requires']      = get_post_meta( $post_id, 'requires', true ) ?: false;
    116         $result['tested']        = get_post_meta( $post_id, 'tested', true ) ?: false;
    117         $result['requires_php']  = get_post_meta( $post_id, 'requires_php', true ) ?: false;
    118         $result['compatibility'] = array();
     115        $result['requires']         = get_post_meta( $post_id, 'requires', true ) ?: false;
     116        $result['tested']           = get_post_meta( $post_id, 'tested', true ) ?: false;
     117        $result['requires_php']     = get_post_meta( $post_id, 'requires_php', true ) ?: false;
     118        $result['requires_plugins'] = get_post_meta( $post_id, 'requires_plugins', true ) ?: [];
     119        $result['compatibility']    = array();
    119120
    120121        if ( class_exists( '\WPORG_Ratings' ) ) {
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php

    r12532 r12533  
    4242    // Plugin headers that are stored in plugin meta
    4343    public $plugin_headers = array(
    44         // Header         => meta_key
    45         'Name'            => 'header_name',
    46         'PluginURI'       => 'header_plugin_uri',
    47         'Author'          => 'header_author',
    48         'AuthorURI'       => 'header_author_uri',
    49         'TextDomain'      => 'header_textdomain',
    50         'RequiresPlugins' => 'requires_plugins'
     44        // Header    => meta_key
     45        'Name'       => 'header_name',
     46        'PluginURI'  => 'header_plugin_uri',
     47        'Author'     => 'header_author',
     48        'AuthorURI'  => 'header_author_uri',
     49        'TextDomain' => 'header_textdomain',
    5150
    5251        // These headers are stored in these fields, but are handled separately.
    53         // 'Version'     => 'version',
    54         // 'RequiresWP'  => 'requires',
    55         // 'RequiresPHP' => 'requires_php',
     52        // 'Version'         => 'version',
     53        // 'RequiresWP'      => 'requires',
     54        // 'RequiresPHP'     => 'requires_php',
     55        // 'RequiresPlugins' => 'requires_plugins'
    5656    );
    5757
     
    240240            $plugin_names[ $headers->Name ] = $headers->Version;
    241241            update_post_meta( $plugin->ID, 'plugin_name_history', wp_slash( $plugin_names ) );
     242        }
     243
     244        // Validate whether the dependencies are met by WordPress.org-hosted plugins.
     245        $requires_plugins       = array_map( 'trim', explode( ',', $headers->RequiresPlugins ) );
     246        $requires_plugins_unmet = false;
     247        foreach ( $requires_plugins as $requires_plugin_slug ) {
     248            // TODO: Add support for premium plugins.
     249            $requires_plugin_post = Plugin_Directory::get_plugin_post( $requires_plugin_slug );
     250            if (
     251                ! $requires_plugin_post ||
     252                'publish' !== $requires_plugin_post->post_status
     253            ) {
     254                $requires_plugins_unmet = true;
     255                break;
     256            }
     257        }
     258
     259        update_post_meta( $plugin->ID, 'requires_plugins', wp_slash( $requires_plugins ) );
     260        if ( $requires_plugins_unmet ) {
     261            update_post_meta( $plugin->ID, '_requires_plugins_unmet', true );
     262        } else {
     263            delete_post_meta( $plugin->ID, '_requires_plugins_unmet' );
    242264        }
    243265
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php

    r12532 r12533  
    378378                    'header_textdomain'        => $this->plugin['TextDomain'],
    379379                    'header_description'       => $this->plugin['Description'],
    380                     'requires_plugins'         => $this->plugin['RequiresPlugins'],
     380                    'requires_plugins'         => array_map( 'trim', explode( ',', $this->plugin['RequiresPlugins'] ) ),
    381381                    'assets_screenshots'       => array(),
    382382                    'assets_icons'             => array(),
Note: See TracChangeset for help on using the changeset viewer.