??????????????
??????????????
??????????????
??????????????
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/store/setInitialState.js
⬅ Kembali
import apiFetch from '@wordpress/api-fetch';
import { dispatch } from '@wordpress/data';
import { addQueryArgs } from '@wordpress/url';
import { store } from './store';
import { EDITOR_URL } from '@Global/constants/api';
const setInitialState = () => {
const queryParams = {};
// If post page.
if ( window?.surerank_globals?.post_id ) {
queryParams.post_id = window?.surerank_globals.post_id;
}
// If term page.
if ( window?.surerank_globals?.term_id ) {
queryParams.term_id = window?.surerank_globals.term_id;
}
if ( window?.surerank_seo_popup?.post_id ) {
queryParams.post_id = window?.surerank_seo_popup.post_id;
}
// If term page.
if ( window?.surerank_seo_popup?.term_id ) {
queryParams.term_id = window?.surerank_seo_popup.term_id;
}
// If user profile page.
if ( window?.surerank_seo_popup?.user_id ) {
queryParams.user_id = window?.surerank_seo_popup.user_id;
}
// If no post, term or user id, return.
if (
! queryParams?.post_id &&
! queryParams?.term_id &&
! queryParams?.user_id
) {
return;
}
apiFetch( {
path: addQueryArgs( EDITOR_URL, queryParams ),
} ).then( ( response ) => {
if ( response?.success ) {
let initialState = {
variables: response.variables,
};
if ( response.other ) {
initialState = { ...initialState, ...response.other };
}
dispatch( store ).updateInitialState( initialState );
}
} );
};
export default setInitialState;
Nama
Tipe
Ukuran
Diubah
Aksi
📜 action-types.js
js
829 B
2026-04-30 14:55
📜 actions.js
js
15.8 KB
2026-06-17 16:29
📜 constants.js
js
38 B
2025-04-16 21:01
📜 controls.js
js
163 B
2025-07-08 15:26
📜 reducer.js
js
6.4 KB
2026-04-30 14:55
📜 resolvers.js
js
3.5 KB
2026-06-17 16:29
📜 selectors.js
js
2.2 KB
2026-04-30 14:55
📜 setInitialState.js
js
1.4 KB
2026-06-17 16:29
📜 store.js
js
1 KB
2025-07-21 08:58