/home/techb158/public_html/wp-content/plugins/kirki/includes
Edit: /home/techb158/public_html/wp-content/plugins/kirki/includes/Ajax.php (25263B)
user_can_access_get_apis()) {
wp_send_json_error('Not authorized');
}
//phpcs:ignore WordPress.Security.NonceVerification.Missing,WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.MissingUnslash,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$endpoint = HelperFunctions::sanitize_text(isset($_GET['endpoint']) ? $_GET['endpoint'] : null);
/**
* PAGE APIS
* @deprecated
* @see GET /pages/{page_id}
*/
// if ($endpoint === 'get-page-data') {
// Page::get_page_blocks_and_styles();
// }
/**
* @deprecated
* @see GET /wp-posts/{post_id}
*/
// if ($endpoint === 'get-wp-single-post') {
// if (!HelperFunctions::has_access(KIRKI_ACCESS_LEVELS['FULL_ACCESS'])) {
// wp_send_json_error('Not authorized', 401);
// }
// $post_id = (int) HelperFunctions::sanitize_text(isset($_GET['post_id']) ? $_GET['post_id'] : null);
// $post = get_post($post_id);
// if (!$post) {
// wp_send_json_error('Post not found');
// }
// wp_send_json_success($post);
// }
/**
* @deprecated
* @see GET /pages
*/
if ($endpoint === 'get-pages-list') {
Page::fetch_list_api();
}
/**
* @deprecated
* @see GET /page-panel-pages
*/
if ($endpoint === 'get-pages-for-pages-panel') {
Page::get_pages_for_pages_panel();
}
/**
* @deprecated
* @see GET /data-list-for-template-edit-search-flyout
*/
// if ($endpoint === 'get-data-list-for-template-edit-search-flyout') {
// Page::get_data_list_for_template_edit_search_flyout();
// }
if ($endpoint === 'get-posts-list') {
Page::fetch_post_list_data_post_type_wise();
}
/**
* @deprecated
* @see GET /current-page/{page_id}
*/
// if ($endpoint === 'get-current-page-data') {
// Page::get_current_page_data();
// }
if ($endpoint === 'get-unused-class-info-from-db') {
Page::get_unused_class_info_from_db();
}
/**
* @deprecated
* @see GET /validate-wp-post-slug
*/
// if ($endpoint === 'validate-wp-post-slug') {
// Page::validate_wp_post_slug();
// }
/**
* USER DATA APIS
* @deprecated
* @see GET /global-ui-controller
*/
// if ( $endpoint === 'get-user-controller' ) {
// UserData::get_user_controller();
// }
/**
* @deprecated
* @see GET /is-user-logged-in
*/
// if ( $endpoint === 'is-user-logged-in' ) {
// UserData::check_user_login();
// }
/**
* USER DATA APIS
* @deprecated
* @see GET /global-ui-saved-data
*/
// if ( $endpoint === 'get-user-saved-data' ) {
// UserData::get_user_saved_data();
// }
/**
* USER DATA APIS
* @deprecated
* @see GET /app-list
*/
// if ( $endpoint === 'get-app-list' ) {
// Apps::get_app_list();
// }
/**
* USER DATA APIS
* @deprecated
* @see GET /installed-app-list
*/
// if ( $endpoint === 'get-installed-app-list' ) {
// Apps::get_installed_apps_list();
// }
/**
* USER DATA APIS
* @deprecated
* @see GET /app-settings
*/
// if ( $endpoint === 'get-app-settings-using-slug' ) {
// Apps::get_app_settings_using_slug();
// }
/**
* @deprecated
* @see GET /global-custom-fonts
*/
// if ( $endpoint === 'get-user-custom-fonts-data' ) {
// UserData::get_user_custom_fonts_data();
// }
/**
* GET SYMBOL LIST API
*/
if ($endpoint === 'get-symbol-list') {
Symbol::fetch_list(false, true);
}
if ($endpoint === 'get-page-custom-section') {
$type = HelperFunctions::sanitize_text(isset($_GET['type']) ? $_GET['type'] : '');
wp_send_json(HelperFunctions::get_page_custom_section($type, true));
}
/**
* GET Single prebuilt html API
*/
if ($endpoint === 'get-pre-built-html') {
if (!HelperFunctions::has_access(KIRKI_ACCESS_LEVELS['FULL_ACCESS'])) {
wp_send_json_error('Not authorized', 401);
}
Symbol::get_pre_built_html_using_url();
}
/**
* GET DYNAMIC CONTENT API
*/
if ($endpoint === 'get-dynamic-content') {
DynamicContent::get_dynamic_element_data();
}
if ($endpoint === 'get-post-terms') {
Taxonomy::get_post_terms();
}
if ($endpoint === 'get-terms') {
Taxonomy::get_terms();
}
if ($endpoint === 'get-post-type-taxonomies') {
Taxonomy::get_post_type_taxonomies();
}
if ($endpoint === 'get-all-terms-by-post-type') {
Taxonomy::get_all_terms_by_post_type();
}
if ($endpoint === 'get_visibility_condition_fields') {
DynamicContent::get_visibility_condition_fields();
}
if ($endpoint === 'get_dynamic_content_fields') {
DynamicContent::get_dynamic_content_fields();
}
/**
* GET WordPress MENUS API
*/
if ($endpoint === 'get-wp-menus') {
WordpressData::get_wordpress_menus_data();
}
/**
* GET WordPress POST TYPES API
*/
if ($endpoint === 'get-wp-post-types') {
WordpressData::get_wordpress_post_types_data();
}
/**
* GET WordPress POST TYPES API
*/
if ($endpoint === 'get-wp-comment-types') {
WordpressData::get_wordpress_comment_types_data();
}
/**
* GET WordPress SINGLE MENU DATA API
*/
if ($endpoint === 'get-wp-sigle-menu') {
//phpcs:ignore WordPress.Security.NonceVerification.Missing,WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.MissingUnslash,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$term_id = HelperFunctions::sanitize_text(isset($_GET['term_id']) ? $_GET['term_id'] : null);
WordpressData::get_wordpress_single_menu_data($term_id);
}
/**
* PAGE SETTINGS
*/
if ($endpoint === 'get-page-settings-data') {
PageSettings::get_page_settings_data();
}
if ($endpoint === 'get-custom-code') {
PageSettings::get_custom_code();
}
/**
* WALKTHROUGH
* @deprecated
* @see GET /walkthrough-shown-state
*/
// if ('get-walkthrough-shown-state' === $endpoint) {
// Walkthrough::get_walkthrough_state();
// }
/**
* COLLECTION
*/
if ('get-collection' === $endpoint) {
Collection::get_collection();
}
if ('get-external-collection-options' === $endpoint) {
Collection::get_external_collection_options();
}
if ('get-external-collection-item-type' === $endpoint) {
Collection::get_external_collection_item_type();
}
/**
* GET USERS
*/
if ('get-users-of-collection' === $endpoint) {
Users::get_users_of_collection();
}
/**
* COMMENTS
*/
if ('get-comments' === $endpoint) {
Comments::get_comments();
}
/**
* AUTHOR LIST
*/
if ('get-authors' === $endpoint) {
if (!HelperFunctions::has_access(KIRKI_ACCESS_LEVELS['FULL_ACCESS'])) {
wp_send_json_error('Not authorized', 401);
}
WordpressData::get_author_list();
}
/**
* ROLE LIST
*/
if ('get-roles' === $endpoint) {
if (!HelperFunctions::has_access(KIRKI_ACCESS_LEVELS['FULL_ACCESS'])) {
wp_send_json_error('Not authorized', 401);
}
WordpressData::get_role_list();
}
/**
* USER LIST
*/
if (
'get-users' === $endpoint
) {
if (!HelperFunctions::has_access(KIRKI_ACCESS_LEVELS['FULL_ACCESS'])) {
wp_send_json_error('Not authorized', 401);
}
WordpressData::get_user_list();
}
/**
* CATEGORY LIST
*/
if ('get-categories' === $endpoint) {
WordpressData::get_category_list();
}
/**
* GET ACCESS LEVEL
*/
if ('editor-access-level' === $endpoint) {
RBAC::get_editor_access_level();
}
if ($endpoint === 'get-common-data') {
if (!HelperFunctions::has_access(KIRKI_ACCESS_LEVELS['FULL_ACCESS'])) {
wp_send_json_error('Not authorized', 401);
}
WpAdmin::get_common_data();
}
/**
* Collaboration data get
*/
if ('collect-collaboration-actions' === $endpoint) {
Collaboration::send_actions();
}
/**
* Collaboration data get
*/
if ('delete-collaboration-connection' === $endpoint) {
$session_id = HelperFunctions::sanitize_text($_GET['session_id']);
Collaboration::delete_connection($session_id);
}
if ($endpoint === 'get-connected-collaboration-users-list') {
$post_id = HelperFunctions::sanitize_text($_GET['post_id']);
$res = Collaboration::get_connected_collaboration_users_list($post_id);
wp_send_json($res);
}
/**
* Staging GET APIs
* @deprecated
* @see GET /pages/{pageId}/staged-versions
*/
// if ('get-all-staged-versions' === $endpoint) {
// $post_id = (int) HelperFunctions::sanitize_text(isset($_GET['post_id']) ? $_GET['post_id'] : null);
// Staging::get_all_staged_versions($post_id, false, true);
// }
}
/**
* Check if the current request can access wp endpoints.
*
* @return bool
*/
private function user_can_access_get_apis()
{
if (HelperFunctions::is_api_call_from_editor_preview() && HelperFunctions::is_api_header_post_editor_preview_token_valid()) {
return true;
}
return is_user_logged_in() && HelperFunctions::has_access(
array(
KIRKI_ACCESS_LEVELS['FULL_ACCESS'],
KIRKI_ACCESS_LEVELS['CONTENT_ACCESS'],
KIRKI_ACCESS_LEVELS['VIEW_ACCESS'],
)
);
}
/**
* Initialize the admin post apis
*
* @return void
*/
public function kirki_wp_admin_post_apis()
{
HelperFunctions::verify_nonce('wp_rest');
if (!HelperFunctions::has_access(KIRKI_ACCESS_LEVELS['FULL_ACCESS'])) {
wp_send_json_error('Not authorized');
}
//phpcs:ignore WordPress.Security.NonceVerification.Missing,WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.MissingUnslash,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$endpoint = HelperFunctions::sanitize_text(isset($_POST['endpoint']) ? $_POST['endpoint'] : null);
if ($endpoint === 'save-common-data') {
WpAdmin::save_common_data();
}
if ($endpoint === 'update-license-validity') {
WpAdmin::update_license_validity();
}
if ($endpoint === 'update-access-level') {
RBAC::update_access_level();
}
if ($endpoint === 'delete-form-row') {
Form::delete_form_row();
}
if ($endpoint === 'delete-form') {
Form::delete_form();
}
if ($endpoint === 'update-form-cell') {
Form::update_form_row();
}
/**
* Export Template
*/
if ($endpoint === 'import-template') {
TemplateExportImport::import();
}
if ($endpoint === 'process-imported-template') {
TemplateExportImport::processImport();
}
if ($endpoint === 'process-export-template') {
TemplateExportImport::processExport();
}
if ($endpoint === 'save-editor-read-only-access-data') {
Page::save_editor_read_only_access_data();
}
/**
* Export Template
*/
if ($endpoint === 'export-template') {
TemplateExportImport::export();
}
}
/**
* Return an explicit unauthorized response for unauthenticated admin AJAX requests.
*
* @return void
*/
public function kirki_wp_admin_unauthorized()
{
wp_send_json_error('Not authorized', 401);
}
/**
* Initialize the admin get apis
*
* @return void
*/
public function kirki_wp_admin_get_apis()
{
HelperFunctions::verify_nonce('wp_rest');
if (!is_admin()) {
wp_send_json_error('Not authorized', 401);
}
if (!HelperFunctions::has_access(KIRKI_ACCESS_LEVELS['FULL_ACCESS'])) {
wp_send_json_error('Not authorized', 401);
}
//phpcs:ignore WordPress.Security.NonceVerification.Missing,WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.MissingUnslash,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$endpoint = HelperFunctions::sanitize_text(isset($_GET['endpoint']) ? $_GET['endpoint'] : null);
if ($endpoint === 'get-common-data') {
WpAdmin::get_common_data();
}
// From manipulation from admin dashboard.
if ($endpoint === 'get-forms') {
Form::get_forms();
}
if ($endpoint === 'get-form-data') {
Form::get_form_data();
}
if ($endpoint === 'get-wp-admin-page-data') {
Page::get_pages_for_pages_panel();
}
if ($endpoint === 'get-members-based-on-role') {
RBAC::members_based_on_role();
}
if ($endpoint === 'download-form-data') {
if (!HelperFunctions::has_access(KIRKI_ACCESS_LEVELS['FULL_ACCESS'])) {
wp_send_json_error('Not authorized');
}
Form::download_form_data();
}
// From manipulation from admin dashboard.
if ($endpoint === 'get-editor-read-only-access-data') {
if (!HelperFunctions::has_access(KIRKI_ACCESS_LEVELS['FULL_ACCESS'])) {
wp_send_json_error('Not authorized', 401);
}
Page::get_editor_read_only_access_data();
}
}
}