WP_Widget_Media_Gallery::has_content()
Whether the widget has content to show.
Method of the class: WP_Widget_Media_Gallery{}
No Hooks.
Return
true|false
. Whether widget has content.
Usage
// protected - for code of main (parent) or child class $result = $this->has_content( $instance );
- $instance(array) (required)
- Widget instance props.
Changelog
Since 4.9.0 | Introduced. |
WP_Widget_Media_Gallery::has_content() WP Widget Media Gallery::has content code WP 6.8
protected function has_content( $instance ) { if ( ! empty( $instance['ids'] ) ) { $attachments = wp_parse_id_list( $instance['ids'] ); // Prime attachment post caches. _prime_post_caches( $attachments, false, false ); foreach ( $attachments as $attachment ) { if ( 'attachment' !== get_post_type( $attachment ) ) { return false; } } return true; } return false; }