Skip to content

Commit 00eb5d6

Browse files
committed
Update Astra theme from 4.12.1 to 4.12.3
1 parent aebdf82 commit 00eb5d6

48 files changed

Lines changed: 435 additions & 386 deletions

Some content is hidden

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

wp-content/themes/astra/admin/assets/build/dashboard-app-rtl.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-element', 'wp-i18n'), 'version' => '32eda592bb7f43fa9b1f');
1+
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-element', 'wp-i18n'), 'version' => '611f111aba2b4fa50e69');

wp-content/themes/astra/admin/assets/build/dashboard-app.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wp-content/themes/astra/admin/assets/build/dashboard-app.js

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

wp-content/themes/astra/admin/class-astra-bsf-analytics.php

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ public function __construct() {
3636

3737
add_action( 'init', array( $this, 'init_bsf_analytics' ), 5 );
3838
add_filter( 'bsf_core_stats', array( $this, 'add_astra_analytics_data' ) );
39+
40+
// Track Astra customizer publish events for kpi tracking.
41+
add_action( 'astra_customizer_save', array( $this, 'maybe_save_customizer_published_timestamp' ) );
3942
}
4043

4144
/**
@@ -173,6 +176,9 @@ public function add_astra_analytics_data( $stats_data ) {
173176
// Add learn progress analytics data.
174177
self::add_learn_progress_analytics_data( $astra_stats );
175178

179+
// Add KPI tracking data.
180+
self::add_kpi_tracking_data( $astra_stats );
181+
176182
$stats_data['plugin_data']['astra'] = array_merge_recursive( $stats_data['plugin_data']['astra'], $astra_stats );
177183

178184
return $stats_data;
@@ -412,6 +418,113 @@ public static function get_hosting_provider( $ip = '', $token = null ) {
412418
return null;
413419
}
414420

421+
/**
422+
* Maybe save customizer published timestamp.
423+
*
424+
* This function checks if Astra customizer settings were modified during the customizer save event.
425+
* If so, it records the current timestamp in the '_astra_customizer_published_timestamps' option for KPI tracking.
426+
*
427+
* @since 4.12.2
428+
* @return void
429+
*/
430+
public function maybe_save_customizer_published_timestamp() {
431+
global $wp_customize;
432+
433+
// Bail if customizer manager not available or no Astra customizer settings modified.
434+
if ( ! $wp_customize || ! self::has_astra_customizer_settings_modified( $wp_customize ) ) {
435+
return;
436+
}
437+
438+
$timestamps = get_option( '_astra_customizer_published_timestamps', array() );
439+
if ( ! is_array( $timestamps ) ) {
440+
$timestamps = array();
441+
}
442+
443+
$timestamps[] = time();
444+
update_option( '_astra_customizer_published_timestamps', $timestamps, false );
445+
}
446+
447+
/**
448+
* Check if any Astra-specific settings were modified in the customizer.
449+
*
450+
* @param WP_Customize_Manager $wp_customize The customizer manager instance.
451+
*
452+
* @since 4.12.2
453+
* @return bool True if Astra customizer settings were modified, false otherwise.
454+
*/
455+
public static function has_astra_customizer_settings_modified( $wp_customize ) {
456+
$posted_values = $wp_customize->unsanitized_post_values();
457+
458+
// Check if any setting key starts with 'astra-' to identify Astra customizer settings.
459+
foreach ( $posted_values as $setting_id => $setting_value ) {
460+
if ( strpos( $setting_id, 'astra-' ) === 0 ) {
461+
return true;
462+
}
463+
}
464+
465+
return false;
466+
}
467+
468+
/**
469+
* Add KPI tracking data.
470+
*
471+
* @param array $astra_stats Reference to the astra stats data.
472+
* @since 4.12.2
473+
* @return void
474+
*/
475+
public static function add_kpi_tracking_data( &$astra_stats ) {
476+
$timestamps = get_option( '_astra_customizer_published_timestamps', array() );
477+
if ( empty( $timestamps ) || ! is_array( $timestamps ) ) {
478+
return;
479+
}
480+
481+
// Get today's date for comparison.
482+
$today = gmdate( 'Y-m-d' );
483+
484+
// Group timestamps by date and count occurrences, excluding today's data.
485+
$kpi_data = array();
486+
$timestamps_to_cleanup = array();
487+
488+
foreach ( $timestamps as $timestamp ) {
489+
// Skip invalid timestamps.
490+
if ( ! is_numeric( $timestamp ) ) {
491+
continue;
492+
}
493+
494+
$date = gmdate( 'Y-m-d', (int) $timestamp );
495+
496+
// Skip today's data as we may have incomplete data for the current day.
497+
if ( $date === $today ) {
498+
continue;
499+
}
500+
501+
// Count occurrences by date.
502+
if ( ! isset( $kpi_data[ $date ] ) ) {
503+
$kpi_data[ $date ] = array(
504+
'numeric_values' => array(
505+
'customizer_published' => 0,
506+
),
507+
);
508+
}
509+
$kpi_data[ $date ]['numeric_values']['customizer_published']++;
510+
511+
// Mark this timestamp for cleanup (all timestamps except today's).
512+
$timestamps_to_cleanup[] = $timestamp;
513+
}
514+
515+
// Only add to stats if we have data to report.
516+
if ( ! empty( $kpi_data ) ) {
517+
$astra_stats['kpi_records'] = $kpi_data;
518+
}
519+
520+
// Cleanup old timestamps that are being sent to analytics.
521+
// Keep only today's timestamps in the option.
522+
if ( ! empty( $timestamps_to_cleanup ) ) {
523+
$remaining_timestamps = array_diff( $timestamps, $timestamps_to_cleanup );
524+
update_option( '_astra_customizer_published_timestamps', array_values( $remaining_timestamps ), false );
525+
}
526+
}
527+
415528
/**
416529
* Initiator.
417530
*

wp-content/themes/astra/admin/includes/class-astra-admin-ajax.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ public function astra_analytics_optin_status() {
265265
}
266266

267267
$opt_in = filter_input( INPUT_POST, 'value', FILTER_VALIDATE_BOOLEAN ) ? 'yes' : 'no';
268-
update_site_option( 'astra_analytics_optin', $opt_in );
268+
update_site_option( 'astra_usage_optin', $opt_in );
269269

270270
$response_data = array(
271271
'message' => esc_html__( 'Successfully saved data!', 'astra' ),

wp-content/themes/astra/admin/includes/class-astra-api-init.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public function get_admin_settings( $request ) {
165165
'preload_local_fonts' => self::get_admin_settings_option( 'preload_local_fonts', false ),
166166
'use_old_header_footer' => astra_get_option( 'is-header-footer-builder', false ),
167167
'use_upgrade_notices' => astra_showcase_upgrade_notices(),
168-
'analytics_enabled' => get_option( 'astra_analytics_optin', 'no' ) === 'yes',
168+
'analytics_enabled' => get_option( 'astra_usage_optin', 'no' ) === 'yes',
169169
)
170170
);
171171

wp-content/themes/astra/admin/includes/class-astra-learn.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,35 @@ public static function get_chapters_structure() {
340340
return apply_filters( 'astra_learn_chapters', $chapters );
341341
}
342342

343+
/**
344+
* Get count of incomplete chapters.
345+
*
346+
* A chapter is considered incomplete if it has at least one incomplete step.
347+
*
348+
* @param int $user_id Optional. User ID to get progress for. Defaults to current user.
349+
* @return int Number of incomplete chapters.
350+
* @since 4.12.2
351+
*/
352+
public static function get_incomplete_chapters_count( $user_id = 0 ) {
353+
$chapters = self::get_learn_chapters( $user_id );
354+
$incomplete_count = 0;
355+
356+
foreach ( $chapters as $chapter ) {
357+
if ( ! isset( $chapter['steps'] ) || ! is_array( $chapter['steps'] ) ) {
358+
continue;
359+
}
360+
361+
foreach ( $chapter['steps'] as $step ) {
362+
if ( empty( $step['completed'] ) ) {
363+
$incomplete_count++;
364+
break;
365+
}
366+
}
367+
}
368+
369+
return $incomplete_count;
370+
}
371+
343372
/**
344373
* Get learn chapters with user progress merged.
345374
*

wp-content/themes/astra/admin/includes/class-astra-menu.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,32 @@ public function setup_menu() {
211211
$capability,
212212
'admin.php?page=' . self::$plugin_slug . '&path=woocommerce'
213213
);
214-
} elseif ( ASTRA_THEME_ORG_VERSION && ! $this->spectra_has_top_level_menu() ) {
214+
}
215+
// elseif ( ASTRA_THEME_ORG_VERSION && ! $this->spectra_has_top_level_menu() ) {
216+
// add_submenu_page( // phpcs:ignore WPThemeReview.PluginTerritory.NoAddAdminPages.add_menu_pages_add_submenu_page -- Taken the menu on top level
217+
// self::$plugin_slug,
218+
// 'Spectra',
219+
// 'Spectra',
220+
// $capability,
221+
// $this->get_spectra_page_admin_link()
222+
// );
223+
// }
224+
}
225+
226+
if ( is_callable( 'Astra_Learn::get_incomplete_chapters_count' ) ) {
227+
$incomplete_count = Astra_Learn::get_incomplete_chapters_count();
228+
if ( $incomplete_count > 0 ) {
229+
$learn_menu_title = __( 'Learn', 'astra' ) . sprintf(
230+
' <span class="awaiting-mod count-%1$d"><span class="pending-count">%1$d</span></span>',
231+
$incomplete_count
232+
);
233+
215234
add_submenu_page( // phpcs:ignore WPThemeReview.PluginTerritory.NoAddAdminPages.add_menu_pages_add_submenu_page -- Taken the menu on top level
216235
self::$plugin_slug,
217-
'Spectra',
218-
'Spectra',
236+
__( 'Learn', 'astra' ),
237+
$learn_menu_title,
219238
$capability,
220-
$this->get_spectra_page_admin_link()
239+
'admin.php?page=' . self::$plugin_slug . '&path=learn'
221240
);
222241
}
223242
}

wp-content/themes/astra/assets/css/minified/command-palette.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)