diff --git a/cmb-field-ajax-search.php b/cmb2-field-ajax-search.php similarity index 82% rename from cmb-field-ajax-search.php rename to cmb2-field-ajax-search.php index 3b71f1b..7ad7bcc 100644 --- a/cmb-field-ajax-search.php +++ b/cmb2-field-ajax-search.php @@ -10,10 +10,11 @@ Author URI: http://rubengc.com/ License: GPLv2+ */ -// This plugin is an update of CMB2 Field Type: Post Search Ajax (https://github.com/alexis-magina/cmb2-field-post-search-ajax) +// This plugin is based on CMB2 Field Type: Post Search Ajax (https://github.com/alexis-magina/cmb2-field-post-search-ajax) // Special thanks to Magina (http://magina.fr/) for him awesome work if( ! class_exists( 'CMB2_Field_Ajax_Search' ) ) { + /** * Class CMB2_Field_Ajax_Search */ @@ -33,6 +34,11 @@ if( ! class_exists( 'CMB2_Field_Ajax_Search' ) ) { add_action( 'cmb2_render_user_ajax_search', array( $this, 'render' ), 10, 5 ); add_action( 'cmb2_render_term_ajax_search', array( $this, 'render' ), 10, 5 ); + // Display + add_filter( 'cmb2_pre_field_display_post_ajax_search', array( $this, 'display' ), 10, 3 ); + add_filter( 'cmb2_pre_field_display_user_ajax_search', array( $this, 'display' ), 10, 3 ); + add_filter( 'cmb2_pre_field_display_term_ajax_search', array( $this, 'display' ), 10, 3 ); + // Sanitize add_action( 'cmb2_sanitize_post_ajax_search', array( $this, 'sanitize' ), 10, 4 ); add_action( 'cmb2_sanitize_user_ajax_search', array( $this, 'sanitize' ), 10, 4 ); @@ -115,6 +121,43 @@ if( ! class_exists( 'CMB2_Field_Ajax_Search' ) ) { } + /** + * Display field + */ + public function display( $pre_output, $field, $display ) { + $object_type = str_replace( 'cmb2_pre_field_display_', '', str_replace( '_ajax_search', '', current_filter() ) ); + + ob_start(); + + $field->peform_param_callback( 'before_display_wrap' ); + + printf( "