Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion assets/dev/js/admin/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,10 @@ import FloatingButtonsHandler from 'elementor/modules/floating-buttons/assets/js
} );

$( '.e-notice--cta.e-notice--dismissible[data-notice_id="site_mailer_promotion"] a.e-button--cta' ).on( 'click', function() {
const isWcNotice = $( this ).closest( '.e-notice' ).hasClass( 'sm-notice-wc' );
elementorCommon.ajax.addRequest( 'elementor_core_site_mailer_campaign', {
data: {
source: 'sm-core-form-install',
source: isWcNotice ? 'sm-core-woo-install' : 'sm-core-form-install',
},
} );
} );
Expand Down
45 changes: 36 additions & 9 deletions core/admin/admin-notices.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,25 +380,28 @@ private function notice_experiment_promotion() {
return true;
}

private function site_has_forms_plugins() {
return defined( 'WPFORMS_VERSION' ) || defined( 'WPCF7_VERSION' ) || defined( 'FLUENTFORM_VERSION' ) || class_exists( '\GFCommon' ) || class_exists( '\Ninja_Forms' ) || function_exists( 'load_formidable_forms' );
}

private function site_has_woocommerce() {
return class_exists( 'WooCommerce' );
}

private function notice_site_mailer_promotion() {
$notice_id = 'site_mailer_promotion';
$has_forms = $this->site_has_forms_plugins();
$has_woocommerce = $this->site_has_woocommerce();

if (
! defined( 'WPFORMS_VERSION' )
&& ! defined( 'WPCF7_VERSION' )
&& ! defined( 'FLUENTFORM_VERSION' )
&& ! class_exists( '\GFCommon' )
&& ! class_exists( '\Ninja_Forms' )
&& ! function_exists( 'load_formidable_forms' )
) {
if ( ! $has_forms && ! $has_woocommerce ) {
return false;
}

if ( ! $this->is_elementor_page() && ! in_array( $this->current_screen_id, [ 'toplevel_page_elementor', 'edit-elementor_library', 'dashboard' ], true ) ) {
return false;
}

if ( Utils::has_pro() || ! current_user_can( 'install_plugins' ) || User::is_user_notice_viewed( $notice_id ) ) {
if ( ( Utils::has_pro() && ! $has_woocommerce ) || ! current_user_can( 'install_plugins' ) || User::is_user_notice_viewed( $notice_id ) ) {
return false;
}

Expand Down Expand Up @@ -428,11 +431,35 @@ private function notice_site_mailer_promotion() {
],
];

if ( $this->should_render_woocommerce_hint( $has_forms, $has_woocommerce ) ) {
// We include WP's default notice class so it will be properly handled by WP's js handler
// And add a new one to distinguish between the two types of notices
$options['classes'] = [ 'notice', 'e-notice', 'sm-notice-wc' ];
$options['title'] = esc_html__( 'Improve Transactional Email Deliverability', 'elementor' );
$options['description'] = esc_html__( 'Use Elementor\'s Site Mailer to ensure your store emails like purchase confirmations, shipping updates and more are reliably delivered.', 'elementor' );
}

$this->print_admin_notice( $options );

return true;
}

private function should_render_woocommerce_hint( $has_forms, $has_woocommerce ): bool {
if ( ! $has_forms && ! $has_woocommerce ) {
return false;
}

if ( ! $has_forms && $has_woocommerce ) {
return true;
}

if ( $has_forms && $has_woocommerce && Utils::has_pro() ) {
return true;
}

return (bool) mt_rand( 0, 1 );
}

private function is_elementor_page(): bool {
return 0 === strpos( $this->current_screen_id, 'elementor_page' );
}
Expand Down
4 changes: 2 additions & 2 deletions core/admin/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -725,14 +725,14 @@ public function admin_action_new_post() {
}

private function get_allowed_fields_for_role() {
$allowed_fields = array(
$allowed_fields = [
'post_title',
'post_content',
'post_excerpt',
'post_category',
'post_type',
'tags_input',
);
];

if ( current_user_can( 'publish_posts' ) ) {
$allowed_fields[] = 'post_status';
Expand Down
16 changes: 8 additions & 8 deletions core/base/background-process/wp-async-request.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,21 @@ abstract class WP_Async_Request {
/**
* Data
*
* (default value: array())
* (default value: [])
*
* @var array
* @access protected
*/
protected $data = array();
protected $data = [];

/**
* Initiate new async request
*/
public function __construct() {
$this->identifier = $this->prefix . '_' . $this->action;

add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) );
add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) );
add_action( 'wp_ajax_' . $this->identifier, [ $this, 'maybe_handle' ] );
add_action( 'wp_ajax_nopriv_' . $this->identifier, [ $this, 'maybe_handle' ] );
}

