$callback ) { if ( is_array( $callback ) && 'entry-thumbnail' === $callback[2] ) { unset( $callbacks[ $key ] ); break; } } } if ( in_array( $format, [ 'audio', 'video' ], true ) ) { array_push( $callbacks, [ [ $this, 'media_markup' ], $format, true ] ); } return $callbacks; } /** * Display HTML markup for the found media in current post. * * @since 1.0.1 * * @param arrray $callbacks Array of callback functions (may be with args). * @return string */ public function entry_featured_media( $callbacks ) { $format = get_post_format(); if ( in_array( $format, [ 'audio', 'video', 'gallery' ], true ) ) { // Add 'media_markup()' to array of callbacks with its args. array_push( $callbacks, [ [ $this, 'media_markup' ], $format, false ] ); } return $callbacks; } /** * Display HTML markup for the found media in current Display post. * * @since 1.0.1 * * @param arrray $callbacks Array of callback functions (may be with args). * @return string */ public function dp_featured_media( $callbacks ) { $format = get_post_format(); if ( in_array( $format, [ 'audio', 'video', 'gallery' ], true ) ) { // Add 'media_markup()' to array of callbacks with its args. array_push( $callbacks, [ [ $this, 'media_markup' ], $format, false, true ] ); } return $callbacks; } /** * Get the HTML markup for the found media in current post. * * @since 1.0.1 * * @param string $media_type audio | video | gallery. * @param bool $split_media Whether to split the media from the post content. * @param bool $wrapper Whether media to be wrapped in 'entry-featured-media'. * @return void */ public function media_markup( $media_type, $split_media, $wrapper = false ) { $media_obj = new Media_Grabber( $media_type, $split_media ); $media_arr = $media_obj->get_media(); $media = $media_arr[0]; if ( ( $wrapper || ! is_single() ) && $media ) { $toggle = sprintf( '', aamla_get_icon( array( 'icon' => 'close' ) ), esc_html__( 'Close Media Window', 'aamla' ) ); $title = the_title( sprintf( '
%s', $this->get_media_text( $media_arr[1] ) . esc_html__( ' from: ', 'aamla' ), esc_url( get_permalink() ) ), '
', false ); $media_post = sprintf( '
%s%s
', $toggle, $title ); $media = sprintf( '%2$s%3$s', aamla_get_attr( 'entry-featured-media' ), $media_post, $media ); } if ( $media ) { echo $media; // WPCS xss ok. Contains HTML, other values escaped. } } /** * Get translated media string. * * @since 1.0.1 * * @param str $media_type audio | video | gallery | playlist. * @return string */ public function get_media_text( $media_type ) { $text_arr = [ 'audio' => esc_html__( 'Audio', 'aamla' ), 'playlist' => esc_html__( 'Playlist', 'aamla' ), 'video' => esc_html__( 'Video', 'aamla' ), 'gallery' => esc_html__( 'Gallery', 'aamla' ), ]; $media_text = ''; if ( $media_type && isset( $text_arr[ $media_type ] ) ) { $media_text = $text_arr[ $media_type ]; } return $media_text; } /** * Enqueue scripts and styles to front end. * * @since 1.0.1 */ public function enqueue_front() { wp_enqueue_style( 'aamla_media_manager_style', get_template_directory_uri() . '/add-on/media-manager/assets/media-manager.css', array(), false, 'all' ); } } Media_Manager::init();