Skip to content

Commit

Permalink
Update Astra theme from 4.8.7 to 4.8.8
Browse files Browse the repository at this point in the history
  • Loading branch information
bitpoke-bot committed Dec 17, 2024
1 parent 883afba commit ab1f055
Show file tree
Hide file tree
Showing 79 changed files with 3,511 additions and 758 deletions.
2,098 changes: 2,098 additions & 0 deletions wp-content/themes/astra/admin/assets/build/dashboard-app-rtl.css

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => '018a8a292b320964c5d4');
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => '6e12b4be15a57c232c38');
161 changes: 78 additions & 83 deletions wp-content/themes/astra/admin/assets/build/dashboard-app.css

Large diffs are not rendered by default.

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions wp-content/themes/astra/admin/assets/hooks/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import useDebounceEffect from "./useDebounceEffect";

export { useDebounceEffect };
25 changes: 25 additions & 0 deletions wp-content/themes/astra/admin/assets/hooks/useDebounceEffect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { useEffect } from 'react';
import { debounce } from '@astra-utils/helpers';

/**
* A hook that wraps a callback function with a debounce effect.
*
* This hook is designed to delay the execution of a function until after a specified delay.
* It's particularly useful for handling events that occur rapidly, such as typing in a text input.
*
* @param {Function} callback - The function to debounce.
* @param {number} delay - The delay in milliseconds before the function is executed.
* @param {Array} dependencies - An array of dependencies that trigger the effect.
*/
function useDebounceEffect( callback, delay, dependencies ) {
useEffect( () => {
const debouncedCallback = debounce( callback, delay );

debouncedCallback();

// Cleanup on unmount or when dependencies change.
return () => debouncedCallback.cancel && debouncedCallback.cancel();
}, [ callback, delay, ...dependencies ] );
}

export default useDebounceEffect;
93 changes: 68 additions & 25 deletions wp-content/themes/astra/admin/assets/utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,31 @@ import apiFetch from '@wordpress/api-fetch';
*/
const classNames = (...classes) => classes.filter(Boolean).join(" ");

/**
* Creates a debounced function that delays its execution until after the specified delay.
*
* The debounce() function can also be used from lodash.debounce package in future.
*
* @param {Function} func - The function to debounce.
* @param {number} delay - The delay in milliseconds before the function is executed.
*
* @returns {Function} A debounced function.
*/
const debounce = ( func, delay ) => {
let timer;
function debounced( ...args ) {
clearTimeout( timer );
timer = setTimeout( () => func( ...args ), delay );
};

// Attach a `cancel` method to clear the timeout.
debounced.cancel = () => {
clearTimeout( timer );
};

return debounced;
};

