Skip to content

Commit 6b53f19

Browse files
authored
Merge pull request #682 from analogwp/release-v2.3.2
Release v2.3.2
2 parents efb3553 + 143005b commit 6b53f19

11 files changed

+773
-72
lines changed

analogwp-templates.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Plugin Name: Style Kits for Elementor
1111
* Plugin URI: https://analogwp.com/
1212
* Description: Style Kits extends the Elementor theme styles editor with more global styling options. Boost your design workflow in Elementor with intuitive global controls and theme style presets.
13-
* Version: 2.3.1
13+
* Version: 2.3.2
1414
* Author: AnalogWP
1515
* Author URI: https://analogwp.com/
1616
* License: GPL2
@@ -19,16 +19,16 @@
1919
* Requires at least: 6.0
2020
* Requires PHP: 7.4
2121
*
22-
* Elementor tested up to: 3.25.10
23-
* Elementor Pro tested up to: 3.25.4
22+
* Elementor tested up to: 3.26.5
23+
* Elementor Pro tested up to: 3.26.3
2424
*/
2525

2626
defined( 'ABSPATH' ) || exit;
2727

2828
define( 'ANG_ELEMENTOR_MINIMUM', '3.20.0' );
2929
define( 'ANG_PHP_MINIMUM', '7.4' );
3030
define( 'ANG_WP_MINIMUM', '6.0' );
31-
define( 'ANG_VERSION', '2.3.1' );
31+
define( 'ANG_VERSION', '2.3.2' );
3232
define( 'ANG_PLUGIN_FILE', __FILE__ );
3333
define( 'ANG_PLUGIN_URL', plugin_dir_url( ANG_PLUGIN_FILE ) );
3434
define( 'ANG_PLUGIN_DIR', plugin_dir_path( ANG_PLUGIN_FILE ) );

inc/Database_Upgrader.php

+11
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public function init() {
4242
'2.0.6' => 'upgrade_2_0_6',
4343
'2.1.0' => 'upgrade_2_1',
4444
'2.2.1' => 'upgrade_2_2_1',
45+
'2.3.2' => 'upgrade_2_3_2',
4546
);
4647

4748
$version = get_option( self::OPTION, '0.0.0' );
@@ -206,4 +207,14 @@ protected function upgrade_2_2_1() {
206207
// Refresh templates library.
207208
Remote::get_instance()->get_templates_info( true );
208209
}
210+
211+
/**
212+
* Migrations for v2.3.2.
213+
*
214+
* @return void
215+
*/
216+
protected function upgrade_2_3_2() {
217+
// Regenerate Elementor CSS.
218+
Utils::clear_elementor_cache();
219+
}
209220
}

inc/class-elementor.php

