Making WordPress.org


Ignore:
Timestamp:
01/12/2016 04:36:29 PM (9 years ago)
Author:
iandunn
Message:

WordCamp Budgets: Move payment-request script enqueing into module.

Since it's not shared across modules, it should live in the Payment Requests module.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/wordcamp-budgets.php

    r2276 r2277  
    1111     */
    1212    public function __construct() {
    13         add_action( 'admin_enqueue_scripts',  array( $this, 'enqueue_assets' ), 11 );
     13        add_action( 'admin_enqueue_scripts',  array( $this, 'enqueue_common_assets' ), 11 );
    1414    }
    1515
    1616    /**
    17      * Enqueue scripts and stylesheets
     17     * Enqueue scripts and stylesheets common to all modules
    1818     */
    19     public function enqueue_assets( $hook ) {
    20         global $post;
    21 
     19    public function enqueue_common_assets() {
    2220        // todo setup grunt to concat/minify js and css?
    23 
    24         // Register our assets
    25         wp_register_script(
    26             'payment-requests',
    27             plugins_url( 'javascript/payment-requests.js', __DIR__ ),
    28             array( 'jquery', 'jquery-ui-datepicker', 'media-upload', 'media-views' ),
    29             self::VERSION,
    30             true
    31         );
    32 
    33         wp_register_script(
    34             'wcp-attached-files',
    35             plugins_url( 'javascript/attached-files.js', __DIR__ ),
    36             array( 'payment-requests', 'backbone', 'wp-util' ),
    37             self::VERSION,
    38             true
    39         );
    4021
    4122        // Let's still include our .css file even if these are unavailable.
     
    5132            self::VERSION
    5233        );
    53 
    54         // Enqueue our assets if they're needed on the current screen
    55         $current_screen = get_current_screen();
    56 
    57         if ( in_array( $current_screen->id, array( 'edit-wcp_payment_request', 'wcp_payment_request' ) ) ) {
    58             wp_enqueue_script( 'payment-requests' );
    59             wp_enqueue_style( 'wordcamp-budgets' );
    60 
    61             if ( in_array( $current_screen->id, array( 'wcp_payment_request' ) ) && isset( $post->ID ) ) {
    62                 wp_enqueue_media( array( 'post' => $post->ID ) );
    63                 wp_enqueue_script( 'wcp-attached-files' );
    64             }
    65 
    66             wp_localize_script(
    67                 'payment-requests',
    68                 'wcpLocalizedStrings',      // todo merge into wordcampBudgets var
    69                 array(
    70                     'uploadModalTitle'  => __( 'Attach Supporting Documentation', 'wordcamporg' ),
    71                     'uploadModalButton' => __( 'Attach Files', 'wordcamporg' ),
    72                 )
    73             );
    74         }
    7534    }
    7635
Note: See TracChangeset for help on using the changeset viewer.