@@ -69,5 +69,5 @@
vendor/
-
+
diff --git a/README.md b/README.md
index 5db89d1e4..1dfd33a86 100644
--- a/README.md
+++ b/README.md
@@ -64,6 +64,18 @@ The wiki has [details about contributing](https://github.com/alleyinteractive/ap
![Alley logo](https://avatars.githubusercontent.com/u/1733454?s=200&v=4)
+## Releasing the Plugin
+
+The plugin uses a [built release workflow](./.github/workflows/built-release.yml)
+to compile and tag releases. Whenever a new version is detected in the root
+`composer.json` file or in the plugin's headers, the workflow will automatically
+build the plugin and tag it with a new version. The built tag will contain all
+the required front-end assets the plugin may require. This works well for
+publishing to WordPress.org or for submodule-ing.
+
+When you are ready to release a new version of the plugin, you can run
+`npm run release` to start the process of setting up a new release.
+
### Contributors
Thanks to all of the [contributors](CONTRIBUTORS.md) to this project.
diff --git a/admin/apple-actions/class-action.php b/admin/apple-actions/class-action.php
index 6e4dcdf58..00a93a1e4 100644
--- a/admin/apple-actions/class-action.php
+++ b/admin/apple-actions/class-action.php
@@ -50,5 +50,4 @@ abstract public function perform();
protected function get_setting( $name ) {
return $this->settings->get( $name );
}
-
}
diff --git a/admin/apple-actions/class-api-action.php b/admin/apple-actions/class-api-action.php
index 5512e3d0a..a4da4de46 100644
--- a/admin/apple-actions/class-api-action.php
+++ b/admin/apple-actions/class-api-action.php
@@ -12,9 +12,9 @@
require_once plugin_dir_path( __FILE__ ) . 'class-action-exception.php';
require_once plugin_dir_path( __FILE__ ) . '../../includes/apple-push-api/autoload.php';
-use Apple_Actions\Action as Action;
-use Apple_Push_API\API as API;
-use Apple_Push_API\Credentials as Credentials;
+use Apple_Actions\Action;
+use Apple_Push_API\API;
+use Apple_Push_API\Credentials;
/**
* A base class that API-related actions can extend.
@@ -88,5 +88,4 @@ protected function is_api_configuration_valid() {
return true;
}
-
}
diff --git a/admin/apple-actions/index/class-delete.php b/admin/apple-actions/index/class-delete.php
index 6c33645b7..3c21e9081 100644
--- a/admin/apple-actions/index/class-delete.php
+++ b/admin/apple-actions/index/class-delete.php
@@ -10,7 +10,7 @@
require_once plugin_dir_path( __FILE__ ) . '../class-api-action.php';
-use Apple_Actions\API_Action as API_Action;
+use Apple_Actions\API_Action;
/**
* A class to handle a delete request from the admin.
@@ -63,12 +63,12 @@ public function perform() {
*/
private function delete() {
if ( ! $this->is_api_configuration_valid() ) {
- throw new \Apple_Actions\Action_Exception( __( 'Your Apple News API settings seem to be empty. Please fill the API key, API secret and API channel fields in the plugin configuration page.', 'apple-news' ) );
+ throw new \Apple_Actions\Action_Exception( esc_html__( 'Your Apple News API settings seem to be empty. Please fill the API key, API secret and API channel fields in the plugin configuration page.', 'apple-news' ) );
}
$remote_id = get_post_meta( $this->id, 'apple_news_api_id', true );
if ( ! $remote_id ) {
- throw new \Apple_Actions\Action_Exception( __( 'This post has not been pushed to Apple News, cannot delete.', 'apple-news' ) );
+ throw new \Apple_Actions\Action_Exception( esc_html__( 'This post has not been pushed to Apple News, cannot delete.', 'apple-news' ) );
}
try {
@@ -103,5 +103,4 @@ private function delete() {
return $e->getMessage();
}
}
-
}
diff --git a/admin/apple-actions/index/class-export.php b/admin/apple-actions/index/class-export.php
index bf7e9ddf6..dfdad36e4 100644
--- a/admin/apple-actions/index/class-export.php
+++ b/admin/apple-actions/index/class-export.php
@@ -341,8 +341,8 @@ public function format_byline( $post, $author = '', $date = '' ) {
}
// Get the date.
- if ( empty( $date ) && ! empty( $post->post_date ) ) {
- $date = $post->post_date;
+ if ( empty( $date ) && ! empty( $post->post_date_gmt ) ) {
+ $date = $post->post_date_gmt;
}
// Set the default date format.
diff --git a/admin/apple-actions/index/class-get.php b/admin/apple-actions/index/class-get.php
index 03ce4b64d..66f221944 100644
--- a/admin/apple-actions/index/class-get.php
+++ b/admin/apple-actions/index/class-get.php
@@ -10,7 +10,7 @@
require_once plugin_dir_path( __FILE__ ) . '../class-api-action.php';
-use Apple_Actions\API_Action as API_Action;
+use Apple_Actions\API_Action;
/**
* A class to handle a get request from the admin.
diff --git a/admin/apple-actions/index/class-push.php b/admin/apple-actions/index/class-push.php
index 739d4b36f..ab9787fcc 100644
--- a/admin/apple-actions/index/class-push.php
+++ b/admin/apple-actions/index/class-push.php
@@ -11,9 +11,9 @@
require_once plugin_dir_path( __FILE__ ) . '../class-api-action.php';
require_once plugin_dir_path( __FILE__ ) . 'class-export.php';
-use \Admin_Apple_Notice;
-use \Admin_Apple_Sections;
-use \Apple_Actions\API_Action;
+use Admin_Apple_Notice;
+use Admin_Apple_Sections;
+use Apple_Actions\API_Action;
/**
* A class to handle a push request from the admin.
@@ -147,7 +147,7 @@ private function is_post_in_sync( $json, $meta = [], $bundles = [] ) {
// Ensure the post (still) exists. Async operations might result in this function being run against a non-existent post.
$post = get_post( $this->id );
if ( ! $post ) {
- throw new \Apple_Actions\Action_Exception( __( 'Apple News Error: Could not find post with id ', 'apple-news' ) . $this->id );
+ throw new \Apple_Actions\Action_Exception( esc_html( __( 'Apple News Error: Could not find post with id ', 'apple-news' ) . $this->id ) );
}
// Compare checksums to determine whether the article is in sync or not.
@@ -187,13 +187,13 @@ private function get() {
// Ensure we have a valid ID.
$apple_id = get_post_meta( $this->id, 'apple_news_api_id', true );
if ( empty( $apple_id ) ) {
- throw new \Apple_Actions\Action_Exception( __( 'This post does not have a valid Apple News ID, so it cannot be retrieved from the API.', 'apple-news' ) );
+ throw new \Apple_Actions\Action_Exception( esc_html__( 'This post does not have a valid Apple News ID, so it cannot be retrieved from the API.', 'apple-news' ) );
}
// Get the article from the API.
$result = $this->get_api()->get_article( $apple_id );
if ( empty( $result->data->revision ) ) {
- throw new \Apple_Actions\Action_Exception( __( 'The Apple News API returned invalid data for this article since the revision is empty.', 'apple-news' ) );
+ throw new \Apple_Actions\Action_Exception( esc_html__( 'The Apple News API returned invalid data for this article since the revision is empty.', 'apple-news' ) );
}
// Update the revision.
@@ -209,7 +209,7 @@ private function get() {
*/
private function push( $user_id = null ) {
if ( ! $this->is_api_configuration_valid() ) {
- throw new \Apple_Actions\Action_Exception( __( 'Your Apple News API settings seem to be empty. Please fill in the API key, API secret and API channel fields in the plugin configuration page.', 'apple-news' ) );
+ throw new \Apple_Actions\Action_Exception( esc_html__( 'Your Apple News API settings seem to be empty. Please fill in the API key, API secret and API channel fields in the plugin configuration page.', 'apple-news' ) );
}
/**
@@ -227,8 +227,8 @@ private function push( $user_id = null ) {
throw new \Apple_Actions\Action_Exception(
sprintf(
// Translators: Placeholder is a post ID.
- __( 'Skipped push of article %d due to the apple_news_skip_push filter.', 'apple-news' ),
- $this->id
+ esc_html__( 'Skipped push of article %d due to the apple_news_skip_push filter.', 'apple-news' ),
+ absint( $this->id )
)
);
}
@@ -277,8 +277,8 @@ private function push( $user_id = null ) {
throw new \Apple_Actions\Action_Exception(
sprintf(
// Translators: Placeholder is a post ID.
- __( 'Skipped push of article %d due to the presence of a skip push taxonomy term.', 'apple-news' ),
- $this->id
+ esc_html__( 'Skipped push of article %d due to the presence of a skip push taxonomy term.', 'apple-news' ),
+ absint( $this->id )
)
);
}
@@ -393,8 +393,8 @@ private function push( $user_id = null ) {
throw new \Apple_Actions\Action_Exception(
sprintf(
// Translators: Placeholder is a post ID.
- __( 'Skipped push of article %d to Apple News because it is already in sync.', 'apple-news' ),
- $this->id
+ esc_html__( 'Skipped push of article %d to Apple News because it is already in sync.', 'apple-news' ),
+ $this->id // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
)
);
}
@@ -451,9 +451,9 @@ private function push( $user_id = null ) {
$this->clean_workspace();
if ( preg_match( '#WRONG_REVISION#', $e->getMessage() ) ) {
- throw new \Apple_Actions\Action_Exception( __( 'Apple News Error: It seems like the article was updated by another call. If the problem persists, try removing and pushing again.', 'apple-news' ) );
+ throw new \Apple_Actions\Action_Exception( esc_html__( 'Apple News Error: It seems like the article was updated by another call. If the problem persists, try removing and pushing again.', 'apple-news' ) );
} else {
- throw new \Apple_Actions\Action_Exception( __( 'There has been an error with the Apple News API: ', 'apple-news' ) . $e->getMessage() );
+ throw new \Apple_Actions\Action_Exception( esc_html__( 'There has been an error with the Apple News API: ', 'apple-news' ) . esc_html( $e->getMessage() ) );
}
}
@@ -536,7 +536,7 @@ private function process_errors( $errors ) {
$this->clean_workspace();
// Throw an exception.
- throw new \Apple_Actions\Action_Exception( $alert_message );
+ throw new \Apple_Actions\Action_Exception( esc_html( $alert_message ) );
} elseif ( 'warn' === $component_alerts && ! empty( $errors[0]['component_errors'] ) ) {
\Admin_Apple_Notice::error( $alert_message, $user_id );
}
@@ -590,7 +590,7 @@ private function sanitize_json( $json ) {
*/
$decoded = json_decode( $json );
if ( ! $decoded ) {
- throw new \Apple_Actions\Action_Exception( __( 'The Apple News JSON is invalid and cannot be published.', 'apple-news' ) );
+ throw new \Apple_Actions\Action_Exception( esc_html__( 'The Apple News JSON is invalid and cannot be published.', 'apple-news' ) );
} else {
return wp_json_encode( $decoded );
}
diff --git a/admin/class-admin-apple-bulk-export-page.php b/admin/class-admin-apple-bulk-export-page.php
index 76cb25d80..276fd64d3 100644
--- a/admin/class-admin-apple-bulk-export-page.php
+++ b/admin/class-admin-apple-bulk-export-page.php
@@ -52,9 +52,9 @@ public function __construct( $settings ) {
*/
public function register_page() {
add_submenu_page(
- null, // Parent, if null, it won't appear in any menu.
- __( 'Bulk Export', 'apple-news' ), // Page title.
- __( 'Bulk Export', 'apple-news' ), // Menu title.
+ 'options.php', // Passing options.php means it won't appear in any menu.
+ __( 'Bulk Export', 'apple-news' ), // Page title.
+ __( 'Bulk Export', 'apple-news' ), // Menu title.
/**
* Filters the capability required to be able to access the Bulk Export page.
*
diff --git a/admin/class-admin-apple-index-page.php b/admin/class-admin-apple-index-page.php
index 2370a734b..51adeb3ce 100644
--- a/admin/class-admin-apple-index-page.php
+++ b/admin/class-admin-apple-index-page.php
@@ -15,7 +15,7 @@
require_once plugin_dir_path( __FILE__ ) . 'apple-actions/index/class-section.php';
require_once plugin_dir_path( __FILE__ ) . 'class-admin-apple-news-list-table.php';
-use \Apple_Exporter\Workspace as Workspace;
+use Apple_Exporter\Workspace;
/**
* A class to manage the index page of the Apple News admin interface.
@@ -441,5 +441,4 @@ private function reset_action( $id ) {
// This can only succeed.
$this->notice_success( __( 'Your article status has been successfully reset!', 'apple-news' ) );
}
-
}
diff --git a/admin/class-admin-apple-meta-boxes.php b/admin/class-admin-apple-meta-boxes.php
index be83d0ee6..90b321c64 100644
--- a/admin/class-admin-apple-meta-boxes.php
+++ b/admin/class-admin-apple-meta-boxes.php
@@ -95,8 +95,10 @@ public function do_publish( $post_id, $post ) {
return;
}
- // Check the nonce.
- check_admin_referer( self::PUBLISH_ACTION, 'apple_news_nonce' );
+ // Check the nonce if we're not in testing mode.
+ if ( ! defined( 'MANTLE_IS_TESTING' ) || ! MANTLE_IS_TESTING ) {
+ check_admin_referer( self::PUBLISH_ACTION, 'apple_news_nonce' );
+ }
// Save meta box fields.
self::save_post_meta( $post_id );
@@ -448,7 +450,7 @@ public static function build_sections_field( $post_id ) {
?>
diff --git a/admin/class-admin-apple-news.php b/admin/class-admin-apple-news.php
index a4cd6eb52..fc39a0e4a 100644
--- a/admin/class-admin-apple-news.php
+++ b/admin/class-admin-apple-news.php
@@ -183,11 +183,11 @@ public function __construct() {
// Prevent Yoast Duplicate Post plugin from cloning apple_news meta.
add_filter(
'duplicate_post_meta_keys_filter',
- function( $meta_keys ) {
+ function ( $meta_keys ) {
return is_array( $meta_keys ) ?
array_filter(
$meta_keys,
- function( $key ) {
+ function ( $key ) {
return substr( $key, 0, 11 ) !== 'apple_news_';
}
)
@@ -197,7 +197,7 @@ function( $key ) {
add_action(
'rest_api_init',
- function() {
+ function () {
$post_types = ! empty( self::$settings->post_types ) ? self::$settings->post_types : [];
foreach ( $post_types as $post_type ) {
diff --git a/admin/class-admin-apple-notice.php b/admin/class-admin-apple-notice.php
index 0b3d153ac..a8976f63c 100644
--- a/admin/class-admin-apple-notice.php
+++ b/admin/class-admin-apple-notice.php
@@ -56,7 +56,7 @@ public static function clear( $notifications ) {
// Sort and JSON-encode the removal array to simplify comparison.
$notifications = array_map(
- function( $value ) {
+ function ( $value ) {
ksort( $value );
return wp_json_encode( $value );
},
diff --git a/admin/class-admin-apple-settings.php b/admin/class-admin-apple-settings.php
index da5b06eec..8dbc5adb7 100644
--- a/admin/class-admin-apple-settings.php
+++ b/admin/class-admin-apple-settings.php
@@ -13,7 +13,7 @@
require_once plugin_dir_path( __FILE__ ) . 'settings/class-admin-apple-settings-section-post-types.php';
require_once plugin_dir_path( __FILE__ ) . 'settings/class-admin-apple-settings-section-developer-tools.php';
-use Apple_Exporter\Settings as Settings;
+use Apple_Exporter\Settings;
/**
* This class is in charge of creating a WordPress page to manage the
diff --git a/admin/class-admin-apple-themes.php b/admin/class-admin-apple-themes.php
index fb36ef12e..43a08ab5d 100644
--- a/admin/class-admin-apple-themes.php
+++ b/admin/class-admin-apple-themes.php
@@ -478,7 +478,7 @@ public function setup_theme_pages() {
// Add the edit theme page.
add_submenu_page(
- null,
+ 'options.php',
__( 'Apple News Edit Theme', 'apple-news' ),
__( 'Edit Theme', 'apple-news' ),
/** This filter is documented in admin/class-admin-apple-settings.php */
diff --git a/admin/class-automation.php b/admin/class-automation.php
index 13ac58191..77b7df585 100644
--- a/admin/class-automation.php
+++ b/admin/class-automation.php
@@ -133,7 +133,7 @@ public static function filter__apple_news_article_metadata( $metadata, $post_id
$metadata_rules = array_values(
array_filter(
self::get_automation_for_post( $post_id ),
- function( $rule ) {
+ function ( $rule ) {
return 'article_metadata' === self::get_fields()[ $rule['field'] ]['location'] ?? '';
}
)
@@ -179,7 +179,7 @@ public static function get_automation_for_post( int $post_id ): array {
return array_values(
array_filter(
self::get_automation_rules(),
- function( $rule ) use ( $post_id ) {
+ function ( $rule ) use ( $post_id ) {
return has_term( $rule['term_id'] ?? '', $rule['taxonomy'] ?? '', $post_id );
}
)
diff --git a/admin/partials/field-meta-component-order.php b/admin/partials/field-meta-component-order.php
index af97fe6ab..1f4b0b983 100644
--- a/admin/partials/field-meta-component-order.php
+++ b/admin/partials/field-meta-component-order.php
@@ -18,7 +18,7 @@