Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Tweak meta settings
- function myprefix_metabox_settings( $array ) {
- $array['media']['settings']['show_media'] = array(
- 'title' => esc_html__( 'Show Media', 'total' ),
- 'id' => 'wpex_display_featured_media',
- 'type' => 'select',
- 'options' => array(
- '' => esc_html__( 'Disable', 'total' ),
- 'on' => esc_html__( 'Enable', 'total' ),
- ),
- 'description' => esc_html__( 'Check the box to display the post featured media.', 'total' ),
- );
- return $array;
- }
- add_filter( 'wpex_metabox_array', 'myprefix_metabox_settings' );
- // Show/hide media block based on admin setting
- function myprefix_blog_post_layout_blocks( $blocks ) {
- // Remove media block by default
- if ( ! is_admin() && is_singular() ) {
- $blocks = array_combine( $blocks, $blocks );
- if ( 'on' != get_post_meta( get_the_ID(), 'wpex_display_featured_media', true ) ) {
- unset( $blocks['featured_media'] );
- }
- }
- // Return blocks
- return $blocks;
- }
- add_filter( 'wpex_blog_single_layout_blocks', 'myprefix_blog_post_layout_blocks' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement