once(); $is_list = 'media_list' === (string) $attr['type']; $attr['type'] = 'text'; $html = parent::maybe_render( $attr ); $values = explode( ',', (string) $attr['value'] ); ob_start(); ?>
'button', 'class' => sprintf( '%s button button-primary widefat', $is_list ? 'upload_carousel_image_button' : 'upload_single_image_button' ), 'value' => $is_list ? __( 'Add images', 'italystrap' ) : __( 'Add image', 'italystrap' ), 'style' => 'margin-bottom:1rem', ]; unset( $this->elements['label'], $this->elements['desc'] ); return $this->style() . $html . parent::maybe_render( $button_attr ); } /** * Get element with image for media fields * * @param array $ids The ID of the image. * * @return string The HTML of the element with image */ protected function list_elements( array $ids ) { $html = ''; foreach ( $ids as $id ) { $html .= $this->get_list_element( $id ); } return $html; } /** * Get element with image for media fields * * @param int $id The ID of the image. * * @return string The HTML of the element with image */ protected function get_list_element( $id ) { if ( empty( $id ) ) { return ''; } $attr = array( 'data-id' => absint( $id ), ); $html = wp_get_attachment_image( $id , 'thumbnail', false, $attr ); if ( '' === $html ) { $id = (int) get_post_thumbnail_id( $id ); $html = wp_get_attachment_image( $id , 'thumbnail', false, $attr ); } if ( empty( $html ) ) { return ''; } return ''; // XSS ok. } /** * */ private function once() { if ( did_action( 'media_fields_loaded' ) ) { return; } // d( did_action( 'wp_enqueue_media' ) ); wp_enqueue_media(); wp_enqueue_script( 'jquery-ui-sortable' ); // $js_file = ( WP_DEBUG ) ? 'assets/js/src/widget.js' : 'assets/js/widget.min.js'; // // if ( ! wp_script_is( 'italystrap-widget' ) ) { // // wp_enqueue_style( // 'italystrap-widget', // plugins_url( 'assets/css/widget.css', __FILE__ ) // ); // // wp_enqueue_script( // 'italystrap-widget', // plugins_url( $js_file, __FILE__ ), // array( 'jquery', 'jquery-ui-sortable' ) // ); // // } ob_start(); ?>