WordPress.org

Make WordPress Core

Changes between Initial Version and Version 3 of Ticket #21107


Ignore:
Timestamp:
06/29/12 09:15:34 (2 years ago)
Author:
scribu
Comment:

We have an example of this in Core:

wp_enqueue_style( 'thickbox' );
wp_enqueue_script( 'thickbox' );

could be replaced with wp_enqueue_resource( 'thickbox' ).

I'm not sure about the proposed API. Maybe have wp_register_resource() only reference script/style handles:

wp_register_resource( 'thickbox', array(
  'scripts' => array( 'thickbox' ),
  'styles'  => array( 'thickbox' ),
) );

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #21107

    • Property Cc johnbillion added
  • Ticket #21107 – Description

    initial v3  
    1919Here is some very rough pseudocode: 
    2020 
    21  
     21{{{ 
    2222wp_register_resource(‘Resource-1’, 
    2323  array( 
     
    3535  ) 
    3636) 
    37 [[BR]]do not call wp_register_style/ wp_register_script upon registering of the resource and wait until this resources or resource requiring this resource is enqueued.  This way the style and script are not enqueued separate from the resource and therefore each other since they are dependent on each other.  It would however register the resource in the resource queue. 
     37}}} 
    3838 
    39 [[BR]]wp_enqueue_resource(‘Resource-1’) would: 
    40 [[BR]]wp_enqueue _script(‘Resource-1’, ‘Script-1-URL’, array(’Script-1-A’,’Script-1-B’)); 
    41 [[BR]]wp_enqueue _style(‘Resource-1’, ‘Style-1-URL’, array(Style-1-A’, Style-1-B’)); 
    42 */ 
     39do not call wp_register_style/ wp_register_script upon registering of the resource and wait until this resources or resource requiring this resource is enqueued.  This way the style and script are not enqueued separate from the resource and therefore each other since they are dependent on each other.  It would however register the resource in the resource queue. 
     40 
     41{{{ 
     42wp_enqueue_resource(‘Resource-1’) would: 
     43wp_enqueue _script(‘Resource-1’, ‘Script-1-URL’, array(’Script-1-A’,’Script-1-B’)); 
     44wp_enqueue _style(‘Resource-1’, ‘Style-1-URL’, array(Style-1-A’, Style-1-B’)); 
     45}}} 
    4346 
    44472a 
    4548//wp_register_resource($handle, $resources=array(),$deps=array()) 
    4649 
     50{{{ 
    4751wp_register_resource(‘Resource-2’, 
    4852  array( 
     
    6165  array(‘Resource-1’) 
    6266); 
     67}}} 
     68 
     69{{{ 
     70wp_enqueue_resource(‘Resource-2’) would: 
     71wp_register_script(‘Resource-1’,’Scipt-1-URL’……) 
     72wp_register_style(‘Resource-1’,’Style-1-URL’……) 
     73wp_enqueue_script(‘Resource-2’, ‘Script-1-URL’, array(‘Resource-1’,’Script-1-A’,’Script-1-B’)) 
     74wp_enqueue_style(‘Resource-2’, ‘’, array(‘Resource-1’)) 
     75}}} 
    6376 
    6477 
    65 wp_enqueue_resource(‘Resource-2’) would: 
    66 [[BR]]wp_register_script(‘Resource-1’,’Scipt-1-URL’……) 
    67 [[BR]]wp_register_style(‘Resource-1’,’Style-1-URL’……) 
    68 [[BR]]wp_enqueue_script(‘Resource-2’, ‘Script-1-URL’, array(‘Resource-1’,’Script-1-A’,’Script-1-B’)) 
    69 [[BR]]wp_enqueue_style(‘Resource-2’, ‘’, array(‘Resource-1’)) 
    70  
    71 [[BR]][[BR]]wp_deenqueue_resource(‘Resource-2’) 
    72 [[BR]]would take dequeue it’s scripts and dependent scripts/styles (assuming those dependent scripts and styles were not enqueued elsewhere) 
     78`wp_deenqueue_resource(‘Resource-2’)` would take dequeue it’s scripts and dependent scripts/styles (assuming those dependent scripts and styles were not enqueued elsewhere) 
    7379 
    7480