'checkbox', 'name' => 'cf_group', 'holderClass' => 'tpg-hidden cf-fields cf-group', 'label' => esc_html__( 'Custom Field group', 'the-post-grid' ), 'multiple' => true, 'alignment' => 'vertical', 'id' => 'cf_group', 'options' => Fns::get_groups_by_post_type( $post_type, $cf ), ]; $error = false; $data = Fns::rtFieldGenerator( $fields ); } } else { $msg = esc_html__( 'Server Error !!', 'the-post-grid' ); } $response = [ 'error' => $error, 'msg' => $msg, 'data' => $data, ]; wp_send_json( $response ); die(); } /** * Default filter. * * @return void */ public function defaultFilterItem() { $error = true; $data = $msg = null; if ( Fns::verifyNonce() ) { $filter = isset( $_REQUEST['filter'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['filter'] ) ) : null; $term = isset( $_REQUEST['include'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['include'] ) ) : null; if ( ! empty( $filter ) ) { $include = []; if ( ! empty( $term ) ) { $include = explode( ',', $term ); } $error = false; $msg = esc_html__( 'Success', 'the-post-grid' ); $data .= "'; $items = Fns::rt_get_selected_term_by_taxonomy( $filter, $include, '', 0 ); if ( ! empty( $items ) ) { foreach ( $items as $id => $item ) { $data .= ''; } } } } else { $msg = esc_html__( 'Session Error !!', 'the-post-grid' ); } $response = [ 'error' => $error, 'msg' => $msg, 'data' => $data, ]; wp_send_json( $response ); die(); } /** * Save settings. * * @return void */ public function rtTPGSaveSettings() { $error = true; if ( Fns::verifyNonce() ) { unset( $_REQUEST['action'] ); unset( $_REQUEST[ rtTPG()->nonceId() ] ); unset( $_REQUEST['_wp_http_referer'] ); update_option( rtTPG()->options['settings'], wp_unslash( $_REQUEST ) ); $response = [ 'error' => false, 'msg' => esc_html__( 'Settings successfully updated', 'the-post-grid' ), ]; } else { $response = [ 'error' => $error, 'msg' => esc_html__( 'Session Error !!', 'the-post-grid' ), ]; } wp_send_json( $response ); die(); } /** * Taxonomy list. * * @return void */ public function rtTPGTaxonomyListByPostType() { $error = true; $msg = $data = null; if ( Fns::verifyNonce() ) { $error = false; $taxonomies = Fns::rt_get_all_taxonomy_by_post_type( $_REQUEST['post_type'] ); if ( is_array( $taxonomies ) && ! empty( $taxonomies ) ) { $data .= Fns::rtFieldGenerator( [ 'tpg_taxonomy' => [ 'type' => 'checkbox', 'label' => esc_html__( 'Taxonomy', 'the-post-grid' ), 'id' => 'post-taxonomy', 'multiple' => true, 'value' => isset( $_REQUEST['taxonomy'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_REQUEST['taxonomy'] ) ) : [], 'options' => $taxonomies, ], ] ); } else { $data = '
' . esc_html__( 'No Taxonomy found', 'the-post-grid' ) . '
'; } } else { $msg = esc_html__( 'Security error', 'the-post-grid' ); } wp_send_json( [ 'error' => $error, 'msg' => $msg, 'data' => $data, ] ); die(); } /** * Isotope Filter * * @return void */ public function rtTPGIsotopeFilter() { $error = true; $msg = $data = null; if ( Fns::verifyNonce() ) { $error = false; $post_type = isset( $_REQUEST['post_type'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['post_type'] ) ) : null; $taxonomies = Fns::rt_get_taxonomy_for_filter( $post_type ); if ( is_array( $taxonomies ) && ! empty( $taxonomies ) ) { foreach ( $taxonomies as $tKey => $tax ) { $data .= ''; } } } else { $msg = esc_html__( 'Security error', 'the-post-grid' ); } wp_send_json( [ 'error' => $error, 'msg' => $msg, 'data' => $data, ] ); die(); } /** * Term list * * @return void */ public function rtTPGTermListByTaxonomy() { $error = true; $msg = $data = null; if ( Fns::verifyNonce() ) { $error = false; $taxonomy = isset( $_REQUEST['taxonomy'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['taxonomy'] ) ) : null; $data .= "
"; $data .= Fns::rtFieldGenerator( [ 'term_' . $taxonomy => [ 'type' => 'select', 'label' => ucfirst( str_replace( '_', ' ', $taxonomy ) ), 'class' => 'rt-select2 full', 'id' => 'term-' . wp_rand(), 'holderClass' => "term-filter-item {$taxonomy}", 'value' => null, 'multiple' => true, 'options' => Fns::rt_get_all_term_by_taxonomy( $taxonomy ), ], ] ); $data .= Fns::rtFieldGenerator( [ 'term_operator_' . $taxonomy => [ 'type' => 'select', 'label' => esc_html__( 'Operator', 'the-post-grid' ), 'class' => 'rt-select2 full', 'holderClass' => "term-filter-item-operator {$taxonomy}", 'options' => Options::rtTermOperators(), ], ] ); $data .= '
'; } else { $msg = esc_html__( 'Security error', 'the-post-grid' ); } wp_send_json( [ 'error' => $error, 'msg' => $msg, 'data' => $data, ] ); die(); } /** * Shortcode list * * @return void */ public function shortCodeList() { $html = null; $scQ = new \WP_Query( apply_filters( 'tpg_sc_list_query_args', [ 'post_type' => rtTPG()->post_type, 'order_by' => 'title', 'order' => 'DESC', 'post_status' => 'publish', 'posts_per_page' => - 1, ] ) ); if ( $scQ->have_posts() ) { $html .= "
"; $html .= "
"; $html .= ''; $html .= "'; $html .= '
'; $html .= '
'; } else { $html .= '
' . esc_html__( 'No shortCode found.', 'the-post-grid' ) . '
'; } Fns::print_html( $html, true ); die(); } }