'OR', array( 'taxonomy' => 'product_type', 'field' => 'slug', 'terms' => array( 'live_stream' ), ), array( 'taxonomy' => 'product_type', 'operator' => 'NOT EXISTS', ), ); } else { $post_type = 'wpstream_product'; $taxonomy_array = array(); } $args = array( 'post_type' => $post_type, 'posts_per_page' => $limit, 'tax_query' => $taxonomy_array, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query 'author' => $current_user->ID, ); $query_list = new WP_Query( $args ); if ( 'found_posts' === $return_type ) { return intval( $query_list->found_posts ); } $return_string .= ''; wp_reset_postdata(); return $return_string; } } /** * Localize the upload script for images. * * @param string $button_upload The ID of the upload button. */ function wpstream_theme_localize_upload_script_images( $button_upload ) { $plup_url = add_query_arg( array( 'action' => 'wpstream_me_upload', 'nonce' => wp_create_nonce( 'aaiu_allow' ), ), esc_url( admin_url( 'admin-ajax.php' ) ) ); $max_file_size = 100 * 1000 * 1000; $plupload_values = array( 'runtimes' => 'html5,flash,html4', 'max_file_size' => $max_file_size . 'b', 'url' => $plup_url, 'file_data_name' => 'aaiu_upload_file', 'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ), 'filters' => array( array( 'title' => esc_html__( 'Allowed Files', 'hello-wpstream' ), 'extensions' => 'jpeg,jpg,gif,png,pdf,webp,mp4,mov', ), ), 'multipart' => true, 'urlstream_upload' => true, 'multipart_params' => array( 'button_id' => $button_upload ), ); $tmp_plupload_values = array( 'browse_button' => $button_upload, 'container' => 'aaiu-upload-container', ); $plupload_values = wp_parse_args( $plupload_values, $tmp_plupload_values ); $plupload_values['drop_element'] = 'drag-and-drop'; $max_images = 20; wp_localize_script( 'ajax-upload', 'ajax_vars', array( 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ), 'nonce' => wp_create_nonce( 'aaiu_upload' ), 'remove' => wp_create_nonce( 'aaiu_remove' ), 'number' => 1, 'upload_enabled' => true, 'warning' => __( 'Image needs to be at least 500px height x 500px wide!', 'hello-wpstream' ), 'max_images' => $max_images, 'warning_max' => __( 'You cannot upload more than', 'hello-wpstream' ) . ' ' . $max_images . ' ' . __( 'images', 'hello-wpstream' ), 'path' => trailingslashit( WPSTREAM_PLUGIN_PATH ), 'confirmMsg' => esc_html__( 'Are you sure you want to delete this?', 'hello-wpstream' ), 'plupload' => $plupload_values, ) ); } if ( ! function_exists( 'wpstream_theme_return_image_upload_markup' ) ) { /** * Return the markup for image upload. * * This function generates and returns the markup for image upload based on the provided post ID. * * @param int $user_id The ID of the user. * @param int $post_id The ID of the post. * @return string The HTML markup for image upload. */ function wpstream_theme_return_image_upload_markup( $user_id, $post_id ) { $post_type = get_post_type( $post_id ); $gallery_images = ''; if ( 'product' === $post_type ) { $gallery_images_source = get_post_meta( $post_id, '_product_image_gallery', true ); $gallery_images = explode( ',', $gallery_images_source ); } else { if(function_exists('rwmb_meta')){ $gallery_images = rwmb_meta( 'wpstream_theme_gallery', array(), $post_id ); if ( is_array( $gallery_images ) ) { $gallery_images = array_keys( $gallery_images ); } } } $gallery_images = wpstream_theme_return_image_gallery( $post_id ); $thumbid = get_post_thumbnail_id( $post_id ); $images = ''; if ( is_array( $gallery_images ) ) { foreach ( $gallery_images as $attachment_id ) { $preview = wp_get_attachment_image_src( $attachment_id, 'wpstream_featured_unit_cards' ); if ( $preview && $preview[0] != '' ) { $images .= '