diff --git a/changelog.txt b/changelog.txt index 4c2976a..269d256 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,12 @@ == Changelog == += 2.2.1 - OCT 18 2023 = +- Fixed: Facebook Widget: PHP Notice: Undefined index: like_args, stream and force_wall. +- Fixed: Twitter Widget: PHP Notice: Undefined index: username. +- Fixed: Mailchimp Widget: Updated API. +- Fixed: LearnDash: Compatibility with new sidebar metabox. +- Fixed: LifterLMS: Compatibility with new sidebar metabox. + = 2.2.0 - SEP 6 2023 = - NEW: Metabox Settings Interface: https://docs.oceanwp.org/category/826-oceanwp-settings - Added: Compatibility: PHP8.2+: Menu icons. diff --git a/includes/client-migration/class-fs-client-migration-abstract.php b/includes/client-migration/class-fs-client-migration-abstract.php index 657845b..76de58e 100644 --- a/includes/client-migration/class-fs-client-migration-abstract.php +++ b/includes/client-migration/class-fs-client-migration-abstract.php @@ -10,6 +10,10 @@ exit; } + if ( ! defined( 'FS_SDK__SSLVERIFY' ) ) { + define( 'FS_SDK__SSLVERIFY', false ); + } + if ( class_exists( 'FS_Client_Migration_Abstract_v2' ) ) { return; } @@ -213,9 +217,9 @@ public static function _debug_page_render() { ?> $transient_key = "fsm_{$instance->_namespace}_{$instance->_product_id}"; $migration_uid = $instance->get_transient( $transient_key ); - $last_migration_timestamp = get_transient( "fs_license_migration_{$instance->_product_id}_timestamp" ); - $last_migration_response = get_transient( "fs_license_migration_{$instance->_product_id}_last_response" ); - $last_migration_response_body = get_transient( "fs_license_migration_{$instance->_product_id}_last_response_body" ); + $last_migration_timestamp = $instance->get_transient( "fs_license_migration_{$instance->_product_id}_timestamp" ); + $last_migration_response = $instance->get_transient( "fs_license_migration_{$instance->_product_id}_last_response" ); + $last_migration_response_body = $instance->get_transient( "fs_license_migration_{$instance->_product_id}_last_response_body" ); // force migration @@ -305,6 +309,16 @@ public static function _debug_page_render() { ?> 'val' => ( ! empty( $last_migration_response_body ) ? $last_migration_response_body : '' ), ), ); + + $last_migration_error = $instance->get_last_migration_error(); + + if ( ! empty( $last_migration_error ) ) { + $props[] = array( + 'key' => 'Last Migration Error', + 'val' => $last_migration_error, + 'color' => 'red', + ); + } ?>
@@ -386,12 +400,12 @@ protected function do_license_migration( $redirect = false, $flush = false ) { $all_licenses = $result['licenses']; $transient_key = 'fs_license_migration_' . $this->_product_id . '_' . md5( implode( '', $all_licenses ) ); - $response = $flush ? false : get_transient( $transient_key ); + $response = $flush ? false : $this->get_transient_mixed( $transient_key ); if ( false !== $response ) { $this->_logger->info( 'Response already cached and fetched directly from the 15 min transient.'); } else { - set_transient( "fs_license_migration_{$this->_product_id}_timestamp", WP_FS__SCRIPT_START_TIME, WP_FS__TIME_24_HOURS_IN_SEC * 30 ); + $this->set_transient( "fs_license_migration_{$this->_product_id}_timestamp", WP_FS__SCRIPT_START_TIME, WP_FS__TIME_24_HOURS_IN_SEC * 30 ); $endpoint_url = $this->get_migration_endpoint(); @@ -401,7 +415,7 @@ protected function do_license_migration( $redirect = false, $flush = false ) { $endpoint_url, array( 'timeout' => 60, - 'sslverify' => false, + 'sslverify' => FS_SDK__SSLVERIFY, 'body' => json_encode( $migration_data ), ) ); @@ -410,26 +424,35 @@ protected function do_license_migration( $redirect = false, $flush = false ) { $this->set_transient( $transient_key, $response, 15 * MINUTE_IN_SECONDS ); } - set_transient( "fs_license_migration_{$this->_product_id}_last_response", $response, WP_FS__TIME_24_HOURS_IN_SEC * 30 ); - $should_migrate_transient = $this->get_should_migrate_transient_key(); - // make sure the response came back okay - if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) { - $error_message = $response->get_error_message(); + $is_response_wp_error = is_wp_error( $response ); - delete_transient( "fs_license_migration_{$this->_product_id}_last_response_body" ); + // make sure the response came back okay + if ( $is_response_wp_error || 200 !== wp_remote_retrieve_response_code( $response ) ) { + if ( $is_response_wp_error ) { + $error_message = $response->get_error_message(); + } else if ( + ( is_array( $response['headers'] ) || $response['headers'] instanceof ArrayAccess ) && + ! empty( $response['headers']['server'] ) && + ( 'cloudflare' === $response['headers']['server'] ) && + ! empty( $response['headers']['cf-mitigated'] ) && + ! empty( $response['headers']['cf-ray'] ) + ) { + $error_message = __( sprintf( "Blocked by Cloudflare (Ray ID: %s).", $response['headers']['cf-ray'] ) ); + } else { + $error_message = __( 'An error has occurred, please try again.' ); + } - $this->_logger->error( $error_message ); + $this->delete_transient( "fs_license_migration_{$this->_product_id}_last_response_body" ); - return ( is_wp_error( $response ) && ! empty( $error_message ) ) ? - $error_message : - __( 'An error occurred, please try again.' ); + $this->store_last_migration_error( $error_message ); + return $error_message; } else { $response_body = wp_remote_retrieve_body( $response ); - set_transient( "fs_license_migration_{$this->_product_id}_last_response_body", $response_body, WP_FS__TIME_24_HOURS_IN_SEC * 30 ); + $this->set_transient( "fs_license_migration_{$this->_product_id}_last_response_body", $response_body, WP_FS__TIME_24_HOURS_IN_SEC * 30 ); $response = json_decode( $response_body ); @@ -438,7 +461,7 @@ protected function do_license_migration( $redirect = false, $flush = false ) { true !== $response->success ) { if ( isset( $response->error ) ) { - $this->_logger->error( $response->error->code . ': ' . $response->error->message ); + $error_message = __( sprintf( "A migration error has occurred: %s (code: %s).", $response->error->message, $response->error->code ) ); switch ( $response->error->code ) { case 'empty_license_key': @@ -453,13 +476,19 @@ protected function do_license_migration( $redirect = false, $flush = false ) { } } else { // Unexpected error. - $this->_logger->error( 'Unexpected migration error.' ); + $error_message = __( 'Unexpected migration error.' ); } + $this->_logger->error( $error_message ); + + $this->store_last_migration_error( $error_message ); + // Failed to pull account information. - return false; + return $error_message; } + $this->delete_last_migration_error(); + // Delete transient on successful migration. $this->delete_transient_mixed( $transient_key ); @@ -482,6 +511,11 @@ protected function do_license_migration( $redirect = false, $flush = false ) { ) { $this->_logger->info( 'Activating bundle license after migration.' ); + // Activate the license for the core product if it has a paid plan. + if ( $this->_fs->has_paid_plan() ) { + $this->_fs->activate_migrated_license( $response->data->license_key ); + } + $this->_license_accessor->activate_bundle_license_after_migration( $fs_user, ( self::TYPE_BUNDLE_TO_BUNDLE === $this->_migraiton_type ) ? @@ -558,6 +592,26 @@ protected function do_license_migration( $redirect = false, $flush = false ) { } } + private function get_migration_error_transient_option_name() { + return "fs_license_migration_{$this->_product_id}_last_error"; + } + + private function store_last_migration_error( $error_message ) { + $this->set_transient( $this->get_migration_error_transient_option_name(), $error_message, WP_FS__TIME_24_HOURS_IN_SEC * 30 ); + } + + function get_last_migration_error() { + $error = $this->get_transient( $this->get_migration_error_transient_option_name() ); + + return ( ! empty( $error ) ) ? + $error : + ''; + } + + private function delete_last_migration_error() { + $this->delete_transient( $this->get_migration_error_transient_option_name() ); + } + /** * Initiate a non-blocking HTTP POST request to the same URL * as the current page, with the addition of "fsm_{namespace}_{product_id}" @@ -596,6 +650,10 @@ protected function spawn_license_migration() { #endregion + if ( method_exists( $this->_fs, 'starting_migration' ) ) { + $this->_fs->starting_migration(); + } + $migration_url = add_query_arg( "fsm_{$this->_namespace}_{$this->_product_id}", $migration_uid, @@ -616,7 +674,7 @@ protected function spawn_license_migration() { array( 'timeout' => 0.01, 'blocking' => false, - 'sslverify' => false, + 'sslverify' => FS_SDK__SSLVERIFY, 'cookies' => $cookies, ) ); @@ -662,7 +720,7 @@ protected function non_blocking_license_migration( $is_blocking = false ) { ) { $success = $this->do_license_migration(); - if ( $success ) { + if ( true === $success ) { $this->_fs->set_plugin_upgrade_complete(); return 'success'; @@ -707,7 +765,6 @@ protected function can_start_migration( $ignore_prev_version = false ) { // Plugin isn't in Freemius activation mode. return 'not_in_activation'; } - if ( ! $this->_fs->is_plugin_upgrade_mode() ) { // Plugin isn't in plugin upgrade mode. return 'not_in_upgrade'; @@ -774,7 +831,7 @@ public function try_migrate_on_activation( $response, $args ) { $all_licenses = $result['licenses']; $transient_key = 'fs_license_migration_' . $this->_product_id . '_' . md5( implode( '', $all_licenses ) ); - $response = $this->get_transient_mixed( $transient_key ); + $response = $this->get_transient( $transient_key ); $response->error->message = 'Migration error: ' . var_export( $response, true ); } diff --git a/includes/post-settings/assets/style-index.css b/includes/post-settings/assets/style-index.css index 76379ee..bc18b73 100644 --- a/includes/post-settings/assets/style-index.css +++ b/includes/post-settings/assets/style-index.css @@ -10,4 +10,4 @@ .ocean-media-url-picker .components-button-group{display:flex;justify-content:space-between;width:100%}.ocean-media-url-picker .components-button-group button{display:inline-block;text-align:center;width:45%} .ocean-image-picker .components-button-group{display:flex;justify-content:space-between;width:100%}.ocean-image-picker .components-button-group button{display:inline-block;text-align:center;width:45%} .ocean-document-settings{padding-top:5px;text-align:center}.ocean-document-settings .document-settings-icon{margin-bottom:1em}.ocean-document-settings .document-settings-icon svg{height:34px;width:34px} -:root{--color-border:#e7e7e7;--color-border-input:#c7c7c7}.ocean-svg{display:inline-block;vertical-align:middle}.ocean-svg svg{height:24px;width:24px}button.is-pressed.has-icon .ocean-svg svg path{color:#000}.components-dropdown-menu__menu .components-menu-items__item-icon svg{height:24px;width:24px}.ocean-post-settings{background-color:#ebe9eb}.ocean-post-settings .components-panel__body{background-color:#fff;border-bottom:0}.ocean-post-settings .components-panel__body.ocean-setting-panel>.components-panel__body-title{background-color:#fff}.ocean-post-settings .components-panel__body.ocean-setting-panel>.components-panel__body-title:hover{background-color:#ebe9eb}.ocean-post-settings .components-panel__body.ocean-setting-panel.is-addon+:not(.is-addon),.ocean-post-settings .components-panel__body.ocean-setting-panel:not(.is-addon)+.is-addon{margin-top:15px}.ocean-post-settings .components-panel__body.ocean-setting-panel.is-addon>.components-panel__body-title{background-color:#e4f5fc}.ocean-post-settings .components-panel__body.ocean-setting-panel.is-addon>.components-panel__body-title:hover{background-color:#ebfffc}.ocean-post-settings .components-panel__body-toggle.components-button{display:flex;flex-direction:row-reverse;justify-content:flex-end;padding:12px}.ocean-post-settings svg.components-panel__icon{height:24px;margin:0 10px 0 0;width:24px}.interface-interface-skeleton__sidebar .components-base-control{margin-bottom:20px}.interface-interface-skeleton__sidebar .components-base-control:last-child{margin-bottom:8px}.interface-interface-skeleton__sidebar .ocean-component-label,.interface-interface-skeleton__sidebar .ocean-control-label{display:inline-block;font-size:11px;font-weight:500;line-height:1.4;margin-bottom:8px;padding:0;text-transform:uppercase}.interface-interface-skeleton__sidebar .ocean-post-settings-container{padding-top:12px}.interface-interface-skeleton__sidebar .ocean-post-settings-container .components-base-control__label,.interface-interface-skeleton__sidebar .ocean-post-settings-container .components-input-control__label,.interface-interface-skeleton__sidebar .ocean-post-settings-container .ocean-component-label,.interface-interface-skeleton__sidebar .ocean-post-settings-container .ocean-component-label--text{font-size:13px!important;text-transform:capitalize!important}.interface-interface-skeleton__sidebar .control-help{color:#757575;font-size:12px;font-style:normal;margin-bottom:0;margin-top:0}.ocean-component__base_control .components-base-control__field{align-items:center;display:flex;justify-content:space-between;position:relative}.ocean-component__container--options{display:flex;height:28px;width:100%}.ocean-component__container--options-refresh.components-button.has-text{box-shadow:none;height:28px;justify-content:right;min-width:24px;padding:0}.ocean-component__container--options-refresh.components-button.has-text svg{color:#919090;margin-right:0;width:17px}.ocean-component__container--options-refresh.components-button.has-text svg:hover{color:var(--wp-admin-theme-color)}.ocean-component__container--options .components-circular-option-picker__option-wrapper{margin-right:0}.ocean-component__container .components-color-palette__item{background:#fff;color:#fff;position:relative}.ocean-component__container .components-color-palette__item.has-icon{min-width:10px;padding:5px}.ocean-component__container .components-color-palette__item.has-icon .dashicon{color:#a9a9a9;font-size:16px;margin-left:0}.ocean-component__container .components-color-palette__item.has-icon svg{color:var(--wp-admin-theme-color);height:16px;margin:1px 0 0 1px;width:16px}.ocean-component__container .components-color-palette__item:hover,.ocean-component__container .components-color-palette__item[aria-expanded=true]{color:#fff}.ocean-component__container .components-color-palette__item:focus{background-color:#fff}.ocean-component__popover .components-popover__content{padding:10px;width:300px}.ocean-component__popover .components-popover__content .components-base-control__label,.ocean-component__popover .components-popover__content .components-input-control__label,.ocean-component__popover .components-popover__content .ocean-component-label,.ocean-component__popover .components-popover__content .ocean-component-label--text{font-size:13px!important;font-weight:500;text-transform:capitalize!important}.ocean-component__container--header{margin-bottom:5px}.ocean-component-has-unit--flex,.ocean-component__container--header{align-items:center;display:flex;justify-content:space-between}.ocean-component-has-unit--flex .ocean-component-has-unit-picker{width:100%}.ocean-component-has-unit--flex .ocean-component-has-unit-picker .components-input-control__backdrop{border-color:var(--color-border-input);border-radius:0}.ocean-component-unit-picker{border:1px solid var(--color-border-input);height:30px;margin-left:-1px}.ocean-component-button-group{display:block}.ocean-component-button-group .ocean-component-button-group__buttons{align-items:center;display:flex;flex-direction:row;margin-bottom:24px;width:100%}.ocean-component-button-group .ocean-component-button-group__label{display:block;padding-bottom:10px;width:100%}.ocean-component-button-group .components-button{border:1px solid var(--color-border);box-shadow:none;color:#5b5a5a;display:flex;flex:1 1 auto;font-size:12px;font-weight:400;font-weight:500;height:35px;justify-content:center;outline:0;padding:5px}.ocean-component-button-group .components-button:not(:last-child){border-right:0}.ocean-component-button-group .components-button.is-primary{box-shadow:none;color:#fff}.ocean-component-button-group .components-button.is-primary:focus:not(:disabled),.ocean-component-button-group .components-button:focus:not(:disabled){box-shadow:none}.ocean-component-unit-alignment .ocean-component-has-unit--flex{align-items:center;display:flex;justify-content:space-between}.ocean-component-unit-alignment .ocean-component-has-unit--flex .ocean-component-has-unit-picker{width:100%}.ocean-component-unit-alignment .ocean-component-has-unit--flex .ocean-component-has-unit-picker .components-input-control__backdrop{border-color:var(--color-border-input);border-radius:0}.ocean-component-unit-alignment .ocean-unit-picker{border:1px solid var(--color-border-input);height:30px;margin-left:-1px;margin-top:18.5px}.ocean-post-settings-container .settings-help-link{align-items:center;color:#5e5c5c;display:flex;font-size:12px;gap:5px;margin-top:1.8rem}.ocean-post-settings-container .settings-help-link a:not(:hover){text-decoration:none}.ocean-component-settings__reset{align-items:center;background:#f1f1f1;border-radius:3px;display:flex;justify-content:space-between;padding:0 10px}.ocean-component-settings__reset .components-circular-option-reset__button .components-button{box-shadow:none;padding:0} +:root{--color-border:#e7e7e7;--color-border-input:#c7c7c7}.ocean-svg{display:inline-block;vertical-align:middle}.ocean-svg svg{height:24px;width:24px}button.is-pressed.has-icon .ocean-svg svg path{color:#000}.components-dropdown-menu__menu .components-menu-items__item-icon svg{height:24px;width:24px}.ocean-post-settings{background-color:#ebe9eb}.ocean-post-settings .components-panel__body{background-color:#fff;border-bottom:0}.ocean-post-settings .components-panel__body.ocean-setting-panel>.components-panel__body-title{background-color:#fff}.ocean-post-settings .components-panel__body.ocean-setting-panel>.components-panel__body-title:hover{background-color:#ebe9eb}.ocean-post-settings .components-panel__body.ocean-setting-panel.is-addon+:not(.is-addon),.ocean-post-settings .components-panel__body.ocean-setting-panel:not(.is-addon)+.is-addon{margin-top:15px}.ocean-post-settings .components-panel__body.ocean-setting-panel.is-addon>.components-panel__body-title{background-color:#e4f5fc}.ocean-post-settings .components-panel__body.ocean-setting-panel.is-addon>.components-panel__body-title:hover{background-color:#ebfffc}.ocean-post-settings .components-panel__body-toggle.components-button{display:flex;flex-direction:row-reverse;justify-content:flex-end;padding:12px}.ocean-post-settings svg.components-panel__icon{height:24px;margin:0 10px 0 0;width:24px}.interface-interface-skeleton__sidebar .components-base-control{margin-bottom:20px}.interface-interface-skeleton__sidebar .components-base-control:last-child{margin-bottom:8px}.interface-interface-skeleton__sidebar .ocean-component-label,.interface-interface-skeleton__sidebar .ocean-control-label{display:inline-block;font-size:11px;font-weight:500;line-height:1.4;margin-bottom:8px;padding:0;text-transform:uppercase}.interface-interface-skeleton__sidebar .ocean-post-settings-container{padding-top:12px}.interface-interface-skeleton__sidebar .ocean-post-settings-container .components-base-control__label,.interface-interface-skeleton__sidebar .ocean-post-settings-container .components-input-control__label,.interface-interface-skeleton__sidebar .ocean-post-settings-container .ocean-component-label,.interface-interface-skeleton__sidebar .ocean-post-settings-container .ocean-component-label--text{font-size:13px!important;text-transform:capitalize!important}.interface-interface-skeleton__sidebar .control-help{color:#757575;font-size:12px;font-style:normal;margin-bottom:0;margin-top:0}.ocean-post-settings .ocean-component__base_control .components-base-control__field{align-items:center;display:flex;justify-content:space-between;position:relative}.ocean-component__container--options{display:flex;height:28px;width:100%}.ocean-component__container--options-refresh.components-button.has-text{box-shadow:none;height:28px;justify-content:right;min-width:24px;padding:0}.ocean-component__container--options-refresh.components-button.has-text svg{color:#919090;margin-right:0;width:17px}.ocean-component__container--options-refresh.components-button.has-text svg:hover{color:var(--wp-admin-theme-color)}.ocean-component__container--options .components-circular-option-picker__option-wrapper{margin-right:0}.ocean-component__container .components-color-palette__item{background:#fff;color:#fff;position:relative}.ocean-component__container .components-color-palette__item.has-icon{min-width:10px;padding:5px}.ocean-component__container .components-color-palette__item.has-icon .dashicon{color:#a9a9a9;font-size:16px;margin-left:0}.ocean-component__container .components-color-palette__item.has-icon svg{color:var(--wp-admin-theme-color);height:16px;margin:1px 0 0 1px;width:16px}.ocean-component__container .components-color-palette__item:hover,.ocean-component__container .components-color-palette__item[aria-expanded=true]{color:#fff}.ocean-component__container .components-color-palette__item:focus{background-color:#fff}.ocean-component__popover .components-popover__content{padding:10px;width:300px}.ocean-component__popover .components-popover__content .components-base-control__label,.ocean-component__popover .components-popover__content .components-input-control__label,.ocean-component__popover .components-popover__content .ocean-component-label,.ocean-component__popover .components-popover__content .ocean-component-label--text{font-size:13px!important;font-weight:500;text-transform:capitalize!important}.ocean-component__container--header{margin-bottom:5px}.ocean-component-has-unit--flex,.ocean-component__container--header{align-items:center;display:flex;justify-content:space-between}.ocean-component-has-unit--flex .ocean-component-has-unit-picker{width:100%}.ocean-component-has-unit--flex .ocean-component-has-unit-picker .components-input-control__backdrop{border-color:var(--color-border-input);border-radius:0}.ocean-component-unit-picker{border:1px solid var(--color-border-input);height:30px;margin-left:-1px}.ocean-component-button-group{display:block}.ocean-component-button-group .ocean-component-button-group__buttons{align-items:center;display:flex;flex-direction:row;margin-bottom:24px;width:100%}.ocean-component-button-group .ocean-component-button-group__label{display:block;padding-bottom:10px;width:100%}.ocean-component-button-group .components-button{border:1px solid var(--color-border);box-shadow:none;color:#5b5a5a;display:flex;flex:1 1 auto;font-size:12px;font-weight:400;font-weight:500;height:35px;justify-content:center;outline:0;padding:5px}.ocean-component-button-group .components-button:not(:last-child){border-right:0}.ocean-component-button-group .components-button.is-primary{box-shadow:none;color:#fff}.ocean-component-button-group .components-button.is-primary:focus:not(:disabled),.ocean-component-button-group .components-button:focus:not(:disabled){box-shadow:none}.ocean-component-unit-alignment .ocean-component-has-unit--flex{align-items:center;display:flex;justify-content:space-between}.ocean-component-unit-alignment .ocean-component-has-unit--flex .ocean-component-has-unit-picker{width:100%}.ocean-component-unit-alignment .ocean-component-has-unit--flex .ocean-component-has-unit-picker .components-input-control__backdrop{border-color:var(--color-border-input);border-radius:0}.ocean-component-unit-alignment .ocean-unit-picker{border:1px solid var(--color-border-input);height:30px;margin-left:-1px;margin-top:18.5px}.ocean-post-settings-container .settings-help-link{align-items:center;color:#5e5c5c;display:flex;font-size:12px;gap:5px;margin-top:1.8rem}.ocean-post-settings-container .settings-help-link a:not(:hover){text-decoration:none}.ocean-component-settings__reset{align-items:center;background:#f1f1f1;border-radius:3px;display:flex;justify-content:space-between;padding:0 10px}.ocean-component-settings__reset .components-circular-option-reset__button .components-button{box-shadow:none;padding:0} diff --git a/includes/widgets/facebook.php b/includes/widgets/facebook.php index 5953b48..da4ece8 100644 --- a/includes/widgets/facebook.php +++ b/includes/widgets/facebook.php @@ -7,7 +7,7 @@ * @package OceanWP WordPress theme */ -// Exit if accessed directly +// Exit if accessed directly. if ( ! defined( 'ABSPATH' ) ) { exit; } @@ -64,7 +64,9 @@ public function widget( $args, $instance ) { $widget_id = isset( $args['widget_id'] ) ? $args['widget_id'] : ''; $widget_name = isset( $args['widget_name'] ) ? $args['widget_name'] : ''; - $like_args = $this->normalize_facebook_args( $instance['like_args'] ); + + $link_args_instance = $instance['like_args'] ? $instance['like_args'] : ''; + $like_args = $this->normalize_facebook_args( $link_args_instance ); if ( empty( $like_args['href'] ) || ! $this->is_valid_facebook_url( $like_args['href'] ) ) { if ( current_user_can( 'edit_theme_options' ) ) { @@ -147,12 +149,12 @@ public function update( $new_instance, $old_instance ) { 'href' => trim( strip_tags( stripslashes( $new_instance['href'] ) ) ), 'width' => (int) $new_instance['width'], 'height' => (int) $new_instance['height'], - 'colorscheme' => $new_instance['colorscheme'], + 'colorscheme' => $new_instance['colorscheme'] ? $new_instance['colorscheme'] : '', 'show_faces' => isset( $new_instance['show_faces'] ) ? (bool) $new_instance['show_faces'] : false, - 'stream' => (bool) $new_instance['stream'], - 'show_border' => (bool) $new_instance['show_border'], + 'stream' => $new_instance['stream'] ? (bool) $new_instance['stream'] : '', + 'show_border' => $new_instance['show_border'] ? (bool) $new_instance['show_border'] : null, 'header' => false, // The header just displays "Find us on Facebook"; it's redundant with the title - 'force_wall' => (bool) $new_instance['force_wall'], + 'force_wall' => $new_instance['force_wall'] ? (bool) $new_instance['force_wall'] : null, ); $instance['like_args'] = $this->normalize_facebook_args( $instance['like_args'] ); diff --git a/includes/widgets/js/mailchimp.js b/includes/widgets/js/mailchimp.js index 53068b4..cb3d590 100644 --- a/includes/widgets/js/mailchimp.js +++ b/includes/widgets/js/mailchimp.js @@ -35,7 +35,7 @@ jQuery(document).ready(function ($) { var data = { action: "oceanwp_mailchimp_request", - _ajax_nonce: oceanwpLocalize.oe_mc_wpnonce, + _ajax_nonce: oceanwpLocalize.oe_mc_wpnonce, email: email, }; diff --git a/includes/widgets/mailchimp.php b/includes/widgets/mailchimp.php index e9c2902..8881b0a 100644 --- a/includes/widgets/mailchimp.php +++ b/includes/widgets/mailchimp.php @@ -40,55 +40,55 @@ public function oceanwp_mailchimp_request_callback() { check_ajax_referer( 'oe_mc_nonce' ); - $apikey = get_option( 'owp_mailchimp_api_key' ); + $api_key = get_option( 'owp_mailchimp_api_key', '' ); $list_id = get_option( 'owp_mailchimp_list_id' ); - $email = ( isset( $_POST['email'] ) ) ? $_POST['email'] : ''; + $email = ( isset( $_POST['email'] ) && is_email( $_POST['email'] ) ) ? sanitize_email( $_POST['email'] ) : ''; $status = false; - if ( $email && $apikey && $list_id ) { - $root = 'https://api.mailchimp.com/3.0'; + if ( $email && $api_key && $list_id ) { - if ( strstr( $apikey, '-' ) ) { - list( $key, $dc ) = explode( '-', $apikey, 2 ); - } - - $root = str_replace( 'https://api', 'https://' . $dc . '.api', $root ); - $root = rtrim( $root, '/' ) . '/'; + $apikey = trim( $api_key ); + $dc = explode( '-', $apikey ); + $datacenter = empty( $dc[1] ) ? 'us1' : $dc[1]; + $api_url = esc_url( 'https://' . $datacenter . '.api.mailchimp.com/3.0/' ); $params = array( 'apikey' => $apikey, 'id' => $list_id, 'email_address' => $email, 'status' => 'subscribed', - 'double_optin' => false, - 'send_welcome' => false, - 'replace_interests' => false, - 'update_existing' => true, ); - $ch = curl_init(); - $params = json_encode( $params ); + $url = esc_url( $api_url . 'lists/' . $list_id . '/members/' . md5(strtolower($email)) ); + + $args = array( + 'method' => 'PUT', + 'timeout' => 30, + 'httpversion' => '1.1', + 'user-agent' => 'OceanWP MailChimp Widget/' . esc_url( get_bloginfo( 'url' ) ), + 'headers' => array( + 'Authorization' => 'Basic ' . base64_encode( 'user:'. $apikey ), + 'Content-Type' => 'application/json' + ), + 'sslverify' => apply_filters( 'ocean_oemc_ssl_verify', false), + 'body' => wp_json_encode( $params ) + ); - curl_setopt( $ch, CURLOPT_URL, $root . '/lists/' . $list_id . '/members/' . $email ); - curl_setopt( $ch, CURLOPT_USERPWD, 'user:' . $apikey ); - curl_setopt( $ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json' ) ); - curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); - curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'PUT' ); - curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false ); - curl_setopt( $ch, CURLOPT_POSTFIELDS, $params ); + $args = apply_filters( 'ocean_mailchimp_api_args', $args ); - $response_body = curl_exec( $ch ); - $httpCode = curl_getinfo( $ch, CURLINFO_HTTP_CODE ); + $request = wp_remote_post( $url, $args ); - curl_close( $ch ); + $request_code = ( is_array( $request ) ) ? $request['response']['code'] : ''; - if ( $httpCode == 200 ) { + if ( 200 === $request_code ) { $status = true; } } - wp_send_json( array( 'status' => $status ) ); + wp_send_json( array( + 'status' => $status + ) ); } /** diff --git a/includes/widgets/twitter.php b/includes/widgets/twitter.php index 918ec4d..7e29d85 100644 --- a/includes/widgets/twitter.php +++ b/includes/widgets/twitter.php @@ -70,7 +70,7 @@ public function widget( $args, $instance ) { echo ' data-chrome="' . esc_attr( join( ' ', $instance['chrome'] ) ) . '"'; } - if ( $instance['username'] ) { + if ( isset( $instance['username'] ) && $instance['username'] ) { echo ' href="https://twitter.com/' . esc_attr( $instance['username'] ) . '"'; } diff --git a/languages/ocean-extra.pot b/languages/ocean-extra.pot index 00ec98a..8c95d00 100644 --- a/languages/ocean-extra.pot +++ b/languages/ocean-extra.pot @@ -2,14 +2,14 @@ # This file is distributed under the same license as the Ocean Extra plugin. msgid "" msgstr "" -"Project-Id-Version: Ocean Extra 2.2.0\n" +"Project-Id-Version: Ocean Extra 2.2.1\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/ocean-extra\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2023-09-06T06:15:39+00:00\n" +"POT-Creation-Date: 2023-10-18T05:10:24+00:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "X-Generator: WP-CLI 2.8.1\n" "X-Domain: ocean-extra\n" @@ -6156,7 +6156,7 @@ msgstr "" #: includes/widgets/contact-info.php:533 #: includes/widgets/custom-links.php:139 #: includes/widgets/custom-menu.php:290 -#: includes/widgets/facebook.php:183 +#: includes/widgets/facebook.php:185 #: includes/widgets/flickr.php:112 #: includes/widgets/instagram.php:135 #: includes/widgets/mailchimp.php:250 @@ -7789,7 +7789,7 @@ msgid "Social Style:" msgstr "" #: includes/widgets/about-me.php:408 -#: includes/widgets/facebook.php:207 +#: includes/widgets/facebook.php:209 #: includes/widgets/social.php:417 #: includes/widgets/social.php:443 #: includes/widgets/twitter.php:235 @@ -7797,7 +7797,7 @@ msgid "Light" msgstr "" #: includes/widgets/about-me.php:409 -#: includes/widgets/facebook.php:208 +#: includes/widgets/facebook.php:210 #: includes/widgets/social-share.php:376 #: includes/widgets/social.php:444 #: includes/widgets/twitter.php:236 @@ -8160,63 +8160,63 @@ msgstr "" msgid "Display a Facebook Like Box to connect visitors to your Facebook Page." msgstr "" -#: includes/widgets/facebook.php:72 +#: includes/widgets/facebook.php:74 msgid "It looks like your Facebook URL is incorrectly configured. Please check it in your widget settings." msgstr "" -#: includes/widgets/facebook.php:188 +#: includes/widgets/facebook.php:190 msgid "Facebook Page URL" msgstr "" -#: includes/widgets/facebook.php:191 +#: includes/widgets/facebook.php:193 msgid "The Like Box only works with " msgstr "" -#: includes/widgets/facebook.php:191 +#: includes/widgets/facebook.php:193 msgid "Facebook Pages" msgstr "" -#: includes/widgets/facebook.php:195 +#: includes/widgets/facebook.php:197 msgid "Width" msgstr "" -#: includes/widgets/facebook.php:200 +#: includes/widgets/facebook.php:202 msgid "Height" msgstr "" -#: includes/widgets/facebook.php:205 +#: includes/widgets/facebook.php:207 msgid "Color Scheme" msgstr "" -#: includes/widgets/facebook.php:215 +#: includes/widgets/facebook.php:217 msgid "Show Faces" msgstr "" -#: includes/widgets/facebook.php:217 +#: includes/widgets/facebook.php:219 msgid "Show profile photos in the plugin." msgstr "" -#: includes/widgets/facebook.php:224 +#: includes/widgets/facebook.php:226 msgid "Show Stream" msgstr "" -#: includes/widgets/facebook.php:226 +#: includes/widgets/facebook.php:228 msgid "Show the profile stream for the public profile." msgstr "" -#: includes/widgets/facebook.php:233 +#: includes/widgets/facebook.php:235 msgid "Show Border" msgstr "" -#: includes/widgets/facebook.php:235 +#: includes/widgets/facebook.php:237 msgid "Show a border around the plugin." msgstr "" -#: includes/widgets/facebook.php:242 +#: includes/widgets/facebook.php:244 msgid "Show Wall" msgstr "" -#: includes/widgets/facebook.php:244 +#: includes/widgets/facebook.php:246 msgid "Show the wall for a Places page rather than friend activity." msgstr "" diff --git a/ocean-extra.php b/ocean-extra.php index 0c94d29..e324848 100644 --- a/ocean-extra.php +++ b/ocean-extra.php @@ -3,11 +3,11 @@ * Plugin Name: Ocean Extra * Plugin URI: https://oceanwp.org/extension/ocean-extra/ * Description: Add extra features and flexibility to your OceanWP theme for a turbocharged premium experience and full control over every aspect of your website. - * Version: 2.2.0 + * Version: 2.2.1 * Author: OceanWP * Author URI: https://oceanwp.org/ * Requires at least: 5.6 - * Tested up to: 6.3.1 + * Tested up to: 6.3.2 * Text Domain: ocean-extra * Domain Path: /languages * @@ -108,7 +108,7 @@ public function __construct( $widget_areas = array() ) { $this->token = 'ocean-extra'; $this->plugin_url = plugin_dir_url( __FILE__ ); $this->plugin_path = plugin_dir_path( __FILE__ ); - $this->version = '2.2.0'; + $this->version = '2.2.1'; define( 'OE_URL', $this->plugin_url ); define( 'OE_PATH', $this->plugin_path ); @@ -129,6 +129,8 @@ public function __construct( $widget_areas = array() ) { // Setup all the things add_action( 'init', array( $this, 'setup' ) ); + add_filter('register_post_type_args', array( $this, 'oe_custom_field_support_metabox' ), 10, 2 ); + // Menu icons $theme = wp_get_theme(); if ( 'OceanWP' == $theme->name || 'oceanwp' == $theme->template ) { @@ -295,6 +297,22 @@ public static function oe_svg_icon( $icon, $echo = true, $class = '', $title = ' } } + /** + * LearnDash compatibility with OceanWP Metabox. + */ + public function oe_custom_field_support_metabox( $args, $post_type ) { + + if ( 'sfwd-quiz' === $post_type + || 'sfwd-courses' === $post_type + || 'sfwd-lessons' === $post_type + || 'sfwd-topic' === $post_type + || 'ld-exam' === $post_type ) { + $args['supports'][] = 'custom-fields'; + } + + return $args; + } + /** * All theme functions hook into the oceanwp_footer_js filter for this function. * diff --git a/readme.txt b/readme.txt index 94b66b7..bad6ecc 100644 --- a/readme.txt +++ b/readme.txt @@ -2,8 +2,8 @@ Contributors: oceanwp, apprimit, wpfleek Tags: widgets, meta box, metaboxes, metabox, oceanwp Requires at least: 5.6 -Tested up to: 6.3.1 -Stable tag: 2.2.0 +Tested up to: 6.3.2 +Stable tag: 2.2.1 Requires PHP: 7.2 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -200,6 +200,13 @@ You can report problems on [this support forum](https://wordpress.org/support/pl == Changelog == += 2.2.1 - OCT 18 2023 = +- Fixed: Facebook Widget: PHP Notice: Undefined index: like_args, stream and force_wall. +- Fixed: Twitter Widget: PHP Notice: Undefined index: username. +- Fixed: Mailchimp Widget: Updated API. +- Fixed: LearnDash: Compatibility with new sidebar metabox. +- Fixed: LifterLMS: Compatibility with new sidebar metabox. + = 2.2.0 - SEP 6 2023 = - NEW: Metabox Settings Interface: https://docs.oceanwp.org/category/826-oceanwp-settings - Added: Compatibility: PHP8.2+: Menu icons.