plugin updates

This commit is contained in:
Tony Volpe
2024-07-16 13:57:46 +00:00
parent 41f50eacc4
commit 8f93917880
1529 changed files with 259452 additions and 25451 deletions

View File

@@ -205,6 +205,7 @@ abstract class GFAddOn {
->set_form_css_properties( array( $this, 'theme_layer_form_css_properties' ) )
->set_styles( array( $this, 'theme_layer_styles' ) )
->set_scripts( array( $this, 'theme_layer_scripts' ) )
->set_capability( $this->get_form_settings_capabilities() )
->register();
add_action( 'gform_form_after_open', array( $this, 'output_third_party_styles' ), 998, 2 );
}
@@ -1644,8 +1645,8 @@ abstract class GFAddOn {
$caps = array();
// Add capabilities.
if ( ! empty( $this->_capabilities_form_settings ) && is_string( $this->_capabilities_form_settings ) ) {
$caps[ $this->_capabilities_form_settings ] = esc_html__( 'Form Settings', 'gravityforms' );
if ( ! empty( $this->get_form_settings_capabilities() ) && is_string( $this->get_form_settings_capabilities() ) ) {
$caps[ $this->get_form_settings_capabilities() ] = esc_html__( 'Form Settings', 'gravityforms' );
}
if ( ! empty( $this->_capabilities_uninstall ) && is_string( $this->_capabilities_uninstall ) ) {
$caps[ $this->_capabilities_uninstall ] = esc_html__( 'Uninstall', 'gravityforms' );
@@ -4174,6 +4175,15 @@ abstract class GFAddOn {
//-------------- Form settings ---------------------------------------------------
/**
* Get the capabilities required to access the form settings page.
*
* @return array
*/
public function get_form_settings_capabilities() {
return $this->_capabilities_form_settings;
}
/**
* Initializes form settings page
* Hooks up the required scripts and actions for the Form Settings page
@@ -4183,7 +4193,7 @@ abstract class GFAddOn {
$subview = rgget( 'subview' );
add_filter( 'gform_form_settings_menu', array( $this, 'add_form_settings_menu' ), 10, 2 );
if ( rgget( 'page' ) == 'gf_edit_forms' && $view == 'settings' && $subview == $this->get_slug() && $this->current_user_can_any( $this->_capabilities_form_settings ) ) {
if ( rgget( 'page' ) == 'gf_edit_forms' && $view == 'settings' && $subview == $this->get_slug() && $this->current_user_can_any( $this->get_form_settings_capabilities() ) ) {
require_once( GFCommon::get_base_path() . '/tooltips.php' );
add_action( 'gform_form_settings_page_' . $this->get_slug(), array( $this, 'form_settings_page' ) );
@@ -4214,7 +4224,7 @@ abstract class GFAddOn {
// Initialize new settings renderer.
$renderer = new Settings(
array(
'capability' => $this->_capabilities_form_settings,
'capability' => $this->get_form_settings_capabilities(),
'fields' => $sections,
'initial_values' => $this->get_form_settings( $form ),
'save_callback' => function( $values ) use ( $form ) {
@@ -4697,7 +4707,7 @@ abstract class GFAddOn {
'name' => $this->get_slug(),
'label' => $this->get_short_title(),
'query' => array( 'fid' => null ),
'capabilities' => $this->_capabilities_form_settings,
'capabilities' => $this->get_form_settings_capabilities(),
'icon' => $this->get_menu_icon(),
'icon_namespace' => $this->get_icon_namespace(),
);
@@ -5446,7 +5456,6 @@ abstract class GFAddOn {
// remove entry meta
$meta_table = version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ? GFFormsModel::get_lead_meta_table_name() : GFFormsModel::get_entry_meta_table_name();
remove_filter( 'query', array( 'GFForms', 'filter_query' ) );
foreach ( $forms as $form ) {
$all_form_ids[] = $form->id;
$entry_meta = $this->get_entry_meta( array(), $form->id );
@@ -5457,7 +5466,6 @@ abstract class GFAddOn {
}
}
}
add_filter( 'query', array( 'GFForms', 'filter_query' ) );
//remove form settings
if ( ! empty( $all_form_ids ) ) {

View File

@@ -1262,7 +1262,7 @@ abstract class GFFeedAddOn extends GFAddOn {
public function ajax_toggle_is_active() {
check_ajax_referer( 'feed_list', 'nonce' );
if ( ! $this->current_user_can_any( $this->_capabilities_form_settings ) ) {
if ( ! $this->current_user_can_any( $this->get_form_settings_capabilities() ) ) {
wp_send_json_error( array( 'message' => esc_html__( 'Access denied.', 'gravityforms' ) ) );
}
@@ -1279,7 +1279,7 @@ abstract class GFFeedAddOn extends GFAddOn {
public function ajax_save_feed_order() {
check_ajax_referer( 'gform_feed_order', 'nonce' );
if ( ! $this->current_user_can_any( $this->_capabilities_form_settings ) ) {
if ( ! $this->current_user_can_any( $this->get_form_settings_capabilities() ) ) {
return;
}
@@ -1371,7 +1371,7 @@ abstract class GFFeedAddOn extends GFAddOn {
// Initialize new settings renderer.
$renderer = new Settings(
array(
'capability' => $this->_capabilities_form_settings,
'capability' => $this->get_form_settings_capabilities(),
'initial_values' => rgar( $current_feed, 'meta' ),
'save_callback' => function( $values ) use ( $feed_id ) {
@@ -1584,7 +1584,7 @@ abstract class GFFeedAddOn extends GFAddOn {
check_admin_referer( $this->get_slug() . '_save_settings', '_' . $this->get_slug() . '_save_settings_nonce' );
if ( ! $this->current_user_can_any( $this->_capabilities_form_settings ) ) {
if ( ! $this->current_user_can_any( $this->get_form_settings_capabilities() ) ) {
GFCommon::add_error_message( esc_html__( "You don't have sufficient permissions to update the form settings.", 'gravityforms' ) );
return $feed_id;
}

View File

@@ -76,7 +76,6 @@ class GF_Background_Upgrader extends GF_Background_Process {
}
if ( is_callable( $callback ) ) {
remove_filter( 'query', array( 'GFForms', 'filter_query' ) );
GFCommon::log_debug( sprintf( '%s(): Running callback: %s', __METHOD__, print_r( $callback, 1 ) ) );
$needs_more_time = call_user_func( $callback );
if ( $needs_more_time ) {

View File

@@ -1379,8 +1379,6 @@ WHERE ln.id NOT IN
* Upgrade routine from gravity forms version 2.0.4.7 and below
*/
protected function post_upgrade_schema_2047() {
remove_filter( 'query', array( 'GFForms', 'filter_query' ) );
global $wpdb;
$versions = $this->get_versions();

View File

@@ -33,6 +33,21 @@ class GF_Field_CAPTCHA extends GF_Field {
*/
private $secret_key;
/**
* The reCAPTCHA field constructor.
*
* @since 2.8.13
*
* @param $data
*/
public function __construct( $data = array() ) {
parent::__construct( $data );
if ( ! has_filter( 'gform_pre_render', array( __CLASS__, 'maybe_remove_recaptcha_v2' ) ) ) {
add_filter( 'gform_pre_render', array( __CLASS__, 'maybe_remove_recaptcha_v2' ), 11 );
}
}
public function get_form_editor_field_title() {
return esc_attr__( 'CAPTCHA', 'gravityforms' );
}
@@ -84,17 +99,58 @@ class GF_Field_CAPTCHA extends GF_Field {
*
* @since 2.8
*
* @return string
* @return string|array
*/
public function get_field_sidebar_messages() {
if ( $this->captchaType === 'math' || $this->captchaType === 'simple_captcha' || ( ! empty( $this->get_site_key() ) && ! empty( $this->get_secret_key() ) ) ) {
// If the field is a math or simple captcha, we don't need to display a warning.
if ( $this->captchaType === 'math' || $this->captchaType === 'simple_captcha' ) {
return '';
}
// If the reCAPTCHA keys are configured and Conversational Forms is active, we need to display a warning.
if ( ( ! empty( $this->get_site_key() ) && ! empty( $this->get_secret_key() ) ) ) {
if ( is_plugin_active( 'gravityformsconversationalforms/conversationalforms.php' ) ) {
return array(
'type' => 'notice',
'content' => esc_html__( 'The reCAPTCHA v2 field is not supported in Conversational Forms and will be removed, but will continue to work as expected in other contexts.', 'gravityforms' )
);
} else {
return '';
}
}
// If the reCAPTCHA keys are not configured, we need to display a warning.
// Translators: 1. Opening <a> tag with link to the Forms > Settings > reCAPTCHA page. 2. closing <a> tag.
return sprintf( __( 'To use reCAPTCHA v2 you must configure the site and secret keys on the %1$sreCAPTCHA Settings%2$s page.', 'gravityforms' ), "<a href='?page=gf_settings&subview=recaptcha' target='_blank'>", '</a>' );
}
/**
* Recaptcha v2 does not work in conversational forms, so we have to remove it.
*
* @since 2.8.13
*
* @param $form
*
* @return void
*/
public static function maybe_remove_recaptcha_v2( $form ) {
if ( ! function_exists( 'is_conversational_form' ) ) {
return $form;
}
if ( ! is_conversational_form( $form ) ) {
return $form;
}
foreach ( $form['fields'] as $key => $field ) {
if ( $field->type === 'captcha' && ( $field->captchaType === '' || $field->captchaType === 'captcha' ) ) {
unset( $form['fields'][ $key ] );
}
}
return $form;
}
/**
* Validate the reCAPTCHA field.
*
@@ -179,6 +235,13 @@ class GF_Field_CAPTCHA extends GF_Field {
* @return bool
*/
public function validate_recaptcha( $form ) {
if ( rgpost( 'gform_conversational_form' ) ) {
$hash = md5( $form['title'] . $form['id'] );
if ( $hash === $_POST['gform_conversational_form'] && is_plugin_active( 'gravityformsconversationalforms/conversationalforms.php' ) ) {
// This is a conversational form, and recaptcha v2 isn't supported
return true;
}
}
$response = $this->get_posted_recaptcha_response();
if ( ! ( $this->verify_decoded_response( $form, $response ) || $this->verify_recaptcha_response( $response ) ) ) {

View File

@@ -62,7 +62,7 @@ class Text extends Base {
esc_attr( $this->input_type ),
esc_attr( $this->settings->get_input_name_prefix() ),
esc_attr( $this->name ),
$value ? esc_attr( htmlspecialchars( $value, ENT_QUOTES ) ) : '',
! rgblank( $value ) ? esc_attr( htmlspecialchars( $value, ENT_QUOTES ) ) : '',
$this->get_describer() ? sprintf( 'aria-describedby="%s"', $this->get_describer() ) : '',
implode( ' ', $this->get_attributes() ),
isset( $this->append ) ? sprintf( '<span class="gform-settings-field__text-append">%s</span>', esc_html( $this->append ) ) : '',

View File

@@ -188,4 +188,18 @@ class Theme_Layer_Builder {
return $this;
}
/**
* Setter for capability.
*
* @param $capability
*
* @return $this
*/
public function set_capability( $capability ) {
$this->layer->set_capability( $capability );
return $this;
}
}

View File

@@ -100,4 +100,8 @@ class Fluent_Theme_Layer extends GF_All_Access_Theme_Layer {
$this->icon = $icon;
}
public function set_capability( $capability ) {
$this->form_settings_capability = $capability;
}
}

View File

@@ -78,13 +78,14 @@ class GF_Theme_Layers extends \GFAddOn {
}
$tabs[] = array(
'name' => $layer->name(),
'label' => $layer->short_title(),
'icon' => $layer->icon(),
'query' => array(
'name' => $layer->name(),
'label' => $layer->short_title(),
'icon' => $layer->icon(),
'query' => array(
'theme_layer' => $layer->name(),
'subview' => $this->get_slug(),
),
'capabilities' => $layer->get_form_settings_capability(),
);
}
@@ -103,5 +104,25 @@ class GF_Theme_Layers extends \GFAddOn {
public function form_settings_fields( $form ) {
return array();
}
/**
* Get the form settings capabilities.
*/
public function get_form_settings_capabilities() {
static $caps;
if ( empty( $caps ) ) {
$theme_layers = \GFForms::get_service_container()->get( GF_Theme_Layers_Provider::THEME_LAYERS );
foreach ( $theme_layers as $layer ) {
/**
* @var GF_Theme_Layer $layer
*/
$caps[ $layer->name() ] = $layer->get_form_settings_capability();
}
}
return rgar( $caps, rgget( 'theme_layer' ) );
}
}

View File

@@ -21,6 +21,8 @@ abstract class GF_Theme_Layer {
protected $short_title;
protected $priority;
protected $form_settings_capability;
/**
* @var Definition_Engine[]
*/
@@ -142,4 +144,13 @@ abstract class GF_Theme_Layer {
return $this->icon;
}
/**
* Getter for form_settings_capability
*
* @return string
*/
public function get_form_settings_capability() {
return $this->form_settings_capability;
}
}