'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 = '