/**
* Returns the Astra Pro title.
*
Expand Down Expand Up @@ -43,35 +68,53 @@ const getSpinner = () => {
* @param {string} key - Settings key.
* @param {string} value - The data to send.
* @param {Function} dispatch - The dispatch function.
* @param {Object} abortControllerRef - The ref object with to hold abort controller.
*
* @return {void}
* @return {Promise} Returns a promise representing the processed request.
*/
const saveSetting = (key, value, dispatch) => {
const formData = new window.FormData();
const saveSetting = debounce(
(key, value, dispatch, abortControllerRef = { current: {} }) => {
// Abort any previous request.
if (abortControllerRef.current[key]) {
abortControllerRef.current[key]?.abort();
}

formData.append("action", "astra_update_admin_setting");
formData.append("security", astra_admin.update_nonce);
formData.append("key", key);
formData.append("value", value);
// Create a new AbortController.
const abortController = new AbortController();
abortControllerRef.current[key] = abortController;

apiFetch({
url: astra_admin.ajax_url,
method: "POST",
body: formData,
})
.then(() => {
dispatch({
type: "UPDATE_SETTINGS_SAVED_NOTIFICATION",
payload: __("Successfully saved!", "astra"),
});
const formData = new window.FormData();

formData.append("action", "astra_update_admin_setting");
formData.append("security", astra_admin.update_nonce);
formData.append("key", key);
formData.append("value", value);

return apiFetch({
url: astra_admin.ajax_url,
method: "POST",
body: formData,
signal: abortControllerRef.current[key]?.signal, // Pass the signal to the fetch request.
})
.catch((error) => {
console.error("Error during API request:", error);
dispatch({
type: "UPDATE_SETTINGS_SAVED_NOTIFICATION",
payload: __("An error occurred while saving.", "astra"),
.then(() => {
dispatch({
type: "UPDATE_SETTINGS_SAVED_NOTIFICATION",
payload: __("Successfully saved!", "astra"),
});
})
.catch((error) => {
// Ignore if it is intentionally aborted.
if (error.name === "AbortError") {
return;
}
console.error("Error during API request:", error);
dispatch({
type: "UPDATE_SETTINGS_SAVED_NOTIFICATION",
payload: __("An error occurred while saving.", "astra"),
});
});
});
};
},
300
);

export { classNames, getAstraProTitle, getSpinner, saveSetting };
export { classNames, debounce, getAstraProTitle, getSpinner, saveSetting };
15 changes: 10 additions & 5 deletions wp-content/themes/astra/admin/includes/class-astra-admin-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,16 @@ public static function get_instance() {
* @since 4.0.0
*/
public function __construct() {
$this->errors = array(
'permission' => esc_html__( 'Sorry, you are not allowed to do this operation.', 'astra' ),
'nonce' => esc_html__( 'Nonce validation failed', 'astra' ),
'default' => esc_html__( 'Sorry, something went wrong.', 'astra' ),
'invalid' => esc_html__( 'No post data found!', 'astra' ),
add_action(
'init',
function() {
$this->errors = array(
'permission' => esc_html__( 'Sorry, you are not allowed to do this operation.', 'astra' ),
'nonce' => esc_html__( 'Nonce validation failed', 'astra' ),
'default' => esc_html__( 'Sorry, something went wrong.', 'astra' ),
'invalid' => esc_html__( 'No post data found!', 'astra' ),
);
}
);

add_action( 'wp_ajax_ast_disable_pro_notices', array( $this, 'disable_astra_pro_notices' ) );
Expand Down
4 changes: 2 additions & 2 deletions wp-content/themes/astra/admin/includes/class-astra-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ public function __construct() {
* @return void
*/
public function initialize_hooks() {

self::$page_title = apply_filters( 'astra_page_title', esc_html__( 'Astra', 'astra' ) );
self::$plugin_slug = self::get_theme_page_slug();

add_action( 'admin_menu', array( $this, 'setup_menu' ) );
Expand Down Expand Up @@ -162,6 +160,8 @@ public function setup_menu() {
return;
}

self::$page_title = apply_filters( 'astra_page_title', esc_html__( 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OTMgNTM2LjE5NiA0ODcuOTA2IDUyMi4wMzEgNDgxLjcxMyA1MDcuNzczSDM4NkwzODcuODc3IDUwNC4wNjlDNDA0LjIwNSA0NzAuNzM4IDQyMC40MzkgNDM3LjQwNiA0MzYuNjczIDQwNC4wNzVaIiBmaWxsPSIjYTdhYWFkIi8+DQo8L3N2Zz4=' );
$priority = apply_filters( 'astra_menu_priority', 59 );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public function theme_builder_admin_enqueue_scripts() {
);

wp_localize_script( 'astra-theme-builder-script', 'astra_theme_builder', $localized_data );
wp_set_script_translations( 'astra-theme-builder-script', 'astra' );
}

/**
Expand Down
5 changes: 4 additions & 1 deletion wp-content/themes/astra/admin/jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
"compilerOptions": {
"baseUrl": ".", // This makes the root directory of your project the base for relative paths
"paths": {
"@astra-utils/*": [ "assets/utils/*" ],
"@astra-hooks": [ "assets/hooks/index.js" ],
"@astra-hooks/*": [ "assets/hooks/*" ],
"@astra-components": [ "assets/components/index.js" ],
"@astra-components/*": [ "assets/components/*" ],
"@astra-utils/*": [ "assets/utils/*" ],
"@DashboardApp/*": [ "assets/src/dashboard-app/*" ],
"@Admin/*": [ "assets/src/*" ],
"@Utils/*": [ "assets/src/utils/*" ],
Expand Down
Loading

0 comments on commit ab1f055

Please sign in to comment.