Making WordPress.org


Ignore:
Timestamp:
12/15/2022 05:57:02 PM (4 years ago)
Author:
coffee2code
Message:

Plugin Directory: Add initial plugin categorization features to the theme.

See #5426.

File:
1 edited

Legend:

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

    r12324 r12336  
    8888                wp_enqueue_script( 'wporg-plugins-popover', get_stylesheet_directory_uri() . '/js/popover.js', array( 'jquery' ), '20171002', true );
    8989                wp_enqueue_script( 'wporg-plugins-faq', get_stylesheet_directory_uri() . '/js/section-faq.js', array( 'jquery' ), filemtime( __DIR__ . '/js/section-faq.js' ), true );
     90
     91                $post = get_post();
     92                if ( $post && current_user_can( 'plugin_admin_edit', $post ) ) {
     93                        wp_enqueue_script( 'wporg-plugins-categorization', get_stylesheet_directory_uri() . '/js/section-categorization.js', array( 'jquery' ), filemtime( __DIR__ . '/js/section-categorization.js' ), true );
     94                        wp_localize_script( 'wporg-plugins-categorization', 'categorizationOptions', [
     95                                'restUrl'    => get_rest_url(),
     96                                'restNonce'  => wp_create_nonce( 'wp_rest' ),
     97                                'pluginSlug' => $post->post_name,
     98                        ] );
     99                }
    90100        }
    91101
     
    230240 */
    231241function custom_body_class( $classes ) {
     242        $post = get_post();     
     243
    232244        $classes[] = 'no-js';
     245
     246        if ( $post && is_singular( 'plugin' ) ) {
     247                if ( has_term( 'commercial', 'plugin_business_model', $post ) ) {
     248                        $classes[] = 'is-commercial-plugin';
     249                }
     250
     251                if ( has_term( 'community', 'plugin_business_model', $post ) ) {
     252                        $classes[] = 'is-community-plugin';
     253                }
     254        }
     255
    233256        return $classes;
    234257}
Note: See TracChangeset for help on using the changeset viewer.