'attachment', 'post_status' => 'inherit', 'fields' => 'ids', 'meta_query' => array( array( 'value' => $file, 'compare' => 'LIKE', 'key' => '_wp_attachment_metadata', ), ) ); $query = new WP_Query( $query_args ); if ( $query->have_posts() ) { foreach ( $query->posts as $post_id ) { $meta = wp_get_attachment_metadata( $post_id ); $original_file = basename( $meta['file'] ); $cropped_image_files = wp_list_pluck( $meta['sizes'], 'file' ); if ( $original_file === $file || in_array( $file, $cropped_image_files ) ) { $attachment_id = $post_id; break; } } } } return (int) $attachment_id; } public static function check_archive() { $return = array( 'type' => NULL, 'id' => NULL, ); if ( is_category() ) { $return['type'] = 'category'; $category = get_category( get_query_var( 'cat' ) ); $return['id'] = $category->cat_ID; } if ( is_tag() ) { $return['type'] = 'tags'; $tags = get_tags(); $return['id'] = $tags[0]->term_id; } if ( is_day() ) { $return['type'] = 'day'; $day = get_query_var( 'day' ); $return['id'] = $day; } if ( is_month() ) { $return['type'] = 'month'; $month = get_query_var( 'monthnum' ); $return['id'] = $month; } if ( is_year() ) { $return['type'] = 'year'; $year = get_query_var( 'year' ); $return['id'] = $year; } return $return; } /** * @param string $format * * @return bool|mixed */ public static function format_icon( $format = 'standard' ) { if ( $format === 'standard' ) { return false; } $icons = array( 'aside' => 'nmicon-hashtag', 'image' => 'nmicon-picture-o', 'quote' => 'nmicon-quote-left', 'link' => 'nmicon-link', 'gallery' => 'nmicon-th-large', 'video' => 'nmicon-video-camera', 'status' => 'nmicon-heartbeat', 'audio' => 'nmicon-headphones', 'chat' => 'nmicon-comment-o' ); return $icons[ $format ]; } /** * Render the breadcrumbs with help of class-breadcrumbs.php * * @return void */ // public static function add_breadcrumbs() { // $breadcrumbs = new bumbeelbee_Breadcrumbs(); // $breadcrumbs->get_breadcrumbs(); // } /** * @param $image_object * * @return array */ public static function get_lazy_image( $image_object ) { $lazy = get_theme_mod( 'bumbeelbee_enable_blazy', '' ); $img = $image_object['image']; if ( $lazy ) { $img = apply_filters( 'bumbeelbee_widget_image', $image_object ); } $allowed_tags = array( 'img' => array( 'data-srcset' => true, 'data-src' => true, 'srcset' => true, 'sizes' => true, 'src' => true, 'class' => true, 'alt' => true, 'width' => true, 'height' => true ), 'noscript' => array() ); return array( 'image' => $img, 'tags' => $allowed_tags ); } public static function get_first_media( $post_id ) { $post = get_post( $post_id ); $content = do_shortcode( apply_filters( 'the_content', $post->post_content, 1 ) ); $embeds = get_media_embedded_in_content( $content ); $href = ''; $type = ''; $html = ''; if ( empty( $embeds ) ) { return false; } foreach ( $embeds as $embed ) { if ( strpos( $embed, 'youtube' ) ) { preg_match( '/src="([^"]+)"/', $embed, $match ); $href = $match[1]; $type = 'youtube'; } elseif ( strpos( $embed, 'vimeo' ) ) { preg_match( '/src="([^"]+)"/', $embed, $match ); $href = $match[1]; $type = 'vimeo'; } else { $element = new SimpleXMLElement( $embeds[0] ); $href = ''; if ( ! empty( $element->a ) ) { $href = (string) $element->a->attributes()->href; } $type = 'local'; } } if ( ! empty( $href ) ) { switch ( $type ) { case 'local': $html = '