Skip to content

Commit 59f02de

Browse files
Merge pull request #223 from Yoast/DUPP-56-enqueue-styles-in-classic-editor
2 parents 5c7119e + 5aae63b commit 59f02de

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/ui/classic-editor.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ public function register_hooks() {
6868
\add_filter( 'post_updated_messages', [ $this, 'change_scheduled_notice_classic_editor' ], 10, 1 );
6969

7070
\add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_classic_editor_scripts' ] );
71-
\add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_classic_editor_styles' ] );
71+
if ( \intval( Utils::get_option( 'duplicate_post_show_link_in', 'submitbox' ) ) === 1 ) {
72+
if ( \intval( Utils::get_option( 'duplicate_post_show_link', 'new_draft' ) ) === 1
73+
|| \intval( Utils::get_option( 'duplicate_post_show_link', 'rewrite_republish' ) ) === 1 ) {
74+
\add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_classic_editor_styles' ] );
75+
}
76+
}
7277

7378
// Remove slug editing from Classic Editor.
7479
\add_action( 'add_meta_boxes', [ $this, 'remove_slug_meta_box' ], 10, 2 );
@@ -102,7 +107,7 @@ public function enqueue_classic_editor_styles() {
102107
$id = \intval( \wp_unslash( $_GET['post'] ) );
103108
$post = \get_post( $id );
104109

105-
if ( ! \is_null( $post ) && $this->permissions_helper->is_rewrite_and_republish_copy( $post ) ) {
110+
if ( ! \is_null( $post ) && $this->permissions_helper->should_links_be_displayed( $post ) ) {
106111
$this->asset_manager->enqueue_styles();
107112
}
108113
}

tests/ui/classic-editor-test.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,28 @@ class Classic_Editor_Test extends TestCase {
1919
/**
2020
* Holds the object to create the action link to duplicate.
2121
*
22-
* @var Link_Builder
22+
* @var Link_Builder|\Mockery\MockInterface
2323
*/
2424
protected $link_builder;
2525

2626
/**
2727
* Holds the permissions helper.
2828
*
29-
* @var Permissions_Helper
29+
* @var Permissions_Helper|\Mockery\MockInterface
3030
*/
3131
protected $permissions_helper;
3232

3333
/**
3434
* Holds the asset manager.
3535
*
36-
* @var Asset_Manager
36+
* @var Asset_Manager|\Mockery\MockInterface
3737
*/
3838
protected $asset_manager;
3939

4040
/**
4141
* The instance.
4242
*
43-
* @var Classic_Editor
43+
* @var Classic_Editor&\Mockery\MockInterface
4444
*/
4545
protected $instance;
4646

@@ -93,12 +93,12 @@ public function test_register_hooks() {
9393

9494
$utils->expects( 'get_option' )
9595
->with( 'duplicate_post_show_link_in', 'submitbox' )
96-
->once()
96+
->twice()
9797
->andReturn( '1' );
9898

9999
$utils->expects( 'get_option' )
100100
->with( 'duplicate_post_show_link', 'new_draft' )
101-
->once()
101+
->twice()
102102
->andReturn( '1' );
103103

104104
$utils->expects( 'get_option' )
@@ -154,7 +154,7 @@ public function test_enqueue_classic_editor_scripts() {
154154
}
155155

156156
/**
157-
* Tests the successful enqueue_classic_editor_scripts function.
157+
* Tests the successful enqueue_classic_editor_styles function.
158158
*
159159
* @covers \Yoast\WP\Duplicate_Post\UI\Classic_Editor::enqueue_classic_editor_styles
160160
*/
@@ -169,7 +169,7 @@ public function test_enqueue_classic_editor_styles() {
169169
->with( 123 )
170170
->andReturn( $post );
171171

172-
$this->permissions_helper->expects( 'is_rewrite_and_republish_copy' )
172+
$this->permissions_helper->expects( 'should_links_be_displayed' )
173173
->with( $post )
174174
->andReturnTrue();
175175

0 commit comments

Comments
 (0)