Fixes for warnings in PHP 7
-
From f7b6b11c176fbd63d601a55d8dd85e5e4a07e9ac Mon Sep 17 00:00:00 2001 From: Nick Palmer <nick@nick.codes> Date: Thu, 14 Sep 2017 10:28:13 -0700 Subject: [PATCH] Fix social flow statics. --- .../includes/class-socialflow-accounts.php | 28 +++++++++++----------- .../includes/class-socialflow-methods.php | 2 +- .../socialflow/includes/settings/general.php | 6 ++--- .../socialflow/libs/class-wp-socialflow.php | 6 ++--- .../views/form/post/advanced-settings.php | 5 ++-- 5 files changed, 24 insertions(+), 23 deletions(-) diff --git a/includes/class-socialflow-accounts.php b/includes/class-socialflow-accounts.php index d2d1a7c..4c6cc6c 100644 --- a/includes/class-socialflow-accounts.php +++ b/includes/class-socialflow-accounts.php @@ -180,9 +180,9 @@ class SocialFlow_Accounts { $name = $prefix = ''; // Get account if account id was passed - $account = is_int( $account ) ? self::get( $account ) : $account; + $account = is_int( $account ) ? $this->get( $account ) : $account; - $type = self::get_global_type( $account ); + $type = $this->get_global_type( $account ); if ( empty( $type ) ) return __( 'Missing account', 'socialflow' ); @@ -229,7 +229,7 @@ class SocialFlow_Accounts { $new = array(); foreach ($accounts as $key => $account) { // Define - $type = self::get_global_type($account); + $type = $this->get_global_type($account); if (isset($new[$type])) $new[$type][] = $account; @@ -241,7 +241,7 @@ class SocialFlow_Accounts { if ( false == $order ) return $accounts; - $types = array_intersect( array_flip( self::$type_order ), array_keys( $accounts ) ); + $types = array_intersect( array_flip( $this->$type_order ), array_keys( $accounts ) ); return array_replace( $types, $accounts ); } @@ -310,7 +310,7 @@ class SocialFlow_Accounts { return $data; } - $data = self::structure_data( $data ); + $data = $this->structure_data( $data ); $api = $socialflow->get_api(); @@ -319,7 +319,7 @@ class SocialFlow_Accounts { $statuses = $errors = $success = array(); // Loop through data and send message to appropriate account - foreach ( self::get( array_keys( $data ) ) as $account_id => $account ) { + foreach ( $this->get( array_keys( $data ) ) as $account_id => $account ) { foreach ( $data[ $account_id ] as $options ) { $statuses[] = $api->add_message( $account['service_user_id'], @@ -390,8 +390,8 @@ class SocialFlow_Accounts { $valid_data = array(); foreach ( $data as $account_id => $values ) { - $account = self::get( $account_id ); - $account_type = self::get_global_type( $account ); + $account = $this->get( $account_id ); + $account_type = $this->get_global_type( $account ); // check for required fields if ( empty( $values['publish_data'] ) OR !is_array( $values['publish_data'] ) ) { @@ -407,11 +407,11 @@ class SocialFlow_Accounts { $total_len = 0; // Add message to valid data array - $valid_data[ $account_id ]['message'] = self::valid_text( $values['message'], 'message', $total_len ); + $valid_data[ $account_id ]['message'] = $this->valid_text( $values['message'], 'message', $total_len ); // Add publish data foreach ( (array) $values['publish_data'] as $key => $options ) { - $options = self::valid_piblish_options( $options, $account_id ); + $options = $this->valid_piblish_options( $options, $account_id ); if ( is_wp_error( $options ) ) { $errors[] = $options; @@ -425,10 +425,10 @@ class SocialFlow_Accounts { if ( isset( $values['content_attributes'] ) ) { if ( isset( $values['content_attributes']['name'] ) ) { - $values['content_attributes']['name'] = self::valid_text( $values['content_attributes']['name'], 'name', $total_len ); + $values['content_attributes']['name'] = $this->valid_text( $values['content_attributes']['name'], 'name', $total_len ); } if ( isset( $values['content_attributes']['description'] ) ) { - $values['content_attributes']['description'] = self::valid_text( $values['content_attributes']['description'], 'description', $total_len ); + $values['content_attributes']['description'] = $this->valid_text( $values['content_attributes']['description'], 'description', $total_len ); } $valid_data[ $account_id ]['content_attributes'] = json_encode( $values['content_attributes'] ); @@ -468,7 +468,7 @@ class SocialFlow_Accounts { if ( empty( $values['scheduled_date'] ) ) return new WP_Error( 'empty_scheduled_date:', __( '<b>Error:</b> Scheduled date is required for schedule publish option for: <i>%s.</i>' ), array( $account_id ) ); - $valid_data['scheduled_date'] = self::get_valid_date( $values['scheduled_date'] ); + $valid_data['scheduled_date'] = $this->get_valid_date( $values['scheduled_date'] ); if ( empty( $valid_data['scheduled_date'] ) ) return new WP_Error( 'incorrect_scheduled_date:', __( '<b>Error:</b> Post could not be sent to SocialFlow: set relevant schedule time for: <i>%s.</i>' ), array( $account_id ) ); @@ -496,7 +496,7 @@ class SocialFlow_Accounts { if ( empty( $values[ $key ] ) ) return new WP_Error( "empty_{$key}:", $msgs['empty'], array( $account_id ) ); - $valid_data[ $key ] = self::get_valid_date( $values[ $key ] ); + $valid_data[ $key ] = $this->get_valid_date( $values[ $key ] ); if ( empty( $valid_data[ $key ] ) ) return new WP_Error( "incorrect_{$key}:", $msgs['incorrect'], array( $account_id ) ); diff --git a/includes/class-socialflow-methods.php b/includes/class-socialflow-methods.php index 3eeba8b..d094c8c 100644 --- a/includes/class-socialflow-methods.php +++ b/includes/class-socialflow-methods.php @@ -254,7 +254,7 @@ class SocialFlow_Methods { } // Recurse only when both values are arrays. elseif ( array_key_exists( $key, $result ) && is_array( $result[$key] ) && is_array( $value ) ) { - $result[$key] = self::array_merge_recursive( $result[$key], $value ); + $result[$key] = $this->array_merge_recursive( $result[$key], $value ); } // Otherwise, use the latter value. else { diff --git a/includes/settings/general.php b/includes/settings/general.php index 6f2d353..3639502 100644 --- a/includes/settings/general.php +++ b/includes/settings/general.php @@ -160,7 +160,7 @@ class SocialFlow_Admin_Settings_General extends SocialFlow_Admin_Settings_Page { <label for="sf_must_send"><?php esc_html_e( 'Must Send', 'socialflow' ); ?></label> <select name="socialflow[optimize_period]" id="js-optimize-period"> - <?php foreach ( self::get_optimize_periods() as $value => $label ): ?> + <?php foreach ( $this->get_optimize_periods() as $value => $label ): ?> <option <?php selected( $optimize_period, $value ); ?> value="<?php echo esc_attr( $value ) ?>" ><?php echo esc_html( $label ); ?></option> <?php endforeach ?> </select> @@ -316,10 +316,10 @@ class SocialFlow_Admin_Settings_General extends SocialFlow_Admin_Settings_Page { if ( isset( $_POST['option_page'] ) AND ( $this->slug == $_POST['option_page'] ) ) { // Whitelist validation - if ( isset( $data['publish_option'] ) && array_key_exists( $data['publish_option'], self::get_publish_options() ) ) + if ( isset( $data['publish_option'] ) && array_key_exists( $data['publish_option'], $this->get_publish_options() ) ) $settings['publish_option'] = $data['publish_option']; - if ( isset( $data['optimize_period'] ) && array_key_exists( $data['optimize_period'], self::get_optimize_periods() ) ) + if ( isset( $data['optimize_period'] ) && array_key_exists( $data['optimize_period'], $this->get_optimize_periods() ) ) $settings['optimize_period'] = $data['optimize_period']; $settings['optimize_range_from'] = isset( $data['optimize_range_from'] ) ? sanitize_text_field( $data['optimize_range_from'] ) : null; diff --git a/libs/class-wp-socialflow.php b/libs/class-wp-socialflow.php index a28d281..ae074fd 100644 --- a/libs/class-wp-socialflow.php +++ b/libs/class-wp-socialflow.php @@ -81,7 +81,7 @@ class WP_SocialFlow { if ( !empty( $oauth_callback ) ) $parameters['oauth_callback'] = $oauth_callback; - $request = $this->oauth_request( self::request_token_url, 'GET', $parameters ); + $request = $this->oauth_request( $this->request_token_url, 'GET', $parameters ); if ( 200 != wp_remote_retrieve_response_code( $request ) ) return false; @@ -133,7 +133,7 @@ class WP_SocialFlow { if ( is_array( $token ) ) $token = $token['oauth_token']; - return self::authorize_url . "?oauth_token={$token}"; + return $this->authorize_url . "?oauth_token={$token}"; } /** @@ -151,7 +151,7 @@ class WP_SocialFlow { if ( !empty( $oauth_verifier ) ) $parameters['oauth_verifier'] = $oauth_verifier; - $request = $this->oauth_request( self::access_token_url, 'GET', $parameters ); + $request = $this->oauth_request( $this->access_token_url, 'GET', $parameters ); $token = OAuthUtil::parse_parameters( wp_remote_retrieve_body( $request ) ); $this->token = new OAuthConsumer( $token['oauth_token'], $token['oauth_token_secret'] ); diff --git a/views/form/post/advanced-settings.php b/views/form/post/advanced-settings.php index 0d09ba1..312768b 100644 --- a/views/form/post/advanced-settings.php +++ b/views/form/post/advanced-settings.php @@ -31,8 +31,9 @@ $send_to = get_post_meta( $post->ID, 'sf_send_accounts', true ); if ( '' === $send_to ) $send_to = $socialflow->options->get( 'send', array() ); -$publish_options = SocialFlow_Admin_Settings_General::get_publish_options(); -$optimize_periods = SocialFlow_Admin_Settings_General::get_optimize_periods(); +$settings = new SocialFlow_Admin_Settings_General(); +$publish_options = $settings->get_publish_options(); +$optimize_periods = $settings->get_optimize_periods(); $data_tz_offset = get_option( 'gmt_offset' ) * HOUR_IN_SECONDS; -- 2.9.0
The topic ‘Fixes for warnings in PHP 7’ is closed to new replies.