Skip to content

Commit

Permalink
Merge branch 'develop' into release/2.7.0
Browse files Browse the repository at this point in the history
# Conflicts:
#	admin/class-admin-apple-news-list-table.php
#	admin/partials/page-bulk-export.php
  • Loading branch information
dlh01 committed Feb 9, 2025
2 parents 1840cf3 + e12365a commit 4549aee
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 55 deletions.
6 changes: 3 additions & 3 deletions admin/apple-actions/index/class-push.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ private function is_post_in_sync( $json, $meta = [], $bundles = [] ) {
/**
* Allows for custom logic to determine if a post is in sync or not.
*
* By default, the plugin simply compares the last modified time to the
* last time it was pushed to Apple News. If you want to apply custom
* logic, you can do that by modifying `$in_sync`. The most common use case
* By default, the plugin compares the checksum that is generated in this class
* with the checksum stored last time it was pushed to Apple News. If you want to apply
* custom logic, you can do that by modifying `$in_sync`. The most common use case
* is to not update posts based on custom criteria.
*
* @param bool $in_sync Whether the current post is in sync or not.
Expand Down
2 changes: 1 addition & 1 deletion admin/class-admin-apple-bulk-export-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function build_page() {
'apple_news_delete_post' => __( 'Bulk Delete Articles', 'apple-news' ),
};
$apple_page_description = match ( $action ) {
'apple_news_push_post' => __( 'The following articles will be exported.', 'apple-news' ),
'apple_news_push_post' => __( 'The following articles will be exported. Articles that are already published will be updated.', 'apple-news' ),
'apple_news_delete_post' => __( 'The following articles will be deleted.', 'apple-news' ),
};
$apple_submit_text = match ( $action ) {
Expand Down
8 changes: 5 additions & 3 deletions admin/class-admin-apple-news-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ public function column_title( $item ) {
return;
}

$apple_news_api_id = get_post_meta( $item->ID, 'apple_news_api_id', true );

// Build the base URL.
$base_url = add_query_arg(
[
Expand Down Expand Up @@ -202,7 +204,7 @@ public function column_title( $item ) {
$actions['push'] = sprintf(
"<a href='%s'>%s</a>",
esc_url( Admin_Apple_Index_Page::action_query_params( 'push', $base_url ) ),
esc_html__( 'Publish', 'apple-news' )
$apple_news_api_id ? esc_html__( 'Update', 'apple-news' ) : esc_html__( 'Publish', 'apple-news' )
);
}

Expand All @@ -216,7 +218,7 @@ public function column_title( $item ) {
}

// Add the delete action, if required.
if ( get_post_meta( $item->ID, 'apple_news_api_id', true ) ) {
if ( $apple_news_api_id ) {
$actions['delete'] = sprintf(
"<a title='%s' href='%s' class='delete-button'>%s</a>",
esc_html__( 'Delete from Apple News', 'apple-news' ),
Expand Down Expand Up @@ -328,7 +330,7 @@ public function get_bulk_actions() {
return apply_filters(
'apple_news_bulk_actions',
[
Admin_Apple_Index_Page::namespace_action( 'push' ) => __( 'Publish', 'apple-news' ),
Admin_Apple_Index_Page::namespace_action( 'push' ) => __( 'Publish/Update', 'apple-news' ),
Admin_Apple_Index_Page::namespace_action( 'delete' ) => __( 'Delete', 'apple-news' ),
],
);
Expand Down
39 changes: 11 additions & 28 deletions apple-news.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
<?php
/**
* Entry point for the plugin.
*
* This file is read by WordPress to generate the plugin information in the
* admin panel.
*
* @link http://github.com/alleyinteractive/apple-news
* @since 0.2.0
* @package WP_Plugin
*/

/*
* Plugin Name: Publish to Apple News
* Plugin Name: Publish To Apple News
* Plugin URI: http://github.com/alleyinteractive/apple-news
* Description: Export and sync posts to Apple format.
* Version: 2.6.1
* Version: 2.6.2
* Author: Alley
* Author URI: https://alley.com
* Text Domain: apple-news
* Domain Path: lang/
* License: GPLv3 or later
* License URI: https://www.gnu.org/licenses/gpl.html
*
* @package Apple_News
*/

/**
Expand Down Expand Up @@ -79,29 +71,20 @@ function apple_news_uninstall_wp_plugin() {
require __DIR__ . '/includes/class-apple-news.php';
require __DIR__ . '/admin/class-admin-apple-news.php';

/**
* Load plugin textdomain.
*
* @since 0.9.0
*/
function apple_news_load_textdomain() {
load_plugin_textdomain( 'apple-news', false, __DIR__ . '/lang' );
}
add_action( 'plugins_loaded', 'apple_news_load_textdomain' );

/**
* Gets plugin data.
* Used to provide generator info in the metadata class.
*
* @return array
*
* @since 1.0.4
*
* @param bool $translate Whether to translate the plugin data.
* @return array
*/
function apple_news_get_plugin_data() {
function apple_news_get_plugin_data( $translate = true ) {
if ( ! function_exists( 'get_plugin_data' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
return get_plugin_data( __DIR__ . '/apple-news.php' );
return get_plugin_data( __DIR__ . '/apple-news.php', true, $translate );
}

new Admin_Apple_News();
Expand Down
36 changes: 21 additions & 15 deletions includes/class-apple-news.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Apple_News {
* @var string
* @access public
*/
public static string $version = '2.6.1';
public static string $version = '2.6.2';

/**
* Link to support for the plugin on WordPress.org.
Expand Down Expand Up @@ -365,34 +365,37 @@ public static function has_uninitialized_error(): WP_Error|null {

/**
* Constructor. Registers action hooks.
*
* @access public
*/
public function __construct() {
add_action(
'admin_enqueue_scripts',
[ $this, 'action_admin_enqueue_scripts' ]
);

add_action(
'enqueue_block_editor_assets',
[ $this, 'action_enqueue_block_editor_assets' ]
);

add_action(
'plugins_loaded',
[ $this, 'action_plugins_loaded' ]
'init',
[ $this, 'action_init' ]
);

add_filter(
'update_post_metadata',
[ $this, 'filter_update_post_metadata' ],
10,
5
);

add_filter(
'author_link',
[ $this, 'filter_author_link' ],
10,
3
);

add_filter(
'the_author',
[ $this, 'filter_the_author' ],
Expand Down Expand Up @@ -471,21 +474,21 @@ public function action_enqueue_block_editor_assets(): void {
}

/**
* Action hook callback for plugins_loaded.
* Action hook callback for init.
*
* @since 1.3.0
*/
public function action_plugins_loaded(): void {
public function action_init(): void {

// Determine if the database version and code version are the same.
$current_version = get_option( 'apple_news_version' );
if ( version_compare( $current_version, self::$version, '>=' ) ) {
$current_version = get_option( 'apple_news_version', '' );
if ( is_string( $current_version ) && version_compare( $current_version, self::$version, '>=' ) ) {
return;
}

// Determine if this is a clean install (no settings set yet).
$settings = get_option( self::$option_name );
if ( ! empty( $settings ) ) {
if ( ! empty( $settings ) && is_string( $current_version ) ) {

// Handle upgrade to version 1.3.0.
if ( version_compare( $current_version, '1.3.0', '<' ) ) {
Expand Down Expand Up @@ -517,8 +520,6 @@ public function action_plugins_loaded(): void {

/**
* Create the default themes, if they do not exist.
*
* @access public
*/
public function create_default_theme(): void {

Expand All @@ -529,9 +530,14 @@ public function create_default_theme(): void {
}

// Build the theme formatting settings from the base settings array.
$theme = new Theme();
$options = Theme::get_options();
$wp_settings = get_option( self::$option_name, [] );
$theme = new Theme();
$options = Theme::get_options();
$wp_settings = get_option( self::$option_name, [] );

if ( ! is_array( $wp_settings ) ) {
$wp_settings = [];
}

$theme_settings = [];
foreach ( array_keys( $options ) as $option_key ) {
if ( isset( $wp_settings[ $option_key ] ) ) {
Expand Down
1 change: 0 additions & 1 deletion lang/apple-export.pot

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "publish-to-apple-news",
"version": "2.5.1",
"version": "2.6.2",
"license": "GPLv3",
"main": "index.php",
"engines": {
Expand Down
12 changes: 10 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tags: publish, apple, news, iOS
Requires at least: 6.3
Tested up to: 6.7
Requires PHP: 8.0
Stable tag: 2.6.1
Stable tag: 2.6.2
License: GPLv3 or later
License URI: https://www.gnu.org/licenses/gpl.html

Expand Down Expand Up @@ -45,6 +45,14 @@ Please visit our [wiki](https://github.com/alleyinteractive/apple-news/wiki) for

== Changelog ==

= 2.6.2 =

* Enhancement: i18n - Remove `load_plugin_textdomain`. Since WordPress 4.6, plugins no longer need to load their own textdomain.
* Enhancement: i18n - Moved some plugin initialization code to the `init` action hook.
* Bugfix: i18n - Fixed the `_load_textdomain_just_in_time` error with WordPress 6.7.
* Bugfix: Update plugin name in plugin header.
* Enhancement: Add license to plugin header.

= 2.6.1 =

* Enhancement: Ensured support for WordPress 6.7.
Expand Down Expand Up @@ -90,4 +98,4 @@ Information on previous releases can be found on the plugin's [GitHub Releases p

== Developers ==

Please visit us on [github](https://github.com/alleyinteractive/apple-news) to [submit issues](https://github.com/alleyinteractive/apple-news/issues), [pull requests](https://github.com/alleyinteractive/apple-news/pulls) or [read our wiki page about contributing](https://github.com/alleyinteractive/apple-news/wiki/contributing).
Please visit us on [GitHub](https://github.com/alleyinteractive/apple-news) to [submit issues](https://github.com/alleyinteractive/apple-news/issues), [pull requests](https://github.com/alleyinteractive/apple-news/pulls) or [read our wiki page about contributing](https://github.com/alleyinteractive/apple-news/wiki/contributing).
2 changes: 1 addition & 1 deletion tests/test-class-apple-news.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ public function test_upgrade_to_2_5_0(): void {
* @see Apple_News::$version
*/
public function test_version() {
$plugin_data = apple_news_get_plugin_data();
$plugin_data = apple_news_get_plugin_data( translate: false );
$this->assertEquals( Apple_News::$version, $plugin_data['Version'] );
}
}

0 comments on commit 4549aee

Please sign in to comment.