Skip to content

Commit 5671a4d

Browse files
release(minor): v3.1.0
### New Features - Add “Random” Sort Option to Otter Posts Block - Add "from" setting for the Forms block - Ability to modify form subject dynamically - Allow tabs to have IDs so they can be linked and opened from an anchor - Allow disabling the Popup block - Display thumbnails in Live Search results ### Improvements - Otter Patterns Modal Improvements - Move AI icon to the end of the toolbar to avoid interfering with core functionality - Responsive settings — add 600 px and 960 px breakpoints - Make Dynamic Content less intrusive - A11y improvements in Sharing Icons Block - Add new ACF types support to the Posts Block - New User Experience Improvements ### Bug Fixes - Review block generating double schema markup - Popup block bypasses the Display Interval feature - Disabling Patterns Library doesn’t hide patterns - Letter-case overlap in the sidebar - Live Search shows incorrect prices for products - Popup template with form not rendering top padding correctly - General accessibility issues - Product Review block inside a Pattern not visible in the Review Comparison Table block - Menu Icons break the font of menu items - Select-field options not editable in Otter Blocks Form - Pagination with Posts block not working on the home page
2 parents af9b2a0 + 2fe6e14 commit 5671a4d

File tree

80 files changed

+2614
-4701
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+2614
-4701
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"dealerdirect/phpcodesniffer-composer-installer": "0.7.1",
2020
"automattic/vipwpcs": "^1.0.0",
2121
"phpunit/phpunit": "9.6.5",
22-
"yoast/phpunit-polyfills": "^3.0",
22+
"yoast/phpunit-polyfills": "^4.0",
2323
"phpstan/phpstan": "^1.10",
2424
"szepeviktor/phpstan-wordpress": "^1.3",
2525
"php-stubs/woocommerce-stubs": "^9.1",
@@ -78,6 +78,6 @@
7878
"wptt/webfont-loader": "^1.1",
7979
"sabberworm/php-css-parser": "^8.4",
8080
"stripe/stripe-php": "^15.3",
81-
"enshrined/svg-sanitize": "^0.19.0"
81+
"enshrined/svg-sanitize": "^0.21.0"
8282
}
8383
}

composer.lock

