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

Change method for registering scripts/styles to fix conflict w/ Jetpack #26

Merged
merged 1 commit into from
Jan 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions php/class-wp-customize-posts-preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ public function tally_queried_posts( array $posts ) {
* Enqueue scripts for the customizer preview.
*/
public function enqueue_preview_scripts() {
$this->manager->posts->register_scripts();
$this->manager->posts->register_styles();
wp_enqueue_script( 'customize-preview-posts' );
}

Expand Down
24 changes: 8 additions & 16 deletions php/class-wp-customize-posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ public function __construct( WP_Customize_Manager $manager ) {
);
$this->sanitize_meta_filters = apply_filters( 'wp_customize_posts_sanitize_meta_filters', $this->sanitize_meta_filters );

add_action( 'wp_default_scripts', array( $this, 'register_scripts' ) );
add_action( 'wp_default_styles', array( $this, 'register_styles' ) );
add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'customize_controls_enqueue_scripts', array( $this, 'export_panel_data' ) );
add_action( 'customize_controls_print_footer_scripts', array( 'WP_Post_Edit_Customize_Control', 'render_templates' ) );
Expand Down Expand Up @@ -274,32 +272,26 @@ public function current_user_can_edit_post_meta( $post, $key, $value = '' ) {

/**
* Register scripts for Customize Posts.
*
* Fires after wp_default_scripts
*
* @param WP_Scripts $scripts
*/
public function register_scripts( &$scripts ) {
$scripts->add( 'customize-base-extensions', CUSTOMIZE_POSTS_PLUGIN_URL . 'js/customize-base-extensions.js', array( 'customize-base' ), false, 1 );
$scripts->add( 'customize-posts', CUSTOMIZE_POSTS_PLUGIN_URL . 'js/customize-posts.js', array( 'jquery', 'wp-backbone', 'customize-base-extensions', 'customize-controls', 'underscore' ), false, 1 );
$scripts->add( 'customize-preview-posts', CUSTOMIZE_POSTS_PLUGIN_URL . 'js/customize-preview-posts.js', array( 'jquery', 'customize-preview' ), false, 1 );
public function register_scripts() {
wp_register_script( 'customize-base-extensions', CUSTOMIZE_POSTS_PLUGIN_URL . 'js/customize-base-extensions.js', array( 'customize-base' ), false, 1 );
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 );
wp_register_script( 'customize-preview-posts', CUSTOMIZE_POSTS_PLUGIN_URL . 'js/customize-preview-posts.js', array( 'jquery', 'customize-preview' ), false, 1 );
}

/**
* Register styles for Customize Posts.
*
* Fires after wp_default_styles
*
* @param WP_Styles $styles
*/
public function register_styles( &$styles ) {
$styles->add( 'customize-posts-style', CUSTOMIZE_POSTS_PLUGIN_URL . 'css/customize-posts.css', array( 'wp-admin' ) );
public function register_styles() {
wp_register_style( 'customize-posts-style', CUSTOMIZE_POSTS_PLUGIN_URL . 'css/customize-posts.css', array( 'wp-admin' ) );
}

/**
* Enqueue scripts and styles for Customize Posts.
*/
public function enqueue_scripts() {
$this->register_scripts();
$this->register_styles();
wp_enqueue_script( 'customize-posts' );
wp_enqueue_style( 'customize-posts-style' );
}
Expand Down