-
Notifications
You must be signed in to change notification settings - Fork 71
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
issue-1208: Improve i18n support for WordPress 6.7 #1209
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
* 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 | ||
*/ | ||
|
||
/** | ||
|
@@ -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 ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Allow this function to be used before |
||
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(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I learned as part of this fix that loading |
||
[ $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' ], | ||
|
@@ -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', '<' ) ) { | ||
|
@@ -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 { | ||
|
||
|
@@ -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 ] ) ) { | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since WordPress 4.7, this is no longer required for plugins hosted in WordPress.org.
The translation comes automatically from here: https://translate.wordpress.org/projects/wp-plugins/publish-to-apple-news/