Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ( ! function_exists( 'jnews_append_podcast_download_button_to_content' ) ) {
- /**
- * Tambahkan tombol download podcast pada akhir konten single post.
- *
- * @param string $content Konten post.
- *
- * @return string
- */
- function jnews_append_podcast_download_button_to_content( $content ) {
- if ( ! is_singular( 'post' ) || ! in_the_loop() || ! is_main_query() ) {
- return $content;
- }
- $post_id = get_the_ID();
- $jnews_podcast_option = get_post_meta( $post_id, 'jnews_podcast_option', true );
- $enable_podcast = isset( $jnews_podcast_option['enable_podcast'] ) && '1' === $jnews_podcast_option['enable_podcast'];
- $upload_url = isset( $jnews_podcast_option['upload'] ) ? $jnews_podcast_option['upload'] : '';
- if ( ! $enable_podcast || empty( $upload_url ) ) {
- return $content;
- }
- $button = sprintf(
- '<div class="jeg_podcast_download_wrapper"><a class="jeg_button jeg_btn_normal" href="%1$s" download target="_blank" rel="noopener">%2$s</a></div>',
- esc_url( $upload_url ),
- esc_html__( 'Download Podcast', 'jnews' )
- );
- return $content . $button;
- }
- }
- add_filter( 'the_content', 'jnews_append_podcast_download_button_to_content', 999 );
Advertisement
Add Comment
Please, Sign In to add comment