Making WordPress.org


Ignore:
Timestamp:
01/20/2021 04:37:47 PM (5 years ago)
Author:
ryelle
Message:

Plugin Directory: Remove unused React code.

As part of the Plugin Directory refresh #1719, the UI was rewritten into a React app, but currently only the screenshot slider uses React. This removes all the React JS except for the screenshots, and flattens the Sass into less complex files. Additionally it updates the packages and JS build process to use @wordpress/scripts.

Fixes #5431.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/functions.php

    r10574 r10605  
    116116    // React is currently only used on detail pages.
    117117    if ( is_single() ) {
    118         wp_enqueue_script( 'wporg-plugins-client', get_stylesheet_directory_uri() . '/js/theme.js', array(), '20200527', true );
    119         wp_localize_script( 'wporg-plugins-client', 'pluginDirectory', array(
    120             'endpoint' => untrailingslashit( rest_url() ), // 'https://wordpress.org/plugins-wp/wp-json',
    121             'nonce'    => wp_create_nonce( 'wp_rest' ),
    122             'base'     => get_blog_details()->path,
    123             'userId'   => get_current_user_id(),
    124         ) );
    125         wp_localize_script( 'wporg-plugins-client', 'localeData', array(
    126             ''            => array(
    127                 'Plural-Forms' => _x( 'nplurals=2; plural=n != 1;', 'plural forms', 'wporg-plugins' ),
    128                 'Language'     => _x( 'en', 'language (fr, fr_CA)', 'wporg-plugins' ),
    129                 'localeSlug'   => _x( 'en', 'locale slug', 'wporg-plugins' ),
    130             ),
    131             'screenshots' => __( 'Screenshots', 'wporg-plugins' ),
    132         ) );
     118        $assets_path = dirname( __FILE__ ) . '/js/build/theme.asset.php';
     119        if ( file_exists( $assets_path ) ) {
     120            $script_info = require( $assets_path );
     121            wp_enqueue_script(
     122                'wporg-plugins-client',
     123                get_stylesheet_directory_uri() . '/js/build/theme.js',
     124                $script_info['dependencies'],
     125                $script_info['version'],
     126                true
     127            );
     128            wp_localize_script(
     129                'wporg-plugins-client',
     130                'localeData',
     131                array(
     132                    '' => array(
     133                        'Plural-Forms' => _x( 'nplurals=2; plural=n != 1;', 'plural forms', 'wporg-plugins' ),
     134                        'Language'     => _x( 'en', 'language (fr, fr_CA)', 'wporg-plugins' ),
     135                        'localeSlug'   => _x( 'en', 'locale slug', 'wporg-plugins' ),
     136                    ),
     137                    'screenshots' => __( 'Screenshots', 'wporg-plugins' ),
     138                )
     139            );
     140        }
    133141    }
    134142
Note: See TracChangeset for help on using the changeset viewer.