Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/display-a-meta-field-as-block/build/index.asset.php
+++ b/display-a-meta-field-as-block/build/index.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-url'), 'version' => '29fad5dde1a6b9f7cddd');
+<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-url'), 'version' => '0922dc7d20199a47c774');
--- a/display-a-meta-field-as-block/includes/helper-functions.php
+++ b/display-a-meta-field-as-block/includes/helper-functions.php
@@ -200,7 +200,10 @@
}
}
- return sprintf( '<%3$s %1$s>%2$s</%3$s>', $wrapper_attributes, $content, esc_attr( $attributes['tagName'] ?? 'div' ) );
+ $valid_tag_names = [ 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'span', 'p', 'header', 'footer', 'section' ];
+ $tag_name = in_array( $attributes['tagName'] ?? '', $valid_tag_names, true ) ? $attributes['tagName'] : 'div';
+
+ return sprintf( '<%3$s %1$s>%2$s</%3$s>', $wrapper_attributes, $content, $tag_name );
}
endif;
--- a/display-a-meta-field-as-block/includes/mb-fields.php
+++ b/display-a-meta-field-as-block/includes/mb-fields.php
@@ -189,6 +189,9 @@
// Update label.
$field['label'] = $field['name'] ?? '';
+ // Allow changing the raw value.
+ $value = apply_filters( '_meta_field_block_mb_refine_field_value', $value, $field, $object_id );
+
return $value;
}
@@ -602,20 +605,53 @@
$field_value = array_map(
function ( $video ) {
- $poster = $video['image']['src'] ?? '';
- if ( $poster === wp_mime_type_icon( $video['ID'] ) ) {
+ if ( ! isset( $video['ID'] ) ) {
+ return '';
+ }
+
+ // Video attributes.
+ $video_attrs = [
+ 'src' => $video['src'] ?? $video['url'],
+ ];
+
+ // Get poster.
+ $poster = ! empty( $video['poster'] ) ? $video['poster'] : $video['image']['src'] ?? '';
+ if ( $poster === wp_mime_type_icon( $video['ID'] ?? 0 ) ) {
// Not the default icon.
$poster = '';
}
- return "<video controls preload="metadata" src="{$video['src']}" width="{$video['dimensions']['width']}" poster="{$poster}" />";
+
+ if ( ! empty( $poster ) ) {
+ $video_attrs['poster'] = $poster;
+ }
+
+ // Width & height dimensions.
+ if ( ! empty( $video['dimensions']['width'] ) && ! empty( $video['dimensions']['height'] ) ) {
+ $video_attrs['width'] = $video['dimensions']['width'];
+ $video_attrs['height'] = $video['dimensions']['height'];
+ }
+
+ $video_attrs_string = implode(
+ ' ',
+ array_map(
+ fn( $key, $value ) => $key . '="' . esc_attr( $value ) . '"',
+ array_keys( $video_attrs ),
+ $video_attrs
+ )
+ );
+
+ return "<video controls preload="metadata" {$video_attrs_string} />";
},
array_values( $field_value )
);
+ // Remove empty values.
+ $field_value = array_filter( $field_value );
+
if ( count( $field_value ) > 1 ) {
$field_value = '<figure class="video-list"><figure class="video-item">' . implode( '</figure><figure class="video-item">', $field_value ) . '</figure></figure>';
} else {
- $field_value = $field_value[0];
+ $field_value = count( $field_value ) > 0 ? reset( $field_value ) : '';
}
return $field_value;
--- a/display-a-meta-field-as-block/meta-field-block.php
+++ b/display-a-meta-field-as-block/meta-field-block.php
@@ -6,7 +6,7 @@
* Description: Display a custom field as a block on the frontend. Supports custom fields for posts, terms, and users. Officially supports ACF, Meta Box, and all text-based meta fields.
* Requires at least: 6.9
* Requires PHP: 7.4
- * Version: 1.5.2
+ * Version: 1.5.3
* Author: Phi Phan
* Author URI: https://metafieldblock.com?utm_source=MFB&utm_campaign=MFB+visit+site&utm_medium=link&utm_content=Author+URI
* License: GPL-3.0
@@ -35,7 +35,7 @@
*
* @var String
*/
- protected $version = '1.5.2';
+ protected $version = '1.5.3';
/**
* Components
--- a/display-a-meta-field-as-block/vendor/freemius/includes/class-freemius.php
+++ b/display-a-meta-field-as-block/vendor/freemius/includes/class-freemius.php
@@ -6558,10 +6558,7 @@
$next_schedule = $this->next_sync_cron();
// The event is properly scheduled, so no need to reschedule it.
- if (
- is_numeric( $next_schedule ) &&
- $next_schedule > time()
- ) {
+ if ( is_numeric( $next_schedule ) ) {
return;
}
@@ -7098,7 +7095,6 @@
*/
function _enqueue_connect_essentials() {
wp_enqueue_script( 'jquery' );
- wp_enqueue_script( 'json2' );
fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.js' );
fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
@@ -17436,7 +17432,7 @@
FS_User_Lock::instance()->unlock();
}
- if ( 1 < count( $installs ) ) {
+ if ( 1 < count( $installs ) || fs_is_network_admin() ) {
// Only network level opt-in can have more than one install.
$is_network_level_opt_in = true;
}
--- a/display-a-meta-field-as-block/vendor/freemius/includes/class-fs-plugin-updater.php
+++ b/display-a-meta-field-as-block/vendor/freemius/includes/class-fs-plugin-updater.php
@@ -540,9 +540,32 @@
return $transient_data;
}
+ // Alias.
+ $basename = $this->_fs->premium_plugin_basename();
+
global $wp_current_filter;
- if ( ! empty( $wp_current_filter ) && in_array( 'upgrader_process_complete', $wp_current_filter ) ) {
+ /**
+ * During bulk updates, avoid re-injecting update data for the plugin itself once it has already been updated.
+ *
+ * If the custom package is re-added to the transient after the plugin update, WordPress may detect the package again and incorrectly report "The plugin is at the latest version" for a pending update, since the custom package version matches the currently installed version.
+ *
+ * Behavior differs depending on how the bulk update is triggered. Please refer to the inline comments for each flow below for details.
+ */
+ if (
+ ! empty( $wp_current_filter ) && (
+ /**
+ * update-core.php and other upgrader pages:
+ * The `upgrader_process_complete` action fires only once after all updates have finished. In this case, it is the current action (`$wp_current_filter[0]`), while `self::$_upgrade_basename` may contain any plugin basename.
+ */
+ 'upgrader_process_complete' === $wp_current_filter[0] ||
+ /**
+ * AJAX bulk updates (e.g., from the Plugins page):
+ * The `upgrader_process_complete` action fires multiple times — once for each plugin after it finishes updating. In this flow, it is not the current action (`$wp_current_filter[0]`) because it is triggered from another action. Instead, we compare `self::$_upgrade_basename` with the basename of the plugin currently being updated, since the `upgrader_process_complete` action runs separately for each plugin.
+ */
+ ( in_array( 'upgrader_process_complete', $wp_current_filter ) && self::$_upgrade_basename === $basename )
+ )
+ ) {
return $transient_data;
}
@@ -566,9 +589,6 @@
}
}
- // Alias.
- $basename = $this->_fs->premium_plugin_basename();
-
if ( is_object( $this->_update_details ) ) {
if ( isset( $transient_data->no_update ) ) {
unset( $transient_data->no_update[ $basename ] );
--- a/display-a-meta-field-as-block/vendor/freemius/includes/fs-essential-functions.php
+++ b/display-a-meta-field-as-block/vendor/freemius/includes/fs-essential-functions.php
@@ -10,6 +10,9 @@
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.1.5
*/
+ if ( ! defined( 'ABSPATH' ) ) {
+ exit;
+ }
if ( ! function_exists( 'fs_normalize_path' ) ) {
if ( function_exists( 'wp_normalize_path' ) ) {
--- a/display-a-meta-field-as-block/vendor/freemius/includes/managers/class-fs-contact-form-manager.php
+++ b/display-a-meta-field-as-block/vendor/freemius/includes/managers/class-fs-contact-form-manager.php
@@ -1,84 +1,84 @@
-<?php
- /**
- * @package Freemius
- * @copyright Copyright (c) 2024, Freemius, Inc.
- * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
- * @since 2.9.0
- */
-
- if ( ! defined( 'ABSPATH' ) ) {
- exit;
- }
-
- class FS_Contact_Form_Manager {
-
- # region Singleton
-
- /**
- * @var FS_Contact_Form_Manager
- */
- private static $_instance;
-
- /**
- * @return FS_Contact_Form_Manager
- */
- static function instance() {
- if ( ! isset( self::$_instance ) ) {
- self::$_instance = new FS_Contact_Form_Manager();
- }
-
- return self::$_instance;
- }
-
- private function __construct() {
- }
-
- #endregion
-
- /**
- * Retrieves the query params needed to load the Freemius Contact Form in the context of the plugin.
- *
- * @param Freemius $fs
- *
- * @return array<string, string>
- */
- public function get_query_params( Freemius $fs ) {
- $context_params = array(
- 'plugin_id' => $fs->get_id(),
- 'plugin_public_key' => $fs->get_public_key(),
- 'plugin_version' => $fs->get_plugin_version(),
- );
-
- // Get site context secure params.
- if ( $fs->is_registered() ) {
- $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
- $fs->get_site(),
- time(),
- 'contact'
- ) );
- }
-
- return array_merge( $_GET, array_merge( $context_params, array(
- 'plugin_version' => $fs->get_plugin_version(),
- 'wp_login_url' => wp_login_url(),
- 'site_url' => Freemius::get_unfiltered_site_url(),
- // 'wp_admin_css' => get_bloginfo('wpurl') . "/wp-admin/load-styles.php?c=1&load=buttons,wp-admin,dashicons",
- ) ) );
- }
-
- /**
- * Retrieves the standalone link to the Freemius Contact Form.
- *
- * @param Freemius $fs
- *
- * @return string
- */
- public function get_standalone_link( Freemius $fs ) {
- $query_params = $this->get_query_params( $fs );
-
- $query_params['is_standalone'] = 'true';
- $query_params['parent_url'] = admin_url( add_query_arg( null, null ) );
-
- return WP_FS__ADDRESS . '/contact/?' . http_build_query( $query_params );
- }
+<?php
+ /**
+ * @package Freemius
+ * @copyright Copyright (c) 2024, Freemius, Inc.
+ * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
+ * @since 2.9.0
+ */
+
+ if ( ! defined( 'ABSPATH' ) ) {
+ exit;
+ }
+
+ class FS_Contact_Form_Manager {
+
+ # region Singleton
+
+ /**
+ * @var FS_Contact_Form_Manager
+ */
+ private static $_instance;
+
+ /**
+ * @return FS_Contact_Form_Manager
+ */
+ static function instance() {
+ if ( ! isset( self::$_instance ) ) {
+ self::$_instance = new FS_Contact_Form_Manager();
+ }
+
+ return self::$_instance;
+ }
+
+ private function __construct() {
+ }
+
+ #endregion
+
+ /**
+ * Retrieves the query params needed to load the Freemius Contact Form in the context of the plugin.
+ *
+ * @param Freemius $fs
+ *
+ * @return array<string, string>
+ */
+ public function get_query_params( Freemius $fs ) {
+ $context_params = array(
+ 'plugin_id' => $fs->get_id(),
+ 'plugin_public_key' => $fs->get_public_key(),
+ 'plugin_version' => $fs->get_plugin_version(),
+ );
+
+ // Get site context secure params.
+ if ( $fs->is_registered() ) {
+ $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
+ $fs->get_site(),
+ time(),
+ 'contact'
+ ) );
+ }
+
+ return array_merge( $_GET, array_merge( $context_params, array(
+ 'plugin_version' => $fs->get_plugin_version(),
+ 'wp_login_url' => wp_login_url(),
+ 'site_url' => Freemius::get_unfiltered_site_url(),
+ // 'wp_admin_css' => get_bloginfo('wpurl') . "/wp-admin/load-styles.php?c=1&load=buttons,wp-admin,dashicons",
+ ) ) );
+ }
+
+ /**
+ * Retrieves the standalone link to the Freemius Contact Form.
+ *
+ * @param Freemius $fs
+ *
+ * @return string
+ */
+ public function get_standalone_link( Freemius $fs ) {
+ $query_params = $this->get_query_params( $fs );
+
+ $query_params['is_standalone'] = 'true';
+ $query_params['parent_url'] = admin_url( add_query_arg( '', '' ) );
+
+ return WP_FS__ADDRESS . '/contact/?' . http_build_query( $query_params );
+ }
}
No newline at end of file
--- a/display-a-meta-field-as-block/vendor/freemius/includes/managers/class-fs-debug-manager.php
+++ b/display-a-meta-field-as-block/vendor/freemius/includes/managers/class-fs-debug-manager.php
@@ -1,508 +1,511 @@
-<?php
- /**
- * @author Daniele Alessandra (@danielealessandra)
- * @copyright Copyright (c) 2024, Freemius, Inc.
- * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
- * @package Freemius
- * @since 2.6.2
- */
-
- class FS_DebugManager {
-
- /**
- * @author Vova Feldman (@svovaf)
- * Moved from Freemius
- *
- * @since 1.0.8
- */
- static function _add_debug_section() {
- if ( ! is_super_admin() ) {
- // Add debug page only for super-admins.
- return;
- }
-
- Freemius::get_static_logger()->entrance();
-
- $title = sprintf( '%s [v.%s]', fs_text_inline( 'Freemius Debug' ), WP_FS__SDK_VERSION );
-
- if ( WP_FS__DEV_MODE ) {
- // Add top-level debug menu item.
- $hook = FS_Admin_Menu_Manager::add_page(
- $title,
- $title,
- 'manage_options',
- 'freemius',
- array( self::class, '_debug_page_render' )
- );
- } else {
- // Add hidden debug page.
- $hook = FS_Admin_Menu_Manager::add_subpage(
- '',
- $title,
- $title,
- 'manage_options',
- 'freemius',
- array( self::class, '_debug_page_render' )
- );
- }
-
- if ( ! empty( $hook ) ) {
- add_action( "load-$hook", array( self::class, '_debug_page_actions' ) );
- }
- }
-
- /**
- * @author Vova Feldman (@svovaf)
- * Moved from Freemius
- *
- * @since 1.0.8
- */
- static function _debug_page_actions() {
- Freemius::_clean_admin_content_section();
-
- if ( fs_request_is_action( 'restart_freemius' ) ) {
- check_admin_referer( 'restart_freemius' );
-
- if ( ! is_multisite() ) {
- // Clear accounts data.
- Freemius::get_accounts()->clear( null, true );
- } else {
- $sites = Freemius::get_sites();
- foreach ( $sites as $site ) {
- $blog_id = Freemius::get_site_blog_id( $site );
- Freemius::get_accounts()->clear( $blog_id, true );
- }
-
- // Clear network level storage.
- Freemius::get_accounts()->clear( true, true );
- }
-
- // Clear SDK reference cache.
- delete_option( 'fs_active_plugins' );
- } else if ( fs_request_is_action( 'clear_updates_data' ) ) {
- check_admin_referer( 'clear_updates_data' );
-
- if ( ! is_multisite() ) {
- set_site_transient( 'update_plugins', null );
- set_site_transient( 'update_themes', null );
- } else {
- $current_blog_id = get_current_blog_id();
-
- $sites = Freemius::get_sites();
- foreach ( $sites as $site ) {
- switch_to_blog( Freemius::get_site_blog_id( $site ) );
-
- set_site_transient( 'update_plugins', null );
- set_site_transient( 'update_themes', null );
- }
-
- switch_to_blog( $current_blog_id );
- }
- } else if ( fs_request_is_action( 'reset_deactivation_snoozing' ) ) {
- check_admin_referer( 'reset_deactivation_snoozing' );
-
- Freemius::reset_deactivation_snoozing();
- } else if ( fs_request_is_action( 'simulate_trial' ) ) {
- check_admin_referer( 'simulate_trial' );
-
- $fs = freemius( fs_request_get( 'module_id' ) );
-
- // Update SDK install to at least 24 hours before.
- $fs->get_storage()->install_timestamp = ( time() - WP_FS__TIME_24_HOURS_IN_SEC );
- // Unset the trial shown timestamp.
- unset( $fs->get_storage()->trial_promotion_shown );
- } else if ( fs_request_is_action( 'simulate_network_upgrade' ) ) {
- check_admin_referer( 'simulate_network_upgrade' );
-
- $fs = freemius( fs_request_get( 'module_id' ) );
-
- Freemius::set_network_upgrade_mode( $fs->get_storage() );
- } else if ( fs_request_is_action( 'delete_install' ) ) {
- check_admin_referer( 'delete_install' );
-
- Freemius::_delete_site_by_slug(
- fs_request_get( 'slug' ),
- fs_request_get( 'module_type' ),
- true,
- fs_request_get( 'blog_id', null )
- );
- } else if ( fs_request_is_action( 'delete_user' ) ) {
- check_admin_referer( 'delete_user' );
-
- self::delete_user( fs_request_get( 'user_id' ) );
- } else if ( fs_request_is_action( 'download_logs' ) ) {
- check_admin_referer( 'download_logs' );
-
- $download_url = FS_Logger::download_db_logs(
- fs_request_get( 'filters', false, 'post' )
- );
-
- if ( false === $download_url ) {
- wp_die( 'Oops... there was an error while generating the logs download file. Please try again and if it doesn't work contact support@freemius.com.' );
- }
-
- fs_redirect( $download_url );
- } else if ( fs_request_is_action( 'migrate_options_to_network' ) ) {
- check_admin_referer( 'migrate_options_to_network' );
-
- Freemius::migrate_options_to_network();
- }
- }
-
- /**
- * @author Vova Feldman (@svovaf)
- * Moved from Freemius
- *
- * @since 1.0.8
- */
- static function _debug_page_render() {
- Freemius::get_static_logger()->entrance();
-
- $all_modules_sites = self::get_all_modules_sites();
-
- $licenses_by_module_type = self::get_all_licenses_by_module_type();
-
- $vars = array(
- 'plugin_sites' => $all_modules_sites[ WP_FS__MODULE_TYPE_PLUGIN ],
- 'theme_sites' => $all_modules_sites[ WP_FS__MODULE_TYPE_THEME ],
- 'users' => Freemius::get_all_users(),
- 'addons' => Freemius::get_all_addons(),
- 'account_addons' => Freemius::get_all_account_addons(),
- 'plugin_licenses' => $licenses_by_module_type[ WP_FS__MODULE_TYPE_PLUGIN ],
- 'theme_licenses' => $licenses_by_module_type[ WP_FS__MODULE_TYPE_THEME ],
- );
-
- fs_enqueue_local_style( 'fs_debug', '/admin/debug.css' );
- fs_require_once_template( 'debug.php', $vars );
- }
-
- /**
- * @author Vova Feldman (@svovaf)
- * Moved from Freemius
- *
- * @since 1.2.1.6
- */
- static function _get_debug_log() {
- check_admin_referer( 'fs_get_debug_log' );
-
- if ( ! is_super_admin() ) {
- return;
- }
-
- if (!FS_Logger::is_storage_logging_on()) {
- return;
- }
-
- $limit = min( ! empty( $_POST['limit'] ) ? absint( $_POST['limit'] ) : 200, 200 );
- $offset = min( ! empty( $_POST['offset'] ) ? absint( $_POST['offset'] ) : 200, 200 );
-
- $logs = FS_Logger::load_db_logs(
- fs_request_get( 'filters', false, 'post' ),
- $limit,
- $offset
- );
-
- Freemius::shoot_ajax_success( $logs );
- }
-
- /**
- * @author Vova Feldman (@svovaf)
- * Moved from Freemius
- *
- * @since 1.2.1.7
- */
- static function _get_db_option() {
- check_admin_referer( 'fs_get_db_option' );
-
- $option_name = fs_request_get( 'option_name' );
-
- if ( ! is_super_admin() ||
- ! fs_starts_with( $option_name, 'fs_' )
- ) {
- Freemius::shoot_ajax_failure();
- }
-
- $value = get_option( $option_name );
-
- $result = array(
- 'name' => $option_name,
- );
-
- if ( false !== $value ) {
- if ( ! is_string( $value ) ) {
- $value = json_encode( $value );
- }
-
- $result['value'] = $value;
- }
-
- Freemius::shoot_ajax_success( $result );
- }
-
- /**
- * @author Vova Feldman (@svovaf)
- * Moved from Freemius
- *
- * @since 1.2.1.7
- */
- static function _set_db_option() {
- check_admin_referer( 'fs_set_db_option' );
-
- $option_name = fs_request_get( 'option_name' );
-
- if ( ! is_super_admin() ||
- ! fs_starts_with( $option_name, 'fs_' )
- ) {
- Freemius::shoot_ajax_failure();
- }
-
- $option_value = fs_request_get_raw( 'option_value' );
-
- if ( ! empty( $option_value ) ) {
- update_option( $option_name, $option_value );
- }
-
- Freemius::shoot_ajax_success();
- }
-
- /**
- * @author Vova Feldman (@svovaf)
- * Moved from Freemius
- *
- * @since 1.1.7.3
- */
- static function _toggle_debug_mode() {
- check_admin_referer( 'fs_toggle_debug_mode' );
-
- if ( ! is_super_admin() ) {
- return;
- }
-
- $is_on = fs_request_get( 'is_on', false, 'post' );
-
- if ( fs_request_is_post() && in_array( $is_on, array( 0, 1 ) ) ) {
- if ( $is_on ) {
- self::_turn_on_debug_mode();
- } else {
- self::_turn_off_debug_mode();
- }
-
- // Logic to turn debugging off automatically
- if ( 1 == $is_on ) {
- // Plan a single event triggering after 24 hours to turn debugging off.
- wp_schedule_single_event( time() + 24 * HOUR_IN_SECONDS, 'fs_debug_turn_off_logging_hook' );
- } else {
- // Cancels any planned event when debugging is turned off manually.
- $timestamp = wp_next_scheduled( 'fs_debug_turn_off_logging_hook' );
- if ( $timestamp ) {
- wp_unschedule_event( $timestamp, 'fs_debug_turn_off_logging_hook' );
- }
- }
- }
-
- exit;
- }
-
- /**
- * @author Daniele Alessandra (@danielealessandra)
- * @since 2.6.2
- *
- */
- static function _turn_off_debug_mode() {
- self::update_debug_mode_option( 0 );
- FS_Logger::_set_storage_logging( false );
- }
-
- /**
- * @author Daniele Alessandra (@danielealessandra)
- * @since 2.6.2
- *
- */
- static function _turn_on_debug_mode() {
- self::update_debug_mode_option( 1 );
- FS_Logger::_set_storage_logging();
- }
-
- /**
- * @author Leo Fajardo (@leorw)
- * Moved from Freemius
- *
- * @param string $url
- * @param array $request
- *
- * @since 2.1.0
- *
- */
- public static function enrich_request_for_debug( &$url, &$request ) {
- if ( WP_FS__DEBUG_SDK || isset( $_COOKIE['XDEBUG_SESSION'] ) ) {
- $url = add_query_arg( 'XDEBUG_SESSION_START', rand( 0, 9999999 ), $url );
- $url = add_query_arg( 'XDEBUG_SESSION', 'PHPSTORM', $url );
-
- $request['cookies'] = array(
- new WP_Http_Cookie( array(
- 'name' => 'XDEBUG_SESSION',
- 'value' => 'PHPSTORM',
- ) ),
- );
- }
- }
-
- /**
- * @author Leo Fajardo (@leorw)
- * Moved from Freemius
- *
- * @return array
- *
- * @since 2.0.0
- *
- */
- private static function get_all_licenses_by_module_type() {
- $licenses = Freemius::get_account_option( 'all_licenses' );
-
- $licenses_by_module_type = array(
- WP_FS__MODULE_TYPE_PLUGIN => array(),
- WP_FS__MODULE_TYPE_THEME => array(),
- );
-
- if ( ! is_array( $licenses ) ) {
- return $licenses_by_module_type;
- }
-
- foreach ( $licenses as $module_id => $module_licenses ) {
- $fs = Freemius::get_instance_by_id( $module_id );
- if ( false === $fs ) {
- continue;
- }
-
- $licenses_by_module_type[ $fs->get_module_type() ] = array_merge( $licenses_by_module_type[ $fs->get_module_type() ],
- $module_licenses );
- }
-
- return $licenses_by_module_type;
- }
-
- /**
- * Moved from the Freemius class.
- *
- * @author Leo Fajardo (@leorw)
- *
- * @return array
- *
- * @since 2.5.0
- */
- static function get_all_modules_sites() {
- Freemius::get_static_logger()->entrance();
-
- $sites_by_type = array(
- WP_FS__MODULE_TYPE_PLUGIN => array(),
- WP_FS__MODULE_TYPE_THEME => array(),
- );
-
- $module_types = array_keys( $sites_by_type );
-
- if ( ! is_multisite() ) {
- foreach ( $module_types as $type ) {
- $sites_by_type[ $type ] = Freemius::get_all_sites( $type );
-
- foreach ( $sites_by_type[ $type ] as $slug => $install ) {
- $sites_by_type[ $type ][ $slug ] = array( $install );
- }
- }
- } else {
- $sites = Freemius::get_sites();
-
- foreach ( $sites as $site ) {
- $blog_id = Freemius::get_site_blog_id( $site );
-
- foreach ( $module_types as $type ) {
- $installs = Freemius::get_all_sites( $type, $blog_id );
-
- foreach ( $installs as $slug => $install ) {
- if ( ! isset( $sites_by_type[ $type ][ $slug ] ) ) {
- $sites_by_type[ $type ][ $slug ] = array();
- }
-
- $install->blog_id = $blog_id;
-
- $sites_by_type[ $type ][ $slug ][] = $install;
- }
- }
- }
- }
-
- return $sites_by_type;
- }
-
- /**
- * Delete user.
- *
- * @author Vova Feldman (@svovaf)
- *
- * @param number $user_id
- * @param bool $store
- *
- * @return false|int The user ID if deleted. Otherwise, FALSE (when install not exist).
- * @since 2.0.0
- *
- */
- public static function delete_user( $user_id, $store = true ) {
- $users = Freemius::get_all_users();
-
- if ( ! is_array( $users ) || ! isset( $users[ $user_id ] ) ) {
- return false;
- }
-
- unset( $users[ $user_id ] );
-
- self::$_accounts->set_option( 'users', $users, $store );
-
- return $user_id;
- }
-
- /**
- * @author Daniele Alessandra (@danielealessandra)
- *
- * @return void
- * @since 2.6.2
- *
- */
- public static function load_required_static() {
- if ( ! WP_FS__DEMO_MODE ) {
- add_action( ( fs_is_network_admin() ? 'network_' : '' ) . 'admin_menu', array(
- self::class,
- '_add_debug_section',
- ) );
- }
-
- add_action( "wp_ajax_fs_toggle_debug_mode", array( self::class, '_toggle_debug_mode' ) );
-
- Freemius::add_ajax_action_static( 'get_debug_log', array( self::class, '_get_debug_log' ) );
- Freemius::add_ajax_action_static( 'get_db_option', array( self::class, '_get_db_option' ) );
- Freemius::add_ajax_action_static( 'set_db_option', array( self::class, '_set_db_option' ) );
- }
-
- /**
- * @author Daniele Alessandra (@danielealessandra)
- *
- * @return void
- *
- * @since 2.6.2
- */
- public static function register_hooks() {
- add_action( 'fs_debug_turn_off_logging_hook', array( self::class, '_turn_off_debug_mode' ) );
- }
-
- /**
- * @author Daniele Alessandra (@danielealessandra)
- *
- * @param int $is_on
- *
- * @return void
- *
- * @since 2.6.2
- */
- private static function update_debug_mode_option( $is_on ) {
- update_option( 'fs_debug_mode', $is_on );
- }
-
- }
+<?php
+ /**
+ * @author Daniele Alessandra (@danielealessandra)
+ * @copyright Copyright (c) 2024, Freemius, Inc.
+ * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
+ * @package Freemius
+ * @since 2.6.2
+ */
+ if ( ! defined( 'ABSPATH' ) ) {
+ exit;
+ }
+
+ class FS_DebugManager {
+
+ /**
+ * @author Vova Feldman (@svovaf)
+ * Moved from Freemius
+ *
+ * @since 1.0.8
+ */
+ static function _add_debug_section() {
+ if ( ! is_super_admin() ) {
+ // Add debug page only for super-admins.
+ return;
+ }
+
+ Freemius::get_static_logger()->entrance();
+
+ $title = sprintf( '%s [v.%s]', fs_text_inline( 'Freemius Debug' ), WP_FS__SDK_VERSION );
+
+ if ( WP_FS__DEV_MODE ) {
+ // Add top-level debug menu item.
+ $hook = FS_Admin_Menu_Manager::add_page(
+ $title,
+ $title,
+ 'manage_options',
+ 'freemius',
+ array( self::class, '_debug_page_render' )
+ );
+ } else {
+ // Add hidden debug page.
+ $hook = FS_Admin_Menu_Manager::add_subpage(
+ '',
+ $title,
+ $title,
+ 'manage_options',
+ 'freemius',
+ array( self::class, '_debug_page_render' )
+ );
+ }
+
+ if ( ! empty( $hook ) ) {
+ add_action( "load-$hook", array( self::class, '_debug_page_actions' ) );
+ }
+ }
+
+ /**
+ * @author Vova Feldman (@svovaf)
+ * Moved from Freemius
+ *
+ * @since 1.0.8
+ */
+ static function _debug_page_actions() {
+ Freemius::_clean_admin_content_section();
+
+ if ( fs_request_is_action( 'restart_freemius' ) ) {
+ check_admin_referer( 'restart_freemius' );
+
+ if ( ! is_multisite() ) {
+ // Clear accounts data.
+ Freemius::get_accounts()->clear( null, true );
+ } else {
+ $sites = Freemius::get_sites();
+ foreach ( $sites as $site ) {
+ $blog_id = Freemius::get_site_blog_id( $site );
+ Freemius::get_accounts()->clear( $blog_id, true );
+ }
+
+ // Clear network level storage.
+ Freemius::get_accounts()->clear( true, true );
+ }
+
+ // Clear SDK reference cache.
+ delete_option( 'fs_active_plugins' );
+ } else if ( fs_request_is_action( 'clear_updates_data' ) ) {
+ check_admin_referer( 'clear_updates_data' );
+
+ if ( ! is_multisite() ) {
+ set_site_transient( 'update_plugins', null );
+ set_site_transient( 'update_themes', null );
+ } else {
+ $current_blog_id = get_current_blog_id();
+
+ $sites = Freemius::get_sites();
+ foreach ( $sites as $site ) {
+ switch_to_blog( Freemius::get_site_blog_id( $site ) );
+
+ set_site_transient( 'update_plugins', null );
+ set_site_transient( 'update_themes', null );
+ }
+
+ switch_to_blog( $current_blog_id );
+ }
+ } else if ( fs_request_is_action( 'reset_deactivation_snoozing' ) ) {
+ check_admin_referer( 'reset_deactivation_snoozing' );
+
+ Freemius::reset_deactivation_snoozing();
+ } else if ( fs_request_is_action( 'simulate_trial' ) ) {
+ check_admin_referer( 'simulate_trial' );
+
+ $fs = freemius( fs_request_get( 'module_id' ) );
+
+ // Update SDK install to at least 24 hours before.
+ $fs->get_storage()->install_timestamp = ( time() - WP_FS__TIME_24_HOURS_IN_SEC );
+ // Unset the trial shown timestamp.
+ unset( $fs->get_storage()->trial_promotion_shown );
+ } else if ( fs_request_is_action( 'simulate_network_upgrade' ) ) {
+ check_admin_referer( 'simulate_network_upgrade' );
+
+ $fs = freemius( fs_request_get( 'module_id' ) );
+
+ Freemius::set_network_upgrade_mode( $fs->get_storage() );
+ } else if ( fs_request_is_action( 'delete_install' ) ) {
+ check_admin_referer( 'delete_install' );
+
+ Freemius::_delete_site_by_slug(
+ fs_request_get( 'slug' ),
+ fs_request_get( 'module_type' ),
+ true,
+ fs_request_get( 'blog_id', null )
+ );
+ } else if ( fs_request_is_action( 'delete_user' ) ) {
+ check_admin_referer( 'delete_user' );
+
+ self::delete_user( fs_request_get( 'user_id' ) );
+ } else if ( fs_request_is_action( 'download_logs' ) ) {
+ check_admin_referer( 'download_logs' );
+
+ $download_url = FS_Logger::download_db_logs(
+ fs_request_get( 'filters', false, 'post' )
+ );
+
+ if ( false === $download_url ) {
+ wp_die( 'Oops... there was an error while generating the logs download file. Please try again and if it doesn't work contact support@freemius.com.' );
+ }
+
+ fs_redirect( $download_url );
+ } else if ( fs_request_is_action( 'migrate_options_to_network' ) ) {
+ check_admin_referer( 'migrate_options_to_network' );
+
+ Freemius::migrate_options_to_network();
+ }
+ }
+
+ /**
+ * @author Vova Feldman (@svovaf)
+ * Moved from Freemius
+ *
+ * @since 1.0.8
+ */
+ static function _debug_page_render() {
+ Freemius::get_static_logger()->entrance();
+
+ $all_modules_sites = self::get_all_modules_sites();
+
+ $licenses_by_module_type = self::get_all_licenses_by_module_type();
+
+ $vars = array(
+ 'plugin_sites' => $all_modules_sites[ WP_FS__MODULE_TYPE_PLUGIN ],
+ 'theme_sites' => $all_modules_sites[ WP_FS__MODULE_TYPE_THEME ],
+ 'users' => Freemius::get_all_users(),
+ 'addons' => Freemius::get_all_addons(),
+ 'account_addons' => Freemius::get_all_account_addons(),
+ 'plugin_licenses' => $licenses_by_module_type[ WP_FS__MODULE_TYPE_PLUGIN ],
+ 'theme_licenses' => $licenses_by_module_type[ WP_FS__MODULE_TYPE_THEME ],
+ );
+
+ fs_enqueue_local_style( 'fs_debug', '/admin/debug.css' );
+ fs_require_once_template( 'debug.php', $vars );
+ }
+
+ /**
+ * @author Vova Feldman (@svovaf)
+ * Moved from Freemius
+ *
+ * @since 1.2.1.6
+ */
+ static function _get_debug_log() {
+ check_admin_referer( 'fs_get_debug_log' );
+
+ if ( ! is_super_admin() ) {
+ return;
+ }
+
+ if (!FS_Logger::is_storage_logging_on()) {
+ return;
+ }
+
+ $limit = min( ! empty( $_POST['limit'] ) ? absint( $_POST['limit'] ) : 200, 200 );
+ $offset = min( ! empty( $_POST['offset'] ) ? absint( $_POST['offset'] ) : 200, 200 );
+
+ $logs = FS_Logger::load_db_logs(
+ fs_request_get( 'filters', false, 'post' ),
+ $limit,
+ $offset
+ );
+
+ Freemius::shoot_ajax_success( $logs );
+ }
+
+ /**
+ * @author Vova Feldman (@svovaf)
+ * Moved from Freemius
+ *
+ * @since 1.2.1.7
+ */
+ static function _get_db_option() {
+ check_admin_referer( 'fs_get_db_option' );
+
+ $option_name = fs_request_get( 'option_name' );
+
+ if ( ! is_super_admin() ||
+ ! fs_starts_with( $option_name, 'fs_' )
+ ) {
+ Freemius::shoot_ajax_failure();
+ }
+
+ $value = get_option( $option_name );
+
+ $result = array(
+ 'name' => $option_name,
+ );
+
+ if ( false !== $value ) {
+ if ( ! is_string( $value ) ) {
+ $value = json_encode( $value );
+ }
+
+ $result['value'] = $value;
+ }
+
+ Freemius::shoot_ajax_success( $result );
+ }
+
+ /**
+ * @author Vova Feldman (@svovaf)
+ * Moved from Freemius
+ *
+ * @since 1.2.1.7
+ */
+ static function _set_db_option() {
+ check_admin_referer( 'fs_set_db_option' );
+
+ $option_name = fs_request_get( 'option_name' );
+
+ if ( ! is_super_admin() ||
+ ! fs_starts_with( $option_name, 'fs_' )
+ ) {
+ Freemius::shoot_ajax_failure();
+ }
+
+ $option_value = fs_request_get_raw( 'option_value' );
+
+ if ( ! empty( $option_value ) ) {
+ update_option( $option_name, $option_value );
+ }
+
+ Freemius::shoot_ajax_success();
+ }
+
+ /**
+ * @author Vova Feldman (@svovaf)
+ * Moved from Freemius
+ *
+ * @since 1.1.7.3
+ */
+ static function _toggle_debug_mode() {
+ check_admin_referer( 'fs_toggle_debug_mode' );
+
+ if ( ! is_super_admin() ) {
+ return;
+ }
+
+ $is_on = fs_request_get( 'is_on', false, 'post' );
+
+ if ( fs_request_is_post() && in_array( $is_on, array( 0, 1 ) ) ) {
+ if ( $is_on ) {
+ self::_turn_on_debug_mode();
+ } else {
+ self::_turn_off_debug_mode();
+ }
+
+ // Logic to turn debugging off automatically
+ if ( 1 == $is_on ) {
+ // Plan a single event triggering after 24 hours to turn debugging off.
+ wp_schedule_single_event( time() + 24 * HOUR_IN_SECONDS, 'fs_debug_turn_off_logging_hook' );
+ } else {
+ // Cancels any planned event when debugging is turned off manually.
+ $timestamp = wp_next_scheduled( 'fs_debug_turn_off_logging_hook' );
+ if ( $timestamp ) {
+ wp_unschedule_event( $timestamp, 'fs_debug_turn_off_logging_hook' );
+ }
+ }
+ }
+
+ exit;
+ }
+
+ /**
+ * @author Daniele Alessandra (@danielealessandra)
+ * @since 2.6.2
+ *
+ */
+ static function _turn_off_debug_mode() {
+ self::update_debug_mode_option( 0 );
+ FS_Logger::_set_storage_logging( false );
+ }
+
+ /**
+ * @author Daniele Alessandra (@danielealessandra)
+ * @since 2.6.2
+ *
+ */
+ static function _turn_on_debug_mode() {
+ self::update_debug_mode_option( 1 );
+ FS_Logger::_set_storage_logging();
+ }
+
+ /**
+ * @author Leo Fajardo (@leorw)
+ * Moved from Freemius
+ *
+ * @param string $url
+ * @param array $request
+ *
+ * @since 2.1.0
+ *
+ */
+ public static function enrich_request_for_debug( &$url, &$request ) {
+ if ( WP_FS__DEBUG_SDK || isset( $_COOKIE['XDEBUG_SESSION'] ) ) {
+ $url = add_query_arg( 'XDEBUG_SESSION_START', rand( 0, 9999999 ), $url );
+ $url = add_query_arg( 'XDEBUG_SESSION', 'PHPSTORM', $url );
+
+ $request['cookies'] = array(
+ new WP_Http_Cookie( array(
+ 'name' => 'XDEBUG_SESSION',
+ 'value' => 'PHPSTORM',
+ ) ),
+ );
+ }
+ }
+
+ /**
+ * @author Leo Fajardo (@leorw)
+ * Moved from Freemius
+ *
+ * @return array
+ *
+ * @since 2.0.0
+ *
+ */
+ private static function get_all_licenses_by_module_type() {
+ $licenses = Freemius::get_account_option( 'all_licenses' );
+
+ $licenses_by_module_type = array(
+ WP_FS__MODULE_TYPE_PLUGIN => array(),
+ WP_FS__MODULE_TYPE_THEME => array(),
+ );
+
+ if ( ! is_array( $licenses ) ) {
+ return $licenses_by_module_type;
+ }
+
+ foreach ( $licenses as $module_id => $module_licenses ) {
+ $fs = Freemius::get_instance_by_id( $module_id );
+ if ( false === $fs ) {
+ continue;
+ }
+
+ $licenses_by_module_type[ $fs->get_module_type() ] = array_merge( $licenses_by_module_type[ $fs->get_module_type() ],
+ $module_licenses );
+ }
+
+ return $licenses_by_module_type;
+ }
+
+ /**
+ * Moved from the Freemius class.
+ *
+ * @author Leo Fajardo (@leorw)
+ *
+ * @return array
+ *
+ * @since 2.5.0
+ */
+ static function get_all_modules_sites() {
+ Freemius::get_static_logger()->entrance();
+
+ $sites_by_type = array(
+ WP_FS__MODULE_TYPE_PLUGIN => array(),
+ WP_FS__MODULE_TYPE_THEME => array(),
+ );
+
+ $module_types = array_keys( $sites_by_type );
+
+ if ( ! is_multisite() ) {
+ foreach ( $module_types as $type ) {
+ $sites_by_type[ $type ] = Freemius::get_all_sites( $type );
+
+ foreach ( $sites_by_type[ $type ] as $slug => $install ) {
+ $sites_by_type[ $type ][ $slug ] = array( $install );
+ }
+ }
+ } else {
+ $sites = Freemius::get_sites();
+
+ foreach ( $sites as $site ) {
+ $blog_id = Freemius::get_site_blog_id( $site );
+
+ foreach ( $module_types as $type ) {
+ $installs = Freemius::get_all_sites( $type, $blog_id );
+
+ foreach ( $installs as $slug => $install ) {
+ if ( ! isset( $sites_by_type[ $type ][ $slug ] ) ) {
+ $sites_by_type[ $type ][ $slug ] = array();
+ }
+
+ $install->blog_id = $blog_id;
+
+ $sites_by_type[ $type ][ $slug ][] = $install;
+ }
+ }
+ }
+ }
+
+ return $sites_by_type;
+ }
+
+ /**
+ * Delete user.
+ *
+ * @author Vova Feldman (@svovaf)
+ *
+ * @param number $user_id
+ * @param bool $store
+ *
+ * @return false|int The user ID if deleted. Otherwise, FALSE (when install not exist).
+ * @since 2.0.0
+ *
+ */
+ public static function delete_user( $user_id, $store = true ) {
+ $users = Freemius::get_all_users();
+
+ if ( ! is_array( $users ) || ! isset( $users[ $user_id ] ) ) {
+ return false;
+ }
+
+ unset( $users[ $user_id ] );
+
+ self::$_accounts->set_option( 'users', $users, $store );
+
+ return $user_id;
+ }
+
+ /**
+ * @author Daniele Alessandra (@danielealessandra)
+ *
+ * @return void
+ * @since 2.6.2
+ *
+ */
+ public static function load_required_static() {
+ if ( ! WP_FS__DEMO_MODE ) {
+ add_action( ( fs_is_network_admin() ? 'network_' : '' ) . 'admin_menu', array(
+ self::class,
+ '_add_debug_section',
+ ) );
+ }
+
+ add_action( "wp_ajax_fs_toggle_debug_mode", array( self::class, '_toggle_debug_mode' ) );
+
+ Freemius::add_ajax_action_static( 'get_debug_log', array( self::class, '_get_debug_log' ) );
+ Freemius::add_ajax_action_static( 'get_db_option', array( self::class, '_get_db_option' ) );
+ Freemius::add_ajax_action_static( 'set_db_option', array( self::class, '_set_db_option' ) );
+ }
+
+ /**
+ * @author Daniele Alessandra (@danielealessandra)
+ *
+ * @return void
+ *
+ * @since 2.6.2
+ */
+ public static function register_hooks() {
+ add_action( 'fs_debug_turn_off_logging_hook', array( self::class, '_turn_off_debug_mode' ) );
+ }
+
+ /**
+ * @author Daniele Alessandra (@danielealessandra)
+ *
+ * @param int $is_on
+ *
+ * @return void
+ *
+ * @since 2.6.2
+ */
+ private static function update_debug_mode_option( $is_on ) {
+ update_option( 'fs_debug_mode', $is_on );
+ }
+
+ }
--- a/display-a-meta-field-as-block/vendor/freemius/start.php
+++ b/display-a-meta-field-as-block/vendor/freemius/start.php
@@ -15,7 +15,7 @@
*
* @var string
*/
- $this_sdk_version = '2.13.0';
+ $this_sdk_version = '2.13.1';
#region SDK Selection Logic --------------------------------------------------------------------
--- a/display-a-meta-field-as-block/vendor/freemius/templates/account.php
+++ b/display-a-meta-field-as-block/vendor/freemius/templates/account.php
@@ -252,6 +252,8 @@
$available_license_paid_plan = is_object( $available_license ) ?
$fs->_get_plan_by_id( $available_license->plan_id ) :
null;
+
+ $is_dev_mode = ( defined( 'WP_FS__DEV_MODE' ) && WP_FS__DEV_MODE );
?>
<div class="wrap fs-section">
<?php if ( ! $has_tabs && ! $fs->apply_filters( 'hide_account_tabs', false ) ) : ?>
@@ -787,7 +789,7 @@
<th><?php echo esc_html( $plan_text ) ?></th>
<th><?php fs_esc_html_echo_x_inline( 'License', 'as software license', 'license', $slug ) ?></th>
<th></th>
- <?php if ( defined( 'WP_FS__DEV_MODE' ) && WP_FS__DEV_MODE ) : ?>
+ <?php if ( $is_dev_mode ) : ?>
<th></th>
<?php endif ?>
</tr>
@@ -853,10 +855,20 @@
'is_whitelabeled' => ( $is_whitelabeled && ! $is_data_debug_mode )
);
- fs_require_template(
- 'account/partials/addon.php',
- $addon_view_params
- );
+ if ( ! empty($addon_view_params['addon_info'] ) ) {
+ fs_require_template(
+ 'account/partials/addon.php',
+ $addon_view_params
+ );
+ } else {
+ // If we are here it means there is an activation of an unreleased add-on and yet the SDK is not in development mode.
+ echo '<tr>';
+ echo '<td style="text-align: right;">' . esc_html( $addon_id ) . '</td>';
+ echo '<td colspan="' . ( $is_dev_mode ? 6 : 5 ) . '" style="text-align: left;">';
+ echo 'The add-on you have activated is no longer <a href="https://freemius.com/help/documentation/wordpress/selling-add-ons-extensions/#preparing-the-add-on-for-sale" rel="noreferrer noopener" target="_blank">listed</a> by the product owner, or the SDK is not running in <a href="https://freemius.com/help/documentation/wordpress-sdk/testing/" rel="noreferrer noopener" target="_blank">test mode</a>. Please <a href="' . esc_url( $fs->contact_url() ) . '">contact support</a> if you need further assistance.';
+ echo '</td>';
+ echo '</tr>';
+ }
$odd = ! $odd;
} ?>
--- a/display-a-meta-field-as-block/vendor/freemius/templates/checkout.php
+++ b/display-a-meta-field-as-block/vendor/freemius/templates/checkout.php
@@ -1,27 +1,29 @@
-<?php
- /**
- * @package Freemius
- * @copyright Copyright (c) 2024, Freemius, Inc.
- * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
- * @since 2.9.0
- */
-
- /**
- * @var array $VARS
- * @var Freemius $fs
- */
- $fs = freemius( $VARS['id'] );
-
- if ( fs_request_get_bool( 'redirect' ) ) {
- fs_require_template( 'checkout/redirect.php', $VARS );
- } else if ( fs_request_get_bool( 'process_redirect' ) ) {
- fs_require_template( 'checkout/process-redirect.php', $VARS );
- } else {
- $fs = freemius( $VARS['id'] );
-
- if ( $fs->is_premium() ) {
- fs_require_template( 'checkout/frame.php', $VARS );
- } else {
- fs_require_template( 'checkout/redirect.php', $VARS );
- }
- }
+<?php
+ /**
+ * @package Freemius
+ * @copyright Copyright (c) 2024, Freemius, Inc.
+ * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
+ * @since 2.9.0
+ */
+ if ( ! defined( 'ABSPATH' ) ) {
+ exit;
+ }
+ /**
+ * @var array $VARS
+ * @var Freemius $fs
+ */
+ $fs = freemius( $VARS['id'] );
+
+ if ( fs_request_get_bool( 'redirect' ) ) {
+ fs_require_template( 'checkout/redirect.php', $VARS );
+ } else if ( fs_request_get_bool( 'process_redirect' ) ) {
+ fs_require_template( 'checkout/process-redirect.php', $VARS );
+ } else {
+ $fs = freemius( $VARS['id'] );
+
+ if ( $fs->is_premium() ) {
+ fs_require_template( 'checkout/frame.php', $VARS );
+ } else {
+ fs_require_template( 'checkout/redirect.php', $VARS );
+ }
+ }
--- a/display-a-meta-field-as-block/vendor/freemius/templates/checkout/frame.php
+++ b/display-a-meta-field-as-block/vendor/freemius/templates/checkout/frame.php
@@ -1,182 +1,181 @@
-<?php
- /**
- * @package Freemius
- * @copyright Copyright (c) 2015, Freemius, Inc.
- * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
- * @since 1.0.3
- */
-
- /**
- * Update (October 9, 2024 by @swashata):
- * Following request from the wp.org plugin review team, we have stopped
- * embedding the checkout inside an i-frame for wp.org hosted free version
- * of plugins and themes. Now they will be redirected instead.
- *
- * Note for WordPress.org Theme/Plugin reviewer:
- * Freemius is an SDK for plugin and theme developers. Since the core
- * of the SDK is relevant both for plugins and themes, for obvious reasons,
- * we only develop and maintain one code base.
- *
- * This code (and page) will not run for wp.org themes and plugins. It will
- * run only for premium version of the plugin/theme that is using the SDK.
- *
- * In addition, when this page loads an i-frame. We intentionally named it 'frame'
- * so it will pass the "Theme Check" that is looking for the string "i" . "frame".
- *
- * If you have any questions or need clarifications, please don't hesitate
- * pinging me on slack, my username is @svovaf.
- *
- * @author Vova Feldman (@svovaf)
- * @since 1.2.2
- */
-
- if ( ! defined( 'ABSPATH' ) ) {
- exit;
- }
-
- wp_enqueue_script( 'jquery' );
- wp_enqueue_script( 'json2' );
- fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.js' );
- fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
- fs_enqueue_local_script( 'fs-form', 'jquery.form.js', array( 'jquery' ) );
-
- /**
- * @var array $VARS
- * @var Freemius $fs
- */
- $fs = freemius( $VARS['id'] );
- $slug = $fs->get_slug();
-
- $fs_checkout = FS_Checkout_Manager::instance();
-
- $plugin_id = fs_request_get( 'plugin_id' );
- if ( ! FS_Plugin::is_valid_id( $plugin_id ) ) {
- $plugin_id = $fs->get_id();
- }
-
- $plan_id = fs_request_get( 'plan_id' );
- $licenses = fs_request_get( 'licenses' );
-
- $query_params = $fs_checkout->get_query_params(
- $fs,
- $plugin_id,
- $plan_id,
- $licenses
- );
-
- $return_url = $fs->_get_sync_license_url( $plugin_id );
- $query_params['return_url'] = $return_url;
-
- $xdebug_session = fs_request_get( 'XDEBUG_SESSION' );
- if ( false !== $xdebug_session ) {
- $query_params['XDEBUG_SESSION'] = $xdebug_session;
- }
-
- $view_params = array(
- 'id' => $VARS['id'],
- 'page' => strtolower( $fs->get_text_inline( 'Checkout', 'checkout' ) ) . ' ' . $fs->get_text_inline( 'PCI compliant', 'pci-compliant' ),
- );
- fs_require_once_template('secure-https-header.php', $view_params);
-?>
- <div id="fs_checkout" class="wrap fs-section fs-full-size-wrapper">
- <div id="fs_frame"></div>
- <script type="text/javascript">
- (function ($) {
- $(function () {
-
- var
- // Keep track of the i-frame height.
- frame_height = 800,
- base_url = '<?php echo FS_CHECKOUT__ADDRESS ?>',
- // Pass the parent page URL into the i-frame in a meaningful way (this URL could be
- // passed via query string or hard coded into the child page, it depends on your needs).
- src = base_url + '/?<?php echo http_build_query( $query_params ) ?>#' + encodeURIComponent(document.location.href),
- // Append the i-frame into the DOM.
- frame = $('<i' + 'frame " src="' + src + '" width="100%" height="' + frame_height + 'px" scrolling="no" frameborder="0" style="background: transparent; width: 1px; min-width: 100%;"></i' + 'frame>')
- .appendTo('#fs_frame');
-
- FS.PostMessage.init(base_url, [frame[0]]);
- FS.PostMessage.receiveOnce('height', function (data) {
- var h = data.height;
- if (!isNaN(h) && h > 0 && h != frame_height) {
- frame_height = h;
- frame.height(frame_height + 'px');
-
- FS.PostMessage.postScroll(frame[0]);
- }
- });
-
- FS.PostMessage.receiveOnce('install', function (data) {
- var requestData = {
- user_id : data.user.id,
- user_secret_key : data.user.secret_key,
- user_public_key : data.user.public_key,
- install_id : data.install.id,
- install_secret_key: data.install.secret_key,
- install_public_key: data.install.public_key
- };
-
- if (true === data.auto_install)
- requestData.auto_install = true;
-
- // Post data to activation URL.
- $.form('<?php echo $fs_checkout->get_install_url( $fs, $plugin_id ); ?>', requestData).submit();
- });
-
- FS.PostMessage.receiveOnce('pending_activation', function (data) {
- var requestData = {
- user_email : data.user_email,
- support_email_address: data.support_email_address
- };
-
- if (true === data.auto_install)
- requestData.auto_install = true;
-
- $.form('<?php echo $fs_checkout->get_pending_activation_url( $fs, $plugin_id ); ?>', requestData).submit();
- });
-
- FS.PostMessage.receiveOnce('get_context', function () {
- console.debug('receiveOnce', 'get_context');
-
- // If the user didn't connect his account with Freemius,
- // once he accepts the Terms of Service and Privacy Policy,
- // and then click the purchase button, the context information
- // of the user will be shared with Freemius in order to complete the
- // purchase workflow and activate the license for the right user.
- <?php $install_data = array_merge( $fs->get_opt_in_params(),
- array(
- 'activation_url' => fs_nonce_url( $fs->_get_admin_page_url( '',
- array(
- 'fs_action' => $fs->get_unique_affix() . '_activate_new',
- 'plugin_id' => $plugin_id,
-
- ) ),
- $fs->get_unique_affix() . '_activate_new' )
- ) ) ?>
- FS.PostMessage.post('context', <?php echo json_encode( $install_data ) ?>, frame[0]);
- });
-
- FS.PostMessage.receiveOnce('purchaseCompleted', <?php echo $fs->apply_filters('checkout/purchaseCompleted', 'function (data) {
- console.log("checkout", "purchaseCompleted");
- }') ?>);
-
- FS.PostMessage.receiveOnce('get_dimensions', function (data) {
- console.d