Skip to content

Commit 4d87c8c

Browse files
authored
Filter post types (#24)
* Add filter for post types * Bump version
1 parent 6006b84 commit 4d87c8c

3 files changed

Lines changed: 23 additions & 4 deletions

File tree

acf-post-type-selector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: Advanced Custom Fields: Post Type Selector
44
Plugin URI: https://github.com/TimPerry/acf-post-type-selector
55
Description: Provides the option to select a single or multiple post types
6-
Version: 1.0.0
6+
Version: 1.0.1
77
Author: Tim Perry
88
Author URI: http://www.forepoint.co.uk
99
License: GPLv2 or later
@@ -69,4 +69,4 @@ function register_fields()
6969

7070
new acf_field_post_type_selector_plugin();
7171

72-
?>
72+
?>

post-type-selector-v4.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,17 @@ function create_field( $field )
120120
$post_types = get_post_types( array(
121121
'public' => true,
122122
), 'objects' );
123-
123+
124+
/**
125+
* Filters the array of post types.
126+
*
127+
* @since 1.0.1
128+
*
129+
* @param array $post_types List of post types.
130+
* @param array $field The field being rendered.
131+
*/
132+
$post_types = apply_filters( 'post_type_selector_post_types', $post_types, $field );
133+
124134
// not required: add emmpty/none value
125135
if (!$field['required']) {
126136
$obj = new stdClass();
@@ -452,4 +462,4 @@ function update_field( $field, $post_id )
452462
// create field
453463
new acf_field_post_type_selector();
454464

455-
?>
465+
?>

post-type-selector-v5.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,15 @@ function render_field( $field ) {
115115
'public' => true,
116116
), 'objects' );
117117

118+
/**
119+
* Filters the array of post types.
120+
*
121+
* @since 1.0.1
122+
*
123+
* @param array $post_types List of post types.
124+
* @param array $field The field being rendered.
125+
*/
126+
$post_types = apply_filters( 'post_type_selector_post_types', $post_types, $field );
118127

119128
// not required: add emmpty/none value
120129
if (!$field['required']) {

0 commit comments

Comments
 (0)