Created
          October 24, 2016 22:48 
        
      - 
      
- 
        Save ScottDeLuzio/3f60d8c362996f0fe9fb726d631f1f99 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // Replace this | |
| function wp_jv_prg_add_rg_meta_box_head() { | |
| add_meta_box('wp_jv_prg_sectionid','WP JV Reading Groups','wp_jv_prg_add_rg_meta_box', 'post','side','high'); | |
| add_meta_box('wp_jv_prg_sectionid','WP JV Reading Groups','wp_jv_prg_add_rg_meta_box', 'page','side','high'); | |
| } | |
| // With this | |
| function wp_jv_prg_add_rg_meta_box_head() { | |
| $post_types = wp_jv_prg_get_post_types(); | |
| foreach( $post_types as $post_type ) { | |
| add_meta_box('wp_jv_prg_sectionid','WP JV Reading Groups','wp_jv_prg_add_rg_meta_box', $post_type,'side','high'); | |
| } | |
| } | |
| //Also add this to get all post type names (including page and post) and allow others to hook into $post_types | |
| function wp_jv_prg_get_post_types() { | |
| $args = array( | |
| 'public' => true, | |
| '_builtin' => false | |
| ); | |
| $output = 'names'; // names or objects, note names is the default | |
| $operator = 'and'; // 'and' or 'or' | |
| $post_types = get_post_types( $args, $output, $operator ); | |
| $post_types = array_merge( $post_types, array( 'post' => 'post' ) ); | |
| if ( has_filter( 'wp_jv_prg_post_types' ) ){ | |
| $post_types = apply_filters( 'wp_jv_prg_post_types', $post_types ); | |
| } | |
| return $post_types; | |
| } | |
| function wp_jv_prg_modify_post_types( $post_types ) { | |
| return $post_types; | |
| } | |
| add_filter( 'wp_jv_prg_post_types', 'wp_jv_prg_modify_post_types' ); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment