diff --git a/admin/apple-actions/index/class-push.php b/admin/apple-actions/index/class-push.php index 1090a9fab..f36b552d8 100644 --- a/admin/apple-actions/index/class-push.php +++ b/admin/apple-actions/index/class-push.php @@ -214,7 +214,7 @@ private function push( $user_id = null ) { } // Get the isPreview setting. - $is_paid = (bool) get_post_meta( $this->id, 'apple_news_is_paid', true ); + $is_paid = (bool) get_post_meta( $this->id, 'apple_news_is_paid', true ); $meta['data']['isPaid'] = $is_paid; // Get the isPreview setting. diff --git a/admin/class-admin-apple-bulk-export-page.php b/admin/class-admin-apple-bulk-export-page.php index bd3a21253..3de6236c4 100644 --- a/admin/class-admin-apple-bulk-export-page.php +++ b/admin/class-admin-apple-bulk-export-page.php @@ -83,7 +83,7 @@ public function set_title( $admin_title ) { * @access public */ public function build_page() { - $ids = isset( $_GET['ids'] ) ? sanitize_text_field( wp_unslash( $_GET['ids'] ) ) : null; // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected + $ids = isset( $_GET['ids'] ) ? sanitize_text_field( wp_unslash( $_GET['ids'] ) ) : null; // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected, WordPress.Security.NonceVerification.Recommended if ( ! $ids ) { wp_safe_redirect( esc_url_raw( menu_page_url( $this->plugin_slug . '_index', false ) ) ); if ( ! defined( 'APPLE_NEWS_UNIT_TESTS' ) || ! APPLE_NEWS_UNIT_TESTS ) { diff --git a/admin/class-admin-apple-index-page.php b/admin/class-admin-apple-index-page.php index 651c7140b..376d347ff 100644 --- a/admin/class-admin-apple-index-page.php +++ b/admin/class-admin-apple-index-page.php @@ -92,8 +92,8 @@ public function setup_admin_page() { * @access public */ public function admin_page() { - $id = isset( $_GET['post_id'] ) ? absint( $_GET['post_id'] ) : null; // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected - $action = isset( $_GET['action'] ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : null; // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected + $id = isset( $_GET['post_id'] ) ? absint( $_GET['post_id'] ) : null; // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected, WordPress.Security.NonceVerification.Recommended + $action = isset( $_GET['action'] ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : null; // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected, WordPress.Security.NonceVerification.Recommended switch ( $action ) { case self::namespace_action( 'push' ): @@ -127,9 +127,9 @@ public function admin_page() { * @return mixed The result of the requested action. */ public function page_router() { - $id = isset( $_GET['post_id'] ) ? absint( $_GET['post_id'] ) : null; // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected - $action = isset( $_GET['action'] ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : null; // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected - $action2 = isset( $_GET['action2'] ) ? sanitize_text_field( wp_unslash( $_GET['action2'] ) ) : null; // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected + $id = isset( $_GET['post_id'] ) ? absint( $_GET['post_id'] ) : null; // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected, WordPress.Security.NonceVerification.Recommended + $action = isset( $_GET['action'] ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : null; // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected, WordPress.Security.NonceVerification.Recommended + $action2 = isset( $_GET['action2'] ) ? sanitize_text_field( wp_unslash( $_GET['action2'] ) ) : null; // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected, WordPress.Security.NonceVerification.Recommended // Allow for bulk actions from top or bottom. if ( ( empty( $action ) || '-1' === $action ) && ! empty( $action2 ) ) { @@ -145,8 +145,8 @@ public function page_router() { case self::namespace_action( 'push' ): // phpcs:ignore PSR2.ControlStructures.SwitchDeclaration.TerminatingComment if ( ! $id ) { $url = menu_page_url( $this->plugin_slug . '_bulk_export', false ); - if ( isset( $_GET['article'] ) ) { // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected - $ids = is_array( $_GET['article'] ) ? array_map( 'absint', $_GET['article'] ) : absint( $_GET['article'] ); // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected + if ( isset( $_GET['article'] ) ) { // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected, WordPress.Security.NonceVerification.Recommended + $ids = is_array( $_GET['article'] ) ? array_map( 'absint', $_GET['article'] ) : absint( $_GET['article'] ); // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected, WordPress.Security.NonceVerification.Recommended $url .= '&ids=' . implode( '.', $ids ); } wp_safe_redirect( esc_url_raw( $url ) ); @@ -233,8 +233,8 @@ public static function action_query_params( $action, $url ) { // Add the other params. foreach ( $keys as $key ) { - if ( ! empty( $_GET[ $key ] ) ) { // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected - $params[ $key ] = rawurlencode( sanitize_text_field( wp_unslash( $_GET[ $key ] ) ) ); // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected + if ( ! empty( $_GET[ $key ] ) ) { // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected, WordPress.Security.NonceVerification.Recommended + $params[ $key ] = rawurlencode( sanitize_text_field( wp_unslash( $_GET[ $key ] ) ) ); // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected, WordPress.Security.NonceVerification.Recommended } } diff --git a/admin/class-admin-apple-json.php b/admin/class-admin-apple-json.php index a0bbfa9d3..5b14d150e 100644 --- a/admin/class-admin-apple-json.php +++ b/admin/class-admin-apple-json.php @@ -425,8 +425,8 @@ public function get_selected_theme() { } // Next, check for a theme loaded in from the query string. - if ( ! empty( $_GET['theme'] ) ) { // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected - return sanitize_text_field( wp_unslash( $_GET['theme'] ) ); // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected + if ( ! empty( $_GET['theme'] ) ) { // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected, WordPress.Security.NonceVerification.Recommended + return sanitize_text_field( wp_unslash( $_GET['theme'] ) ); // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected, WordPress.Security.NonceVerification.Recommended } return ''; diff --git a/admin/class-admin-apple-meta-boxes.php b/admin/class-admin-apple-meta-boxes.php index db7ede0f0..1b76b7818 100644 --- a/admin/class-admin-apple-meta-boxes.php +++ b/admin/class-admin-apple-meta-boxes.php @@ -314,7 +314,7 @@ public static function build_sections_field( $post_id ) { foreach ( $sections as $section ) { ?>
- links->self, $section->isDefault ) ); ?>> + links->self, $section->isDefault ) ); ?>>
settings->get( 'api_autosync_update' ) ) { // This needs to happen after meta boxes save. - if ( apple_news_block_editor_is_active() ) { // check if GB is active - add_action( 'rest_after_insert_post', [ $this, 'do_publish_from_rest' ]); + if ( apple_news_block_editor_is_active() ) { + add_action( 'rest_after_insert_post', [ $this, 'do_publish_from_rest' ] ); } else { add_action( 'save_post', [ $this, 'do_publish' ], 99, 2 ); } @@ -61,6 +61,12 @@ public function __construct( $settings = null ) { } } + /** + * An action callback for rest_after_insert_post. Handles the publish action. + * + * @since 2.0.0 + * @param WP_Post $post The post object to publish. + */ public function do_publish_from_rest( $post ) { $this->do_publish( $post->ID, $post ); } diff --git a/admin/class-admin-apple-sections.php b/admin/class-admin-apple-sections.php index cce56289f..651f0a65a 100644 --- a/admin/class-admin-apple-sections.php +++ b/admin/class-admin-apple-sections.php @@ -258,7 +258,7 @@ public function action_router() { public function ajax_apple_news_section_taxonomy_autocomplete() { // Determine if we have anything to search for. - if ( empty( $_GET['term'] ) ) { // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected + if ( empty( $_GET['term'] ) ) { // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected, WordPress.Security.NonceVerification.Recommended echo wp_json_encode( array() ); exit; } @@ -276,7 +276,7 @@ public function ajax_apple_news_section_taxonomy_autocomplete() { 'fields' => 'names', 'hide_empty' => false, 'number' => 10, - 'search' => sanitize_text_field( wp_unslash( $_GET['term'] ) ), // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected + 'search' => sanitize_text_field( wp_unslash( $_GET['term'] ) ), // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected, WordPress.Security.NonceVerification.Recommended 'taxonomy' => $taxonomy->name, ) ); diff --git a/admin/class-admin-apple-themes.php b/admin/class-admin-apple-themes.php index 5765a0a2f..ce201e870 100644 --- a/admin/class-admin-apple-themes.php +++ b/admin/class-admin-apple-themes.php @@ -34,7 +34,7 @@ class Admin_Apple_Themes extends Apple_News { * @var array * @access private */ - private $_valid_actions; + private $valid_actions; /** * Renders a theme option field for use in a form. @@ -158,7 +158,7 @@ public function __construct() { $this->theme_page_name = $this->plugin_domain . '-themes'; $this->theme_edit_page_name = $this->plugin_domain . '-theme-edit'; - $this->_valid_actions = array( + $this->valid_actions = array( 'apple_news_upload_theme' => array( 'callback' => array( $this, 'upload_theme' ), 'nonce' => 'apple_news_themes', @@ -203,18 +203,18 @@ public function action_router() { $action = isset( $_REQUEST['action'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ) : null; - if ( ( empty( $action ) || ! array_key_exists( $action, $this->_valid_actions ) ) ) { + if ( ( empty( $action ) || ! array_key_exists( $action, $this->valid_actions ) ) ) { return; } // Check the nonce. - check_admin_referer( $this->_valid_actions[ $action ]['nonce'] ); + check_admin_referer( $this->valid_actions[ $action ]['nonce'] ); // Call the callback for the action for further processing. - if ( isset( $this->_valid_actions[ $action ]['callback'] ) - && is_callable( $this->_valid_actions[ $action ]['callback'] ) + if ( isset( $this->valid_actions[ $action ]['callback'] ) + && is_callable( $this->valid_actions[ $action ]['callback'] ) ) { - call_user_func( $this->_valid_actions[ $action ]['callback'] ); + call_user_func( $this->valid_actions[ $action ]['callback'] ); } } @@ -269,8 +269,8 @@ public function page_theme_edit_render() { // Negotiate theme object. $error = ''; $theme = new \Apple_Exporter\Theme(); - if ( isset( $_GET['theme'] ) ) { // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected - $theme_name = sanitize_text_field( wp_unslash( $_GET['theme'] ) ); // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected + if ( isset( $_GET['theme'] ) ) { // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected, WordPress.Security.NonceVerification.Recommended + $theme_name = sanitize_text_field( wp_unslash( $_GET['theme'] ) ); // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected, WordPress.Security.NonceVerification.Recommended $theme->set_name( $theme_name ); if ( false === $theme->load() ) { $error = sprintf( @@ -566,7 +566,7 @@ private function delete_theme() { $action = isset( $_REQUEST['action'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ) : null; - check_admin_referer( $this->_valid_actions[ $action ]['nonce'] ); + check_admin_referer( $this->valid_actions[ $action ]['nonce'] ); // Attempt to get the name of the theme from postdata. if ( empty( $name ) && ! empty( $_POST['apple_news_theme'] ) ) { @@ -607,7 +607,7 @@ private function export_theme() { $action = isset( $_REQUEST['action'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ) : null; - check_admin_referer( $this->_valid_actions[ $action ]['nonce'] ); + check_admin_referer( $this->valid_actions[ $action ]['nonce'] ); // Get the theme name from POST data. if ( ! empty( $_POST['apple_news_theme'] ) ) { @@ -671,7 +671,7 @@ private function save_edit_theme() { $action = isset( $_REQUEST['action'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ) : null; - check_admin_referer( $this->_valid_actions[ $action ]['nonce'] ); + check_admin_referer( $this->valid_actions[ $action ]['nonce'] ); // Create a theme object. $theme = new \Apple_Exporter\Theme(); @@ -776,7 +776,7 @@ private function set_theme() { $action = isset( $_REQUEST['action'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ) : null; - check_admin_referer( $this->_valid_actions[ $action ]['nonce'] ); + check_admin_referer( $this->valid_actions[ $action ]['nonce'] ); // Get the theme name from postdata. if ( ! empty( $_POST['apple_news_active_theme'] ) ) { diff --git a/apple-news.php b/apple-news.php index 103be42f8..33c52e1d9 100644 --- a/apple-news.php +++ b/apple-news.php @@ -8,13 +8,15 @@ * @link http://github.com/alleyinteractive/apple-news * @since 0.2.0 * @package WP_Plugin - * + */ + +/* * Plugin Name: Publish to Apple News * Plugin URI: http://github.com/alleyinteractive/apple-news * Description: Export and sync posts to Apple format. - * Version: 1.4.4 - * Author: Alley Interactive - * Author URI: https://www.alleyinteractive.com + * Version: 2.0.0 + * Author: Alley + * Author URI: https://alley.co * Text Domain: apple-news * Domain Path: lang/ */ @@ -104,22 +106,22 @@ function apple_news_is_exporting() { function apple_news_block_editor_is_active() { $active = true; - // Gutenberg plugin is installed and activated. - $gutenberg = ! ( false === has_filter( 'replace_editor', 'gutenberg_init' ) ); + // Gutenberg plugin is installed and activated. + $gutenberg = ! ( false === has_filter( 'replace_editor', 'gutenberg_init' ) ); - // Block editor since 5.0. - $block_editor = version_compare( $GLOBALS['wp_version'], '5.0-beta', '>' ); + // Block editor since 5.0. + $block_editor = version_compare( $GLOBALS['wp_version'], '5.0-beta', '>' ); - if ( ! $gutenberg && ! $block_editor ) { - $active = false; - } + if ( ! $gutenberg && ! $block_editor ) { + $active = false; + } - if ( $active && apple_news_is_classic_editor_plugin_active() ) { - $editor_option = get_option( 'classic-editor-replace' ); - $block_editor_active = array( 'no-replace', 'block' ); + if ( $active && apple_news_is_classic_editor_plugin_active() ) { + $editor_option = get_option( 'classic-editor-replace' ); + $block_editor_active = array( 'no-replace', 'block' ); - $active = in_array( $editor_option, $block_editor_active, true ); - } + $active = in_array( $editor_option, $block_editor_active, true ); + } /** * Overrides whether Apple News thinks the block editor is active or not. @@ -169,15 +171,15 @@ function apple_news_block_editor_is_active_for_post( $post_id = 0 ) { * @return bool */ function apple_news_is_classic_editor_plugin_active() { - if ( ! function_exists( 'is_plugin_active' ) ) { - include_once ABSPATH . 'wp-admin/includes/plugin.php'; - } + if ( ! function_exists( 'is_plugin_active' ) ) { + include_once ABSPATH . 'wp-admin/includes/plugin.php'; + } - if ( is_plugin_active( 'classic-editor/classic-editor.php' ) ) { - return true; - } + if ( is_plugin_active( 'classic-editor/classic-editor.php' ) ) { + return true; + } - return false; + return false; } /** @@ -189,4 +191,4 @@ function apple_news_is_classic_editor_plugin_active() { * @param int $user_id The user ID to check. * * @return bool True if the user can perform the action, false otherwise. - */ \ No newline at end of file + */ diff --git a/assets/js/pluginsidebar/components/notifications/index.js b/assets/js/pluginsidebar/components/notifications/index.js index f020bf1e0..6acd95c7d 100644 --- a/assets/js/pluginsidebar/components/notifications/index.js +++ b/assets/js/pluginsidebar/components/notifications/index.js @@ -51,6 +51,7 @@ export default class Notifications extends React.PureComponent { status={notification.type} >

'POST', 'callback' => function( $data ) { - $body = json_decode( $data->get_body(), true ); + $body = json_decode( $data->get_body(), true ); $notifications = ! empty( $body['toClear'] ) && is_array( $body['toClear'] ) ? $body['toClear'] : []; diff --git a/includes/REST/apple-news-delete.php b/includes/REST/apple-news-delete.php index 39f1fc613..25a4e0a4a 100644 --- a/includes/REST/apple-news-delete.php +++ b/includes/REST/apple-news-delete.php @@ -4,6 +4,7 @@ * * @package Apple_News */ + namespace Apple_News\REST; use \WP_Error; diff --git a/includes/REST/apple-news-get-published-state.php b/includes/REST/apple-news-get-published-state.php index ef6938354..73f8413d0 100644 --- a/includes/REST/apple-news-get-published-state.php +++ b/includes/REST/apple-news-get-published-state.php @@ -4,7 +4,9 @@ * * @package Apple_News */ + namespace Apple_News\REST; + /** * Get API response. * @@ -12,13 +14,13 @@ * @return array updated response. */ function get_published_state_response( $data ) { - $response = []; + $response = []; if ( ! empty( get_current_user_id() ) ) { $response['publishState'] = \Admin_Apple_News::get_post_status( $data['id'] ); } - return $response; + return $response; } /** diff --git a/includes/REST/apple-news-get-settings.php b/includes/REST/apple-news-get-settings.php index 3e4472b40..0a690640c 100644 --- a/includes/REST/apple-news-get-settings.php +++ b/includes/REST/apple-news-get-settings.php @@ -4,7 +4,9 @@ * * @package Apple_News */ + namespace Apple_News\REST; + /** * Get API response. * @@ -18,7 +20,7 @@ function get_settings_response( $data ) { // Compile non-sensitive plugin settings into a JS-friendly format and return. $admin_settings = new \Admin_Apple_Settings(); - $settings = $admin_settings->fetch_settings(); + $settings = $admin_settings->fetch_settings(); return [ 'adminUrl' => esc_url_raw( admin_url( 'admin.php?page=apple-news-options' ) ), 'automaticAssignment' => ! empty( get_option( 'apple_news_section_taxonomy_mappings' ) ), diff --git a/includes/REST/apple-news-modify-post.php b/includes/REST/apple-news-modify-post.php index f70610fdd..b2980c89b 100644 --- a/includes/REST/apple-news-modify-post.php +++ b/includes/REST/apple-news-modify-post.php @@ -4,6 +4,7 @@ * * @package Apple_News */ + namespace Apple_News\REST; use \Admin_Apple_News; @@ -76,7 +77,7 @@ function modify_post( $post_id, $operation ) { $action = new Push( Admin_Apple_News::$settings, $post_id ); break; case 'delete': - $action = new Delete( Admin_Apple_News::$settings, $post_id ); + $action = new Delete( Admin_Apple_News::$settings, $post_id ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_delete break; default: $message = __( 'You specified an invalid API operation.', 'apple-news' ); @@ -85,7 +86,6 @@ function modify_post( $post_id, $operation ) { 'apple_news_bad_operation', $message ); - break; } try { $action->perform(); @@ -96,6 +96,7 @@ function modify_post( $post_id, $operation ) { } elseif ( 'delete' === $operation ) { Admin_Apple_Notice::success( sprintf( + // translators: The title of the article. __( 'Article %s has been successfully deleted from Apple News!', 'apple-news' ), $post->post_title ) diff --git a/includes/REST/apple-news-publish.php b/includes/REST/apple-news-publish.php index 89b1e45b0..937e42954 100644 --- a/includes/REST/apple-news-publish.php +++ b/includes/REST/apple-news-publish.php @@ -4,6 +4,7 @@ * * @package Apple_News */ + namespace Apple_News\REST; use \WP_Error; diff --git a/includes/REST/apple-news-sections.php b/includes/REST/apple-news-sections.php index d492c703f..3a755827c 100644 --- a/includes/REST/apple-news-sections.php +++ b/includes/REST/apple-news-sections.php @@ -1,30 +1,31 @@ esc_html( 'https://news-api.apple.com/sections/' . $section->id ), - 'name' => esc_html( $section->name ), - ]; - } - } + if ( ! empty( $sections ) && ! empty( get_current_user_id() ) ) { + foreach ( $sections as $section ) { + $response[] = [ + 'id' => esc_html( 'https://news-api.apple.com/sections/' . $section->id ), + 'name' => esc_html( $section->name ), + ]; + } + } - return $response; + return $response; } /** diff --git a/includes/REST/apple-news-update.php b/includes/REST/apple-news-update.php index 20d023ebd..09940ac53 100644 --- a/includes/REST/apple-news-update.php +++ b/includes/REST/apple-news-update.php @@ -4,6 +4,7 @@ * * @package Apple_News */ + namespace Apple_News\REST; use \WP_Error; diff --git a/includes/REST/apple-news-user-can-publish.php b/includes/REST/apple-news-user-can-publish.php index 4aed9f740..08fb3dae7 100644 --- a/includes/REST/apple-news-user-can-publish.php +++ b/includes/REST/apple-news-user-can-publish.php @@ -4,6 +4,7 @@ * * @package Apple_News */ + namespace Apple_News\REST; use \Apple_News; diff --git a/includes/apple-exporter/builders/class-text-styles.php b/includes/apple-exporter/builders/class-text-styles.php index 972fb94e5..c27ee1838 100644 --- a/includes/apple-exporter/builders/class-text-styles.php +++ b/includes/apple-exporter/builders/class-text-styles.php @@ -27,7 +27,7 @@ class Text_Styles extends Builder { * @access private * @var array */ - private $_styles = array(); + private $styles = array(); /** * Constructor. @@ -61,7 +61,7 @@ public function build() { * * @param array $styles The styles to be filtered. */ - return apply_filters( 'apple_news_text_styles', $this->_styles ); + return apply_filters( 'apple_news_text_styles', $this->styles ); } /** @@ -75,12 +75,12 @@ public function build() { public function register_style( $name, $values ) { // Only register once, since styles have unique names. - if ( array_key_exists( $name, $this->_styles ) ) { + if ( array_key_exists( $name, $this->styles ) ) { return; } // Register the style. - $this->_styles[ $name ] = $values; + $this->styles[ $name ] = $values; } /** diff --git a/includes/apple-exporter/class-component-factory.php b/includes/apple-exporter/class-component-factory.php index d17df9385..c009734cc 100644 --- a/includes/apple-exporter/class-component-factory.php +++ b/includes/apple-exporter/class-component-factory.php @@ -197,13 +197,13 @@ public static function get_components_from_node( $node ) { } // We matched a single node. - $html = $node->ownerDocument->saveXML( $matched_node ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + $html = $node->ownerDocument->saveXML( $matched_node ); $result[] = self::get_component( $shortname, $html ); return $result; } // Nothing found. Maybe it's a container element? if ( $node->hasChildNodes() ) { - foreach ( $node->childNodes as $child ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + foreach ( $node->childNodes as $child ) { $result = array_merge( $result, self::get_components_from_node( $child, $node ) ); } // Remove all nulls from the array. @@ -216,8 +216,8 @@ public static function get_components_from_node( $node ) { * Others nodes without a match are almost always just stray empty text nodes * that are always safe to remove. Paragraphs should also be ignored for this reason. */ - if ( empty( $result ) && ( ! empty( $node->tagName ) && 'p' !== $node->tagName ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar - self::$workspace->log_error( 'component_errors', $node->tagName ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + if ( empty( $result ) && ( ! empty( $node->tagName ) && 'p' !== $node->tagName ) ) { + self::$workspace->log_error( 'component_errors', $node->tagName ); } return $result; diff --git a/includes/apple-exporter/class-exporter-content.php b/includes/apple-exporter/class-exporter-content.php index e4ee1747c..4f0e14c52 100644 --- a/includes/apple-exporter/class-exporter-content.php +++ b/includes/apple-exporter/class-exporter-content.php @@ -231,7 +231,7 @@ public function nodes() { libxml_clear_errors( true ); // Find the first-level nodes of the body tag. - return $dom->getElementsByTagName( 'body' )->item( 0 )->childNodes; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + return $dom->getElementsByTagName( 'body' )->item( 0 )->childNodes; } } diff --git a/includes/apple-exporter/class-html.php b/includes/apple-exporter/class-html.php index bfa5b0bae..2fe62f5d4 100644 --- a/includes/apple-exporter/class-html.php +++ b/includes/apple-exporter/class-html.php @@ -24,7 +24,7 @@ class HTML { * @access private * @var array */ - private $_allowed_html = array( + private $allowed_html = array( 'a' => array( 'href' => true, ), @@ -71,7 +71,7 @@ public function format( $html ) { $html = preg_replace( '/]*?>.*?<\/script>/', '', $html ); // Strip out all tags and attributes other than what is allowed. - $html = wp_kses( $html, $this->_allowed_html ); + $html = wp_kses( $html, $this->allowed_html ); // Remove any tempty tags. $html = preg_replace( '/<([a-z0-9]+)[^>]*>\s*<\/\1>/', '', $html ); diff --git a/includes/apple-exporter/class-markdown.php b/includes/apple-exporter/class-markdown.php index caeef263d..63647bfca 100644 --- a/includes/apple-exporter/class-markdown.php +++ b/includes/apple-exporter/class-markdown.php @@ -31,7 +31,7 @@ class Markdown { * @access private * @var int */ - private $_list_index = 1; + private $list_index = 1; /** * List mode for lists being transformed to Markdown. @@ -39,7 +39,7 @@ class Markdown { * @access private * @var string */ - private $_list_mode = 'ul'; + private $list_mode = 'ul'; /** * Parse an array of nodes into the specified format. @@ -69,7 +69,7 @@ public function parse_nodes( $nodes ) { * @return string The processed content, converted to a Markdown string. */ private function parse_node( $node ) { - switch ( $node->nodeName ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + switch ( $node->nodeName ) { case 'strong': return $this->parse_node_strong( $node ); case 'i': @@ -113,7 +113,7 @@ private function parse_node( $node ) { private function parse_node_emphasis( $node ) { // If there is no text for this node, bail. - $text = $this->parse_nodes( $node->childNodes ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + $text = $this->parse_nodes( $node->childNodes ); $check = trim( $text ); if ( empty( $check ) ) { return ''; @@ -133,7 +133,7 @@ private function parse_node_emphasis( $node ) { private function parse_node_heading( $node ) { // If there is no text for this node, bail. - $text = $this->parse_nodes( $node->childNodes ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + $text = $this->parse_nodes( $node->childNodes ); $check = trim( $text ); if ( empty( $check ) ) { return ''; @@ -141,7 +141,7 @@ private function parse_node_heading( $node ) { return sprintf( '%s %s' . "\n", - str_repeat( '#', intval( substr( $node->nodeName, 1, 1 ) ) ), // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + str_repeat( '#', intval( substr( $node->nodeName, 1, 1 ) ) ), $text ); } @@ -160,7 +160,7 @@ private function parse_node_hyperlink( $node ) { $url = $node->getAttribute( 'href' ); // Set the text from the content of the child nodes. - $text = $this->parse_nodes( $node->childNodes ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + $text = $this->parse_nodes( $node->childNodes ); /** * Allows for filtering of the formatted content before return. @@ -191,17 +191,17 @@ private function parse_node_hyperlink( $node ) { private function parse_node_list_item( $node ) { // If there is no text for this node, bail. - $text = $this->parse_nodes( $node->childNodes ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + $text = $this->parse_nodes( $node->childNodes ); $check = trim( $text ); if ( empty( $check ) ) { return ''; } // Fork for ordered list items. - if ( 'ol' === $this->_list_mode ) { + if ( 'ol' === $this->list_mode ) { return sprintf( '%d. %s', - $this->_list_index ++, + $this->list_index ++, $text ); } @@ -218,11 +218,11 @@ private function parse_node_list_item( $node ) { * @return string The processed node, converted to a string. */ private function parse_node_ordered_list( $node ) { - $this->_list_mode = 'ol'; - $this->_list_index = 1; + $this->list_mode = 'ol'; + $this->list_index = 1; // If there is no text for this node, bail. - $text = $this->parse_nodes( $node->childNodes ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + $text = $this->parse_nodes( $node->childNodes ); $check = trim( $text ); if ( empty( $check ) ) { return ''; @@ -242,7 +242,7 @@ private function parse_node_ordered_list( $node ) { private function parse_node_paragraph( $node ) { // If there is no text for this node, bail. - $text = $this->parse_nodes( $node->childNodes ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + $text = $this->parse_nodes( $node->childNodes ); $check = trim( $text ); if ( empty( $check ) ) { return ''; @@ -262,7 +262,7 @@ private function parse_node_paragraph( $node ) { private function parse_node_strong( $node ) { // If there is no text for this node, bail. - $text = $this->parse_nodes( $node->childNodes ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + $text = $this->parse_nodes( $node->childNodes ); $check = trim( $text ); if ( empty( $check ) ) { return ''; @@ -280,7 +280,7 @@ private function parse_node_strong( $node ) { * @return string The processed node, converted to a string. */ private function parse_node_text( $node ) { - return str_replace( '!', '\\!', $node->nodeValue ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + return str_replace( '!', '\\!', $node->nodeValue ); } /** @@ -292,10 +292,10 @@ private function parse_node_text( $node ) { * @return string The processed node, converted to a string. */ private function parse_node_unordered_list( $node ) { - $this->_list_mode = 'ul'; + $this->list_mode = 'ul'; // If there is no text for this node, bail. - $text = $this->parse_nodes( $node->childNodes ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + $text = $this->parse_nodes( $node->childNodes ); $check = trim( $text ); if ( empty( $check ) ) { return ''; diff --git a/includes/apple-exporter/class-parser.php b/includes/apple-exporter/class-parser.php index d5b25ba80..20a354f78 100644 --- a/includes/apple-exporter/class-parser.php +++ b/includes/apple-exporter/class-parser.php @@ -120,7 +120,7 @@ private function parse_markdown( $html ) { libxml_use_internal_errors( false ); // Find the first-level nodes of the body tag. - $nodes = $dom->getElementsByTagName( 'body' )->item( 0 )->childNodes; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + $nodes = $dom->getElementsByTagName( 'body' )->item( 0 )->childNodes; // Perform parsing. $parser = new Markdown(); diff --git a/includes/apple-exporter/class-settings.php b/includes/apple-exporter/class-settings.php index 14bf5e0a1..196072299 100644 --- a/includes/apple-exporter/class-settings.php +++ b/includes/apple-exporter/class-settings.php @@ -29,7 +29,7 @@ class Settings { * @var array * @access private */ - private $_settings = array( + private $settings = array( 'api_async' => 'no', 'api_autosync' => 'yes', 'api_autosync_delete' => 'yes', @@ -65,8 +65,8 @@ public function __get( $name ) { } // Check for regular settings. - if ( isset( $this->_settings[ $name ] ) ) { - return $this->_settings[ $name ]; + if ( isset( $this->settings[ $name ] ) ) { + return $this->settings[ $name ]; } // Fall back to trying to get the setting dynamically from the theme. @@ -118,7 +118,7 @@ public function __isset( $name ) { } // Check for regular settings. - if ( isset( $this->_settings[ $name ] ) ) { + if ( isset( $this->settings[ $name ] ) ) { return true; } @@ -134,7 +134,7 @@ public function __isset( $name ) { * @access public */ public function __set( $name, $value ) { - $this->_settings[ $name ] = $value; + $this->settings[ $name ] = $value; } /** @@ -144,7 +144,7 @@ public function __set( $name, $value ) { * @return array The array of all settings defined in this class. */ public function all() { - return $this->_settings; + return $this->settings; } /** diff --git a/includes/apple-exporter/class-theme.php b/includes/apple-exporter/class-theme.php index 71f62795f..de70b4138 100644 --- a/includes/apple-exporter/class-theme.php +++ b/includes/apple-exporter/class-theme.php @@ -39,7 +39,7 @@ class Theme { * @access private * @var array */ - private static $_fonts = array( + private static $fonts = array( 'AcademyEngravedLetPlain', 'AlNile-Bold', 'AlNile', @@ -333,14 +333,14 @@ class Theme { * * @var array */ - private static $_groups = array(); + private static $groups = array(); /** * Theme options configuration. * * @var array */ - private static $_options = array(); + private static $options = array(); /** * Theme in current usage. @@ -348,7 +348,7 @@ class Theme { * @access private * @var self */ - private static $_used; + private static $used; /** * Theme name in current usage. @@ -356,7 +356,7 @@ class Theme { * @access private * @var string */ - private static $_used_name; + private static $used_name; /** * Tracks whether a dropcap was applied or not. @@ -372,7 +372,7 @@ class Theme { * @access private * @var string */ - private $_last_error = ''; + private $last_error = ''; /** * The name of this theme. @@ -380,7 +380,7 @@ class Theme { * @access private * @var string */ - private $_name = ''; + private $name = ''; /** * Values for theme options for this theme. @@ -388,7 +388,7 @@ class Theme { * @access private * @var array */ - private $_values = array(); + private $values = array(); /** * Gets the active theme name. @@ -416,7 +416,7 @@ public static function get_fonts() { * * @param array $fonts An array of TrueType font names. */ - return apply_filters( 'apple_news_fonts_list', self::$_fonts ); + return apply_filters( 'apple_news_fonts_list', self::$fonts ); } /** @@ -428,11 +428,11 @@ public static function get_fonts() { public static function get_options() { // If options have not been initialized, initialize them now. - if ( empty( self::$_options ) ) { + if ( empty( self::$options ) ) { self::initialize_options(); } - return self::$_options; + return self::$options; } /** @@ -460,8 +460,8 @@ public static function get_registry() { public static function get_used() { // Determine if a theme is already set. - if ( ! empty( self::$_used ) && self::$_used instanceof self ) { - return self::$_used; + if ( ! empty( self::$used ) && self::$used instanceof self ) { + return self::$used; } // Set the default. @@ -471,7 +471,7 @@ public static function get_used() { $theme->load(); $theme->use_this(); - return self::$_used; + return self::$used; } /** @@ -553,7 +553,7 @@ private static function sort_registry( $registry ) { * @access private */ private static function initialize_options() { - self::$_options = array( + self::$options = array( 'ad_frequency' => array( 'default' => 1, 'description' => __( 'A number between 1 and 10 defining the frequency for automatically inserting Banner Advertisement components into articles. For more information, see the Apple News Format Reference.', 'apple-news' ), @@ -1183,9 +1183,9 @@ public function delete() { $this->remove_from_registry( $this->get_name() ); // Remove from used, if necessary. - if ( self::$_used_name === $this->get_name() ) { - self::$_used_name = null; - self::$_used = null; + if ( self::$used_name === $this->get_name() ) { + self::$used_name = null; + self::$used = null; } } @@ -1239,11 +1239,11 @@ public function get_body_offset() { public function get_groups() { // If groups have not been initialized, initialize them now. - if ( empty( self::$_groups ) ) { + if ( empty( self::$groups ) ) { $this->initialize_groups(); } - return self::$_groups; + return self::$groups; } /** @@ -1253,7 +1253,7 @@ public function get_groups() { * @return string The text of the last error. */ public function get_last_error() { - return $this->_last_error; + return $this->last_error; } /** @@ -1274,11 +1274,11 @@ public function get_layout_columns() { public function get_name() { // If no name is set, use the default. - if ( empty( $this->_name ) ) { - $this->_name = __( 'Default', 'apple-news' ); + if ( empty( $this->name ) ) { + $this->name = __( 'Default', 'apple-news' ); } - return $this->_name; + return $this->name; } /** @@ -1292,8 +1292,8 @@ public function get_name() { public function get_value( $option ) { // Attempt to return the value from the values array. - if ( isset( $this->_values[ $option ] ) ) { - return $this->_values[ $option ]; + if ( isset( $this->values[ $option ] ) ) { + return $this->values[ $option ]; } // Attempt to fall back to the default. @@ -1317,12 +1317,12 @@ public function is_default() { foreach ( self::get_options() as $option => $option_config ) { // If the option is not specified, it is using the default. - if ( ! isset( $this->_values[ $option ] ) ) { + if ( ! isset( $this->values[ $option ] ) ) { continue; } // If the values don't match, it is not using the default. - if ( $this->_values[ $option ] !== $option_config['default'] ) { + if ( $this->values[ $option ] !== $option_config['default'] ) { return false; } } @@ -1362,21 +1362,21 @@ public function load( $values = array() ) { // Convert the format of the value based on type. switch ( $options[ $key ]['type'] ) { case 'float': - $this->_values[ $key ] = (float) $value; + $this->values[ $key ] = (float) $value; break; case 'integer': - $this->_values[ $key ] = (int) $value; + $this->values[ $key ] = (int) $value; break; default: - $this->_values[ $key ] = $value; + $this->values[ $key ] = $value; break; } } // Loop over local values and remove any that aren't present in loaded data. - foreach ( $this->_values as $key => $value ) { + foreach ( $this->values as $key => $value ) { if ( ! isset( $values[ $key ] ) ) { - unset( $this->_values[ $key ] ); + unset( $this->values[ $key ] ); } } @@ -1394,14 +1394,14 @@ public function load_postdata() { check_admin_referer( 'apple_news_save_edit_theme' ); // Remove all configured values except for JSON templates. - if ( ! empty( $this->_values['json_templates'] ) - && is_array( $this->_values['json_templates'] ) + if ( ! empty( $this->values['json_templates'] ) + && is_array( $this->values['json_templates'] ) ) { - $this->_values = array( - 'json_templates' => $this->_values['json_templates'], + $this->values = array( + 'json_templates' => $this->values['json_templates'], ); } else { - $this->_values = array(); + $this->values = array(); } // Loop through options and extract each from postdata. @@ -1422,7 +1422,7 @@ public function load_postdata() { switch ( $option['type'] ) { case 'array': if ( is_array( $_POST[ $option_key ] ) ) { - $this->_values[ $option_key ] = array_map( + $this->values[ $option_key ] = array_map( 'sanitize_text_field', array_map( 'wp_unslash', @@ -1434,17 +1434,17 @@ public function load_postdata() { break; case 'float': - $this->_values[ $option_key ] = floatval( $_POST[ $option_key ] ); + $this->values[ $option_key ] = floatval( $_POST[ $option_key ] ); break; case 'integer': - $this->_values[ $option_key ] = intval( $_POST[ $option_key ] ); + $this->values[ $option_key ] = intval( $_POST[ $option_key ] ); break; default: - $this->_values[ $option_key ] = sanitize_text_field( + $this->values[ $option_key ] = sanitize_text_field( wp_unslash( $_POST[ $option_key ] ) @@ -1458,7 +1458,7 @@ public function load_postdata() { if ( ! isset( $_POST['meta_component_order'] ) // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected && ! empty( $_POST['meta_component_inactive'] ) // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected ) { - $this->_values['meta_component_order'] = array(); + $this->values['meta_component_order'] = array(); } } @@ -1498,7 +1498,7 @@ public function rename( $name ) { $old_theme->delete(); // Refresh used if in active use. - if ( $old_name === self::$_used_name ) { + if ( $old_name === self::$used_name ) { $this->use_this(); } @@ -1519,13 +1519,13 @@ public function save() { } // Save the theme. - update_option( self::theme_key( $this->get_name() ), $this->_values, false ); + update_option( self::theme_key( $this->get_name() ), $this->values, false ); // Add to the registry. $this->add_to_registry( $this->get_name() ); // Refresh loaded theme, if currently in use. - if ( self::$_used_name === $this->get_name() ) { + if ( self::$used_name === $this->get_name() ) { $this->use_this(); } @@ -1559,7 +1559,7 @@ public function set_active() { * @param string $name The name to set. */ public function set_name( $name ) { - $this->_name = $name; + $this->name = $name; } /** @@ -1574,14 +1574,14 @@ public function set_name( $name ) { public function set_value( $option, $value ) { // Attempt to change the value. - $starting_values = $this->_values; - $this->_values[ $option ] = $value; + $starting_values = $this->values; + $this->values[ $option ] = $value; if ( $this->validate() ) { return true; } // Change was unsuccessful, so revert to old values. - $this->_values = $starting_values; + $this->values = $starting_values; return false; } @@ -1592,14 +1592,14 @@ public function set_value( $option, $value ) { * @access public */ public function use_this() { - self::$_used_name = $this->get_name(); - self::$_used = $this; + self::$used_name = $this->get_name(); + self::$used = $this; } /** * Sanitizes and validates the values array. * - * If an error is encountered, it will be saved in the $_last_error property. + * If an error is encountered, it will be saved in the $last_error property. * * @access public * @return bool True if the values are valid, false if not. @@ -1607,7 +1607,7 @@ public function use_this() { public function validate() { // If values is not an array, then the configuration is invalid. - if ( ! is_array( $this->_values ) ) { + if ( ! is_array( $this->values ) ) { $this->log_error( __( 'Theme values were not in array format.', @@ -1620,7 +1620,7 @@ public function validate() { // Loop through provided values and check each. $options = self::get_options(); - foreach ( $this->_values as $key => &$value ) { + foreach ( $this->values as $key => &$value ) { // If the provided key is not in the valid options spec, mark invalid. if ( ! isset( $options[ $key ] ) ) { @@ -1749,10 +1749,10 @@ public function validate() { } // Validate meta_component_order separately. - if ( ! empty( $this->_values['meta_component_order'] ) ) { + if ( ! empty( $this->values['meta_component_order'] ) ) { // Ensure no values were provided other than what is permissible. - foreach ( $this->_values['meta_component_order'] as $component ) { + foreach ( $this->values['meta_component_order'] as $component ) { if ( ! in_array( $component, $options['meta_component_order']['default'], true ) ) { $this->log_error( __( 'Invalid value for meta component order', 'apple-news' ) @@ -1801,7 +1801,7 @@ private function add_to_registry( $name ) { * @access private */ private function initialize_groups() { - self::$_groups = array( + self::$groups = array( 'layout' => array( 'label' => __( 'Layout Spacing', 'apple-news' ), 'description' => __( 'The spacing for the base layout of the exported articles', 'apple-news' ), @@ -2017,7 +2017,7 @@ private function initialize_groups() { * @access private */ private function log_error( $message ) { - $this->_last_error = $message; + $this->last_error = $message; } /** @@ -2057,7 +2057,7 @@ private function remove_from_registry( $name ) { private function validate_json_templates() { // If no JSON templates are defined, count as a success. - if ( empty( $this->_values['json_templates'] ) ) { + if ( empty( $this->values['json_templates'] ) ) { return true; } @@ -2067,7 +2067,7 @@ private function validate_json_templates() { $components = $component_factory::get_components(); // Iterate over components and look for customized JSON for each. - $invalid_components = $this->_values['json_templates']; + $invalid_components = $this->values['json_templates']; foreach ( $components as $component_class ) { // Negotiate the component key. @@ -2075,14 +2075,14 @@ private function validate_json_templates() { $component_key = $component->get_component_name(); // Determine if this component key is defined in this theme. - if ( empty( $this->_values['json_templates'][ $component_key ] ) - || ! is_array( $this->_values['json_templates'][ $component_key ] ) + if ( empty( $this->values['json_templates'][ $component_key ] ) + || ! is_array( $this->values['json_templates'][ $component_key ] ) ) { continue; } // Loop through component key and validate. - $current_component = &$this->_values['json_templates'][ $component_key ]; + $current_component = &$this->values['json_templates'][ $component_key ]; $specs = $component->get_specs(); foreach ( $specs as $spec_key => $spec ) { diff --git a/includes/apple-exporter/components/class-audio.php b/includes/apple-exporter/components/class-audio.php index 091d23d0b..2287745e6 100644 --- a/includes/apple-exporter/components/class-audio.php +++ b/includes/apple-exporter/components/class-audio.php @@ -26,7 +26,7 @@ class Audio extends Component { */ public static function node_matches( $node ) { // Is this an audio node? - if ( 'audio' === $node->nodeName && self::remote_file_exists( $node ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + if ( 'audio' === $node->nodeName && self::remote_file_exists( $node ) ) { return $node; } diff --git a/includes/apple-exporter/components/class-body.php b/includes/apple-exporter/components/class-body.php index 00a932d7f..d924ec420 100644 --- a/includes/apple-exporter/components/class-body.php +++ b/includes/apple-exporter/components/class-body.php @@ -37,30 +37,30 @@ class Body extends Component { * * @param \DOMElement $node The node to examine for matches. * @access public - * @return \DOMElement|null The node on success, or null on no match. + * @return array|null The node on success, or null on no match. */ public static function node_matches( $node ) { // We are only interested in p, pre, ul and ol. - if ( ! in_array( $node->nodeName, array( 'p', 'pre', 'ul', 'ol' ), true ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + if ( ! in_array( $node->nodeName, array( 'p', 'pre', 'ul', 'ol' ), true ) ) { return null; } // If the node is p, ul or ol AND it's empty, just ignore. - if ( empty( $node->nodeValue ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + if ( empty( $node->nodeValue ) ) { return null; } // Negotiate open and close values. - $open = '<' . $node->nodeName . '>'; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar - $close = 'nodeName . '>'; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar - if ( 'ol' === $node->nodeName || 'ul' === $node->nodeName ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + $open = '<' . $node->nodeName . '>'; + $close = 'nodeName . '>'; + if ( 'ol' === $node->nodeName || 'ul' === $node->nodeName ) { $open .= '

  • '; $close = '
  • ' . $close; } return self::split_unsupported_elements( - $node->ownerDocument->saveXML( $node ), // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar - $node->nodeName, // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + $node->ownerDocument->saveXML( $node ), + $node->nodeName, $open, $close ); diff --git a/includes/apple-exporter/components/class-component.php b/includes/apple-exporter/components/class-component.php index 428d7f7a9..12ccf1416 100644 --- a/includes/apple-exporter/components/class-component.php +++ b/includes/apple-exporter/components/class-component.php @@ -290,7 +290,7 @@ protected static function clean_html( $html ) { libxml_clear_errors( true ); // Find the first-level nodes of the body tag. - $element = $dom->getElementsByTagName( 'body' )->item( 0 )->childNodes->item( 0 ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + $element = $dom->getElementsByTagName( 'body' )->item( 0 )->childNodes->item( 0 ); $html = $dom->saveHTML( $element ); return preg_replace( '#<[^/>][^>]*>]+>#', '', $html ); } @@ -740,7 +740,7 @@ public function get_component_name() { protected static function remote_file_exists( $node ) { // Try to get a URL from the src attribute of the HTML. - $html = $node->ownerDocument->saveXML( $node ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + $html = $node->ownerDocument->saveXML( $node ); $path = self::url_from_src( $html ); if ( empty( $path ) ) { return false; @@ -775,8 +775,7 @@ protected static function url_from_src( $html ) { return ''; } - // Loop through matches, returning the first valid URL found. - // Matching on src= + // Loop through matches, returning the first valid URL found, matching on src=. foreach ( $matches[1] as $url ) { // Run the URL through the formatter. @@ -788,7 +787,7 @@ protected static function url_from_src( $html ) { } } - // Matching on background-image:url + // Matching on background-image:url. foreach ( $matches[2] as $url ) { // Run the URL through the formatter. @@ -804,10 +803,10 @@ protected static function url_from_src( $html ) { } /** - * Get iframe/embed node + * Get iframe/embed node. * - * @param [mixed] $node $node object - * @return boolean $has_figure_iframe + * @param \DOMElement $node The node to examine. + * @return bool True if the figure is an iframe. */ public static function is_embed_figure( $node ) { diff --git a/includes/apple-exporter/components/class-divider.php b/includes/apple-exporter/components/class-divider.php index bbf7d18ce..c11bcb5f1 100644 --- a/includes/apple-exporter/components/class-divider.php +++ b/includes/apple-exporter/components/class-divider.php @@ -23,7 +23,7 @@ class Divider extends Component { * @return \DOMElement|null The node on success, or null on no match. */ public static function node_matches( $node ) { - if ( 'hr' === $node->nodeName ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + if ( 'hr' === $node->nodeName ) { return $node; } diff --git a/includes/apple-exporter/components/class-embed-generic.php b/includes/apple-exporter/components/class-embed-generic.php index 336dbc4eb..e235ecdf1 100644 --- a/includes/apple-exporter/components/class-embed-generic.php +++ b/includes/apple-exporter/components/class-embed-generic.php @@ -35,7 +35,7 @@ public static function node_matches( $node ) { // Check for Gutenberg-style embeds, which have a helpful signature. if ( 'figure' === $node->nodeName - && false !== strpos( $node->getAttribute('class'), 'wp-block-embed-' ) + && false !== strpos( $node->getAttribute( 'class' ), 'wp-block-embed-' ) ) { return $node; } @@ -48,7 +48,7 @@ public static function node_matches( $node ) { // Check for paragraphs containing iframes. if ( 'p' === $node->nodeName && $node->hasChildNodes() - && 'iframe' === $node->childNodes->item(0)->nodeName + && 'iframe' === $node->childNodes->item( 0 )->nodeName ) { return $node; } @@ -77,7 +77,7 @@ public function register_specs() { 'embed-generic-layout', __( 'Embed (generic) Layout', 'apple-news' ), [ - 'margin' => [ + 'margin' => [ 'top' => 15, 'bottom' => 15, ], @@ -102,12 +102,13 @@ protected function build( $html ) { if ( preg_match( '/wp-block-embed-([0-9a-zA-Z-]+)/', $html, $matches ) ) { $provider = $matches[1]; } else { - /* Define a map of domain names to provider slugs to check for as a best guess. + /* + * Define a map of domain names to provider slugs to check for as a best guess. * This list is intentionally organized from most specific to least specific, so do not * alphabetize it! The logic here is that a block may contain references to amazon.com either * in-text or via links to Amazon services (AWS, S3, etc) but actually be an embed for a * different provider. Therefore, we will only consider an embed to be from "generic" providers - * like Amazon or Imgur if no other, more specifc, providers were matched first. + * like Amazon or Imgur if no other, more specific, providers were matched first. */ $provider_map = [ 'animoto.com' => 'animoto', diff --git a/includes/apple-exporter/components/class-embed-web-video.php b/includes/apple-exporter/components/class-embed-web-video.php index 77f2e5a0f..f6600b402 100644 --- a/includes/apple-exporter/components/class-embed-web-video.php +++ b/includes/apple-exporter/components/class-embed-web-video.php @@ -38,9 +38,9 @@ class Embed_Web_Video extends Component { */ public static function is_embed_web_video( $node, $pattern ) { return ( - ( 'p' === $node->nodeName && preg_match( $pattern, trim( $node->nodeValue ) ) ) // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar - || ( 'iframe' === $node->nodeName && preg_match( $pattern, trim( $node->getAttribute( 'src' ) ) ) ) // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar - || ( 'figure' === $node->nodeName && Component::is_embed_figure( $node ) && preg_match( $pattern, trim( $node->nodeValue ) ) ) // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + ( 'p' === $node->nodeName && preg_match( $pattern, trim( $node->nodeValue ) ) ) + || ( 'iframe' === $node->nodeName && preg_match( $pattern, trim( $node->getAttribute( 'src' ) ) ) ) + || ( 'figure' === $node->nodeName && Component::is_embed_figure( $node ) && preg_match( $pattern, trim( $node->nodeValue ) ) ) ); } @@ -55,7 +55,7 @@ public static function node_matches( $node ) { // Handling for a Gutenberg web video embed. if ( - 'figure' === $node->nodeName // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + 'figure' === $node->nodeName && ( self::node_has_class( $node, 'wp-block-embed-vimeo' ) || self::node_has_class( $node, 'wp-block-embed-youtube' ) ) diff --git a/includes/apple-exporter/components/class-facebook.php b/includes/apple-exporter/components/class-facebook.php index 6aca729a1..853ea1b5d 100644 --- a/includes/apple-exporter/components/class-facebook.php +++ b/includes/apple-exporter/components/class-facebook.php @@ -32,7 +32,7 @@ class Facebook extends Component { * @access private * @var array */ - private static $_url_signatures = array( + private static $url_signatures = array( '/data-href="([^"]+)"/i', '/<(?:fb:)?post\s.*?href="([^"]+)"/i', ); @@ -64,20 +64,20 @@ public static function node_matches( $node ) { // Handling for a Gutenberg Facebook embed. if ( - 'figure' === $node->nodeName // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + 'figure' === $node->nodeName && self::node_has_class( $node, 'wp-block-embed-facebook' ) ) { return $node; } // Check for element with just a Facebook url. - if ( false !== self::get_facebook_url( $node->nodeValue ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + if ( false !== self::get_facebook_url( $node->nodeValue ) ) { return $node; } // Handling for a rendered Facebook embed. if ( - 'div' === $node->nodeName // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + 'div' === $node->nodeName && self::node_has_class( $node, 'fb-post' ) ) { @@ -94,7 +94,7 @@ public static function node_matches( $node ) { } // Handling for a rendered WordPress.com Facebook embed. - $html = $node->ownerDocument->saveXML( $node ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + $html = $node->ownerDocument->saveXML( $node ); if ( preg_match( '/<(?:fb:)?post\s.*?href="([^"]+)"/i', $html, $matches ) ) { // Ensure we have a valid Facebook embed URL. @@ -118,7 +118,7 @@ public static function node_matches( $node ) { protected function build( $html ) { // Check for href properties on rendered embeds. - foreach ( self::$_url_signatures as $signature ) { + foreach ( self::$url_signatures as $signature ) { if ( preg_match( $signature, $html, $matches ) ) { $html = $matches[1]; break; diff --git a/includes/apple-exporter/components/class-gallery.php b/includes/apple-exporter/components/class-gallery.php index 841c5559c..7f2a9797c 100644 --- a/includes/apple-exporter/components/class-gallery.php +++ b/includes/apple-exporter/components/class-gallery.php @@ -77,20 +77,20 @@ protected function build( $html ) { $dom->loadHTML( '' . $html ); libxml_clear_errors(); libxml_use_internal_errors( false ); - $nodes = $dom->getElementsByTagName( 'body' )->item( 0 )->childNodes; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + $nodes = $dom->getElementsByTagName( 'body' )->item( 0 )->childNodes; // Determine if we have items. - if ( ! $nodes || ! $nodes->item( 0 )->childNodes ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + if ( ! $nodes || ! $nodes->item( 0 )->childNodes ) { return; } // Loop through items and construct slides. $theme = \Apple_Exporter\Theme::get_used(); $items = array(); - foreach ( $nodes->item( 0 )->childNodes as $item ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + foreach ( $nodes->item( 0 )->childNodes as $item ) { // Convert item into HTML for regex matching. - $item_html = $item->ownerDocument->saveXML( $item ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + $item_html = $item->ownerDocument->saveXML( $item ); // Try to get URL. if ( ! preg_match( '/src="([^"]+)"/', $item_html, $matches ) ) { @@ -113,7 +113,7 @@ protected function build( $html ) { if ( $caption && $caption->length ) { $content['caption'] = array( 'text' => sanitize_text_field( - trim( $caption->item( 0 )->nodeValue ) // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + trim( $caption->item( 0 )->nodeValue ) ), ); } diff --git a/includes/apple-exporter/components/class-heading.php b/includes/apple-exporter/components/class-heading.php index 09a78847f..332d4bfbc 100644 --- a/includes/apple-exporter/components/class-heading.php +++ b/includes/apple-exporter/components/class-heading.php @@ -37,11 +37,11 @@ public static function node_matches( $node ) { self::$levels[ count( self::$levels ) - 1 ] ); - if ( ! preg_match( $regex, $node->nodeName ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + if ( ! preg_match( $regex, $node->nodeName ) ) { return null; } - $html = $node->ownerDocument->saveXML( $node ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + $html = $node->ownerDocument->saveXML( $node ); if ( preg_match( '##si', $html ) ) { return self::split_image( $html ); } diff --git a/includes/apple-exporter/components/class-image.php b/includes/apple-exporter/components/class-image.php index 2f5aa8308..272104983 100644 --- a/includes/apple-exporter/components/class-image.php +++ b/includes/apple-exporter/components/class-image.php @@ -28,7 +28,7 @@ public static function node_matches( $node ) { // Is this an image node? if ( - ( self::node_has_class( $node, 'wp-block-cover' ) || 'img' === $node->nodeName || ( 'figure' === $node->nodeName && Component::is_embed_figure( $node ) ) ) // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + ( self::node_has_class( $node, 'wp-block-cover' ) || 'img' === $node->nodeName || ( 'figure' === $node->nodeName && Component::is_embed_figure( $node ) ) ) && self::remote_file_exists( $node ) ) { return $node; @@ -176,14 +176,14 @@ protected function build( $html ) { // Check for caption. $caption_regex = $is_cover_block ? '#?\n(.*)#m' : '#(.*?)#m'; if ( preg_match( $caption_regex, $html, $matches ) ) { - $caption = trim( $matches[1] ); - $values['#caption#'] = ! $is_cover_block ? $caption : array( - 'text' => $caption, - 'format' => 'html', + $caption = trim( $matches[1] ); + $values['#caption#'] = ! $is_cover_block ? $caption : array( + 'text' => $caption, + 'format' => 'html', ); $values['#caption_text#'] = $caption; - $values = $this->group_component( $values['#caption#'], $values ); - $spec_name = 'json-with-caption'; + $values = $this->group_component( $values['#caption#'], $values ); + $spec_name = 'json-with-caption'; } else { $spec_name = 'json-without-caption'; } diff --git a/includes/apple-exporter/components/class-instagram.php b/includes/apple-exporter/components/class-instagram.php index 8080c280d..5a413ec92 100644 --- a/includes/apple-exporter/components/class-instagram.php +++ b/includes/apple-exporter/components/class-instagram.php @@ -29,14 +29,14 @@ public static function node_matches( $node ) { // Handling for a Gutenberg Instagram embed. if ( - 'figure' === $node->nodeName // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + 'figure' === $node->nodeName && self::node_has_class( $node, 'wp-block-embed-instagram' ) ) { return $node; } // Handle Instagram oEmbed URLs. - if ( false !== self::get_instagram_url( $node->nodeValue ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + if ( false !== self::get_instagram_url( $node->nodeValue ) ) { return $node; } diff --git a/includes/apple-exporter/components/class-quote.php b/includes/apple-exporter/components/class-quote.php index ec62e1e05..8d056015a 100644 --- a/includes/apple-exporter/components/class-quote.php +++ b/includes/apple-exporter/components/class-quote.php @@ -26,7 +26,7 @@ class Quote extends Component { * @return \DOMElement|null The node on success, or null on no match. */ public static function node_matches( $node ) { - return ( 'blockquote' === $node->nodeName || ( isset( $node->firstChild->tagName ) && 'blockquote' === $node->firstChild->tagName ) ) ? $node : null; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + return ( 'blockquote' === $node->nodeName || ( isset( $node->firstChild->tagName ) && 'blockquote' === $node->firstChild->tagName ) ) ? $node : null; } /** @@ -236,7 +236,7 @@ protected function build( $html ) { preg_match( $string_match, $html, $matches ); $this->text_alignment = 3 === count( $matches ) && $matches[1] ? $matches[1] : 'left'; $this->text_alignment = 'wide' === $this->text_alignment ? 'center' : $this->text_alignment; - $text = isset( $matches[2] ) ? $matches[2] : $matches[1]; + $text = isset( $matches[2] ) ? $matches[2] : $matches[1]; // If there is no text for this element, bail. $check = trim( $text ); @@ -331,7 +331,7 @@ private function build_blockquote( $text ) { '#blockquote_background_color#' => $theme->get_value( 'blockquote_background_color' ), '#text#' => $this->parser->parse( $text ), '#format#' => $this->parser->format, - '#default_blockquote#' => 'default-blockquote' . '-' . $this->text_alignment, + '#default_blockquote#' => 'default-blockquote-' . $this->text_alignment, ); // Set component attributes. @@ -438,11 +438,11 @@ private function set_blockquote_layout() { private function set_blockquote_style() { // Get information about the currently loaded theme. - $theme = \Apple_Exporter\Theme::get_used(); - $textAlignment = $this->find_text_alignment( $this->text ); + $theme = \Apple_Exporter\Theme::get_used(); + $text_alignment = $this->find_text_alignment( $this->text ); $this->register_style( - 'default-blockquote' . '-' . $textAlignment, + 'default-blockquote-' . $text_alignment, 'default-blockquote', array( '#blockquote_font#' => $theme->get_value( 'blockquote_font' ), diff --git a/includes/apple-exporter/components/class-table.php b/includes/apple-exporter/components/class-table.php index 8bc278396..02d26730d 100644 --- a/includes/apple-exporter/components/class-table.php +++ b/includes/apple-exporter/components/class-table.php @@ -25,7 +25,7 @@ class Table extends Component { public static function node_matches( $node ) { // First, check to see if the primary node is a table. - if ( 'table' !== $node->nodeName ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + if ( 'table' !== $node->nodeName ) { return null; } diff --git a/includes/apple-exporter/components/class-tweet.php b/includes/apple-exporter/components/class-tweet.php index 86055cb4c..3a6d13c03 100644 --- a/includes/apple-exporter/components/class-tweet.php +++ b/includes/apple-exporter/components/class-tweet.php @@ -27,16 +27,16 @@ public static function node_matches( $node ) { // Handling for a Gutenberg Twitter embed. if ( - 'figure' === $node->nodeName // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + 'figure' === $node->nodeName && self::node_has_class( $node, 'wp-block-embed-twitter' ) ) { return $node; } // Check if the body of a node is solely a tweet URL. - $is_twitter_url = 'p' === $node->nodeName && preg_match( // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + $is_twitter_url = 'p' === $node->nodeName && preg_match( '#https?://(www\.)?twitter\.com/.+?/status(es)?/.*#i', - trim( $node->nodeValue ) // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + trim( $node->nodeValue ) ); if ( self::node_has_class( $node, 'twitter-tweet' ) || $is_twitter_url ) { diff --git a/includes/apple-exporter/components/class-video.php b/includes/apple-exporter/components/class-video.php index 89bc38602..8691fa63a 100644 --- a/includes/apple-exporter/components/class-video.php +++ b/includes/apple-exporter/components/class-video.php @@ -30,7 +30,7 @@ class Video extends Component { public static function node_matches( $node ) { // Ensure that this is a video tag and that the source exists. - if ( 'video' === $node->nodeName && self::remote_file_exists( $node ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + if ( 'video' === $node->nodeName && self::remote_file_exists( $node ) ) { return $node; } diff --git a/includes/apple-push-api/request/class-request.php b/includes/apple-push-api/request/class-request.php index f18e74681..e5d17b029 100644 --- a/includes/apple-push-api/request/class-request.php +++ b/includes/apple-push-api/request/class-request.php @@ -282,8 +282,8 @@ private function parse_response( $response, $json = true, $type = 'post', $meta foreach ( $response_decoded->errors as $error ) { // If there is a keyPath, build it into a string. $key_path = ''; - if ( ! empty( $error->keyPath ) && is_array( $error->keyPath ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar - foreach ( $error->keyPath as $i => $path ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + if ( ! empty( $error->keyPath ) && is_array( $error->keyPath ) ) { + foreach ( $error->keyPath as $i => $path ) { if ( $i > 0 ) { $key_path .= "->$path"; } else { @@ -291,7 +291,7 @@ private function parse_response( $response, $json = true, $type = 'post', $meta } } - $key_path = " (keyPath $key_path)"; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + $key_path = " (keyPath $key_path)"; } // Add the code, message and keyPath. @@ -385,4 +385,4 @@ private function sign( $url, $verb, $content = null ) { * @package Apple_News * @subpackage Apple_Push_API\Request */ -class Request_Exception extends \Exception {} // phpcs:ignore Generic.Files.OneClassPerFile.MultipleFound +class Request_Exception extends \Exception {} // phpcs:ignore Generic.Files.OneObjectStructurePerFile.MultipleFound diff --git a/includes/class-apple-news.php b/includes/class-apple-news.php index 173f51015..6ab90a223 100644 --- a/includes/class-apple-news.php +++ b/includes/class-apple-news.php @@ -39,7 +39,7 @@ class Apple_News { * @var string * @access public */ - public static $version = '1.4.4'; + public static $version = '2.0.0'; /** * Link to support for the plugin on WordPress.org. @@ -55,7 +55,7 @@ class Apple_News { * @var bool * @access private */ - private static $_is_initialized; + private static $is_initialized; /** * Plugin domain. @@ -79,7 +79,7 @@ class Apple_News { * @var array * @access private */ - private $_contexts = array( + private $contexts = array( 'post.php', 'post-new.php', 'toplevel_page_apple_news_index', @@ -182,15 +182,15 @@ public static function get_support_info( $format = 'html', $with_padding = true public static function is_initialized() { // Look up required information in plugin settings, if necessary. - if ( null === self::$_is_initialized ) { - $settings = get_option( self::$option_name ); - self::$_is_initialized = ( ! empty( $settings['api_channel'] ) + if ( null === self::$is_initialized ) { + $settings = get_option( self::$option_name ); + self::$is_initialized = ( ! empty( $settings['api_channel'] ) && ! empty( $settings['api_key'] ) && ! empty( $settings['api_secret'] ) ); } - return self::$_is_initialized; + return self::$is_initialized; } /** @@ -237,7 +237,7 @@ public function action_admin_enqueue_scripts( $hook ) { } // Ensure we are in an appropriate context. - if ( ! in_array( $hook, $this->_contexts, true ) ) { + if ( ! in_array( $hook, $this->contexts, true ) ) { return; } diff --git a/includes/meta.php b/includes/meta.php index 2eb45848c..388354da3 100644 --- a/includes/meta.php +++ b/includes/meta.php @@ -93,7 +93,7 @@ function apple_news_sanitize_coverart_data( $meta_value ) { $image_sizes = array_keys( Admin_Apple_News::get_image_sizes() ); // Construct the meta value from the array of image sizes. - $raw_value = json_decode( $meta_value, true ); + $raw_value = json_decode( $meta_value, true ); $sanitized_value = []; foreach ( $image_sizes as $image_size ) { if ( ! empty( $raw_value[ $image_size ] ) && is_int( $raw_value[ $image_size ] ) ) { diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 45729c6bd..ed47a7318 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -34,19 +34,22 @@ assets/ + webpack.config.js - - - - - - + + + + + + + + @@ -54,20 +57,34 @@ - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - + + 0 @@ -83,9 +100,6 @@ 0 - - 0 - 0 @@ -122,4 +136,7 @@ 0 + + 0 + diff --git a/readme.txt b/readme.txt index a58e228cb..4560a65d8 100644 --- a/readme.txt +++ b/readme.txt @@ -1,11 +1,11 @@ === Publish To Apple News === -Contributors: potatomaster, kevinfodness, alleyinteractive, beezwaxbuzz, gosukiwi, pilaf, jaygonzales, brianschick +Contributors: potatomaster, kevinfodness, jomurgel, danbowles, alleyinteractive, beezwaxbuzz, gosukiwi, pilaf, jaygonzales, brianschick Donate link: https://wordpress.org Tags: publish, apple, news, iOS Requires at least: 4.0 -Tested up to: 5.1.1 +Tested up to: 5.2.2 Requires PHP: 5.6 -Stable tag: 1.4.4 +Stable tag: 2.0.0 License: GPLv3 or later License URI: https://www.gnu.org/licenses/gpl.html @@ -46,6 +46,11 @@ Please visit our [wiki](https://github.com/alleyinteractive/apple-news/wiki) for == Changelog == += 2.0.0 = +* Enhancement: Adds full support for Gutenberg. If Gutenberg is active for a post, uses a Gutenberg PluginSidebar to house all of the Apple News options rather than a metabox. Also adds support for new HTML generated by Gutenberg, including various embeds. +* Enhancement: Adds support for the isPaid flag to indicate that a post is part of News+ and requires a subscription to view. +* Bugfix: Refreshes the nonce after re-authenticating to prevent data loss when Gutenberg is not active. Props to @hrkhal for the fix. + = 1.4.4 = * Enhancement: Added the apple_news_notification_headers filter to allow headers to be added to the notification email message. Props to @paulschreiber for the addition. * Bugfix: Improved handling of UTF-8 multibyte characters to provide better support for the French language.