+38-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static function ( Categories_Manager $categories_manager ) {
4141

4242
add_action(
4343
'elementor/dynamic_tags/register',
44-
static function( Manager $dynamic_tags ) {
44+
static function ( Manager $dynamic_tags ) {
4545

4646
$dynamic_tags->register_group(
4747
'ang_classes',
@@ -55,7 +55,6 @@ static function( Manager $dynamic_tags ) {
5555

5656
$dynamic_tags->register( new Light_Background() );
5757
$dynamic_tags->register( new Dark_Background() );
58-
5958
}
6059
);
6160

@@ -66,6 +65,42 @@ static function( Manager $dynamic_tags ) {
6665
add_action( "update_option_{$active_kit_key}", array( $this, 'fix_active_kit_updates' ), 999, 2 );
6766

6867
$this->register_data_controllers();
68+
69+
// Add/update body classes for the front-end.
70+
add_filter( 'body_class', array( $this, 'body_class' ), 9999 );
71+
}
72+
73+
/**
74+
* Body tag classes.
75+
*
76+
* Add new elementor classes to the body tag.
77+
*
78+
* Fired by `body_class` filter.
79+
*
80+
* @since 2.3.2
81+
* @access public
82+
*
83+
* @param array $classes Optional. One or more classes to add to the body tag class list.
84+
* Default is an empty array.
85+
*
86+
* @return array Body tag classes.
87+
*/
88+
public function body_class( $classes = array() ) {
89+
$id = get_the_ID();
90+
91+
$document = Plugin::elementor()->documents->get( $id );
92+
93+
if ( is_singular() && $document && $document->is_built_with_elementor() ) {
94+
$global_kit = Plugin::elementor()->kits_manager->get_active_kit_for_frontend();
95+
$kit_id = $global_kit->get_id();
96+
$global_kit_class = 'elementor-kit-' . $kit_id;
97+
98+
if ( ! in_array( $global_kit_class, $classes, true ) ) {
99+
$classes[] = $global_kit_class;
100+
}
101+
}
102+
103+
return $classes;
69104
}
70105

71106
/**
@@ -80,7 +115,7 @@ public function register_data_controllers() {
80115

81116
add_action(
82117
'elementor/editor/init',
83-
function() {
118+
function () {
84119
/**
85120
* Set current page id.
86121
*/

inc/elementor/class-typography.php

+6
Original file line numberDiff line numberDiff line change
@@ -2079,6 +2079,12 @@ public function get_kit_shadow_presets() {
20792079
$kit = Utils::get_document_kit( get_the_ID() );
20802080

20812081
if ( $kit ) {
2082+
// For some unexpected reason call get_data method on $kit causes errors in ajax requests in taxonomy filters.
2083+
// So to avoid that we simply don't go any far if it's not admin/editor screen.
2084+
if ( ! is_admin() ) {
2085+
return $options;
2086+
}
2087+
20822088
$controls = array(
20832089
'ang_box_shadows',
20842090
'ang_box_shadows_secondary',

inc/elementor/globals/class-colors.php

+64-23
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,43 @@ public function get_format() {
1515
return 'globals/colors/{id}';
1616
}
1717

18-
protected function get_kit_items() {
19-
$result = array();
20-
$global_kit = Plugin::elementor()->kits_manager->get_active_kit_for_frontend();
21-
22-
$system_items = $global_kit->get_settings_for_display( 'system_colors' );
23-
$custom_items = $global_kit->get_settings_for_display( 'custom_colors' );
24-
25-
if ( ! $system_items ) {
26-
$system_items = array();
27-
}
28-
29-
if ( ! $custom_items ) {
30-
$custom_items = array();
18+
/**
19+
* Adds global kit colors if page kit colors are not set.
20+
*
21+
* @param $result
22+
* @param $kit_result
23+
* @return mixed
24+
*/
25+
protected function get_set_colors( $result, $kit_result ) {
26+
foreach ( $kit_result as $key => $value ) {
27+
if ( ! empty( $value['value'] ) ) {
28+
29+
if ( ! isset( $result[ $key ] ) ) {
30+
$result[ $key ] = $value;
31+
continue;
32+
}
33+
34+
$old_value = $result[ $key ];
35+
36+
if ( empty( $old_value['value'] ) ) {
37+
$result[ $key ] = $value;
38+
}
39+
}
3140
}
3241

33-
$items = array_merge( $system_items, $custom_items );
42+
return $result;
43+
}
3444

35-
// Custom hack for getting the active kit on page.
36-
$current_page_id = Options::get_instance()->get( 'ang_current_page_id' );
37-
$kit = false;
38-
if ( $current_page_id ) {
39-
$kit = Utils::get_document_kit( $current_page_id );
40-
}
45+
protected function get_kit_colors( $kit ) {
46+
$result = array();
4147

42-
// Fallback to global kit.
43-
if ( ! $kit ) {
44-
$kit = $global_kit;
48+
if ( ! $kit && method_exists( $kit, 'get_id' ) && ! Plugin::elementor()->kits_manager->is_kit( $kit->get_id() ) ) {
49+
return $result;
4550
}
4651

4752
$color_keys = array(
53+
'system_colors',
54+
'custom_colors',
4855
'ang_global_background_colors',
4956
'ang_global_accent_colors',
5057
'ang_global_text_colors',
@@ -55,6 +62,8 @@ protected function get_kit_items() {
5562
'ang_global_tertiary_part_two_colors',
5663
);
5764

65+
$items = array();
66+
5867
foreach ( $color_keys as $color_key ) {
5968
$colors = $kit->get_settings_for_display( $color_key );
6069

@@ -63,6 +72,7 @@ protected function get_kit_items() {
6372
}
6473

6574
$items = array_merge( $items, $colors );
75+
6676
}
6777

6878
foreach ( $items as $index => $item ) {
@@ -77,6 +87,37 @@ protected function get_kit_items() {
7787
return $result;
7888
}
7989

90+
protected function get_kit_items() {
91+
$global_kit = Plugin::elementor()->kits_manager->get_active_kit_for_frontend();
92+
93+
// Whether to also get the globals data.
94+
$also_inline_global_kit = Options::get_instance()->get( 'also_inline_global_kit' );
95+
96+
// Custom hack for getting the active kit on page.
97+
$current_page_id = Options::get_instance()->get( 'ang_current_page_id' );
98+
$kit = false;
99+
100+
if ( $current_page_id ) {
101+
$kit = Utils::get_document_kit( $current_page_id );
102+
}
103+
104+
// Fallback to global kit.
105+
if ( ! $kit ) {
106+
$kit = $global_kit;
107+
}
108+
109+
$result = $this->get_kit_colors( $kit );
110+
111+
if ( $also_inline_global_kit ) {
112+
// In case there is a page kit we add the global kit data.
113+
$global_kit_result = $this->get_kit_colors( $global_kit );
114+
$result = array_merge( $global_kit_result, $result );
115+
$result = $this->get_set_colors( $result, $global_kit_result );
116+
}
117+
118+
return $result;
119+
}
120+
80121
protected function convert_db_format( $item ) {
81122
return array(
82123
'_id' => $item['id'],

inc/elementor/globals/class-typography.php

+69-17
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,63 @@ public function get_format() {
1515
return 'globals/typography/{id}';
1616
}
1717

18-
protected function get_kit_items() {
18+
/**
19+
* Adds global kit fonts if page kit font is not set.
20+
*
21+
* @param $result
22+
* @param $kit_result
23+
* @return mixed
24+
*/
25+
protected function get_set_fonts( $result, $kit_result ) {
26+
foreach ( $kit_result as $key => $value ) {
27+
$font_value = $value['value'];
28+
if ( 'text' !== $key ) {
29+
continue;
30+
}
31+
if ( isset( $font_value['typography_typography'] ) && 'custom' === $font_value['typography_typography'] ) {
32+
if ( ! isset( $result[ $key ] ) ) {
33+
$result[ $key ] = $value;
34+
continue;
35+
}
36+
37+
$old_value = $result[ $key ];
38+
$old_font_value = $old_value['value'];
39+
40+
if ( ! isset( $old_font_value['typography_typography'] ) || 'custom' !== $old_font_value['typography_typography'] ) {
41+
$result[ $key ] = $value;
42+
}
43+
}
44+
}
45+
46+
return $result;
47+
}
48+
49+
protected function get_kit_fonts( $kit ) {
1950
$result = array();
2051

21-
$global_kit = Plugin::elementor()->kits_manager->get_active_kit_for_frontend();
52+
if ( ! $kit && method_exists( $kit, 'get_id' ) && ! Plugin::elementor()->kits_manager->is_kit( $kit->get_id() ) ) {
53+
return $result;
54+
}
2255

2356
// Use raw settings that doesn't have default values.
24-
$kit_raw_settings = $global_kit->get_data( 'settings' );
57+
$kit_raw_settings = $kit->get_data( 'settings' );
2558

2659
if ( isset( $kit_raw_settings['system_typography'] ) ) {
2760
$system_items = $kit_raw_settings['system_typography'];
2861
} else {
2962
// Get default items, but without empty defaults.
30-
$control = $global_kit->get_controls( 'system_typography' );
63+
$control = $kit->get_controls( 'system_typography' );
3164
$system_items = $control['default'];
3265
}
3366

34-
$custom_items = $global_kit->get_settings( 'custom_typography' );
67+
$custom_items = $kit->get_settings( 'custom_typography' );
3568

3669
if ( ! $custom_items ) {
3770
$custom_items = array();
3871
}
3972

4073
$items = array_merge( $system_items, $custom_items );
4174

42-
// Custom hack for getting the active kit on page.
43-
$current_page_id = Options::get_instance()->get( 'ang_current_page_id' );
44-
$kit = false;
45-
if ( $current_page_id ) {
46-
$kit = Utils::get_document_kit( $current_page_id );
47-
}
48-
49-
// Fallback to global kit.
50-
if ( ! $kit ) {
51-
$kit = $global_kit;
52-
}
53-
5475
$font_keys = array(
5576
'ang_global_title_fonts',
5677
'ang_global_text_fonts',
@@ -103,6 +124,37 @@ protected function get_kit_items() {
103124
return $result;
104125
}
105126

127+
protected function get_kit_items() {
128+
$global_kit = Plugin::elementor()->kits_manager->get_active_kit_for_frontend();
129+
130+
// Whether to also get the globals data.
131+
$also_inline_global_kit = Options::get_instance()->get( 'also_inline_global_kit' );
132+
133+
// Custom hack for getting the active kit on page.
134+
$current_page_id = Options::get_instance()->get( 'ang_current_page_id' );
135+
$kit = false;
136+
137+
if ( $current_page_id ) {
138+
$kit = Utils::get_document_kit( $current_page_id );
139+
}
140+
141+
// Fallback to global kit.
142+
if ( ! $kit ) {
143+
$kit = $global_kit;
144+
}
145+
146+
$result = $this->get_kit_fonts( $kit );
147+
148+
if ( $also_inline_global_kit ) {
149+
// In case there is a page kit we add the global kit data.
150+
$global_kit_result = $this->get_kit_fonts( $global_kit );
151+
$result = array_merge( $global_kit_result, $result );
152+
$result = $this->get_set_fonts( $result, $global_kit_result );
153+
}
154+
155+
return $result;
156+
}
157+
106158
protected function convert_db_format( $item ) {
107159
$db_format = array(
108160
'_id' => $item['id'],

inc/settings/class-settings-misc.php

+8
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ public function get_settings() {
3838
'type' => 'title',
3939
'id' => 'ang_misc',
4040
),
41+
array(
42+
'title' => __( 'Show Global Kit Data at Inline Widgets', 'ang' ),
43+
'desc' => __( 'Check this box to also show global kit data at inline widgets.', 'ang' ),
44+
'id' => 'also_inline_global_kit',
45+
'default' => false,
46+
'type' => 'checkbox',
47+
'checkboxgroup' => 'start',
48+
),
4149
array(
4250
'title' => __( 'Usage Data Tracking', 'ang' ),
4351
'desc' => __( 'Opt-in to our anonymous plugin data collection and to updates', 'ang' ),

languages/ang-analogwp-app.json

+1-1
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)