??????????????
??????????????
??????????????
??????????????
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/mayshine.co.uk/wp-content/plugins/surerank/src/store/resolvers.js
⬅ Kembali
import { select } from '@wordpress/data';
import { STORE_NAME } from './constants';
import { addQueryArgs } from '@wordpress/url';
import {
fetchFromAPI,
setPageSeoChecksByIdAndType,
setCurrentPostIgnoredList,
setBatchPageSeoChecks,
} from './actions';
import { __ } from '@wordpress/i18n';
import { toast } from '@bsf/force-ui';
export function* getCurrentPostIgnoredList() {
// Do NOT yield on select here; it's a synchronous read from the store.
const state = yield select( STORE_NAME ).getState();
// Try multiple sources for postId (state first, then window globals)
const postId =
state.pageSeoChecks?.postId ||
state.variables?.post?.ID?.value ||
state.variables?.term?.ID?.value ||
state.variables?.user?.ID?.value ||
window?.surerank_seo_popup?.post_id ||
window?.surerank_seo_popup?.term_id ||
window?.surerank_seo_popup?.user_id ||
window?.surerank_globals?.post_id ||
window?.surerank_globals?.term_id;
// Determine check type from multiple sources
let fallbackCheckType = 'post';
if ( window?.surerank_seo_popup?.is_user ) {
fallbackCheckType = 'user';
} else if ( window?.surerank_seo_popup?.is_taxonomy === '1' ) {
fallbackCheckType = 'taxonomy';
}
const checkType = state.pageSeoChecks?.checkType || fallbackCheckType;
// If we don't yet have a postId or checkType, defer resolution.
if ( ! postId || ! checkType ) {
return [];
}
try {
const ignoredChecks = yield fetchFromAPI( {
path: addQueryArgs( 'surerank/v1/checks/ignore-page-check', {
post_id: postId,
check_type: checkType,
} ),
method: 'GET',
} );
yield setCurrentPostIgnoredList( ignoredChecks?.checks || [] );
} catch ( error ) {
// Silently handle errors by setting an empty list
yield setCurrentPostIgnoredList( [] );
}
}
export function* getSeoBarChecks( postIds, postType, forceRefresh = null ) {
if ( ! postIds || ! postType ) {
return {};
}
const ids = Array.isArray( postIds ) ? postIds : [ postIds ];
const state = select( STORE_NAME ).getState();
let idsToFetch = ids;
if ( ! forceRefresh ) {
idsToFetch = ids.filter( ( id ) => {
const existingData = state.pageSeoChecks?.[ id ]?.checks;
return ! existingData;
} );
}
if ( idsToFetch.length === 0 ) {
return;
}
try {
yield fetchSeoBarChecks( idsToFetch, postType, forceRefresh );
} catch ( error ) {
const errorMessage =
error?.message || __( 'Error loading SEO checks', 'surerank' );
// For single ID calls, set error. For batch, we might want to set error for all?
// Keeping it simple for now as per previous logic.
if ( ! Array.isArray( postIds ) ) {
yield setPageSeoChecksByIdAndType(
postIds,
postType,
[],
errorMessage
);
}
}
}
export function* fetchSeoBarChecks( ids, type, forceRefresh = false ) {
if ( ! ids || ! ids.length ) {
return;
}
let endpoint = '/surerank/v1/checks/page';
let queryArg = 'post_ids';
if ( type === 'taxonomy' ) {
endpoint = '/surerank/v1/checks/taxonomy';
queryArg = 'term_ids';
} else if ( type === 'user' ) {
endpoint = '/surerank/v1/checks/user';
queryArg = 'user_ids';
}
const cacheBuster = forceRefresh ? `&_t=${ forceRefresh }` : '';
try {
const response = yield fetchFromAPI( {
path:
addQueryArgs( endpoint, {
[ queryArg ]: ids,
} ) + cacheBuster,
method: 'GET',
} );
if ( response?.status !== 'success' || ! response?.data ) {
throw response;
}
yield setBatchPageSeoChecks( response.data, type );
} catch ( error ) {
toast( {
message:
error?.message || __( 'Error loading SEO checks', 'surerank' ),
type: 'error',
} );
}
}
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