WC_Brands_Admin::edit_thumbnail_field()
Edit thumbnail field row.
Метод класса: WC_Brands_Admin{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$WC_Brands_Admin = new WC_Brands_Admin(); $WC_Brands_Admin->edit_thumbnail_field( $term );
- $term(WP_Term) (обязательный)
- Current taxonomy term object.
Код WC_Brands_Admin::edit_thumbnail_field() WC Brands Admin::edit thumbnail field WC 9.4.2
<?php public function edit_thumbnail_field( $term ) { global $woocommerce; $image = ''; $thumbnail_id = get_term_meta( $term->term_id, 'thumbnail_id', true ); if ( $thumbnail_id ) { $image = wp_get_attachment_url( $thumbnail_id ); } if ( empty( $image ) ) { $image = wc_placeholder_img_src(); } ?> <tr class="form-field"> <th scope="row" valign="top"><label><?php esc_html_e( 'Thumbnail', 'woocommerce' ); ?></label></th> <td> <div id="product_cat_thumbnail" style="float:left;margin-right:10px;"><img src="<?php echo esc_url( $image ); ?>" width="60px" height="60px" /></div> <div style="line-height:60px;"> <input type="hidden" id="product_cat_thumbnail_id" name="product_cat_thumbnail_id" value="<?php echo esc_attr( $thumbnail_id ); ?>" /> <button type="button" class="upload_image_button button"><?php esc_html_e( 'Upload/Add image', 'woocommerce' ); ?></button> <button type="button" class="remove_image_button button"><?php esc_html_e( 'Remove image', 'woocommerce' ); ?></button> </div> <script type="text/javascript"> jQuery(function(){ // Only show the "remove image" button when needed if ( ! jQuery('#product_cat_thumbnail_id').val() ) jQuery('.remove_image_button').hide(); // Uploading files var file_frame; jQuery(document).on( 'click', '.upload_image_button', function( event ){ event.preventDefault(); // If the media frame already exists, reopen it. if ( file_frame ) { file_frame.open(); return; } // Create the media frame. file_frame = wp.media.frames.downloadable_file = wp.media({ title: '<?php echo esc_js( __( 'Choose an image', 'woocommerce' ) ); ?>', button: { text: '<?php echo esc_js( __( 'Use image', 'woocommerce' ) ); ?>', }, multiple: false }); // When an image is selected, run a callback. file_frame.on( 'select', function() { attachment = file_frame.state().get('selection').first().toJSON(); jQuery('#product_cat_thumbnail_id').val( attachment.id ); jQuery('#product_cat_thumbnail img').attr('src', attachment.url ); jQuery('.remove_image_button').show(); }); // Finally, open the modal. file_frame.open(); }); jQuery(document).on( 'click', '.remove_image_button', function( event ){ jQuery('#product_cat_thumbnail img').attr('src', '<?php echo esc_js( wc_placeholder_img_src() ); ?>'); jQuery('#product_cat_thumbnail_id').val(''); jQuery('.remove_image_button').hide(); return false; }); }); </script> <div class="clear"></div> </td> </tr> <?php }