Lines changed: 71 additions & 64 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inc/class-blocks-animation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public function enqueue_editor_assets() {
129129
* @access public
130130
*/
131131
public function enqueue_block_frontend_assets() {
132-
if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
132+
if ( did_action( 'parse_request' ) && function_exists( 'amp_is_request' ) && amp_is_request() ) {
133133
self::$can_load_frontend = false;
134134
}
135135

inc/class-main.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public function init() {
5151
add_filter( 'themeisle_sdk_blackfriday_data', array( $this, 'add_black_friday_data' ) );
5252

5353
add_action( 'parse_query', array( $this, 'pagination_support' ) );
54+
add_filter( 'rest_post_collection_params', array( $this, 'add_random_orderby_param' ) );
5455
}
5556

5657
/**
@@ -630,6 +631,21 @@ public function add_black_friday_data( $configs ) {
630631
return $configs;
631632
}
632633

634+
/**
635+
* Add random orderby parameter to REST API.
636+
*
637+
* @param array $params REST API parameters.
638+
*
639+
* @return array Modified parameters.
640+
*/
641+
public function add_random_orderby_param( $params ) {
642+
if ( isset( $params['orderby'] ) ) {
643+
$params['orderby']['enum'][] = 'rand';
644+
}
645+
646+
return $params;
647+
}
648+
633649
/**
634650
* Singleton method.
635651
*

inc/class-registration.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
namespace ThemeIsle\GutenbergBlocks;
99

1010
use ThemeIsle\GutenbergBlocks\Main, ThemeIsle\GutenbergBlocks\Pro, ThemeIsle\GutenbergBlocks\Plugins\Stripe_API;
11+
use ThemeIsle\GutenbergBlocks\Plugins\Dashboard;
1112
use ThemeIsle\GutenbergBlocks\Plugins\LimitedOffers;
13+
use ThemeIsle\GutenbergBlocks\Plugins\Template_Cloud;
1214

1315
/**
1416
* Class Registration.
@@ -292,10 +294,14 @@ public function enqueue_block_editor_assets() {
292294
'isRTL' => is_rtl(),
293295
'highlightDynamicText' => get_option( 'themeisle_blocks_settings_highlight_dynamic', true ),
294296
'hasOpenAiKey' => ! empty( get_option( 'themeisle_open_ai_api_key' ) ),
297+
'hasPatternSources' => Template_Cloud::has_used_pattern_sources(),
295298
)
296299
);
297300

298301
wp_enqueue_style( 'otter-editor', OTTER_BLOCKS_URL . 'build/blocks/editor.css', array( 'wp-edit-blocks', 'font-awesome-5', 'font-awesome-4-shims' ), $asset_file['version'] );
302+
303+
add_filter( 'themeisle-sdk/survey/' . OTTER_PRODUCT_SLUG, array( Dashboard::class, 'get_survey_metadata' ), 10, 2 );
304+
do_action( 'themeisle_internal_page', OTTER_PRODUCT_SLUG, 'editor' );
299305
}
300306

301307
/**
@@ -441,7 +447,7 @@ function( $block ) {
441447
}
442448
}
443449

444-
if ( ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) || is_admin() ) {
450+
if ( ( did_action( 'parse_request' ) && function_exists( 'amp_is_request' ) && amp_is_request() ) || is_admin() ) {
445451
return;
446452
}
447453

@@ -615,6 +621,8 @@ function() {
615621
'themeisleGutenbergSlider',
616622
array(
617623
'isRTL' => is_rtl(),
624+
'next' => __( 'Next Slide', 'otter-blocks' ),
625+
'prev' => __( 'Previous Slide', 'otter-blocks' ),
618626
)
619627
);
620628
}
@@ -942,7 +950,7 @@ public function subscribe_fa( $block_content, $block ) {
942950
self::$is_fa_loaded = true;
943951

944952
// See the src/blocks/plugins/menu-icons/inline.css file for where this comes from.
945-
$styles = '.fab.wp-block-navigation-item,.far.wp-block-navigation-item,.fas.wp-block-navigation-item{-moz-osx-font-smoothing:inherit;-webkit-font-smoothing:inherit;font-weight:inherit}.fab.wp-block-navigation-item:before,.far.wp-block-navigation-item:before,.fas.wp-block-navigation-item:before{font-family:Font Awesome\ 5 Free;margin-right:5px}.fab.wp-block-navigation-item:before,.far.wp-block-navigation-item:before{font-weight:400;padding-right:5px}.fas.wp-block-navigation-item:before{font-weight:900;padding-right:5px}.fab.wp-block-navigation-item:before{font-family:Font Awesome\ 5 Brands}';
953+
$styles = '.fab.wp-block-navigation-item,.far.wp-block-navigation-item,.fas.wp-block-navigation-item{-moz-osx-font-smoothing:inherit;-webkit-font-smoothing:inherit;font-weight:inherit;font-family: inherit}.fab.wp-block-navigation-item:before,.far.wp-block-navigation-item:before,.fas.wp-block-navigation-item:before{font-family:Font Awesome\ 5 Free;margin-right:5px}.fab.wp-block-navigation-item:before,.far.wp-block-navigation-item:before{font-weight:400;padding-right:5px}.fas.wp-block-navigation-item:before{font-weight:900;padding-right:5px}.fab.wp-block-navigation-item:before{font-family:Font Awesome\ 5 Brands}';
946954

947955
wp_add_inline_style( 'font-awesome-5', $styles );
948956
return $block_content;
@@ -976,7 +984,7 @@ public function subscribe_fa( $block_content, $block ) {
976984
* @since 2.0.5
977985
*/
978986
public function load_sticky( $block_content, $block ) {
979-
if ( ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) || self::$scripts_loaded['sticky'] ) {
987+
if ( ( did_action( 'parse_request' ) && function_exists( 'amp_is_request' ) && amp_is_request() ) || self::$scripts_loaded['sticky'] ) {
980988
return $block_content;
981989
}
982990

inc/css/class-css-handler.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function init() {
3232
add_action( 'rest_api_init', array( $this, 'autoload_block_classes' ) );
3333
add_action( 'before_delete_post', array( __CLASS__, 'delete_css_file' ) );
3434
add_action( 'customize_save_after', array( $this, 'customize_save_after' ) );
35+
add_action( 'rest_after_insert_wp_block', array( $this, 'insert_pattern' ), 10, 3 );
3536
add_filter( 'customize_dynamic_partial_args', array( $this, 'customize_dynamic_partial_args' ), 10, 2 );
3637
}
3738

@@ -568,6 +569,22 @@ public static function mark_review_block_metadata( $post_id ) {
568569
}
569570
}
570571

572+
/**
573+
* Action to run after inserting a pattern.
574+
*
575+
* @param \WP_Post $post The post object.
576+
* @param \WP_REST_Request $request The request object.
577+
* @param bool $creating Whether the post is being created.
578+
* @access public
579+
*/
580+
public function insert_pattern( $post, $request, $creating ) {
581+
// Generate CSS for the inserted pattern.
582+
self::generate_css_file( $post->ID );
583+
584+
// Mark the post as having a review block if applicable.
585+
self::mark_review_block_metadata( $post->ID );
586+
}
587+
571588
/**
572589
* The instance method for the static class.
573590
* Defines and returns the instance of the static class.

inc/integrations/class-form-settings-data.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ class Form_Settings_Data {
9393
*/
9494
private $from_name;
9595

96+
/**
97+
* The email of the sender.
98+
*
99+
* @var string|null
100+
*/
101+
private $from_email;
102+
96103
/**
97104
* The CC recipients.
98105
*
@@ -233,6 +240,9 @@ public static function get_form_setting_from_wordpress_options( $form_option ) {
233240
if ( isset( $form['fromName'] ) ) {
234241
$integration->set_from_name( $form['fromName'] );
235242
}
243+
if ( isset( $form['fromEmail'] ) ) {
244+
$integration->set_from_email( $form['fromEmail'] );
245+
}
236246
if ( isset( $form['cc'] ) ) {
237247
$integration->set_cc( $form['cc'] );
238248
}
@@ -419,6 +429,16 @@ public function has_from_name() {
419429
return isset( $this->from_name ) && '' !== $this->from_name;
420430
}
421431

432+
/**
433+
* Check if it has the from_email set.
434+
*
435+
* @return bool
436+
* @since 2.0.3
437+
*/
438+
public function has_from_email() {
439+
return isset( $this->from_email ) && '' !== $this->from_email && filter_var( $this->from_email, FILTER_VALIDATE_EMAIL ) !== false;
440+
}
441+
422442
/**
423443
* Check if it has an autoresponder.
424444
*
@@ -615,6 +635,30 @@ public function set_from_name( $from_name ) {
615635
return $this;
616636
}
617637

638+
/**
639+
* Get the email of the sender.
640+
*
641+
* @return string
642+
*/
643+
public function get_from_email() {
644+
return $this->from_email;
645+
}
646+
647+
/**
648+
* Set the email of the sender.
649+
*
650+
* @param string $from_email The email of the sender.
651+
* @return Form_Settings_Data
652+
*/
653+
public function set_from_email( $from_email ) {
654+
if ( filter_var( $from_email, FILTER_VALIDATE_EMAIL ) !== false ) {
655+
$this->from_email = $from_email;
656+
} else {
657+
$this->from_email = '';
658+
}
659+
return $this;
660+
}
661+
618662
/**
619663
* Get the email cc.
620664
*

inc/plugins/class-dashboard.php

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use ThemeIsle\GutenbergBlocks\Pro;
1111
use ThemeIsle\GutenbergBlocks\Plugins\FSE_Onboarding;
12+
use ThemeIsle\GutenbergBlocks\Plugins\Template_Cloud;
1213

1314
/**
1415
* Class Dashboard
@@ -28,15 +29,16 @@ class Dashboard {
2829
public function init() {
2930
add_action( 'admin_menu', array( $this, 'register_menu_page' ) );
3031
add_action( 'admin_init', array( $this, 'maybe_redirect' ) );
31-
add_action( 'admin_head', array( $this, 'form_submission_elements' ) );
32+
add_action( 'admin_head', array( $this, 'survey_elements' ) );
33+
add_action( 'admin_notices', array( $this, 'form_submission_elements' ), 30 );
3234
add_action( 'admin_head', array( $this, 'add_inline_css' ) );
3335

3436
$form_options = get_option( 'themeisle_blocks_form_emails' );
3537
if ( ! empty( $form_options ) ) {
3638
add_action( 'wp_dashboard_setup', array( $this, 'form_submissions_widget' ) );
3739
}
3840

39-
add_filter( 'themeisle-sdk/survey/' . OTTER_PRODUCT_SLUG, array( $this, 'get_survey_metadata' ), 10, 2 );
41+
add_filter( 'themeisle-sdk/survey/' . OTTER_PRODUCT_SLUG, array( __CLASS__, 'get_survey_metadata' ), 10, 2 );
4042
}
4143

4244
/**
@@ -241,11 +243,13 @@ public function get_dashboard_data() {
241243
'assetsPath' => OTTER_BLOCKS_URL . 'assets/',
242244
'stylesExist' => is_dir( $basedir ) || boolval( get_transient( 'otter_animations_parsed' ) ),
243245
'hasPro' => Pro::is_pro_installed(),
246+
'otterPage' => tsdk_translate_link( tsdk_utmify( 'https://themeisle.com/plugins/otter-blocks/', 'welcome', 'admin' ) ),
244247
'upgradeLink' => tsdk_translate_link( tsdk_utmify( Pro::get_url(), 'options', Pro::get_reference() ) ),
245248
'upgradeLinkFromTc' => tsdk_utmify( Pro::get_url(), 'templatecloud' ),
246249
'tcUpgradeLink' => tsdk_utmify( 'https://themeisle.com/plugins/templates-cloud/', 'templatecloud', 'otter-blocks' ),
247250
'tcDocs' => 'https://docs.themeisle.com/article/2191-templates-cloud-collections',
248251
'docsLink' => Pro::get_docs_url(),
252+
'newPageUrl' => esc_url( admin_url( 'post-new.php?post_type=page' ) ),
249253
'showFeedbackNotice' => $this->should_show_feedback_notice(),
250254
'deal' => ! Pro::is_pro_installed() ? $offer->get_localized_data() : array(),
251255
'hasOnboarding' => false !== get_theme_support( FSE_Onboarding::SUPPORT_KEY ),
@@ -278,6 +282,7 @@ public function get_dashboard_data() {
278282
)
279283
),
280284
'neveInstalled' => defined( 'NEVE_VERSION' ),
285+
'hasPatternSources' => Template_Cloud::has_used_pattern_sources(),
281286
);
282287

283288
$global_data = apply_filters( 'otter_dashboard_data', $global_data );
@@ -313,24 +318,34 @@ public function maybe_redirect() {
313318
}
314319

315320
update_option( 'themeisle_blocks_settings_redirect', false );
316-
wp_safe_redirect( admin_url( 'admin.php?page=otter' ) );
321+
wp_safe_redirect( admin_url( 'admin.php?page=otter&welcome=true' ) );
317322
exit;
318323
}
319324

325+
/**
326+
* Add elements for the survey.
327+
*
328+
* @return void
329+
*/
330+
public function survey_elements() {
331+
$screen = get_current_screen();
332+
333+
if ( 'edit-otter_form_record' === $screen->id ) {
334+
do_action( 'themeisle_internal_page', OTTER_PRODUCT_SLUG, 'form-submissions' );
335+
}
336+
}
337+
320338
/**
321339
* Add elements for Form Block submission page.
322340
*
323341
* @return void
324342
*/
325343
public function form_submission_elements() {
326344
$screen = get_current_screen();
345+
327346
if ( 'edit-otter_form_record' === $screen->id || 'otter-blocks_page_form-submissions-free' === $screen->id ) {
328347
$this->the_otter_banner();
329348
}
330-
331-
if ( 'edit-otter_form_record' === $screen->id ) {
332-
do_action( 'themeisle_internal_page', OTTER_PRODUCT_SLUG, 'form-submissions' );
333-
}
334349
}
335350

336351
/**
@@ -761,17 +776,16 @@ public function form_submissions_widget_content() {
761776
*
762777
* @return array The data in Frombricks format.
763778
*/
764-
public function get_survey_metadata( $data, $page_slug ) {
765-
$dash_data = $this->get_dashboard_data();
766-
767-
$install_days_number = $dash_data['days_since_install'];
779+
public static function get_survey_metadata( $data, $page_slug ) {
780+
$dash_data = apply_filters( 'otter_dashboard_data', array() );
781+
$install_days_number = intval( ( time() - get_option( 'otter_blocks_install', time() ) ) / DAY_IN_SECONDS );
768782

769783
$data = array(
770784
'environmentId' => 'clp9hqm8c1osfdl2ixwd0k0iz',
771785
'attributes' => array(
772786
'install_days_number' => $install_days_number,
773787
'plan' => isset( $dash_data['license'], $dash_data['license']['type'] ) ? $dash_data['license']['type'] : 'free',
774-
'freeVersion' => $dash_data['version'],
788+
'freeVersion' => OTTER_BLOCKS_VERSION,
775789
),
776790
);
777791

inc/plugins/class-dynamic-content.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,11 +525,10 @@ public function get_archive_description( $data ) {
525525
$description = get_the_archive_description();
526526

527527
if ( empty( $description ) ) {
528-
$default = isset( $data['default'] ) ? esc_html( $data['default'] ) : '';
529-
$description = $default;
528+
$description = isset( $data['default'] ) ? esc_html( $data['default'] ) : '';
530529
}
531530

532-
return $description;
531+
return wp_strip_all_tags( $description );
533532
}
534533

535534
/**
@@ -630,7 +629,7 @@ public function apply_link( $data ) {
630629
'<a href="%s" %s>%s</a>',
631630
esc_url( $link ),
632631
$attrs,
633-
esc_html( $data['text'] )
632+
wp_kses_post( $data['text'] )
634633
);
635634

636635
return $value;

inc/plugins/class-options-settings.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,9 @@ function ( $item ) {
324324
if ( isset( $item['fromName'] ) ) {
325325
$item['fromName'] = sanitize_text_field( $item['fromName'] );
326326
}
327+
if ( isset( $item['fromEmail'] ) ) {
328+
$item['fromEmail'] = sanitize_email( $item['fromEmail'] );
329+
}
327330
if ( isset( $item['cc'] ) ) {
328331
$item['cc'] = sanitize_text_field( $item['cc'] );
329332
}
@@ -389,6 +392,9 @@ function ( $item ) {
389392
'fromName' => array(
390393
'type' => 'string',
391394
),
395+
'fromEmail' => array(
396+
'type' => 'string',
397+
),
392398
'redirectLink' => array(
393399
'type' => 'string',
394400
),

0 commit comments

Comments
 (0)