override_get_post_types

The ACF Location Rules Post Type Attachment override get post types function.

Description

override_get_post_types( $post_types, (array) $exclude = array(), (array) $include = array() ); 

Parameters (3)

0. $post_types
The post types.
1. $exclude — Optional. (array) => array()
The exclude.
2. $include — Optional. (array) => array()
The include.

Usage

  1. if ( !function_exists( 'override_get_post_types' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'acf-location-rules-post-type-attachment/acf-location-rules-post-type-attachment.php'; 
  3.  
  4. // The post types. 
  5. $post_types = null; 
  6.  
  7. // The exclude. 
  8. $exclude = array(); 
  9.  
  10. // The include. 
  11. $include = array(); 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = override_get_post_types($post_types, $exclude, $include); 
  15.  

Defined (1)

The function is defined in the following location(s).

/acf-location-rules-post-type-attachment.php  
  1. function override_get_post_types( $post_types, $exclude = array(), $include = array() ) 
  2. // The key line to this plugin: 
  3. $exclude = array_diff($exclude, array('attachment')); 
  4.  
  5. // get all custom post types 
  6. $post_types = array_merge($post_types, get_post_types()); 
  7.  
  8.  
  9. // core include / exclude 
  10. $acf_includes = array_merge( array(), $include ); 
  11. $acf_excludes = array_merge( array( 'acf', 'revision', 'nav_menu_item' ), $exclude ); 
  12.  
  13.  
  14. // include 
  15. foreach( $acf_includes as $p ) 
  16. if( post_type_exists($p) ) 
  17. $post_types[ $p ] = $p; 
  18.  
  19.  
  20. // exclude 
  21. foreach( $acf_excludes as $p ) 
  22. unset( $post_types[ $p ] ); 
  23.  
  24.  
  25. return $post_types; 
  26.