diff --git a/includes/class-syndication-admin-notices.php b/includes/class-syndication-admin-notices.php index 06103407..ccc5517a 100644 --- a/includes/class-syndication-admin-notices.php +++ b/includes/class-syndication-admin-notices.php @@ -96,7 +96,17 @@ public static function display_valid_notices() { foreach( $message_values as $message_key => $message_data ) { $dismiss_nonce = wp_create_nonce( esc_attr( $message_key ) ); printf( '

', esc_attr( $message_data['class'] ) ); - printf( __('%1$s : %2$s Hide Notice'), esc_html( $message_type ), wp_kses_post( $message_data['message_text'] ), add_query_arg( array( self::$dismiss_parameter => esc_attr( $message_key ), 'syn_dismiss_nonce' => esc_attr( $dismiss_nonce ) ) ) ); + printf( + __('%1$s : %2$s Hide Notice'), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + esc_html( $message_type ), + wp_kses_post( $message_data['message_text'] ), + esc_url( add_query_arg( + array( + self::$dismiss_parameter => esc_attr( $message_key ), + 'syn_dismiss_nonce' => esc_attr( $dismiss_nonce ) + ) + ) ) + ); printf( '

' ); } } @@ -112,9 +122,9 @@ public static function handle_dismiss_syndication_notice() { if ( isset( $_GET[self::$dismiss_parameter] ) && current_user_can( $capability ) ) { $dismiss_key = esc_attr( $_GET[self::$dismiss_parameter] ); - $dismiss_nonce = esc_attr( $_GET['syn_dismiss_nonce'] ); + $dismiss_nonce = esc_attr( isset( $_GET['syn_dismiss_nonce'] ) ? $_GET['syn_dismiss_nonce'] : '' ); if ( ! wp_verify_nonce( $dismiss_nonce, $dismiss_key ) ) { - wp_die( __( "Invalid security check" ) ); + wp_die( esc_html__( "Invalid security check" ) ); } $messages = get_option( self::$notice_option ); $notice_bundles = get_option( self::$notice_bundles_option ); diff --git a/includes/class-syndication-logger.php b/includes/class-syndication-logger.php index ab5f8340..c2471007 100644 --- a/includes/class-syndication-logger.php +++ b/includes/class-syndication-logger.php @@ -276,7 +276,7 @@ private function log( $storage_type, $msg_type, $object_type = 'post', $object_i } if ( ! empty( $log_time ) ) { - $log_entry['time'] = date('Y-m-d H:i:s', strtotime( $log_time ) ); + $log_entry['time'] = gmdate('Y-m-d H:i:s', strtotime( $log_time ) ); } else { $log_entry['time'] = current_time('mysql'); } @@ -288,6 +288,7 @@ private function log( $storage_type, $msg_type, $object_type = 'post', $object_i if ( true === $this->use_php_error_logging ) { + // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log error_log( $this->format_log_message( $msg_type, $log_entry ) ); } diff --git a/includes/class-syndication-site-auto-retry.php b/includes/class-syndication-site-auto-retry.php index e11a9ab1..aea6181f 100644 --- a/includes/class-syndication-site-auto-retry.php +++ b/includes/class-syndication-site-auto-retry.php @@ -81,7 +81,7 @@ public function handle_pull_failure_event( $site_id = 0, $failed_attempts = 0 ) // and hence order better in the log viewer // without this, sometimes when the pull occurs quickly // these log items appear to occur at the same time as the failure - $log_time = date( 'Y-m-d H:i:s', $time_now + 1 ); + $log_time = gmdate( 'Y-m-d H:i:s', $time_now + 1 ); // Are we still below the auto retry limit? if ( $site_auto_retry_count < $auto_retry_limit ) { diff --git a/includes/class-wp-push-syndication-server.php b/includes/class-wp-push-syndication-server.php index 5da03d62..400a7063 100644 --- a/includes/class-wp-push-syndication-server.php +++ b/includes/class-wp-push-syndication-server.php @@ -14,6 +14,18 @@ class WP_Push_Syndication_Server { function __construct() { + $this->push_syndicate_default_settings = array( + 'selected_pull_sitegroups' => array(), + 'selected_post_types' => array( 'post' ), + 'delete_pushed_posts' => 'off', + 'pull_time_interval' => '3600', + 'update_pulled_posts' => 'off', + 'client_id' => '', + 'client_secret' => '' + ); + + $this->push_syndicate_settings = wp_parse_args( (array) get_option( 'push_syndicate_settings' ), $this->push_syndicate_default_settings ); + // initialization add_action( 'init', array( $this, 'init' ) ); add_action( 'admin_init', array( $this, 'admin_init' ) ); @@ -136,18 +148,6 @@ public function init() { 'capabilities' => $taxonomy_capabilities, )); - $this->push_syndicate_default_settings = array( - 'selected_pull_sitegroups' => array(), - 'selected_post_types' => array( 'post' ), - 'delete_pushed_posts' => 'off', - 'pull_time_interval' => '3600', - 'update_pulled_posts' => 'off', - 'client_id' => '', - 'client_secret' => '' - ); - - $this->push_syndicate_settings = wp_parse_args( (array) get_option( 'push_syndicate_settings' ), $this->push_syndicate_default_settings ); - $this->version = get_option( 'syn_version' ); do_action( 'syn_after_init_server' ); @@ -183,7 +183,7 @@ public function manage_columns( $column_name, $id ) { $client_data = $client->get_client_data(); echo esc_html( sprintf( '%s (%s)', $client_data['name'], array_shift( $client_data['modes'] ) ) ); } catch ( Exception $e ) { - printf( __( 'Unknown (%s)', 'push-syndication' ), esc_html( $transport_type ) ); + printf( esc_html__( 'Unknown (%s)', 'push-syndication' ), esc_html( $transport_type ) ); } break; case 'syn_sitegroup': @@ -346,7 +346,7 @@ public function display_pull_sitegroups_selection() {

description ); ?> @@ -421,7 +421,7 @@ public function display_post_types_selection() {

  • @@ -560,7 +560,7 @@ public function display_sitegroups_selection() {

    description ); ?> @@ -621,7 +621,7 @@ public function add_site_status_metabox( $site ) {

    - +
    @@ -663,7 +663,7 @@ public function add_site_settings_metabox( $post ) { try { Syndication_Client_Factory::display_client_settings( $post, $transport_type ); } catch( Exception $e ) { - echo $e; + echo $e; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } ?> @@ -684,7 +684,7 @@ public function display_transports( $transport_type, $mode ) { $max_len = 0; foreach( $this->push_syndicate_transports as $key => $value ) { $mode = array_shift( $value['modes'] ); - echo ''; + echo ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } echo ''; @@ -702,12 +702,12 @@ public function save_site_settings() { if( !isset( $_POST['site_settings_noncename'] ) || !wp_verify_nonce( $_POST['site_settings_noncename'], plugin_basename( __FILE__ ) ) ) return; - $transport_type = sanitize_text_field( $_POST['transport_type'] ); // TODO: validate this exists + $transport_type = sanitize_text_field( isset( $_POST['transport_type'] ) ? $_POST['transport_type'] : '' ); // @TODO validate that type and mode are valid update_post_meta( $post->ID, 'syn_transport_type', $transport_type ); - $site_enabled = sanitize_text_field( $_POST['site_enabled'] ); + $site_enabled = sanitize_text_field( isset( $_POST['site_enabled'] ) ? $_POST['site_enabled'] : '' ); try { $save = Syndication_Client_Factory::save_client_settings( $post->ID, $transport_type ); @@ -808,7 +808,7 @@ public function add_syndicate_metabox( ) { ?>
  • description ); ?>

    @@ -1222,7 +1222,6 @@ public function current_user_can_syndicate() { } public function cron_add_pull_time_interval( $schedules ) { - // Adds the custom time interval to the existing schedules. $schedules['syn_pull_time_interval'] = array( 'interval' => intval( $this->push_syndicate_settings['pull_time_interval'] ), @@ -1485,9 +1484,11 @@ private function upgrade() { foreach ( $inserted_posts_by_site as $site_id ) { $inserted_posts = get_post_meta( $site_id, 'syn_inserted_posts', true ); - foreach ( $inserted_posts as $inserted_post_id => $inserted_post_guid ) { - update_post_meta( $inserted_post_id, 'syn_post_guid', $inserted_post_guid ); - update_post_meta( $inserted_post_id, 'syn_source_site_id', $site_id ); + if ( is_array( $inserted_posts ) ) { + foreach ( $inserted_posts as $inserted_post_id => $inserted_post_guid ) { + update_post_meta( $inserted_post_id, 'syn_post_guid', $inserted_post_guid ); + update_post_meta( $inserted_post_id, 'syn_source_site_id', $site_id ); + } } }