' . esc_html__( 'Select Taxonomy', 'smart-post-show' ) . ''; foreach ( $taxonomy_names as $taxonomy => $label ) { echo ''; } } } else { wp_send_json_error( array( 'error' => esc_html__( 'You do not have required permissions to access.', 'smart-post-show' ) ) ); } } else { wp_send_json_error( array( 'error' => esc_html__( 'Error: Nonce verification has failed. Please try again.', 'smart-post-show' ) ) ); } } add_action( 'wp_ajax_sps_get_taxonomies', 'sps_get_taxonomies' ); /** * Populate the taxonomy terms list to the select option. * * @return void */ function sps_get_terms() { $nonce = ( ! empty( $_POST['nonce'] ) ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : ''; // Check for nonce security. if ( wp_verify_nonce( $nonce, 'spf_pcp_metabox_nonce' ) ) { $capability = apply_filters( 'sp_pc_dashboard_capability', 'manage_options' ); if ( current_user_can( $capability ) ) { $the_pcp_taxonomy = ( ! empty( $_POST['pcp_post_taxonomy'] ) ) ? sanitize_text_field( wp_unslash( $_POST['pcp_post_taxonomy'] ) ) : ''; $sp_post_types = get_post_types( array(), 'names' ); $pcp_taxonomy = $the_pcp_taxonomy ? $the_pcp_taxonomy : get_object_taxonomies( $sp_post_types, 'names' ); if ( version_compare( get_bloginfo( 'version' ), '4.5', '>=' ) ) { $terms = get_terms( array( 'taxonomy' => $pcp_taxonomy ) ); } else { $terms = get_terms( array( $pcp_taxonomy ) ); } foreach ( $terms as $key => $value ) { echo ''; } } else { wp_send_json_error( array( 'error' => esc_html__( 'You do not have required permissions to access.', 'smart-post-show' ) ) ); } } else { wp_send_json_error( array( 'error' => esc_html__( 'Error: Nonce verification has failed. Please try again.', 'smart-post-show' ) ) ); } } add_action( 'wp_ajax_sps_get_terms', 'sps_get_terms' ); if ( ! function_exists( 'spf_chosen_ajax' ) ) { /** * * Chosen Ajax * * @since 1.0.0 * @version 1.0.0 */ function spf_chosen_ajax() { $nonce = ( ! empty( $_POST['nonce'] ) ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : ''; $type = ( ! empty( $_POST['type'] ) ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : ''; $term = ( ! empty( $_POST['term'] ) ) ? sanitize_text_field( wp_unslash( $_POST['term'] ) ) : ''; $query = ( ! empty( $_POST['query_args'] ) ) ? wp_kses_post_deep( wp_unslash( $_POST['query_args'] ) ) : array(); // phpcs:ignore if ( wp_verify_nonce( $nonce, 'spf_chosen_ajax_nonce' ) ) { $capability = apply_filters( 'spf_chosen_ajax_capability', 'manage_options' ); if ( current_user_can( $capability ) ) { $options = SP_PC_Fields::field_data( $type, $term, $query ); wp_send_json_success( $options ); } else { wp_send_json_error( array( 'error' => esc_html__( 'You do not have required permissions to access.', 'smart-post-show' ) ) ); } } else { wp_send_json_error( array( 'error' => esc_html__( 'Error: Nonce verification has failed. Please try again.', 'smart-post-show' ) ) ); } } add_action( 'wp_ajax_spf-chosen', 'spf_chosen_ajax' ); } if ( ! function_exists( 'spf_set_icons' ) ) { /** * * Set icons for wp dialog * * @since 1.0.0 * @version 1.0.0 */ function spf_set_icons() { global $post_type; if ( 'sp_post_carousel' === $post_type ) { ?>