Advertisement
Guest User

Untitled

a guest
Jul 26th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. // Tweak meta settings
  2. function myprefix_metabox_settings( $array ) {
  3. $array['media']['settings']['show_media'] = array(
  4. 'title' => esc_html__( 'Show Media', 'total' ),
  5. 'id' => 'wpex_display_featured_media',
  6. 'type' => 'select',
  7. 'options' => array(
  8. '' => esc_html__( 'Disable', 'total' ),
  9. 'on' => esc_html__( 'Enable', 'total' ),
  10. ),
  11. 'description' => esc_html__( 'Check the box to display the post featured media.', 'total' ),
  12. );
  13. return $array;
  14. }
  15. add_filter( 'wpex_metabox_array', 'myprefix_metabox_settings' );
  16.  
  17. // Show/hide media block based on admin setting
  18. function myprefix_blog_post_layout_blocks( $blocks ) {
  19.  
  20. // Remove media block by default
  21. if ( ! is_admin() && is_singular() ) {
  22. $blocks = array_combine( $blocks, $blocks );
  23. if ( 'on' != get_post_meta( get_the_ID(), 'wpex_display_featured_media', true ) ) {
  24. unset( $blocks['featured_media'] );
  25. }
  26. }
  27.  
  28. // Return blocks
  29. return $blocks;
  30.  
  31. }
  32. add_filter( 'wpex_blog_single_layout_blocks', 'myprefix_blog_post_layout_blocks' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement