Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/feedzy-rss-feeds/feedzy-rss-feed.php
+++ b/feedzy-rss-feeds/feedzy-rss-feed.php
@@ -15,7 +15,7 @@
* Plugin Name: Feedzy RSS Feeds Lite
* Plugin URI: https://themeisle.com/plugins/feedzy-rss-feeds/
* Description: A small and lightweight RSS aggregator plugin. Fast and very easy to use, it allows you to aggregate multiple RSS feeds into your WordPress site through fully customizable shortcodes & widgets.
- * Version: 5.2.17
+ * Version: 5.2.18
* Author: Themeisle
* Author URI: http://themeisle.com
* License: GPL-2.0+
--- a/feedzy-rss-feeds/includes/admin/feedzy-rss-feeds-import.php
+++ b/feedzy-rss-feeds/includes/admin/feedzy-rss-feeds-import.php
@@ -525,6 +525,7 @@
if ( empty( $import_content ) ) {
$import_content = '[[{"value":"%5B%7B%22id%22%3A%22%22%2C%22tag%22%3A%22item_content%22%2C%22data%22%3A%7B%7D%7D%5D"}]]';
}
+ $import_content = $this->with_iframe_allowed( 'feedzy_custom_tag_escape', $import_content );
if ( feedzy_is_pro() && empty( $import_post_term ) && 'post-new.php' === $pagenow ) {
$import_post_term = '[#auto_categories]';
@@ -668,7 +669,7 @@
} else {
if ( 'import_post_content' === $key ) {
$val = escape_html_to_tag( $val );
- $val = feedzy_custom_tag_escape( $val );
+ $val = $this->with_iframe_allowed( 'feedzy_custom_tag_escape', $val );
} elseif ( 'default_thumbnail_id' === $key && ! empty( $val ) ) {
$val = explode( ',', $val );
$val = array_map( 'intval', $val );
@@ -761,8 +762,7 @@
$source_is_valid = empty( $invalid_urls );
}
if ( 'import_post_content' === $key ) {
- add_filter( 'wp_kses_allowed_html', array( $this, 'feedzy_wp_kses_allowed_html' ) );
- $value = feedzy_custom_tag_escape( $value );
+ $value = $this->with_iframe_allowed( 'feedzy_custom_tag_escape', $value );
} else {
$value = wp_kses( $value, wp_kses_allowed_html( 'post' ) );
}
@@ -2455,7 +2455,7 @@
$post_date = str_replace( '[#post_date]', $now, $post_date );
if ( ! defined( 'FEEDZY_ALLOW_UNSAFE_HTML' ) || ! FEEDZY_ALLOW_UNSAFE_HTML ) {
- $post_content = wp_kses_post( $post_content );
+ $post_content = $this->with_iframe_allowed( 'wp_kses_post', $post_content );
if ( ! function_exists( 'use_block_editor_for_post_type' ) ) {
require_once ABSPATH . 'wp-admin/includes/post.php';
@@ -2619,7 +2619,8 @@
add_filter( 'wp_targeted_link_rel', $link_rel_callback );
}
- $new_post_id = wp_insert_post( $new_post, true );
+ // Core KSES filters the insert on cron.
+ $new_post_id = $this->with_iframe_allowed( 'wp_insert_post', $new_post, true );
if ( $link_rel_callback ) {
remove_filter( 'wp_targeted_link_rel', $link_rel_callback );
@@ -4293,23 +4294,13 @@
}
/**
- * Add iframe to allowed wp_kses_post tags.
+ * Allow the disabled attribute on span tags, used by the locked magic tags.
*
* @param array|string $context Allowed tags, attributes, and/or entities.
*
* @return array
*/
public function feedzy_wp_kses_allowed_html( $context ) {
- if ( ! isset( $context['iframe'] ) ) {
- $context['iframe'] = array(
- 'src' => true,
- 'height' => true,
- 'width' => true,
- 'frameborder' => true,
- 'allowfullscreen' => true,
- 'data-*' => true,
- );
- }
if ( isset( $context['span'] ) ) {
$context['span']['disabled'] = true;
}
@@ -4318,6 +4309,48 @@
}
/**
+ * Add iframe to the post KSES context while Feedzy sanitizes import content.
+ *
+ * @param array<string, array<string, mixed>|true> $tags Allowed tags and their attributes.
+ * @param string $context KSES context name.
+ *
+ * @return array<string, array<string, mixed>|true>
+ */
+ public function allow_iframe_tag( $tags, $context ) {
+ if ( 'post' !== $context || isset( $tags['iframe'] ) ) {
+ return $tags;
+ }
+
+ $tags['iframe'] = array(
+ 'src' => true,
+ 'height' => true,
+ 'width' => true,
+ 'frameborder' => true,
+ 'allowfullscreen' => true,
+ 'data-*' => true,
+ );
+
+ return $tags;
+ }
+
+ /**
+ * Call a function with iframes allowed in the post KSES context.
+ *
+ * @param callable $callback Function to call.
+ * @param mixed ...$args Arguments passed to the function.
+ *
+ * @return mixed The function's return value.
+ */
+ private function with_iframe_allowed( callable $callback, ...$args ) {
+ add_filter( 'wp_kses_allowed_html', array( $this, 'allow_iframe_tag' ), 10, 2 );
+ try {
+ return $callback( ...$args );
+ } finally {
+ remove_filter( 'wp_kses_allowed_html', array( $this, 'allow_iframe_tag' ), 10 );
+ }
+ }
+
+ /**
* Get post data using meta key and value.
*
* @param string $post_type Post type Default post.
--- a/feedzy-rss-feeds/includes/feedzy-rss-feeds.php
+++ b/feedzy-rss-feeds/includes/feedzy-rss-feeds.php
@@ -104,7 +104,7 @@
*/
public function init() {
self::$plugin_name = 'feedzy-rss-feeds';
- self::$version = '5.2.17';
+ self::$version = '5.2.18';
self::$instance->load_dependencies();
self::$instance->define_admin_hooks();
}
--- a/feedzy-rss-feeds/includes/views/import-metabox-edit.php
+++ b/feedzy-rss-feeds/includes/views/import-metabox-edit.php
@@ -340,7 +340,7 @@
<input type="text" name="feedzy_meta_data[import_post_content]"
placeholder="<?php esc_attr_e( 'Post Content', 'feedzy-rss-feeds' ); ?>"
class="form-control fz-input-tagify"
- value="<?php echo esc_attr( feedzy_custom_tag_escape( $import_content ) ); ?>" />
+ value="<?php echo esc_attr( $import_content ); ?>" />
<div class="fz-input-group-right fz-content-action-tags position-absolute fz-insert-tags">
<div class="dropdown">
<button type="button" class="btn btn-outline-primary btn-add-fields dropdown-toggle" aria-haspopup="true"
--- a/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/assets/js/build/support_hub/support-hub.asset.php
+++ b/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/assets/js/build/support_hub/support-hub.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array(), 'version' => 'f76623f102b0d57fa656');
+<?php return array('dependencies' => array(), 'version' => 'f8ff7ac435ecbc91bf66');
--- a/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/load.php
+++ b/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/load.php
@@ -14,7 +14,7 @@
return;
}
// Current SDK version and path.
-$themeisle_sdk_version = '3.3.72';
+$themeisle_sdk_version = '3.3.73';
$themeisle_sdk_path = dirname( __FILE__ );
global $themeisle_sdk_max_version;
--- a/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/src/Loader.php
+++ b/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/src/Loader.php
@@ -29,12 +29,6 @@
*/
private static $instance;
/**
- * Current loader version.
- *
- * @var string $version The class version.
- */
- private static $version = '2.0.0';
- /**
* Holds registered products.
*
* @var array<Product> The products which use the SDK.
@@ -207,12 +201,33 @@
'button_submit' => 'Submit & Deactivate',
'button_cancel' => 'Skip & Deactivate',
'disclosure' => [
- 'title' => 'Below is a detailed view of all data that Themeisle will receive if you fill in this survey. No email address or IP addresses are transmitted after you submit the survey.',
- 'version' => '%s %s version %s %s %s %s',
- 'website' => '%sCurrent website:%s %s %s %s',
- 'usage' => '%sUsage time:%s %s %s%s',
- 'reason' => '%s Uninstall reason %s %s Selected reason from the above survey %s ',
- 'diagnostics' => '%sCrash diagnostics:%s Anonymized technical details of errors recorded for this product, if any.',
+ 'title' => 'Below is a detailed view of all data that Themeisle will receive if you fill in this survey. No email address or IP addresses are transmitted after you submit the survey.',
+ 'version' => '%s %s version %s %s %s %s',
+ 'website' => '%sCurrent website:%s %s %s %s',
+ 'usage' => '%sUsage time:%s %s %s%s',
+ 'reason' => '%s Uninstall reason %s %s Selected reason from the above survey %s ',
+ 'diagnostics' => '%sCrash diagnostics:%s Anonymized technical details of errors recorded for this product, if any.',
+ // Products with the Support Hub: what goes along when the user asks support for help under a reason.
+ 'title_support' => 'Below is a detailed view of all data that Themeisle will receive if you fill in this survey. No IP addresses are transmitted after you submit the survey.',
+ 'email' => '%s Email address %s %s Reply to address, if you contact support %s',
+ 'plan' => '%s Plan %s %s Free or Pro, if you contact support %s',
+ 'site_info' => '%sSite info:%s WordPress and PHP versions, language, active theme and plugins, license status and error details for this product, if you contact support.',
+ ],
+ // Products with the Support Hub: fields under the reasons support can help with.
+ 'support' => [
+ 'help' => 'Want us to look into it?',
+ 'contact' => 'Contact support',
+ // translators: %s is the email address support will reply to.
+ 'reply' => 'We'll reply to %s',
+ 'change' => 'Change',
+ 'email' => 'Reply to',
+ 'email_invalid' => 'Enter a full email address, like name@example.com.',
+ 'cancel' => 'Cancel',
+ 'keep_active' => 'Send and keep the plugin active',
+ 'button_send' => 'Send & Deactivate',
+ 'sent_title' => 'Message sent',
+ 'sent_text' => 'The plugin stays active. We usually reply within 1 business day.',
+ 'error' => 'We could not send your message. Please try again.',
],
'options' => [
@@ -235,7 +250,9 @@
'placeholder' => 'What problem are you experiencing?',
],
'id7' => [
- 'title' => 'I don't know how to make it look like demo',
+ 'title' => 'I don't know how to make it look like demo',
+ // Shown only for products with the Support Hub, where this reason gets a comment box.
+ 'placeholder' => 'Which demo, and what is different?',
],
'id8' => [
@@ -416,103 +433,40 @@
],
],
'support_hub' => [
- 'launcher' => 'Help',
- 'launcher_aria' => 'Open help',
- 'close' => 'Close',
- 'title' => 'Got a question, idea or problem?',
- // translators: %s is the product name.
- 'subtitle' => 'Ask us anything about %s. We usually reply within 1 business day.',
- 'message_label' => 'Your message',
- 'message_placeholder' => 'What can we help you with?',
- 'email_label' => 'Reply to',
- 'site_info_label' => 'Include my site info so we can help faster',
- 'site_info_toggle' => 'What's included',
- 'site_info_description' => 'Product name, version and plan, WordPress and PHP versions, your active theme, the list of active plugins, and pending crash reports (messages, file locations and product trace frames). Never license keys, tokens or payment data.',
- 'send' => 'Send message',
- 'sending' => 'Sending…',
- 'sent_title' => 'Message sent',
- 'sent_text' => 'Thanks! We usually reply within 1 business day.',
- 'nudge_help' => 'Get help',
- 'nudge_dismiss' => 'Dismiss',
- 'error_attached' => 'Error attached',
- 'error_link' => 'Get help with this',
- 'error_form_title' => 'Something not working?',
- 'error_form_text' => 'Tell us what you were doing. The error details are attached. We usually reply within 1 business day.',
- 'error_placeholder' => 'e.g. I clicked Save on my settings and got this error',
+ 'launcher' => 'Help',
+ 'launcher_aria' => 'Open help',
+ 'close' => 'Close',
+ 'title' => 'Got a question, idea or problem?',
// translators: %s is the product name.
- 'setup_title' => 'Need a hand setting up %s?',
- 'setup_text' => 'Tell us where you got stuck and we'll help you finish.',
- 'setup_prefill' => 'I need help finishing the setup: ',
- 'error_permission' => 'You are not allowed to do this.',
- 'error_product' => 'Unknown product.',
- 'error_empty' => 'Please write a message first.',
- 'error_email' => 'Please enter a valid email address.',
- 'error_throttled' => 'Please wait a moment before sending another message.',
- 'error_send' => 'We could not send your message. Opening your email app instead.',
- 'mailto_subject' => '[%s] Support request',
- 'deactivation_title' => 'Quick question before you go',
+ 'subtitle' => 'Ask us anything about %s. We usually reply within 1 business day.',
+ 'message_label' => 'Your message',
+ 'message_placeholder' => 'What can we help you with?',
+ 'email_label' => 'Reply to',
+ 'site_info_label' => 'Include my site info to get help faster',
+ 'site_info_toggle' => 'What's included',
+ 'site_info_description' => 'Product name, version and plan, WordPress and PHP versions, your active theme, the list of active plugins, and pending crash reports (messages, file locations and product trace frames). Never license keys, tokens or payment data.',
+ 'send' => 'Send message',
+ 'sending' => 'Sending…',
+ 'sent_title' => 'Message sent',
+ 'sent_text' => 'Thanks! We usually reply within 1 business day.',
+ 'nudge_help' => 'Get help',
+ 'nudge_dismiss' => 'Dismiss',
+ 'error_attached' => 'Error attached',
+ 'error_link' => 'Get help with this',
+ 'error_form_title' => 'Something not working?',
+ 'error_form_text' => 'Tell us what you were doing. The error details are attached. We usually reply within 1 business day.',
+ 'error_placeholder' => 'e.g. I clicked Save on my settings and got this error',
// translators: %s is the product name.
- 'deactivation_subtitle' => 'Why are you deactivating %s?',
- 'deactivation_email' => 'Reply to',
- 'deactivation_site_info' => 'Include site info',
- 'deactivation_keep_active' => 'Keep the plugin active until you reply',
- 'deactivation_cancel' => 'Cancel',
- 'deactivation_deactivate' => 'Deactivate',
- 'deactivation_send_deactivate' => 'Send & deactivate',
- 'deactivation_send' => 'Send & keep active',
- // Themes (Add Themes screen): same window, other wording. Keys with `_theme` win over the plugin ones.
- 'deactivation_title_theme' => 'Looking for a different theme?',
- // translators: %s is the theme name.
- 'deactivation_subtitle_theme' => 'What does not work for you in %s?',
- 'deactivation_send_theme' => 'Send',
- 'reasons' => [
- 'not_working' => [
- 'label' => 'Couldn't get it working',
- 'placeholder' => 'What were you trying to do? Tell us and we'll help you get it working, free.',
- ],
- 'missing' => [
- 'label' => 'Missing something I need',
- 'placeholder' => 'What do you need? It may already exist, or we can build it.',
- ],
- 'no_longer_need' => [
- 'label' => 'I no longer need it',
- 'placeholder' => '',
- ],
- 'switching' => [
- 'label' => 'Switching to another plugin',
- 'placeholder' => '',
- ],
- 'temporary' => [
- 'label' => 'Just temporary',
- 'placeholder' => '',
- ],
- 'other' => [
- 'label' => 'Something else',
- 'placeholder' => 'Tell us what happened and we'll get back to you.',
- ],
- ],
- 'reasons_theme' => [
- 'not_like_demo' => [
- 'label' => 'Couldn't make it look like the demo',
- 'placeholder' => 'Which demo, and what is different? We'll help you get there, free.',
- ],
- 'missing' => [
- 'label' => 'Missing something I need',
- 'placeholder' => 'What do you need? It may already exist, or we can build it.',
- ],
- 'plugin_conflict' => [
- 'label' => 'Not working with a plugin I need',
- 'placeholder' => 'Which plugin? We'll look into it.',
- ],
- 'new_design' => [
- 'label' => 'Trying a different design',
- 'placeholder' => '',
- ],
- 'other' => [
- 'label' => 'Something else',
- 'placeholder' => 'Tell us what happened and we'll get back to you.',
- ],
- ],
+ 'setup_title' => 'Need a hand setting up %s?',
+ 'setup_text' => 'Tell us where you got stuck and we'll help you finish.',
+ 'setup_prefill' => 'I need help finishing the setup: ',
+ 'error_permission' => 'You are not allowed to do this.',
+ 'error_product' => 'Unknown product.',
+ 'error_empty' => 'Please write a message first.',
+ 'error_email' => 'Please enter a valid email address.',
+ 'error_throttled' => 'Please wait a moment before sending another message.',
+ 'error_send' => 'We could not send your message. Opening your email app instead.',
+ 'mailto_subject' => '[%s] Support request',
],
];
@@ -626,7 +580,7 @@
$cache_token = get_transient( 'themeisle_sdk_cache_token' );
if ( false === $cache_token ) {
$cache_token = wp_generate_password( 6, false );
- set_transient( $cache_token, WEEK_IN_SECONDS );
+ set_transient( 'themeisle_sdk_cache_token', $cache_token, WEEK_IN_SECONDS );
}
return $cache_token;
@@ -701,11 +655,14 @@
}
/**
- * Get the version of the SDK.
+ * Get the version of the SDK that load.php picked: the highest one any
+ * active product ships.
*
* @return string The version.
*/
public static function get_version() {
- return self::$version;
+ global $themeisle_sdk_max_version;
+
+ return (string) $themeisle_sdk_max_version;
}
}
--- a/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/src/Modules/About_us.php
+++ b/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/src/Modules/About_us.php
@@ -50,9 +50,9 @@
/**
* Hand-picked display order for featured products, keyed by WP.org slug.
*
- * @var array
+ * @var array<string, int>
*/
- const COMMON_PRODUCTS_PRIORITY = [
+ private static $common_products_priority = [
'neve' => 0,
'otter-blocks' => 1,
'wp-cloudflare-page-cache' => 2,
@@ -66,9 +66,9 @@
/**
* Sort weight per install status, lowest shows first.
*
- * @var array
+ * @var array<string, int>
*/
- const STATUS_PRIORITY = [
+ private static $status_priority = [
'not-installed' => 0,
'installed' => 1,
'active' => 2,
@@ -357,15 +357,16 @@
],
];
- return array_filter(
- $pages,
- function ( $page_data, $page_key ) use ( $product_pages ) {
- return in_array( $page_key, $product_pages, true ) &&
- isset( $page_data['plugin']['status'] ) &&
- $page_data['plugin']['status'] === 'not-installed';
- },
- ARRAY_FILTER_USE_BOTH
- );
+ $filtered = [];
+ foreach ( $pages as $page_key => $page_data ) {
+ if ( in_array( $page_key, $product_pages, true ) &&
+ isset( $page_data['plugin']['status'] ) &&
+ $page_data['plugin']['status'] === 'not-installed' ) {
+ $filtered[ $page_key ] = $page_data;
+ }
+ }
+
+ return $filtered;
}
/**
@@ -503,8 +504,10 @@
uksort(
$products,
function ( $left_slug, $right_slug ) use ( $products ) {
- return $this->get_product_sort_key( $left_slug, $products )
- <=> $this->get_product_sort_key( $right_slug, $products );
+ $left = $this->get_product_sort_key( $left_slug, $products );
+ $right = $this->get_product_sort_key( $right_slug, $products );
+
+ return $left < $right ? -1 : ( $left > $right ? 1 : 0 );
}
);
@@ -522,11 +525,11 @@
private function get_product_sort_key( $slug, $products ) {
$status = isset( $products[ $slug ]['status'] ) ? $products[ $slug ]['status'] : 'not-installed';
$is_active = 'active' === $status ? 1 : 0;
- $common_weight = isset( self::COMMON_PRODUCTS_PRIORITY[ $slug ] ) ? self::COMMON_PRODUCTS_PRIORITY[ $slug ] : self::SORT_WEIGHT_UNRANKED;
+ $common_weight = isset( self::$common_products_priority[ $slug ] ) ? self::$common_products_priority[ $slug ] : self::SORT_WEIGHT_UNRANKED;
// Install status only breaks ties between unranked products.
$status_weight = self::SORT_WEIGHT_UNRANKED === $common_weight
- ? ( isset( self::STATUS_PRIORITY[ $status ] ) ? self::STATUS_PRIORITY[ $status ] : self::SORT_WEIGHT_UNRANKED )
+ ? ( isset( self::$status_priority[ $status ] ) ? self::$status_priority[ $status ] : self::SORT_WEIGHT_UNRANKED )
: 0;
// Tuple order = sort precedence: active last, featured rank, status, then slug.
--- a/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/src/Modules/Ai_connect.php
+++ b/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/src/Modules/Ai_connect.php
@@ -64,7 +64,7 @@
* After a dismissal nothing is shown for this long; then the next product
* the user has not dismissed gets its turn.
*/
- const REMIND_AFTER = 30 * DAY_IN_SECONDS;
+ const REMIND_AFTER = 2592000; // 30 days.
/**
* A user is asked this many times at most, however many products opted in.
@@ -80,7 +80,7 @@
* And this long after the module first ran on the site, so an update does
* not greet a long-time user with it.
*/
- const MINIMUM_SINCE = 2 * DAY_IN_SECONDS;
+ const MINIMUM_SINCE = 172800; // 2 days.
/**
* When the module first ran on this site.
--- a/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/src/Modules/Announcements.php
+++ b/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/src/Modules/Announcements.php
@@ -24,7 +24,7 @@
class Announcements extends Abstract_Module {
const SALE_DURATION_BLACK_FRIDAY = '+7 days'; // DateTime modifier. (Include Cyber Monday)
- const MINIMUM_INSTALL_AGE = 3 * DAY_IN_SECONDS;
+ const MINIMUM_INSTALL_AGE = 259200; // 3 days.
/**
* Mark if the notice was already loaded.
--- a/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/src/Modules/Compatibilities.php
+++ b/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/src/Modules/Compatibilities.php
@@ -195,17 +195,19 @@
$should_block = true;
}
if ( $should_block ) {
- echo( sprintf(
- esc_html( Loader::$labels['compatibilities']['notice2'] ),
- esc_attr( $product->get_friendly_name() ),
- esc_attr( $requirement->get_friendly_name() ),
- '<a href="' . esc_url( admin_url( $requirement->is_theme() ? 'themes.php' : 'plugins.php' ) ) . '">',
- '</a>',
- esc_attr( $requirement->get_friendly_name() ),
- esc_attr( $requirement->is_theme() ? Loader::$labels['compatibilities']['theme'] : Loader::$labels['compatibilities']['plugin'] )
- ) );
- $upgrader->maintenance_mode( false );
- die();
+ // Returning a WP_Error aborts only this item; a die() here would kill bulk, cron and WP-CLI runs.
+ return new WP_Error(
+ 'themeisle_sdk_requirement_not_met',
+ sprintf(
+ esc_html( Loader::$labels['compatibilities']['notice2'] ),
+ esc_attr( $product->get_friendly_name() ),
+ esc_attr( $requirement->get_friendly_name() ),
+ '<a href="' . esc_url( admin_url( $requirement->is_theme() ? 'themes.php' : 'plugins.php' ) ) . '">',
+ '</a>',
+ esc_attr( $requirement->get_friendly_name() ),
+ esc_attr( $requirement->is_theme() ? Loader::$labels['compatibilities']['theme'] : Loader::$labels['compatibilities']['plugin'] )
+ )
+ );
}
return $return;
--- a/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/src/Modules/Float_widget.php
+++ b/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/src/Modules/Float_widget.php
@@ -77,7 +77,7 @@
}
// The Support Hub replaces this widget for the products that opted into it.
- if ( ! empty( apply_filters( $product->get_key() . '_support_hub_metadata', array() ) ) ) {
+ if ( apply_filters( $product->get_key() . '_support_hub_metadata', array() ) ) {
return false;
}
--- a/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/src/Modules/Licenser.php
+++ b/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/src/Modules/Licenser.php
@@ -861,7 +861,8 @@
),
array(
'timeout' => 15, //phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout, Inherited by wp_remote_get only, for vip environment we use defaults.
- 'sslverify' => false,
+ // Kill switch for hosts with broken trust stores: return false to skip certificate checks on the update feed.
+ 'sslverify' => apply_filters( 'themeisle_sdk_update_sslverify', true ),
)
);
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
@@ -965,23 +966,6 @@
}
/**
- * Disable SSL verification in order to prevent download update failures.
- *
- * @param array $args Http args.
- * @param string $url Url to check.
- *
- * @return array $array
- */
- public function http_request_args( $args, $url ) {
- // If it is an https request and we are performing a package download, disable ssl verification.
- if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
- $args['sslverify'] = false;
- }
-
- return $args;
- }
-
- /**
* Check if we should load the module for this product.
*
* @param Product $product Product data.
@@ -1020,7 +1004,7 @@
add_filter( 'themeisle_sdk_license/is-valid', [ __CLASS__, 'is_valid' ], 999, 1 );
add_filter( 'themeisle_sdk_license/plan', [ __CLASS__, 'plan' ], 999, 1 );
add_filter( 'themeisle_sdk_license/key', [ __CLASS__, 'key' ], 999, 1 );
- $globals_loaded = true;
+ self::$globals_loaded = true;
}
$namespace = apply_filters( 'themesle_sdk_namespace_' . md5( $product->get_basefile() ), false );
@@ -1048,15 +1032,6 @@
]
);
add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
- add_filter( //phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.http_request_args
- 'http_request_args',
- array(
- $this,
- 'http_request_args',
- ),
- 10,
- 2
- );
if ( ! self::is_valid( $product->get_basefile() ) ) {
add_filter(
'plugin_action_links_' . plugin_basename( $product->get_basefile() ),
--- a/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/src/Modules/Logger.php
+++ b/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/src/Modules/Logger.php
@@ -287,7 +287,8 @@
if ( defined( 'WP_DEBUG' ) && WP_DEBUG && defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
error_log( $e->getMessage() ); // phpcs:ignore
}
- } finally {
+ } catch ( Throwable $e ) {
+ // Telemetry must never break the page.
return;
}
}
--- a/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/src/Modules/Promotions.php
+++ b/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/src/Modules/Promotions.php
@@ -496,8 +496,8 @@
update_option( 'easy_mcp_reference_key', sanitize_key( $_GET['easy_mcp_reference_key'] ) );
}
- if ( isset( $_GET['feedzy_reference_key'] ) || ( isset( $_GET['from'], $_GET['plugin'] ) && $_GET['from'] === 'import' && str_starts_with( sanitize_key( $_GET['plugin'] ), 'feedzy' ) ) ) {
- update_option( 'feedzy_reference_key', sanitize_key( $_GET['feedzy_reference_key'] ?? 'i-' . $this->product->get_key() ) );
+ if ( isset( $_GET['feedzy_reference_key'] ) || ( isset( $_GET['from'], $_GET['plugin'] ) && $_GET['from'] === 'import' && 0 === strpos( sanitize_key( $_GET['plugin'] ), 'feedzy' ) ) ) {
+ update_option( 'feedzy_reference_key', sanitize_key( isset( $_GET['feedzy_reference_key'] ) ? $_GET['feedzy_reference_key'] : 'i-' . $this->product->get_key() ) );
update_option( $this->option_feedzy, 1 );
}
}
@@ -980,15 +980,14 @@
$return = array_merge( $return, $this->promotions[ $slug ] );
}
- $return = array_filter(
- $return,
- function ( $value, $key ) {
- return ! in_array( $key, $this->dissallowed_promotions, true );
- },
- ARRAY_FILTER_USE_BOTH
- );
+ $allowed = [];
+ foreach ( array_keys( $return ) as $key ) {
+ if ( ! in_array( $key, $this->dissallowed_promotions, true ) ) {
+ $allowed[] = $key;
+ }
+ }
- return array_keys( $return );
+ return $allowed;
}
/**
@@ -1271,7 +1270,7 @@
*/
public function render_easy_mcp_notice() {
// A product on this site already offers the connector in its own words.
- if ( class_exists( Ai_Connect::class ) && Ai_Connect::has_products() ) {
+ if ( class_exists( 'ThemeisleSDKModulesAi_Connect' ) && Ai_Connect::has_products() ) {
return;
}
// Cards are injected only when a paid product loaded Featured_plugins; only then can this request already show one.
@@ -1469,13 +1468,12 @@
*/
public function woocommerce_tab_content() {
// Filter content based on if the key exists in $this->promotions array.
- $content = array_filter(
- $this->woo_promos,
- function ( $key ) {
- return in_array( $key, $this->promotions, true );
- },
- ARRAY_FILTER_USE_KEY
- );
+ $content = [];
+ foreach ( $this->woo_promos as $key => $promo ) {
+ if ( in_array( $key, $this->promotions, true ) ) {
+ $content[ $key ] = $promo;
+ }
+ }
// Display CSS
self::render_woo_tabs_css();
@@ -1941,7 +1939,7 @@
$page_title_matches = get_transient( 'tisdk_page_title_signals_v1' );
- if ( is_array( $page_title_matches ) && empty( array_diff_key( $default_matches, $page_title_matches ) ) ) {
+ if ( is_array( $page_title_matches ) && ! array_diff_key( $default_matches, $page_title_matches ) ) {
return array_merge( $default_matches, $page_title_matches );
}
--- a/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/src/Modules/Support_hub.php
+++ b/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/src/Modules/Support_hub.php
@@ -4,7 +4,7 @@
*
* One floating Help button on the product's admin screens that opens straight
* into a short contact form, nudges at the moments users need help most
- * (unfinished setup) and a simpler deactivation window.
+ * (unfinished setup).
*
* Here's how to hook it in your product:
*
@@ -72,7 +72,7 @@
/**
* The setup nudge waits this long after the product was installed.
*/
- const SETUP_MIN_AGE = 3 * DAY_IN_SECONDS;
+ const SETUP_MIN_AGE = 259200; // 3 days.
/**
* And repeats at most this often.
@@ -102,71 +102,37 @@
/**
* Sources a message can carry.
+ *
+ * @var list<string>
*/
- const SOURCES = [ 'widget', 'error', 'setup', 'deactivation', 'custom' ];
+ private static $sources = [ 'widget', 'error', 'setup', 'deactivation', 'custom' ];
/**
- * Plugin deactivation reasons, in display order. `feedback_id` is the id
- * sent to the existing uninstall feedback endpoint so Metabase keeps its
- * data; 11 is new ("Missing something I need"), the others reuse the old
- * survey ids.
- *
- * @var array<string, array{feedback_id: int, message: bool}>
- */
- const REASONS = [
- 'not_working' => [
- 'feedback_id' => 4,
- 'message' => true,
- ],
- 'missing' => [
- 'feedback_id' => 11,
- 'message' => true,
- ],
- 'no_longer_need' => [
- 'feedback_id' => 5,
- 'message' => false,
- ],
- 'switching' => [
- 'feedback_id' => 3,
- 'message' => false,
- ],
- 'temporary' => [
- 'feedback_id' => 6,
- 'message' => false,
- ],
- 'other' => [
- 'feedback_id' => 999,
- 'message' => true,
- ],
+ * Uninstall feedback reason ids, as the deactivation reasons the support
+ * endpoint labels: 3-6 are the plugin reasons, 7-10 the theme ones.
+ *
+ * @var array<int, string>
+ */
+ private static $feedback_reasons = [
+ 3 => 'switching',
+ 4 => 'not_working',
+ 5 => 'no_longer_need',
+ 6 => 'temporary',
+ 7 => 'not_like_demo',
+ 8 => 'missing',
+ 9 => 'plugin_conflict',
+ 10 => 'new_design',
+ 999 => 'other',
];
/**
- * Theme switch reasons, in display order, on the old theme survey ids.
+ * The uninstall feedback reasons support can help with. Selecting one in
+ * the form offers a "Contact support" link: a comment sent after it is
+ * clicked opens a support conversation.
*
- * @var array<string, array{feedback_id: int, message: bool}>
+ * @var list<int>
*/
- const REASONS_THEME = [
- 'not_like_demo' => [
- 'feedback_id' => 7,
- 'message' => true,
- ],
- 'missing' => [
- 'feedback_id' => 8,
- 'message' => true,
- ],
- 'plugin_conflict' => [
- 'feedback_id' => 9,
- 'message' => true,
- ],
- 'new_design' => [
- 'feedback_id' => 10,
- 'message' => false,
- ],
- 'other' => [
- 'feedback_id' => 999,
- 'message' => true,
- ],
- ];
+ private static $support_reasons = [ 4, 6, 7, 8, 9, 999 ];
/**
* Every product that opted in, keyed by product key. Shared by all the
@@ -375,15 +341,43 @@
}
/**
- * Does the hub own the deactivation flow of this product? Plugins get the
- * window on the Plugins screen, themes get feedback on Add Themes.
+ * The uninstall feedback reasons that offer to contact support for this
+ * product: none without the Support Hub, or for a user who cannot use it.
*
* @param Product $product Product.
*
- * @return bool
+ * @return list<int>
*/
- public static function handles_deactivation( $product ) {
- return ( $product->is_plugin() || $product->is_theme() ) && self::handles( $product ) && self::user_can_use() && ! apply_filters( $product->get_key() . '_hide_uninstall_feedback', false );
+ public static function uninstall_support_reasons( $product ) {
+ return self::handles( $product ) && self::user_can_use() ? self::$support_reasons : array();
+ }
+
+ /**
+ * Open a support conversation for a comment written in the uninstall
+ * feedback form under a reason support can help with, when the user asked
+ * to contact support. Sent with the site info, which the form's data
+ * notice lists.
+ *
+ * @param Product $product Product.
+ * @param int $feedback_id Uninstall feedback reason id.
+ * @param string $comment Comment the user wrote.
+ * @param string $email Reply-to address from the form; the current user's when empty.
+ * @param bool $keep_active Whether the user asked to keep the plugin active.
+ *
+ * @return DeliveryResult|WP_Error|null Null when support has nothing to answer: no Support Hub, another reason, or no comment.
+ */
+ public static function send_uninstall_comment( $product, $feedback_id, $comment, $email = '', $keep_active = false ) {
+ $key = $product->get_key();
+ if ( ! in_array( (int) $feedback_id, self::uninstall_support_reasons( $product ), true ) || '' === trim( $comment ) ) {
+ return null;
+ }
+ $context = array( 'reason' => self::$feedback_reasons[ (int) $feedback_id ] );
+ if ( $product->is_plugin() ) {
+ $context['keep_active'] = $keep_active ? 1 : 0;
+ }
+ $entry = self::$registered[ $key ];
+
+ return self::send( $entry['product'], $entry['data'], 'deactivation', $comment, $email, true, $context );
}
/**
@@ -441,37 +435,7 @@
}
/**
- * The products whose deactivation window is rendered on this screen: every
- * hub plugin on the Plugins screen, the active hub theme on the Add Themes
- * screen (the same trigger as the legacy theme drawer, which the window
- * replaces), unless its feedback was sent in the last 100 days.
- *
- * @return array<string, RegisteredProduct>
- */
- private static function deactivation_products() {
- $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
- $id = $screen && ! empty( $screen->id ) ? $screen->id : '';
- if ( ! in_array( $id, array( 'plugins', 'theme-install' ), true ) ) {
- return array();
- }
- $list = array();
- foreach ( self::$registered as $key => $entry ) {
- $product = $entry['product'];
- if ( ! self::handles_deactivation( $product ) ) {
- continue;
- }
- if ( $product->is_plugin() && 'plugins' === $id ) {
- $list[ $key ] = $entry;
- } elseif ( $product->is_theme() && 'theme-install' === $id && in_array( $product->get_slug(), array( get_stylesheet(), get_template() ), true ) && false === get_transient( 'ti_sdk_pause_' . $key ) ) {
- $list[ $key ] = $entry;
- }
- }
-
- return $list;
- }
-
- /**
- * Assets, only where the launcher or the deactivation window can be.
+ * Assets, only where the launcher can be.
*
* @return void
*/
@@ -479,9 +443,8 @@
if ( self::$enqueued || ! self::user_can_use() ) {
return;
}
- $current = self::current();
- $deactivation = self::deactivation_products();
- if ( null === $current && empty( $deactivation ) ) {
+ $current = self::current();
+ if ( null === $current ) {
return;
}
self::$enqueued = true;
@@ -500,7 +463,7 @@
// so a `<!--<script>` in any string would swallow the rest of the page.
wp_add_inline_script(
$handle,
- 'var themeisleSDKSupportHub = ' . wp_json_encode( $this->localize( $current, $deactivation ), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) . ';',
+ 'var themeisleSDKSupportHub = ' . wp_json_encode( $this->localize( $current ), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) . ';',
'before'
);
}
@@ -508,37 +471,29 @@
/**
* Everything the script needs.
*
- * @param RegisteredProduct|null $current The product owning the launcher.
- * @param array<string, RegisteredProduct> $deactivation Products with a deactivation window on this screen.
+ * @param RegisteredProduct $current The product owning the launcher.
*
* @return array
*/
- private function localize( $current, $deactivation ) {
+ private function localize( $current ) {
$user = wp_get_current_user();
$labels = Loader::$labels['support_hub'];
- $config = array(
- 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
- 'nonce' => wp_create_nonce( self::NONCE ),
- 'actions' => array(
+ $product = $current['product'];
+ $data = $current['data'];
+
+ return array(
+ 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
+ 'nonce' => wp_create_nonce( self::NONCE ),
+ 'actions' => array(
'send' => self::AJAX_SEND,
'mark' => self::AJAX_MARK,
),
- 'user' => array(
+ 'user' => array(
'email' => $user ? $user->user_email : '',
),
- 'labels' => $labels,
- 'product' => null,
- 'nudges' => array(),
- 'deactivation' => array(),
- 'maxLength' => self::MAX_MESSAGE_LENGTH,
- );
-
- if ( null !== $current ) {
- $product = $current['product'];
- $data = $current['data'];
-
- $config['product'] = array(
+ 'labels' => self::fill_labels( $labels, $product->get_friendly_name() ),
+ 'product' => array(
'key' => $product->get_key(),
'slug' => $product->get_slug(),
'name' => $product->get_friendly_name(),
@@ -547,40 +502,10 @@
'errorSelectors' => $data['error_selectors'],
'supportEmail' => $data['support_email'],
'primaryColor' => $data['primary_color'],
- );
- $config['nudges'] = $this->nudges( $product, $data );
- $config['labels'] = self::fill_labels( $labels, $product->get_friendly_name() );
- }
-
- foreach ( $deactivation as $key => $entry ) {
- $product = $entry['product'];
- $theme = $product->is_theme();
- $texts = $labels[ $theme ? 'reasons_theme' : 'reasons' ];
- $reasons = array();
- foreach ( $theme ? self::REASONS_THEME : self::REASONS as $id => $reason ) {
- $reasons[] = array(
- 'id' => $id,
- 'label' => $texts[ $id ]['label'],
- 'placeholder' => $reason['message'] ? $texts[ $id ]['placeholder'] : '',
- 'message' => $reason['message'],
- 'feedbackId' => $reason['feedback_id'],
- );
- }
- $config['deactivation'][ $product->get_slug() ] = array(
- 'key' => $key,
- 'type' => $product->get_type(),
- 'name' => $product->get_friendly_name(),
- 'supportEmail' => $entry['data']['support_email'],
- 'primaryColor' => $entry['data']['primary_color'],
- 'feedbackAction' => $key . '_uninstall_feedback',
- 'feedbackNonce' => wp_create_nonce( 'ThemeisleSDKModulesUninstall_Feedback' ),
- 'reasons' => $reasons,
- // Themes: the window opens by itself, like the drawer it replaces.
- 'autoOpen' => $theme ? Uninstall_Feedback::AUTO_TRIGGER_DEACTIVATE_WINDOW_SECONDS : 0,
- );
- }
-
- return $config;
+ ),
+ 'nudges' => $this->nudges( $product, $data ),
+ 'maxLength' => self::MAX_MESSAGE_LENGTH,
+ );
}
/**
@@ -703,7 +628,7 @@
}
/**
- * The launcher root, and the deactivation windows on the Plugins and Add Themes screens.
+ * The launcher root.
*
* @return void
*/
@@ -716,19 +641,12 @@
// were decided. Both are footer-safe, so enqueue them now.
$this->enqueue();
- $current = self::current();
- $deactivation = self::deactivation_products();
- if ( null === $current && empty( $deactivation ) ) {
+ if ( null === self::current() ) {
return;
}
self::$rendered = true;
- if ( null !== $current ) {
- echo '<div id="ti-support-hub" class="ti-support-hub"></div>';
- }
- foreach ( $deactivation as $entry ) {
- echo '<div class="ti-support-deactivate-root" data-ti-support-deactivate="' . esc_attr( $entry['product']->get_slug() ) . '" data-ti-support-type="' . esc_attr( $entry['product']->get_type() ) . '"></div>';
- }
+ echo '<div id="ti-support-hub" class="ti-support-hub"></div>';
}
/**
@@ -847,7 +765,7 @@
*
* @param Product $product Product.
* @param Metadata $data Product metadata.
- * @param string $source One of SOURCES.
+ * @param string $source One of self::$sources.
* @param string $message The user's message.
* @param string $email Reply-to address.
* @param bool $include_site_info Whether to attach the site info.
@@ -861,7 +779,7 @@
'product_name' => $product->get_friendly_name(),
'version' => $product->get_version(),
'plan' => self::plan( $product, $data ),
- 'source' => in_array( $source, self::SOURCES, true ) ? $source : 'custom',
+ 'source' => in_array( $source, self::$sources, true ) ? $source : 'custom',
'message' => $message,
'email' => $email,
'site' => get_site_url(),
@@ -1022,7 +940,7 @@
}
/**
- * Send a message from the widget or the deactivation window.
+ * Send a message from the widget.
*
* @return void
*/
--- a/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/src/Modules/Translations.php
+++ b/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/src/Modules/Translations.php
@@ -108,7 +108,8 @@
self::API_URL . 'translations',
array(
'timeout' => 15, //phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout, Inherited by wp_remote_get only, for vip environment we use defaults.
- 'sslverify' => false,
+ // Kill switch for hosts with broken trust stores: return false to skip certificate checks on the update feed.
+ 'sslverify' => apply_filters( 'themeisle_sdk_update_sslverify', true ),
)
);
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
--- a/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/src/Modules/Uninstall_feedback.php
+++ b/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/src/Modules/Uninstall_feedback.php
@@ -112,12 +112,6 @@
return;
}
- // The Support Hub owns the plugin deactivation / Add Themes feedback window; only the
- // AJAX handler below stays, so the reason still reaches the feedback endpoint.
- if ( class_exists( 'ThemeisleSDKModulesSupport_Hub' ) && Support_Hub::handles_deactivation( $this->product ) ) {
- return;
- }
-
$this->add_feedback_popup_style();
if ( $this->product->get_type() === 'theme' ) {
@@ -245,6 +239,130 @@
margin-bottom: 0;
}
+ /* Support Hub: asking support for help, under the reasons it can help with. */
+ .ti-feedback .ti-feedback-support {
+ display: none;
+ width: 100%;
+ margin-top: 6px;
+ font-size: 12px;
+ color: #646970;
+ }
+
+ .ti-feedback .popup--form input[type="radio"]:checked ~ .ti-feedback-support {
+ display: block;
+ }
+
+ .ti-feedback .ti-feedback-support p {
+ margin: 0;
+ font-size: 12px;
+ }
+
+ /* Where to reply, once support is asked: one line in a quiet box. */
+ .ti-feedback .ti-feedback-contact-fields {
+ display: none;
+ position: relative;
+ padding: 6px 10px 10px;
+ padding-inline-end: 28px;
+ background: #f6f7f7;
+ border-radius: 3px;
+ }
+
+ .ti-feedback .ti-feedback-support.is-contacting .ti-feedback-help {
+ display: none;
+ }
+
+ .ti-feedback .ti-feedback-support.is-contacting .ti-feedback-contact-fields {
+ display: block;
+ }
+
+ .ti-feedback .ti-feedback-contact-close {
+ position: absolute;
+ top: 6px;
+ inset-inline-end: 6px;
+ padding: 2px 4px;
+ border: 0;
+ background: none;
+ color: #787c82;
+ font-size: 16px;
+ line-height: 1;
+ cursor: pointer;
+ }
+
+ .ti-feedback .ti-feedback-contact-close:hover {
+ color: #1d2327;
+ }
+
+ .ti-feedback .ti-feedback-reply {
+ display: flex;
+ align-items: center;
+ min-height: 24px;
+ }
+
+ .ti-feedback .ti-feedback-reply-address {
+ font-weight: 600;
+ word-break: break-all;
+ }
+
+ .ti-feedback .ti-feedback-reply-edit {
+ display: none;
+ flex: 1;
+ align-items: center;
+ max-width: 100%;
+ }
+
+ .ti-feedback .ti-feedback-support.is-editing .ti-feedback-reply-text {
+ display: none;
+ }
+
+ .ti-feedback .ti-feedback-support.is-editing .ti-feedback-reply-edit {
+ display: flex;
+ }
+
+ .ti-feedback .ti-feedback-reply-edit input[type="email"] {
+ flex: 1;
+ min-width: 0;
+ min-height: 24px;
+ height: 24px;
+ margin: 0;
+ margin-inline-start: 6px;
+ padding: 0 6px;
+ font-size: 12px;
+ line-height: 1;
+ }
+
+ .ti-feedback .ti-feedback-keep {
+ display: block;
+ margin-top: 6px;
+ }
+
+ .ti-feedback .ti-feedback-error {
+ margin: 6px 0 0;
+ color: #d63638;
+ }
+
+ .ti-feedback .ti-feedback-error:empty {
+ display: none;
+ }
+
+ .ti-feedback .ti-feedback-sent-message {
+ display: none;
+ padding: 20px 15px;
+ text-align: center;
+ }
+
+ .ti-feedback .ti-feedback-sent-message p {
+ margin: 5px 0 0;
+ }
+
+ .ti-feedback.ti-feedback-sent .ti-feedback-sent-message {
+ display: block;
+ }
+
+ .ti-feedback.ti-feedback-sent .popup--body,
+ .ti-feedback.ti-feedback-sent .popup--footer {
+ display: none;
+ }
+
.ti-feedback .popup--footer {
padding: 0 15px 15px;
}
@@ -267,7 +385,7 @@
}
.ti-feedback .info-disclosure-content.active {
- max-height: 300px;
+ max-height: 500px;
}
.ti-feedback .info-disclosure-content p {
@@ -450,9 +568,11 @@
$('.info-disclosure-content').toggleClass('active');
});
+ <?php $this->print_support_fields_js( '.ti-theme-uninstall-feedback-drawer' ); ?>
+
$('.ti-theme-uninstall-feedback-drawer input[type="radio"]').on('change', function () {
var radio = $(this);
- if (radio.parent().find('textarea').length > 0 &&
+ if (radio.parent().find('textarea').not('[data-optional]').length > 0 &&
radio.parent().find('textarea').val().length === 0) {
$('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').attr('disabled', 'disabled');
radio.parent().find('textarea').on('keyup', function (e) {
@@ -473,14 +593,32 @@
var selectedOption = $(
'.ti-theme-uninstall-feedback-drawer input[name="ti-deactivate-option"]:checked');
- $.post(ajaxurl, {
+ var data = {
'action': '<?php echo esc_attr( $key ) . '_uninstall_feedback'; ?>',
'nonce': '<?php echo esc_attr( wp_create_nonce( (string) __CLASS__ ) ); ?>',
'id': selectedOption.parent().attr('ti-option-id'),
'msg': selectedOption.parent().find('textarea').val(),
'type': 'theme',
'key': '<?php echo esc_attr( $key ); ?>'
- });
+ };
+ // Support Hub: with support asked, the comment goes to them too, with where to reply.
+ var support = selectedOption.parent().find('.ti-feedback-support');
+ if (support.hasClass('is-contacting')) {
+ // Support needs something to answer.
+ if ($.trim(data.msg) === '') {
+ selectedOption.parent().find('textarea').trigger('focus');
+ return;
+ }
+ var email = support.find('input[type="email"]')[0];
+ if (!email.checkValidity()) {
+ support.addClass('is-editing');
+ email.reportValidity();
+ return;
+ }
+ data.support = 1;
+ data.email = email.value;
+ }
+ $.post(ajaxurl, data);
$('.ti-theme-uninstall-feedback-drawer').fadeOut();
});
});
@@ -510,17 +648,19 @@
* @param array $options the options for the feedback form.
*/
private function render_options_list( $options ) {
- $key = $this->product->get_key();
- $inputs_row_map = [
+ $key = $this->product->get_key();
+ $inputs_row_map = [
'text' => 1,
'textarea' => 2,
];
+ $support_reasons = $this->support_reasons();
?>
<ul class="popup--form">
<?php
foreach ( $options as $idx => $attributes ) {
$title = Loader::$labels['uninstall']['options'][ $idx ]['title'];
$placeholder = array_key_exists( 'placeholder', Loader::$labels['uninstall']['options'][ $idx ] ) ? Loader::$labels['uninstall']['options'][ $idx ]['placeholder'] : '';
+ $has_support = in_array( (int) $attributes['id'], $support_reasons, true );
?>
<li ti-option-id="<?php echo esc_attr( $attributes['id'] ); ?>">
<input type="radio" name="ti-deactivate-option"
@@ -532,6 +672,12 @@
if ( array_key_exists( 'type', $attributes ) ) {
echo '<textarea width="100%" rows="' . esc_attr( $inputs_row_map[ $attributes['type'] ] ) . '" name="comments" placeholder="' . esc_attr( $placeholder ) . '"></textarea>';
+ } elseif ( $has_support ) {
+ // Support needs something to answer; the comment stays optional, as the reason had no box before.
+ echo '<textarea width="100%" rows="2" name="comments" data-optional="1" placeholder="' . esc_attr( $placeholder ) . '"></textarea>';
+ }
+ if ( $has_support ) {
+ $this->render_support_fields();
}
?>
</li>
@@ -541,6 +687,99 @@
}
/**
+ * The reasons support can help with: empty unless the product has the Support Hub.
+ *
+ * @return list<int>
+ */
+ private function support_reasons() {
+ return class_exists( 'ThemeisleSDKModulesSupport_Hub' ) ? Support_Hub::uninstall_support_reasons( $this->product ) : array();
+ }
+
+ /**
+ * Render the Support Hub part of a reason support can help with: a line
+ * offering to contact support which, once clicked, becomes where they
+ * will reply and, for plugins, the way to keep the plugin active.
+ */
+ private function render_support_fields() {
+ $labels = Loader::$labels['uninstall']['support'];
+ $user = wp_get_current_user();
+ $email = $user ? $user->user_email : '';
+ ?>
+ <div class="ti-feedback-support">
+ <p class="ti-feedback-help">
+ <?php echo esc_html( $labels['help'] ); ?>
+ <a href="#" class="ti-feedback-contact"><?php echo esc_html( $labels['contact'] ); ?></a>
+ </p>
+ <div class="ti-feedback-contact-fields">
+ <button type="button" class="ti-feedback-contact-close" aria-label="<?php echo esc_attr( $labels['cancel'] ); ?>">×</button>
+ <p class="ti-feedback-reply">
+ <span class="ti-feedback-reply-text">
+ <?php echo wp_kses( sprintf( $labels['reply'], '<span class="ti-feedback-reply-address">' . esc_html( $email ) . '</span>' ), array( 'span' => array( 'class' => true ) ) ); ?>
+ ·
+ <a href="#" class="ti-feedback-reply-change"><?php echo esc_html( $labels['change'] ); ?></a>
+ </span>
+ <label class="ti-feedback-reply-edit">
+ <span><?php echo esc_html( $labels['email'] ); ?></span>
+ <?php // A dotted domain and 6 characters at least, as is_email() requires: the browser refuses what the server would. ?>
+ <input type="email" required minlength="6" pattern="[^@s]+@[^@s]+.[^@s]+" title="<?php echo esc_attr( $labels['email_invalid'] ); ?>" value="<?php echo esc_attr( $email ); ?>">
+ </label>
+ </p>
+ <?php if ( $this->product->is_plugin() ) { ?>
+ <button type="button" class="button button-small ti-feedback-keep"><?php echo esc_html( $labels['keep_active'] ); ?></button>
+ <?php } ?>
+ </div>
+ <p class="ti-feedback-error" role="alert"></p>
+ </div>
+ <?php
+ }
+
+ /**
+ * Print the JS the popup and the drawer share: opening and closing the
+ * support block, and changing where to reply.
+ *
+ * @param string $root Selector of the popup or the drawer.
+ */
+ private function print_support_fields_js( $root ) {
+ ?>
+ $('<?php echo esc_attr( $root ); ?>').on('click', '.ti-feedback-contact', function (e) {
+ e.preventDefault();
+ var support = $(this).closest('.ti-feedback-support').addClass('is-contacting');
+ // No address on the account: ask for one right away.
+ support.toggleClass('is-editing', support.find('input[type="email"]').val() === '').trigger('ti-support-change');
+ }).on('click', '.ti-feedback-contact-close', function (e) {
+ e.preventDefault();
+ $(this).closest('.ti-feedback-support').removeClass('is-contacting is-editing').trigger('ti-support-change');
+ }).on('click', '.ti-feedback-reply-change', function (e) {
+ e.preventDefault();
+ $(this).closest('.ti-feedback-support').addClass('is-editing').find('input[type="email"]').trigger('focus');
+ }).on('change', '.ti-feedback-support input[type="email"]', function () {
+ // A valid address goes back to one line of text.
+ if (this.checkValidity()) {
+ $(this).closest('.ti-feedback-support').removeClass('is-editing').find('.ti-feedback-reply-address').text(this.value);
+ }
+ });
+ <?php
+ }
+
+ /**
+ * Render the confirmation shown when a message was sent and the plugin stays active.
+ */
+ private function render_support_sent() {
+ // A variable, not the call: PHP 5.4 cannot parse empty() on a function result.
+ $support_reasons = $this->support_reasons();
+ if ( empty( $support_reasons ) ) {
+ return;
+ }
+ $labels = Loader::$labels['uninstall']['support'];
+ ?>
+ <div class="ti-feedback-sent-message" role="status">
+ <strong><?php echo esc_html( $labels['sent_title'] ); ?></strong>
+ <p><?php echo esc_html( $labels['sent_text'] ); ?></p>
+ </div>
+ <?php
+ }
+
+ /**
* Render plugin feedback popup.
*/
private function render_plugin_feedback_popup() {
@@ -560,6 +799,7 @@
<div class="popup--body">
<?php $this->render_options_list( $options ); ?>
</div><!--/.popup--body-->
+ <?php $this->render_support_sent(); ?>
<div class="popup--footer">
<div class="actions">
<?php
@@ -644,6 +884,10 @@
$('<?php echo esc_attr( $popup_id ); ?> #<?php echo esc_attr( $key ); ?>ti-deactivate-no').on('click', function (e) {
e.preventDefault();
e.stopPropagation();
+ // Disabled while a message to support is on its way.
+ if ($(this).is(':disabled')) {
+ return;
+ }
$deactivateLink.unbind('click');
$('body').removeClass('ti-feedback-open');
$('<?php echo esc_attr( $popup_id ); ?>').remove();
@@ -652,12 +896,28 @@
}
});
- $('<?php echo esc_attr( $popup_id ); ?> #<?php echo esc_attr( $key ); ?>ti-deactivate-yes').on('click', function (e) {
- e.preventDefault();
- e.stopPropagation();
- $deactivateLink.unbind('click');
- var selectedOption = $(
- '<?php echo esc_attr( $popup_id ); ?> input[name="ti-deactivate-option"]:checked');
+ // Support Hub: asking support for help under the reasons it can help with.
+ var $popup = $('<?php echo esc_attr( $popup_id ); ?>');
+ var $submit = $popup.find('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes');
+ var $skip = $popup.find('#<?php echo esc_attr( $key ); ?>ti-deactivate-no');
+ var submitText = $submit.val();
+ var sendText = $('<textarea/>').html('<?php echo esc_js( Loader::$labels['uninstall']['support']['button_send'] ); ?>').text();
+ var sendError = '<?php echo esc_js( Loader::$labels['uninstall']['support']['error'] ); ?>';
+ var sending = false;
+ <?php $this->print_support_fields_js( $popup_id ); ?>
+
+ var supportFields = function () {
+ return $popup.find('input[name="ti-deactivate-option"]:checked').parent().find('.ti-feedback-support');
+ };
+ // The button says what it will do: with support asked, the comment is sent to them too.
+ var refreshSubmit = function () {
+ $submit.val(supportFields().hasClass('is-contacting') ? sendText : submitText);
+ };
+ $popup.find('input[type="radio"]').on('change', refreshSubmit);
+ $popup.on('ti-support-change', refreshSubmit);
+ // What the form sends. Null when support is asked and the reply address is not valid.
+ var feedbackData = function () {
+ var selectedOption = $popup.find('input[name="ti-deactivate-option"]:checked');
var data = {
'action': '<?php echo esc_attr( $key ) . '_uninstall_feedback'; ?>',
'nonce': '<?php echo esc_attr( wp_create_nonce( (string) __CLASS__ ) ); ?>',
@@ -666,6 +926,75 @@
'type': 'plugin',
'key': '<?php echo esc_attr( $key ); ?>'
};
+ var support = supportFields();
+ if (support.hasClass('is-contacting')) {
+ var email = support.find('input[type="email"]')[0];
+ if (!email.checkValidity()) {
+ support.addClass('is-editing');
+ email.reportValidity();
+ return null;
+ }
+ data.support = 1;
+ data.email = email.value;
+ }
+ return data;
+ };
+ var closeSent = function () {
+ if (!$popup.hasClass('ti-feedback-sent')) {
+ return;
+ }
+ $popup.removeClass('ti-feedback-sent active');
+ $('body').removeClass('ti-feedback-open');
+ $popup.find('input[type="radio"]').prop('checked', false);
+ $popup.find('.ti-feedback-support').removeClass('is-contacting is-editing');
+ $popup.find('textarea').val('');
+ $submit.attr('disabled', 'disabled');
+ refreshSubmit();
+ };
+ $('.ti-feedback-overlay').on('click', closeSent);
+
+ // "Send and keep the plugin active": send the message, confirm, close. Nothing is deactivated.
+ $popup.on('click', '.ti-feedback-keep', function (e) {
+ e.preventDefault();
+ var support = $(this).closest('.ti-feedback-support');
+ var comment = support.parent().find('textarea');
+ // Support needs something to answer.
+ if ($.trim(comment.val()) === '') {
+ comment.trigger('focus');
+ return