105 if ( $this->registered ) { |
105 if ( $this->registered ) { |
106 return; |
106 return; |
107 } |
107 } |
108 $this->registered = true; |
108 $this->registered = true; |
109 |
109 |
110 // Note that the widgets component in the customizer will also do |
110 /* |
111 // the 'admin_print_scripts-widgets.php' action in WP_Customize_Widgets::print_scripts(). |
111 * Note that the widgets component in the customizer will also do |
|
112 * the 'admin_print_scripts-widgets.php' action in WP_Customize_Widgets::print_scripts(). |
|
113 */ |
112 add_action( 'admin_print_scripts-widgets.php', array( $this, 'enqueue_admin_scripts' ) ); |
114 add_action( 'admin_print_scripts-widgets.php', array( $this, 'enqueue_admin_scripts' ) ); |
113 |
115 |
114 if ( $this->is_preview() ) { |
116 if ( $this->is_preview() ) { |
115 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_preview_scripts' ) ); |
117 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_preview_scripts' ) ); |
116 } |
118 } |
117 |
119 |
118 // Note that the widgets component in the customizer will also do |
120 /* |
119 // the 'admin_footer-widgets.php' action in WP_Customize_Widgets::print_footer_scripts(). |
121 * Note that the widgets component in the customizer will also do |
|
122 * the 'admin_footer-widgets.php' action in WP_Customize_Widgets::print_footer_scripts(). |
|
123 */ |
120 add_action( 'admin_footer-widgets.php', array( $this, 'render_control_template_scripts' ) ); |
124 add_action( 'admin_footer-widgets.php', array( $this, 'render_control_template_scripts' ) ); |
121 |
125 |
122 add_filter( 'display_media_states', array( $this, 'display_media_state' ), 10, 2 ); |
126 add_filter( 'display_media_states', array( $this, 'display_media_state' ), 10, 2 ); |
123 } |
127 } |
124 |
128 |
367 |
371 |
368 // Count how many times this attachment is used in widgets. |
372 // Count how many times this attachment is used in widgets. |
369 $use_count = 0; |
373 $use_count = 0; |
370 foreach ( $this->get_settings() as $instance ) { |
374 foreach ( $this->get_settings() as $instance ) { |
371 if ( isset( $instance['attachment_id'] ) && $instance['attachment_id'] === $post->ID ) { |
375 if ( isset( $instance['attachment_id'] ) && $instance['attachment_id'] === $post->ID ) { |
372 $use_count++; |
376 ++$use_count; |
373 } |
377 } |
374 } |
378 } |
375 |
379 |
376 if ( 1 === $use_count ) { |
380 if ( 1 === $use_count ) { |
377 $states[] = $this->l10n['media_library_state_single']; |
381 $states[] = $this->l10n['media_library_state_single']; |