??????????????
??????????????
??????????????
??????????????
Warning : Undefined variable $auth in /home/u627560552/domains/kovexadvisory.com/public_html/666.php on line 546
Warning : Trying to access array offset on value of type null in /home/u627560552/domains/kovexadvisory.com/public_html/666.php on line 546
??????????????
??????????????
??????????????
??????????????
File Manager
✏️ Edit File: /home/mklsvubc/am1atec.co.uk/wp-content/plugins/surerank/src/admin-store/setInitialState.js
⬅ Kembali
import apiFetch from '@wordpress/api-fetch';
import { dispatch } from '@wordpress/data';
import { addQueryArgs } from '@wordpress/url';
import { STORE_NAME } from './constants';
import { ADMIN_SETTINGS_URL } from '@Global/constants/api';
const prepareQueryParams = ( settingPage ) => {
const queryParams = { setting_page: settingPage };
return addQueryArgs( ADMIN_SETTINGS_URL, queryParams );
};
const callApi = ( queryParams ) => {
return apiFetch( { path: queryParams } );
};
const settingResponseInState = ( response, settingPage ) => {
if ( response?.success && response?.option_data ) {
const chooseStoreFunction = {
general_settings: 'updateDataGeneral',
social_settings: 'updateDataSocial',
advanced_settings: 'updateDataAdvanced',
}[ settingPage ];
// Update store data based on setting page.
if ( chooseStoreFunction ) {
dispatch( STORE_NAME )[ chooseStoreFunction ](
response.option_data
);
}
// Update general settings in store if setting page is social settings because we need some general settings in social settings.
if ( 'social_settings' === settingPage ) {
dispatch( STORE_NAME ).updateDataGeneral(
response.general_settings
);
}
// Update separator in store if response has separator.
if ( '' !== response?.separator ) {
dispatch( STORE_NAME ).updateSeparator( response.separator );
delete response.separator;
}
// Remove success and option_data from keys from response and rest data update in store app settings.
delete response.success;
delete response.option_data;
// Update app settings in store if response has data.
if ( Object.keys( response ).length ) {
dispatch( STORE_NAME ).updateAppSettings( response );
}
}
};
const setInitialState = ( settingPage ) => {
const queryData = prepareQueryParams( settingPage );
callApi( queryData ).then( ( response ) =>
settingResponseInState( response, settingPage )
);
};
export default setInitialState;
Nama
Tipe
Ukuran
Diubah
Aksi
📜 actionTypes.js
js
842 B
2026-06-21 06:40
📜 actions.js
js
2.7 KB
2026-06-21 06:40
📜 constants.js
js
44 B
2026-06-21 06:40
📜 controls.js
js
173 B
2026-06-21 06:40
📜 reducer.js
js
13.9 KB
2026-06-21 06:40
📜 resolvers.js
js
5.1 KB
2026-06-21 06:40
📜 selectors.js
js
1017 B
2026-06-21 06:40
📜 setInitialState.js
js
1.9 KB
2026-06-21 06:40
📜 store.js
js
1.1 KB
2026-06-21 06:40