Filter for excluded post types
-
Hey, love the plugin, it is very helpful.
Would you consider adding a filter to the post types so that we could add additional exclusions when conflicts arise? I had a conflict with the soliloquy slider post type, so just wanted to exclude it.
Here is new admin_init function:
function admin_init() { // Class properties $post_types = get_post_types(); $excluded = apply_filters( 'address_geocoder_excluded_post_types', array( 'attachment', 'revision', 'nav_menu_item' ) ); $this->available_post_types = array_diff( $post_types, $excluded ); $this->options = get_option( 'address_geocoder_options' ); // Set some default options if none are already set if( !$this->options ) { $this->options = $this->available_post_types; } // Actions add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) ); add_action( 'save_post', array( $this, 'save_post' ), 10, 2 ); // Settings register_setting( 'address_geocoder_options', 'address_geocoder_options', array( $this, 'validate_options' ) ); }
And here is an example for other users, on how to use it (use post type slug):
add_filter( 'address_geocoder_excluded_post_types', 'dont_geocode_sliders' ); function dont_geocode_sliders( $excluded ){ $excluded[] = 'soliloquy'; return $excluded; }
- The topic ‘Filter for excluded post types’ is closed to new replies.