plugin updates
This commit is contained in:
@@ -51,6 +51,8 @@ if ( ! class_exists( 'GFResults' ) ) {
|
||||
require_once( GFCommon::get_base_path() . '/tooltips.php' );
|
||||
add_filter( 'gform_tooltips', array( $this, 'add_tooltips' ) );
|
||||
|
||||
add_filter( 'admin_title', array( $this, 'set_unique_page_title' ), 100, 2 );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -886,6 +888,32 @@ if ( ! class_exists( 'GFResults' ) ) {
|
||||
) ) ? GFSurvey::get_field_score( $field, $entry ) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a unique page title to the results page based on the title
|
||||
* and the form the user is viewing.
|
||||
*
|
||||
* @since 2.8.16
|
||||
*
|
||||
* @filter admin_title
|
||||
*
|
||||
* @param string $admin_title The page title with extra context added.
|
||||
* @param string $title The original page title.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function set_unique_page_title( $admin_title, $title ) {
|
||||
$form_id = rgget( 'id' );
|
||||
if ( ! $form_id ) {
|
||||
$forms = RGFormsModel::get_forms( null, 'title' );
|
||||
$form_id = ( ! empty( $forms ) ) ? $forms[0]->id : '';
|
||||
}
|
||||
|
||||
$form = GFAPI::get_form( $form_id );
|
||||
$form_title = rgar( $form, 'title', esc_html__( 'Form Not Found', 'gravityforms' ) );
|
||||
$admin_title = sprintf( '%1$s ‹ %2$s ‹ %3$s', esc_html( $this->_title ), esc_html( $form_title ), esc_html( $admin_title ) );
|
||||
|
||||
return $admin_title;
|
||||
}
|
||||
|
||||
public static function get_default_field_results( $form_id, $field, $search_criteria, &$offset, $page_size, &$more_remaining = false ) {
|
||||
$field_results = '';
|
||||
|
||||
@@ -1104,10 +1104,14 @@ class GFConfirmationTable extends WP_List_Table {
|
||||
unset( $actions['delete'] );
|
||||
}
|
||||
|
||||
|
||||
$aria_label = sprintf(
|
||||
/* translators: %s: Confirmation name */
|
||||
__( '%s (Edit)', 'gravityforms' ),
|
||||
$item['name']
|
||||
);
|
||||
?>
|
||||
|
||||
<a href="<?php echo esc_url( $edit_url ); ?>"><strong><?php echo esc_html( rgar( $item, 'name' ) ); ?></strong></a>
|
||||
<a href="<?php echo esc_url( $edit_url ); ?>" aria-label="<?php echo esc_attr( $aria_label ); ?>"><strong><?php echo esc_html( rgar( $item, 'name' ) ); ?></strong></a>
|
||||
<div class="row-actions">
|
||||
|
||||
<?php
|
||||
|
||||
@@ -68,7 +68,7 @@ class GF_Upgrade {
|
||||
$this->install();
|
||||
|
||||
// Show installation wizard for all new installations as long as the key wasn't already set e.g. by the CLI.
|
||||
if ( ! get_option( 'rg_gforms_key' ) ) {
|
||||
if ( ! GFCommon::get_key() ) {
|
||||
update_option( 'gform_pending_installation', true );
|
||||
}
|
||||
} elseif ( $this->is_downgrading() ) {
|
||||
@@ -156,6 +156,7 @@ class GF_Upgrade {
|
||||
$this->test_auto_increment();
|
||||
|
||||
$this->sync_auto_updates( $from_db_version );
|
||||
$this->set_license_network_option();
|
||||
|
||||
// Start upgrade routine
|
||||
if ( $force_upgrade || ! ( defined( 'GFORM_AUTO_DB_MIGRATION_DISABLED' ) && GFORM_AUTO_DB_MIGRATION_DISABLED ) ) {
|
||||
@@ -165,6 +166,38 @@ class GF_Upgrade {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures the network option for the license key is set.
|
||||
*
|
||||
* @since 2.8.17
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set_license_network_option() {
|
||||
if ( ! GFCommon::is_network_active() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! is_main_site() ) {
|
||||
delete_option( 'gform_pending_installation' );
|
||||
delete_option( 'rg_gforms_message' );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$key = get_network_option( null, GFForms::LICENSE_KEY_OPT );
|
||||
if ( $key ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$key = GFCommon::get_key();
|
||||
if ( ! $key ) {
|
||||
return;
|
||||
}
|
||||
|
||||
update_network_option( null, GFForms::LICENSE_KEY_OPT, $key );
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the WP auto_update_plugins option to match the background updates setting.
|
||||
*
|
||||
|
||||
@@ -262,7 +262,7 @@ class GF_Field_Number extends GF_Field {
|
||||
$invalid_attribute = $this->failed_validation ? 'aria-invalid="true"' : 'aria-invalid="false"';
|
||||
|
||||
$range_message = $this->get_range_message();
|
||||
$describedby_extra_id = empty( $range_message ) ? array() : array( "gfield_instruction_{$this->formId}_{$this->id}" );
|
||||
$describedby_extra_id = empty( $range_message && ! $this->failed_validation ) ? array() : array( "gfield_instruction_{$this->formId}_{$this->id}" );
|
||||
$aria_describedby = $this->get_aria_describedby( $describedby_extra_id );
|
||||
|
||||
$autocomplete_attribute = $this->enableAutocomplete ? $this->get_field_autocomplete_attribute() : '';
|
||||
|
||||
@@ -97,6 +97,10 @@ if ( ! class_exists( 'GF_Background_Process' ) ) {
|
||||
|
||||
add_action( $this->cron_hook_identifier, array( $this, 'handle_cron_healthcheck' ) );
|
||||
add_filter( 'cron_schedules', array( $this, 'schedule_cron_healthcheck' ) );
|
||||
add_action( 'wp_delete_site', array( $this, 'delete_site_batches' ) );
|
||||
add_action( 'make_spam_blog', array( $this, 'delete_site_batches' ) );
|
||||
add_action( 'archive_blog', array( $this, 'delete_site_batches' ) );
|
||||
add_action( 'make_delete_blog', array( $this, 'delete_site_batches' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,6 +176,7 @@ if ( ! class_exists( 'GF_Background_Process' ) ) {
|
||||
$key = $this->generate_key();
|
||||
|
||||
if ( ! empty( $this->data ) ) {
|
||||
GFCommon::log_debug( sprintf( '%s(): Saving batch %s. Tasks: %d.', __METHOD__, $key, count( $this->data ) ) );
|
||||
$data = array(
|
||||
'blog_id' => get_current_blog_id(),
|
||||
'data' => $this->data,
|
||||
@@ -423,6 +428,12 @@ if ( ! class_exists( 'GF_Background_Process' ) ) {
|
||||
if ( is_multisite() ) {
|
||||
$current_blog_id = get_current_blog_id();
|
||||
if ( $current_blog_id !== $batch->blog_id ) {
|
||||
if ( ! $this->is_valid_blog( $batch->blog_id ) ) {
|
||||
GFCommon::log_debug( sprintf( '%s(): Blog #%s is no longer valid for batch %s.', __METHOD__, $batch->blog_id, $batch->key ) );
|
||||
$this->delete_batches( $batch->blog_id );
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->spawn_multisite_child_process( $batch->blog_id );
|
||||
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
|
||||
// Switch back to the current blog and return so the other tasks queued in this process can be run.
|
||||
@@ -721,32 +732,9 @@ if ( ! class_exists( 'GF_Background_Process' ) ) {
|
||||
* @return false|int
|
||||
*/
|
||||
public function clear_queue( $all_blogs_in_network = false ) {
|
||||
global $wpdb;
|
||||
|
||||
$table = $wpdb->options;
|
||||
$column = 'option_name';
|
||||
|
||||
if ( is_multisite() ) {
|
||||
$table = $wpdb->sitemeta;
|
||||
$column = 'meta_key';
|
||||
}
|
||||
|
||||
$key = $this->identifier . '_batch_';
|
||||
|
||||
if ( ! $all_blogs_in_network ) {
|
||||
$key .= 'blog_id_' . get_current_blog_id() . '_';
|
||||
}
|
||||
|
||||
$key = $wpdb->esc_like( $key ) . '%';
|
||||
|
||||
$result = $wpdb->query( $wpdb->prepare( "
|
||||
DELETE FROM {$table}
|
||||
WHERE {$column} LIKE %s
|
||||
", $key ) );
|
||||
|
||||
$this->data = array();
|
||||
|
||||
return $result;
|
||||
return $this->delete_batches( $all_blogs_in_network );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -782,5 +770,76 @@ if ( ! class_exists( 'GF_Background_Process' ) ) {
|
||||
), $form, $entry );
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the specified blog is suitable for batch processing.
|
||||
*
|
||||
* @since 2.8.16
|
||||
*
|
||||
* @param int $blog_id The blog ID.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_valid_blog( $blog_id ) {
|
||||
$site = get_site( $blog_id );
|
||||
|
||||
return $site instanceof WP_Site && ! $site->deleted && ! $site->archived && ! $site->spam;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the site batches when the site is deleted.
|
||||
*
|
||||
* @since 2.8.16
|
||||
*
|
||||
* @param WP_Site|int $old_site The deleted site object or ID.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete_site_batches( $old_site ) {
|
||||
$blog_id = is_object( $old_site ) ? $old_site->blog_id : $old_site;
|
||||
$this->delete_batches( $blog_id );
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes batches from the database.
|
||||
*
|
||||
* @since 2.8.16
|
||||
*
|
||||
* @param bool|int $all_blogs_in_network True to delete batches for all blogs. False to delete batches for the current blog. A blog ID to delete batches for the specified blog.
|
||||
*
|
||||
* @return bool|int
|
||||
*/
|
||||
public function delete_batches( $all_blogs_in_network = false ) {
|
||||
global $wpdb;
|
||||
|
||||
if ( is_multisite() ) {
|
||||
$table = $wpdb->sitemeta;
|
||||
$column = 'meta_key';
|
||||
} else {
|
||||
$table = $wpdb->options;
|
||||
$column = 'option_name';
|
||||
}
|
||||
|
||||
$key = $this->identifier . '_batch_';
|
||||
|
||||
if ( is_bool( $all_blogs_in_network ) ) {
|
||||
$blog_id = $all_blogs_in_network ? 0 : get_current_blog_id();
|
||||
} else {
|
||||
$blog_id = absint( $all_blogs_in_network );
|
||||
if ( ! $blog_id ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $blog_id ) {
|
||||
$key .= 'blog_id_' . $blog_id . '_';
|
||||
}
|
||||
|
||||
$result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$table} WHERE {$column} LIKE %s", $wpdb->esc_like( $key ) . '%' ) );
|
||||
|
||||
GFCommon::log_debug( sprintf( '%s(): %d batch(es) deleted with prefix %s.', __METHOD__, $result, $key ) );
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ class GF_License_Statuses {
|
||||
const URL_CHANGED = 'gravityapi_site_url_changed';
|
||||
const MAX_SITES_EXCEEDED = 'gravityapi_exceeds_number_of_sites';
|
||||
const MULTISITE_NOT_ALLOWED = 'gravityapi_multisite_not_allowed';
|
||||
const NO_LICENSE_KEY = 'no_license_key';
|
||||
const NO_DATA = 'rest_no_route';
|
||||
|
||||
const USABILITY_VALID = 'success';
|
||||
@@ -39,27 +40,35 @@ class GF_License_Statuses {
|
||||
|
||||
$general_invalid_message = sprintf(
|
||||
/* translators: %1s and %2s are link tag markup */
|
||||
__( 'The license key entered is incorrect; please visit the %1$sGravity Forms website%2$s to verify your license.', 'gravityforms' ),
|
||||
__( 'The license key entered is incorrect; please visit the %1$sGravity Forms website%2$s to verify your license. ', 'gravityforms' ),
|
||||
'<a href="https://www.gravityforms.com/my-account/licenses/?utm_source=gf-admin&utm_medium=purchase-link&utm_campaign=license-enforcement" target="_blank">',
|
||||
'</a>'
|
||||
);
|
||||
|
||||
$map = array(
|
||||
self::VALID_KEY => __( 'Your license key has been successfully validated.', 'gravityforms' ),
|
||||
self::VALID_KEY => __( 'Your license key has been successfully validated. ', 'gravityforms' ),
|
||||
self::SITE_REVOKED => sprintf(
|
||||
/* translators: %1s and %2s are link tag markup */
|
||||
__( 'The license key entered has been revoked; please check its status in your %1$sGravity Forms account.%2$s', 'gravityforms' ),
|
||||
__( 'The license key entered has been revoked; please check its status in your %1$sGravity Forms account.%2$s ', 'gravityforms' ),
|
||||
'<a href="https://www.gravityforms.com/my-account/licenses/?utm_source=gf-admin&utm_medium=account-link-revoked&utm_campaign=license-enforcement" target="_blank">',
|
||||
'</a>'
|
||||
),
|
||||
self::MAX_SITES_EXCEEDED => __( 'This license key has already been activated on its maximum number of sites; please upgrade your license.', 'gravityforms' ),
|
||||
self::MULTISITE_NOT_ALLOWED => __( 'This license key does not support multisite installations. Please use a different license.', 'gravityforms' ),
|
||||
self::MAX_SITES_EXCEEDED => __( 'The license key has already been activated on its maximum number of sites; please upgrade your license. ', 'gravityforms' ),
|
||||
self::MULTISITE_NOT_ALLOWED => __( 'The license key does not support multisite installations. Please use a different license. ', 'gravityforms' ),
|
||||
self::EXPIRED_LICENSE_KEY => sprintf(
|
||||
/* translators: %1s and %2s are link tag markup */
|
||||
__( 'This license key has expired; please visit your %1$sGravity Forms account%2$s to manage your license.', 'gravityforms' ),
|
||||
__( 'The license key has expired; please visit your %1$sGravity Forms account%2$s to manage your license. ', 'gravityforms' ),
|
||||
'<a href="https://www.gravityforms.com/my-account/licenses/?utm_source=gf-admin&utm_medium=account-link-expired&utm_campaign=license-enforcement" target="_blank">',
|
||||
'</a>'
|
||||
),
|
||||
self::NO_LICENSE_KEY => sprintf(
|
||||
/* translators: %1$s admin link tag markup, %2$s closing markup, %3$s Gravity Forms link tag markup, %4$s closing markup */
|
||||
__( '%1$sRegister%2$s your copy of Gravity Forms to receive access to automatic upgrades and support. Need a license key? %3$sPurchase one now%4$s. ', 'gravityforms' ),
|
||||
'<a href="' . admin_url() . 'admin.php?page=gf_settings">',
|
||||
'</a>',
|
||||
'<a href="https://www.gravityforms.com" target="_blank">',
|
||||
'</a>'
|
||||
),
|
||||
self::SITE_UNREGISTERED => $general_invalid_message,
|
||||
self::INVALID_LICENSE_KEY => $general_invalid_message,
|
||||
self::URL_CHANGED => $general_invalid_message,
|
||||
|
||||
@@ -443,7 +443,7 @@ class GF_System_Report {
|
||||
'label' => esc_html__( 'WordPress Multisite', 'gravityforms' ),
|
||||
'label_export' => 'WordPress Multisite',
|
||||
'value' => is_multisite() ? __( 'Yes', 'gravityforms' ) : __( 'No', 'gravityforms' ),
|
||||
'value_export' => is_multisite() ? 'Yes' : 'No',
|
||||
'value_export' => is_multisite() ? sprintf( 'Yes (%d sites)', rgar( wp_count_sites(), 'all' ) ) : 'No',
|
||||
),
|
||||
array(
|
||||
'label' => esc_html__( 'WordPress Memory Limit', 'gravityforms' ),
|
||||
|
||||
@@ -116,7 +116,7 @@ abstract class GF_Telemetry_Data {
|
||||
$endpoint = defined( 'GF_TELEMETRY_ENDPOINT' ) ? GF_TELEMETRY_ENDPOINT : self::TELEMETRY_ENDPOINT;
|
||||
$site_url = get_site_url();
|
||||
$data = array(
|
||||
'license_key_md5' => md5( get_option( 'rg_gforms_key', '' ) ),
|
||||
'license_key_md5' => GFCommon::get_key(),
|
||||
'site_url' => $site_url,
|
||||
'product' => 'gravityforms',
|
||||
'tag' => 'system_report',
|
||||
|
||||
Reference in New Issue
Block a user