Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QA: use global constants with a fully qualified name #140

Merged
merged 1 commit into from
Mar 22, 2021
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: 1 addition & 1 deletion src/admin/class-options-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function register_capabilities() {
public function generate_page() {
$this->register_capabilities();

require_once DUPLICATE_POST_PATH . 'src/admin/views/options.php';
require_once \DUPLICATE_POST_PATH . 'src/admin/views/options.php';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/class-post-republisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public function is_classic_editor_post_request() {
* @return bool Whether or not the request is a REST request.
*/
public function is_rest_request() {
return \defined( 'REST_REQUEST' ) && REST_REQUEST;
return \defined( 'REST_REQUEST' ) && \REST_REQUEST;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/handlers/class-check-changes-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public function require_wordpress_header() {
\set_current_screen( 'revision' );
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- The revision screen expects $post to be set.
$post = $this->post;
require_once ABSPATH . 'wp-admin/admin-header.php';
require_once \ABSPATH . 'wp-admin/admin-header.php';
}

/**
Expand All @@ -205,6 +205,6 @@ public function require_wordpress_header() {
* @return void
*/
public function require_wordpress_footer() {
require_once ABSPATH . 'wp-admin/admin-footer.php';
require_once \ABSPATH . 'wp-admin/admin-footer.php';
}
}
2 changes: 1 addition & 1 deletion src/handlers/class-save-post-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function register_hooks() {
* @return void
*/
public function delete_on_save_post( $post_id ) {
if ( ( \defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
if ( ( \defined( 'DOING_AUTOSAVE' ) && \DOING_AUTOSAVE )
|| empty( $_POST['duplicate_post_remove_original'] ) // phpcs:ignore WordPress.Security.NonceVerification
|| ! \current_user_can( 'edit_post', $post_id ) ) {
return;
Expand Down
28 changes: 14 additions & 14 deletions src/ui/class-asset-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public function register_hooks() {
* @return void
*/
public function register_styles() {
\wp_register_style( 'duplicate-post', \plugins_url( '/css/duplicate-post.css', DUPLICATE_POST_FILE ), [], DUPLICATE_POST_CURRENT_VERSION );
\wp_register_style( 'duplicate-post-options', \plugins_url( '/css/duplicate-post-options.css', DUPLICATE_POST_FILE ), [], DUPLICATE_POST_CURRENT_VERSION );
\wp_register_style( 'duplicate-post', \plugins_url( '/css/duplicate-post.css', \DUPLICATE_POST_FILE ), [], \DUPLICATE_POST_CURRENT_VERSION );
\wp_register_style( 'duplicate-post-options', \plugins_url( '/css/duplicate-post-options.css', \DUPLICATE_POST_FILE ), [], \DUPLICATE_POST_CURRENT_VERSION );
}

/**
Expand All @@ -35,45 +35,45 @@ public function register_styles() {
* @return void
*/
public function register_scripts() {
$flattened_version = Utils::flatten_version( DUPLICATE_POST_CURRENT_VERSION );
$flattened_version = Utils::flatten_version( \DUPLICATE_POST_CURRENT_VERSION );

\wp_register_script(
'duplicate_post_edit_script',
\plugins_url( \sprintf( 'js/dist/duplicate-post-edit-%s.js', $flattened_version ), DUPLICATE_POST_FILE ),
\plugins_url( \sprintf( 'js/dist/duplicate-post-edit-%s.js', $flattened_version ), \DUPLICATE_POST_FILE ),
[
'wp-components',
'wp-element',
'wp-i18n',
],
DUPLICATE_POST_CURRENT_VERSION,
\DUPLICATE_POST_CURRENT_VERSION,
true
);

\wp_register_script(
'duplicate_post_strings',
\plugins_url( \sprintf( 'js/dist/duplicate-post-strings-%s.js', $flattened_version ), DUPLICATE_POST_FILE ),
\plugins_url( \sprintf( 'js/dist/duplicate-post-strings-%s.js', $flattened_version ), \DUPLICATE_POST_FILE ),
[
'wp-components',
'wp-element',
'wp-i18n',
],
DUPLICATE_POST_CURRENT_VERSION,
\DUPLICATE_POST_CURRENT_VERSION,
true
);

\wp_register_script(
'duplicate_post_quick_edit_script',
\plugins_url( \sprintf( 'js/dist/duplicate-post-quick-edit-%s.js', $flattened_version ), DUPLICATE_POST_FILE ),
\plugins_url( \sprintf( 'js/dist/duplicate-post-quick-edit-%s.js', $flattened_version ), \DUPLICATE_POST_FILE ),
[ 'jquery' ],
DUPLICATE_POST_CURRENT_VERSION,
\DUPLICATE_POST_CURRENT_VERSION,
true
);

\wp_register_script(
'duplicate_post_options_script',
\plugins_url( \sprintf( 'js/dist/duplicate-post-options-%s.js', $flattened_version ), DUPLICATE_POST_FILE ),
\plugins_url( \sprintf( 'js/dist/duplicate-post-options-%s.js', $flattened_version ), \DUPLICATE_POST_FILE ),
[ 'jquery' ],
DUPLICATE_POST_CURRENT_VERSION,
\DUPLICATE_POST_CURRENT_VERSION,
true
);
}
Expand Down Expand Up @@ -161,14 +161,14 @@ public function enqueue_options_script() {
* @return void
*/
public function enqueue_elementor_script( $object = [] ) {
$flattened_version = Utils::flatten_version( DUPLICATE_POST_CURRENT_VERSION );
$flattened_version = Utils::flatten_version( \DUPLICATE_POST_CURRENT_VERSION );
$handle = 'duplicate_post_elementor_script';

\wp_register_script(
$handle,
\plugins_url( \sprintf( 'js/dist/duplicate-post-elementor-%s.js', $flattened_version ), DUPLICATE_POST_FILE ),
\plugins_url( \sprintf( 'js/dist/duplicate-post-elementor-%s.js', $flattened_version ), \DUPLICATE_POST_FILE ),
[ 'jquery' ],
DUPLICATE_POST_CURRENT_VERSION,
\DUPLICATE_POST_CURRENT_VERSION,
true
);
\wp_enqueue_script( $handle );
Expand Down
14 changes: 7 additions & 7 deletions tests/ui/class-asset-manager-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ public function test_register_styles() {
'duplicate-post',
$styles_url,
[],
DUPLICATE_POST_CURRENT_VERSION
\DUPLICATE_POST_CURRENT_VERSION
);

Monkey\Functions\expect( '\wp_register_style' )
->with(
'duplicate-post-options',
$options_styles_url,
[],
DUPLICATE_POST_CURRENT_VERSION
\DUPLICATE_POST_CURRENT_VERSION
);

$this->instance->register_styles();
Expand All @@ -88,7 +88,7 @@ public function test_register_scripts() {
$options_script_url = 'http://basic.wordpress.test/wp-content/plugins/duplicate-post/js/dist/duplicate-post-options-40.js';

$utils->expects( 'flatten_version' )
->with( DUPLICATE_POST_CURRENT_VERSION )
->with( \DUPLICATE_POST_CURRENT_VERSION )
->andReturn( $flattened_version );

Monkey\Functions\expect( '\plugins_url' )
Expand All @@ -103,7 +103,7 @@ public function test_register_scripts() {
'wp-element',
'wp-i18n',
],
DUPLICATE_POST_CURRENT_VERSION,
\DUPLICATE_POST_CURRENT_VERSION,
true
);

Expand All @@ -116,7 +116,7 @@ public function test_register_scripts() {
'wp-element',
'wp-i18n',
],
DUPLICATE_POST_CURRENT_VERSION,
\DUPLICATE_POST_CURRENT_VERSION,
true
);

Expand All @@ -125,7 +125,7 @@ public function test_register_scripts() {
'duplicate_post_quick_edit_script',
$quick_edit_script_url,
[ 'jquery' ],
DUPLICATE_POST_CURRENT_VERSION,
\DUPLICATE_POST_CURRENT_VERSION,
true
);

Expand All @@ -134,7 +134,7 @@ public function test_register_scripts() {
'duplicate_post_options_script',
$options_script_url,
[ 'jquery' ],
DUPLICATE_POST_CURRENT_VERSION,
\DUPLICATE_POST_CURRENT_VERSION,
true
);

Expand Down