: '99999999'; // Query Hack $ids = explode( ',', $request['ids'] ); $args['include'] = $ids; } if ( isset( $request['s'] ) ) { $args['name__like'] = $request['s']; } $options = []; $taxonomies = get_object_taxonomies( $post_type, 'objects' ); if ( ! empty($taxonomies) ) { foreach ( $taxonomies as $taxonomy ) { $options[] = [ 'id' => $taxonomy->name, 'text' => $taxonomy->label, ]; } } wp_reset_postdata(); return [ 'results' => $options ]; } /** ** Get Custom Meta Keys */ public function get_custom_meta_keys( $request ) { if ( ! current_user_can( 'edit_posts' ) ) { return; } $data = []; $options = []; $merged_meta_keys = []; $post_types = Utilities::get_custom_types_of( 'post', false ); foreach ( $post_types as $post_type_slug => $post_type_name ) { $data[ $post_type_slug ] = []; $posts = get_posts( [ 'post_type' => $post_type_slug, 'posts_per_page' => -1 ] ); foreach ( $posts as $key => $post ) { $meta_keys = get_post_custom_keys( $post->ID ); if ( ! empty($meta_keys) ) { for ( $i = 0; $i < count( $meta_keys ); $i++ ) { if ( '_' !== substr( $meta_keys[$i], 0, 1 ) ) { array_push( $data[$post_type_slug], $meta_keys[$i] ); } } } } $data[ $post_type_slug ] = array_unique( $data[ $post_type_slug ] ); } foreach ( $data as $array ) { $merged_meta_keys = array_unique( array_merge( $merged_meta_keys, $array ) ); } // Rekey $merged_meta_keys = array_values($merged_meta_keys); for ( $i = 0; $i < count( $merged_meta_keys ); $i++ ) { // Add a search condition here if ( ! isset( $request['s'] ) || strpos( $merged_meta_keys[$i], $request['s'] ) !== false ) { $options[] = [ 'id' => $merged_meta_keys[$i], 'text' => $merged_meta_keys[$i], ]; } } return [ 'results' => $options ]; } /** ** Get Custom Meta Keys Product */ public function get_custom_meta_keys_product( $request ) { if ( ! current_user_can( 'edit_posts' ) ) { return; } $data = []; $options = []; $merged_meta_keys = []; $post_types = Utilities::get_custom_types_of( 'post', false ); foreach ( $post_types as $post_type_slug => $post_type_name ) { $data[ $post_type_slug ] = []; $posts = get_posts( [ 'post_type' => $post_type_slug, 'posts_per_page' => -1 ] ); foreach ( $posts as $key => $post ) { $meta_keys = get_post_custom_keys( $post->ID ); if ( ! empty($meta_keys) ) { for ( $i = 0; $i < count( $meta_keys ); $i++ ) { if ( '_' !== substr( $meta_keys[$i], 0, 1 ) ) { array_push( $data[$post_type_slug], $meta_keys[$i] ); } } } } $data[ $post_type_slug ] = array_unique( $data[ $post_type_slug ] ); } foreach ( $data as $array ) { $merged_meta_keys = array_unique( array_merge( $merged_meta_keys, $array ) ); } // Rekey $merged_meta_keys = array_values($merged_meta_keys); for ( $i = 0; $i < count( $merged_meta_keys ); $i++ ) { // Add a search condition here if ( ! isset( $request['s'] ) || strpos( $merged_meta_keys[$i], $request['s'] ) !== false ) { $options[] = [ 'id' => $merged_meta_keys[$i], 'text' => $merged_meta_keys[$i], ]; } } // Get a list of all product attributes used by products $product_attributes = array(); // Query for all products of the "product" post type $args = array( 'post_type' => 'product', // Change to the correct post type if needed 'posts_per_page' => -1, // Retrieve all products ); $products_query = new \WP_Query($args); if ($products_query->have_posts()) { while ($products_query->have_posts()) { $products_query->the_post(); // Get the product object $product = wc_get_product(get_the_ID()); // Get product attributes $attributes = $product->get_attributes(); // Loop through attributes and add them to the master list foreach ($attributes as $attribute) { $product_attributes[$attribute->get_name()] = true; } } // Reset post data wp_reset_postdata(); // Extract attribute names from the master list $attribute_names = array_keys($product_attributes); // Initialize an empty array $attributes_array = []; // Iterate through the original array and set both key and value to be the same foreach ($attribute_names as $value) { $attributes_array[] = [ 'id' => $value, 'text' => $value, ]; } $options = array_merge($options, $attributes_array); } return [ 'results' => $options ]; } /** ** Get Custom Meta Keys Data */ public function get_custom_meta_keys_data() { // TODO if ( ! current_user_can( 'edit_posts' ) ) { return; } $data = []; $options = []; $merged_meta_keys = []; $post_types = Utilities::get_custom_types_of( 'post', false ); foreach ( $post_types as $post_type_slug => $post_type_name ) { $data[ $post_type_slug ] = []; $posts = get_posts( [ 'post_type' => $post_type_slug, 'posts_per_page' => -1 ] ); foreach ( $posts as $key => $post ) { $meta_keys = get_post_custom_keys( $post->ID ); if ( ! empty($meta_keys) ) { for ( $i = 0; $i < count( $meta_keys ); $i++ ) { if ( '_' !== substr( $meta_keys[$i], 0, 1 ) ) { array_push( $data[$post_type_slug], $meta_keys[$i] ); } } } } $data[ $post_type_slug ] = array_unique( $data[ $post_type_slug ] ); } foreach ( $data as $array ) { $merged_meta_keys = array_unique( array_merge( $merged_meta_keys, $array ) ); } // Rekey $merged_meta_keys = array_values($merged_meta_keys); for ( $i = 0; $i < count( $merged_meta_keys ); $i++ ) { $options[ $merged_meta_keys[$i] ] = $merged_meta_keys[$i]; } // return [ $data, $options ]; return [ 'results' => $data ]; } } new Wpr_Control_Ajax_Select2_Api();
Warning: Cannot modify header information - headers already sent by (output started at /htdocs/wp-content/plugins/royal-elementor-addons/includes/controls/wpr-ajax-select2/wpr-control-ajax-select2-api.php:1) in /htdocs/wp-content/plugins/sellkit/includes/contact-segmentation/contact-data-updater.php on line 114
Recrutement d’un cabinet pour le renforcement des capacités des organisations communautaires de base à l’élaboration et la mise en oeuvre de projets environnementaux dans le paysage du lac télé, République du Congo – the Magazine