/**
Expand Down Expand Up @@ -103,10 +103,10 @@ protected function get_query_args() {
return $this->query_args;
}

return array(
return [
'action' => $this->identifier,
'nonce' => wp_create_nonce( $this->identifier ),
);
];
}

/**
Expand All @@ -132,14 +132,14 @@ protected function get_post_args() {
return $this->post_args;
}

return array(
return [
'timeout' => 0.01,
'blocking' => false,
'body' => $this->data,
'cookies' => $_COOKIE,
/** This filter is documented in wp-includes/class-wp-http-streams.php */
'sslverify' => apply_filters( 'https_local_ssl_verify', false ),
);
];
}

/**
Expand Down
8 changes: 4 additions & 4 deletions core/base/background-process/wp-background-process.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public function __construct() {
$this->cron_hook_identifier = $this->identifier . '_cron';
$this->cron_interval_identifier = $this->identifier . '_cron_interval';

add_action( $this->cron_hook_identifier, array( $this, 'handle_cron_healthcheck' ) );
add_filter( 'cron_schedules', array( $this, 'schedule_cron_healthcheck' ) );
add_action( $this->cron_hook_identifier, [ $this, 'handle_cron_healthcheck' ] );
add_filter( 'cron_schedules', [ $this, 'schedule_cron_healthcheck' ] );
}

/**
Expand Down Expand Up @@ -432,14 +432,14 @@ public function schedule_cron_healthcheck( $schedules ) {
}

// Adds every 5 minutes to the existing schedules.
$schedules[ $this->identifier . '_cron_interval' ] = array(
$schedules[ $this->identifier . '_cron_interval' ] = [
'interval' => MINUTE_IN_SECONDS * $interval,
'display' => sprintf(
/* translators: %d: Interval in minutes. */
esc_html__( 'Every %d minutes', 'elementor' ),
$interval,
),
);
];

return $schedules;
}
Expand Down
4 changes: 2 additions & 2 deletions core/base/background-task.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,14 @@ public function schedule_cron_healthcheck( $schedules ) {
$interval = apply_filters( $this->identifier . '_cron_interval', 5 );

// Adds every 5 minutes to the existing schedules.
$schedules[ $this->identifier . '_cron_interval' ] = array(
$schedules[ $this->identifier . '_cron_interval' ] = [
'interval' => MINUTE_IN_SECONDS * $interval,
'display' => sprintf(
/* translators: %d: Interval in minutes. */
esc_html__( 'Every %d minutes', 'elementor' ),
$interval
),
);
];

return $schedules;
}
Expand Down
20 changes: 20 additions & 0 deletions core/settings/page/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ public function ajax_before_save_settings( array $data, $id ) {
}

