Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.

Commit 169b043

Browse files
committed
Merge pull request #26 from xwp/feature/jetpack-script-enqueue-compat
Change method for registering scripts/styles to fix conflict w/ Jetpack
2 parents 80ded6a + 1a33609 commit 169b043

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

php/class-wp-customize-posts-preview.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ public function tally_queried_posts( array $posts ) {
192192
* Enqueue scripts for the customizer preview.
193193
*/
194194
public function enqueue_preview_scripts() {
195+
$this->manager->posts->register_scripts();
196+
$this->manager->posts->register_styles();
195197
wp_enqueue_script( 'customize-preview-posts' );
196198
}
197199

php/class-wp-customize-posts.php

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,6 @@ public function __construct( WP_Customize_Manager $manager ) {
113113
);
114114
$this->sanitize_meta_filters = apply_filters( 'wp_customize_posts_sanitize_meta_filters', $this->sanitize_meta_filters );
115115

116-
add_action( 'wp_default_scripts', array( $this, 'register_scripts' ) );
117-
add_action( 'wp_default_styles', array( $this, 'register_styles' ) );
118116
add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
119117
add_action( 'customize_controls_enqueue_scripts', array( $this, 'export_panel_data' ) );
120118
add_action( 'customize_controls_print_footer_scripts', array( 'WP_Post_Edit_Customize_Control', 'render_templates' ) );
@@ -274,32 +272,26 @@ public function current_user_can_edit_post_meta( $post, $key, $value = '' ) {
274272

275273
/**
276274
* Register scripts for Customize Posts.
277-
*
278-
* Fires after wp_default_scripts
279-
*
280-
* @param WP_Scripts $scripts
281275
*/
282-
public function register_scripts( &$scripts ) {
283-
$scripts->add( 'customize-base-extensions', CUSTOMIZE_POSTS_PLUGIN_URL . 'js/customize-base-extensions.js', array( 'customize-base' ), false, 1 );
284-
$scripts->add( 'customize-posts', CUSTOMIZE_POSTS_PLUGIN_URL . 'js/customize-posts.js', array( 'jquery', 'wp-backbone', 'customize-base-extensions', 'customize-controls', 'underscore' ), false, 1 );
285-
$scripts->add( 'customize-preview-posts', CUSTOMIZE_POSTS_PLUGIN_URL . 'js/customize-preview-posts.js', array( 'jquery', 'customize-preview' ), false, 1 );
276+
public function register_scripts() {
277+
wp_register_script( 'customize-base-extensions', CUSTOMIZE_POSTS_PLUGIN_URL . 'js/customize-base-extensions.js', array( 'customize-base' ), false, 1 );
278+
wp_register_script( 'customize-posts', CUSTOMIZE_POSTS_PLUGIN_URL . 'js/customize-posts.js', array( 'jquery', 'wp-backbone', 'customize-base-extensions', 'customize-controls', 'underscore' ), false, 1 );
279+
wp_register_script( 'customize-preview-posts', CUSTOMIZE_POSTS_PLUGIN_URL . 'js/customize-preview-posts.js', array( 'jquery', 'customize-preview' ), false, 1 );
286280
}
287281

288282
/**
289283
* Register styles for Customize Posts.
290-
*
291-
* Fires after wp_default_styles
292-
*
293-
* @param WP_Styles $styles
294284
*/
295-
public function register_styles( &$styles ) {
296-
$styles->add( 'customize-posts-style', CUSTOMIZE_POSTS_PLUGIN_URL . 'css/customize-posts.css', array( 'wp-admin' ) );
285+
public function register_styles() {
286+
wp_register_style( 'customize-posts-style', CUSTOMIZE_POSTS_PLUGIN_URL . 'css/customize-posts.css', array( 'wp-admin' ) );
297287
}
298288

299289
/**
300290
* Enqueue scripts and styles for Customize Posts.
301291
*/
302292
public function enqueue_scripts() {
293+
$this->register_scripts();
294+
$this->register_styles();
303295
wp_enqueue_script( 'customize-posts' );
304296
wp_enqueue_style( 'customize-posts-style' );
305297
}

0 commit comments

Comments
 (0)