Improved enqueue scripts

This commit is contained in:
Ruben Garcia 2017-04-08 13:02:22 +02:00
parent 27aed50d12
commit 9967570898
1 changed files with 2 additions and 1 deletions

View File

@ -29,6 +29,8 @@ if( ! class_exists( 'CMB2_Field_Ajax_Search' ) ) {
* Initialize the plugin by hooking into CMB2 * Initialize the plugin by hooking into CMB2
*/ */
public function __construct() { public function __construct() {
add_action( 'admin_enqueue_scripts', array( $this, 'setup_admin_scripts' ) );
// Render // Render
add_action( 'cmb2_render_post_ajax_search', array( $this, 'render' ), 10, 5 ); add_action( 'cmb2_render_post_ajax_search', array( $this, 'render' ), 10, 5 );
add_action( 'cmb2_render_user_ajax_search', array( $this, 'render' ), 10, 5 ); add_action( 'cmb2_render_user_ajax_search', array( $this, 'render' ), 10, 5 );
@ -52,7 +54,6 @@ if( ! class_exists( 'CMB2_Field_Ajax_Search' ) ) {
* Render field * Render field
*/ */
public function render( $field, $value, $object_id, $object_type, $field_type ) { public function render( $field, $value, $object_id, $object_type, $field_type ) {
$this->setup_admin_scripts();
$field_name = $field->_name(); $field_name = $field->_name();
$default_limit = 1; $default_limit = 1;