Skip to content

Commit

Permalink
Merge pull request #21696 from Yoast/fix-adding-style-to-iframe
Browse files Browse the repository at this point in the history
Refactor assets enqueing hooks and callbacks
  • Loading branch information
thijsoo authored Oct 14, 2024
2 parents 5fe591e + ff2eb84 commit 025850b
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions admin/metabox/class-metabox.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public function __construct() {
}

add_action( 'add_meta_boxes', [ $this, 'add_meta_box' ] );
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] );
add_action( 'enqueue_block_assets', [ $this, 'enqueue' ] );
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_post_overview_assets' ] );
add_action( 'wp_insert_post', [ $this, 'save_postdata' ] );
add_action( 'edit_attachment', [ $this, 'save_postdata' ] );
add_action( 'add_attachment', [ $this, 'save_postdata' ] );
Expand Down Expand Up @@ -798,6 +799,22 @@ public function is_meta_value_disabled( $key ) {
return false;
}

/**
* Enqueues assets for the post overview page.
*
* @return void
*/
public function enqueue_post_overview_assets() {
global $pagenow;

$asset_manager = new WPSEO_Admin_Asset_Manager();

if ( self::is_post_overview( $pagenow ) ) {
$asset_manager->enqueue_style( 'edit-page' );
$asset_manager->enqueue_script( 'edit-page' );
}
}

/**
* Enqueues all the needed JS and CSS.
*
Expand All @@ -812,13 +829,6 @@ public function enqueue() {

$is_editor = self::is_post_overview( $pagenow ) || self::is_post_edit( $pagenow );

if ( self::is_post_overview( $pagenow ) ) {
$asset_manager->enqueue_style( 'edit-page' );
$asset_manager->enqueue_script( 'edit-page' );

return;
}

/* Filter 'wpseo_always_register_metaboxes_on_admin' documented in wpseo-main.php */
if ( ( $is_editor === false && apply_filters( 'wpseo_always_register_metaboxes_on_admin', false ) === false ) || $this->display_metabox() === false ) {
return;
Expand Down

0 comments on commit 025850b

Please sign in to comment.