if ( isset( $data['post_featured_image'] ) && post_type_supports( $post->post_type, 'thumbnail' ) ) {
// Check if the user is at least an Author before allowing them to modify the thumbnail
if ( ! current_user_can( 'publish_posts' ) ) {
throw new \Exception( 'You do not have permission to modify the featured image.', Exceptions::FORBIDDEN );
}

if ( empty( $data['post_featured_image']['id'] ) ) {
delete_post_thumbnail( $post->ID );
} else {
Expand Down Expand Up @@ -342,6 +347,12 @@ public function save_post_status( $post_id, $status ) {

$allowed_post_statuses = get_post_statuses();

if ( $this->is_contributor_user() && $this->has_invalid_post_status_for_contributor( $status ) ) {
// If the status is not allowed, set it to 'pending' by default
$status = 'pending';
$post->post_status = $status;
}

if ( isset( $allowed_post_statuses[ $status ] ) ) {
$post_type_object = get_post_type_object( $post->post_type );
if ( 'publish' !== $status || current_user_can( $post_type_object->cap->publish_posts ) ) {
Expand All @@ -351,4 +362,13 @@ public function save_post_status( $post_id, $status ) {

wp_update_post( $post );
}

private function is_contributor_user(): bool {
return current_user_can( 'edit_posts' ) && ! current_user_can( 'publish_posts' );
}

private function has_invalid_post_status_for_contributor( $status ): bool {
return 'draft' !== $status && 'pending' !== $status;
}

}
4 changes: 2 additions & 2 deletions core/utils/import-export/parsers/wxr-parser-xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function parse( $file ) {
return new WP_Error( 'WXR_parse_error', esc_html__( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'elementor' ) );
}

return array(
return [
'authors' => $this->authors,
'posts' => $this->posts,
'categories' => $this->category,
Expand All @@ -199,7 +199,7 @@ public function parse( $file ) {
'base_url' => $this->base_url,
'base_blog_url' => $this->base_blog_url,
'version' => $this->wxr_version,
);
];
}

private function tag_open( $tag, $attr ) {
Expand Down
4 changes: 2 additions & 2 deletions core/utils/plugins-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function install( $plugins ) {
$api = Plugin::$instance->wp->plugins_api('plugin_information',
[
'slug' => $slug,
'fields' => array(
'fields' => [
'short_description' => false,
'sections' => false,
'requires' => false,
Expand All @@ -70,7 +70,7 @@ public function install( $plugins ) {
'compatibility' => false,
'homepage' => false,
'donate_link' => false,
),
],
]
);

Expand Down
2 changes: 1 addition & 1 deletion data/base/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ protected function register_internal_endpoints() {
register_rest_route( $this->get_namespace(), '/' . $this->get_rest_base(), [
[
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'get_items' ),
'callback' => [ $this, 'get_items' ],
'args' => [],
'permission_callback' => function ( $request ) {
return $this->get_permission_callback( $request );
Expand Down
1 change: 1 addition & 0 deletions includes/base/element-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,7 @@ protected function register_transform_section( $element_selector = '', $transfor
'condition' => [
"_transform_rotate_popover{$tab}!" => '',
],
'frontend_available' => true,
]
);

Expand Down
41 changes: 31 additions & 10 deletions includes/elements/container.php
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,9 @@ protected function register_background_controls() {
],
'render_type' => 'ui',
'separator' => 'before',
'condition' => [
'background_hover_background' => [ 'classic', 'gradient' ],
],
'selectors' => [
'{{WRAPPER}}' => '--background-transition: {{SIZE}}s;',
],
Expand Down Expand Up @@ -910,14 +913,6 @@ protected function register_background_overlay_controls() {
]
);

$this->add_group_control(
Group_Control_Css_Filter::get_type(),
[
'name' => 'css_filters_hover',
'selector' => '{{WRAPPER}}:hover::before',
]
);

$this->add_control(
'background_overlay_hover_transition',
[
Expand All @@ -932,12 +927,23 @@ protected function register_background_overlay_controls() {
],
'render_type' => 'ui',
'separator' => 'before',
'condition' => [
'background_overlay_hover_background' => [ 'classic', 'gradient' ],
],
'selectors' => [
'{{WRAPPER}}, {{WRAPPER}}::before' => '--overlay-transition: {{SIZE}}s;',
],
]
);

$this->add_group_control(
Group_Control_Css_Filter::get_type(),
[
'name' => 'css_filters_hover',
'selector' => '{{WRAPPER}}:hover::before',
]
);

$this->end_controls_tab();

$this->end_controls_tabs();
Expand Down Expand Up @@ -1087,12 +1093,27 @@ protected function register_border_controls() {
'relation' => 'or',
'terms' => [
[
'name' => 'background_background',
'name' => 'border_hover_border',
'operator' => '!==',
'value' => '',
],
[
'name' => 'border_hover_border',
'name' => 'border_radius_hover[top]',
'operator' => '!==',
'value' => '',
],
[
'name' => 'border_radius_hover[right]',
'operator' => '!==',
'value' => '',
],
[
'name' => 'border_radius_hover[bottom]',
'operator' => '!==',
'value' => '',
],
[
'name' => 'border_radius_hover[left]',
'operator' => '!==',
'value' => '',
],
Expand Down
4 changes: 2 additions & 2 deletions includes/frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ public function register_scripts() {
[
'jquery',
],
'4.1.4',
'4.6.13',
true
);

Expand Down Expand Up @@ -521,7 +521,7 @@ public function register_styles() {
'flatpickr',
$this->get_css_assets_url( 'flatpickr', 'assets/lib/flatpickr/' ),
[],
'4.1.4'
'4.6.13'
);

wp_register_style(
Expand Down
Loading