/home/techb158/public_html/wp-content/plugins/kirki/includes/Ajax
NameSizeModeActions
Collaboration/-0755rm
Apps.php123350644editdlrm
Collection.php72630644editdlrm
Comments.php17220644editdlrm
DynamicContent.php262170644editdlrm
ExportImport.php219800644editdlrm
Form.php314420644editdlrm
Media.php319290644editdlrm
Page.php406210644editdlrm
PageSettings.php113030644editdlrm
RBAC.php50230644editdlrm
Symbol.php375670644editdlrm
Taxonomy.php45360644editdlrm
TemplateExportImport.php37700644editdlrm
UserData.php197030644editdlrm
Users.php71460644editdlrm
Walkthrough.php14660644editdlrm
WordpressData.php47200644editdlrm
WpAdmin.php43590644editdlrm
Edit: /home/techb158/public_html/wp-content/plugins/kirki/includes/Ajax/Taxonomy.php (4536B)
getMessage(), $e->getCode() ?? 400 ); } die; } public static function get_terms() { try { $name = HelperFunctions::sanitize_text( isset( $_GET['name'] ) ? $_GET['name'] : null ); $terms = get_terms( array( 'taxonomy' => $name, 'hide_empty' => false, ) ); if ( $terms instanceof \WP_Error ) { throw new Exception( 'Error!' ); } wp_send_json_success( $terms ); } catch ( Exception $e ) { wp_send_json_error( $e->getMessage(), $e->getCode() ?? 400 ); } die; } public static function get_post_type_taxonomies() { try { $post_types = get_post_types( array(), 'objects' ); $response = array(); foreach ( $post_types as $post_type => $details ) { $taxonomies = get_object_taxonomies( $post_type, 'objects' ); if ( ! empty( $taxonomies ) ) { // Format taxonomies as array with value and title $formatted_taxonomies = array(); foreach ( $taxonomies as $taxonomy ) { $formatted_taxonomies[] = array( 'value' => $taxonomy->name, 'title' => $taxonomy->label, ); } if ( ! empty( $formatted_taxonomies ) ) { $response[] = array( 'value' => $post_type, 'title' => $details->label, 'taxonomies' => $formatted_taxonomies, ); } } } wp_send_json_success( $response ); } catch ( Exception $e ) { wp_send_json_error( $e->getMessage(), $e->getCode() ?? 400 ); } } public static function get_post_type_from_term_id( $term_id ) { // Get the term object from the term ID $term = get_term( $term_id ); // Check if the term exists if ( ! $term || is_wp_error( $term ) ) { return null; } // Get the taxonomy associated with the term $taxonomy = $term->taxonomy; // Get the post types associated with the taxonomy $post_types = get_post_types( array() ); foreach ( $post_types as $key => $post_type ) { // Get all taxonomies associated with the post type $taxonomies = get_object_taxonomies( $post_type, 'objects' ); if ( ! empty( $taxonomies ) ) { foreach ( $taxonomies as $taxonomy_slug => $taxonomy_object ) { if ( $taxonomy_slug === $taxonomy ) { return $post_type; } } } } return false; } public static function get_term_by_id( $term_id ) { $term = get_term( $term_id ); $term = get_object_vars( $term ); $post_type = self::get_post_type_from_term_id( $term_id ); $term['post_type'] = $post_type; return $term; } public static function get_all_terms_by_post_type() { $post_type = HelperFunctions::sanitize_text( isset( $_GET['post_type'] ) ? $_GET['post_type'] : null ); // Get taxonomy objects related to the post type $taxonomies = get_object_taxonomies( $post_type, 'objects' ); $result = array(); if ( count( $taxonomies ) > 0 ) { // Loop through each taxonomy foreach ( $taxonomies as $taxonomy_slug => $taxonomy_obj ) { // Get all terms for this taxonomy $terms = get_terms( array( 'taxonomy' => $taxonomy_slug, 'hide_empty' => false, ) ); // Skip if error or empty if ( is_wp_error( $terms ) || empty( $terms ) ) { continue; } // Prepare term list with required fields $terms_array = array(); foreach ( $terms as $term ) { $terms_array[] = array( 'term_id' => $term->term_id, 'name' => $term->name, 'slug' => $term->slug, ); } // Add taxonomy with terms to result $result[] = array( 'value' => $taxonomy_slug, 'title' => $taxonomy_obj->label, 'terms' => $terms_array, ); } } wp_send_json( $result ); } }