• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / duplicate-post / 21727773261

05 Feb 2026 08:43PM UTC coverage: 58.14% (+0.02%) from 58.118%
21727773261

push

github

web-flow
Merge pull request #453 from Yoast/JRF/composer-update-yoastcs

Update to YoastCS 3.3.0

66 of 118 new or added lines in 29 files covered. (55.93%)

4 existing lines in 2 files now uncovered.

1532 of 2635 relevant lines covered (58.14%)

7.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.26
/src/ui/asset-manager.php
1
<?php
2

3
namespace Yoast\WP\Duplicate_Post\UI;
4

5
use Yoast\WP\Duplicate_Post\Utils;
6

7
/**
8
 * Duplicate Post class to manage assets.
9
 */
10
class Asset_Manager {
11

12
        /**
13
         * Adds hooks to integrate with WordPress.
14
         *
15
         * @return void
16
         */
17
        public function register_hooks() {
2✔
18
                \add_action( 'init', [ $this, 'register_styles' ] );
2✔
19
                \add_action( 'init', [ $this, 'register_scripts' ] );
2✔
20
        }
21

22
        /**
23
         * Registers the styles.
24
         *
25
         * @return void
26
         */
27
        public function register_styles() {
2✔
28
                \wp_register_style( 'duplicate-post', \plugins_url( '/css/duplicate-post.css', \DUPLICATE_POST_FILE ), [], \DUPLICATE_POST_CURRENT_VERSION );
2✔
29
                \wp_register_style( 'duplicate-post-options', \plugins_url( '/css/duplicate-post-options.css', \DUPLICATE_POST_FILE ), [], \DUPLICATE_POST_CURRENT_VERSION );
2✔
30
        }
31

32
        /**
33
         * Registers the scripts.
34
         *
35
         * @return void
36
         */
37
        public function register_scripts() {
2✔
38
                $flattened_version = Utils::flatten_version( \DUPLICATE_POST_CURRENT_VERSION );
2✔
39

40
                \wp_register_script(
2✔
41
                        'duplicate_post_edit_script',
2✔
42
                        \plugins_url( \sprintf( 'js/dist/duplicate-post-edit-%s.js', $flattened_version ), \DUPLICATE_POST_FILE ),
2✔
43
                        [
2✔
44
                                'wp-api-fetch',
2✔
45
                                'wp-components',
2✔
46
                                'wp-element',
2✔
47
                                'wp-i18n',
2✔
48
                        ],
2✔
49
                        \DUPLICATE_POST_CURRENT_VERSION,
2✔
50
                        true,
2✔
51
                );
2✔
52
                \wp_set_script_translations( 'duplicate_post_edit_script', 'duplicate-post' );
2✔
53

54
                \wp_register_script(
2✔
55
                        'duplicate_post_strings',
2✔
56
                        \plugins_url( \sprintf( 'js/dist/duplicate-post-strings-%s.js', $flattened_version ), \DUPLICATE_POST_FILE ),
2✔
57
                        [
2✔
58
                                'wp-components',
2✔
59
                                'wp-element',
2✔
60
                                'wp-i18n',
2✔
61
                        ],
2✔
62
                        \DUPLICATE_POST_CURRENT_VERSION,
2✔
63
                        true,
2✔
64
                );
2✔
65
                \wp_set_script_translations( 'duplicate_post_strings', 'duplicate-post' );
2✔
66

67
                \wp_register_script(
2✔
68
                        'duplicate_post_quick_edit_script',
2✔
69
                        \plugins_url( \sprintf( 'js/dist/duplicate-post-quick-edit-%s.js', $flattened_version ), \DUPLICATE_POST_FILE ),
2✔
70
                        [ 'jquery' ],
2✔
71
                        \DUPLICATE_POST_CURRENT_VERSION,
2✔
72
                        true,
2✔
73
                );
2✔
74

75
                \wp_register_script(
2✔
76
                        'duplicate_post_options_script',
2✔
77
                        \plugins_url( \sprintf( 'js/dist/duplicate-post-options-%s.js', $flattened_version ), \DUPLICATE_POST_FILE ),
2✔
78
                        [ 'jquery' ],
2✔
79
                        \DUPLICATE_POST_CURRENT_VERSION,
2✔
80
                        true,
2✔
81
                );
2✔
82
        }
83

84
        /**
85
         * Enqueues the styles.
86
         *
87
         * @return void
88
         */
89
        public function enqueue_styles() {
2✔
90
                \wp_enqueue_style( 'duplicate-post' );
2✔
91
        }
92

93
        /**
94
         * Enqueues the styles for the options page.
95
         *
96
         * @return void
97
         */
98
        public function enqueue_options_styles() {
×
99
                \wp_enqueue_style( 'duplicate-post-options' );
×
100
        }
101

102
        /**
103
         * Enqueues the script for the Block editor and passes object via localization.
104
         *
105
         * @param array $data_object The object to pass to the script.
106
         *
107
         * @return void
108
         */
109
        public function enqueue_edit_script( $data_object = [] ) {
2✔
110
                $handle = 'duplicate_post_edit_script';
2✔
111
                \wp_enqueue_script( $handle );
2✔
112
                \wp_add_inline_script(
2✔
113
                        $handle,
2✔
114
                        'let duplicatePostNotices = {};',
2✔
115
                        'before',
2✔
116
                );
2✔
117
                \wp_localize_script(
2✔
118
                        $handle,
2✔
119
                        'duplicatePost',
2✔
120
                        $data_object,
2✔
121
                );
2✔
122
        }
123

124
        /**
125
         * Enqueues the script for the Javascript strings and passes object via localization.
126
         *
127
         * @param array $data_object The object to pass to the script.
128
         *
129
         * @return void
130
         */
131
        public function enqueue_strings_script( $data_object = [] ) {
2✔
132
                $handle = 'duplicate_post_strings';
2✔
133
                \wp_enqueue_script( $handle );
2✔
134
                \wp_localize_script(
2✔
135
                        $handle,
2✔
136
                        'duplicatePostStrings',
2✔
137
                        $data_object,
2✔
138
                );
2✔
139
        }
140

141
        /**
142
         * Enqueues the script for the Quick Edit.
143
         *
144
         * @return void
145
         */
146
        public function enqueue_quick_edit_script() {
2✔
147
                \wp_enqueue_script( 'duplicate_post_quick_edit_script' );
2✔
148
        }
149

150
        /**
151
         * Enqueues the script for the Options page.
152
         *
153
         * @return void
154
         */
155
        public function enqueue_options_script() {
×
156
                \wp_enqueue_script( 'duplicate_post_options_script' );
×
157
        }
158

159
        /**
160
         * Enqueues the script for the Elementor plugin.
161
         *
162
         * @param array $data_object The object to pass to the script.
163
         *
164
         * @return void
165
         */
166
        public function enqueue_elementor_script( $data_object = [] ) {
×
167
                $flattened_version = Utils::flatten_version( \DUPLICATE_POST_CURRENT_VERSION );
×
168
                $handle            = 'duplicate_post_elementor_script';
×
169

170
                \wp_register_script(
×
171
                        $handle,
×
172
                        \plugins_url( \sprintf( 'js/dist/duplicate-post-elementor-%s.js', $flattened_version ), \DUPLICATE_POST_FILE ),
×
173
                        [ 'jquery' ],
×
174
                        \DUPLICATE_POST_CURRENT_VERSION,
×
NEW
175
                        true,
×
176
                );
×
177
                \wp_enqueue_script( $handle );
×
178
                \wp_localize_script(
×
179
                        $handle,
×
180
                        'duplicatePost',
×
NEW
181
                        $data_object,
×
182
                );
×
183
        }
184
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc