role_names as $name => $role ) { $roles[ $name ] = translate_user_role( $role ); } return $roles; } function load_textdomain() { load_plugin_textdomain( 'acf-field-roles-filter', false, plugin_dir_url( __FILE__ ) . 'lang/' ); } public function enqueue_scripts() { // cares only about ACF edit pages if ( 'acf' !== get_post_type() ) { return; } wp_enqueue_style( 'acf-field-roles-style', plugin_dir_url( __FILE__ ) . 'css/acf_roles.css' ); wp_enqueue_script( 'acf-field-roles', plugin_dir_url( __FILE__ ) . 'js/acf_roles.js', array( 'jquery', 'acf-field-group' ) ); wp_localize_script( 'acf-field-roles', 'roles', $this->get_roles() ); } public function add_role_metabox() { global $wp_meta_boxes; add_meta_box( 'acf_roles', __( 'User Roles Fields Filters', 'acf-field-roles-filter' ), array( $this, 'roles_metabox' ) , 'acf', 'normal', 'high' ); // reorder metaboxes $roles_metabox = $wp_meta_boxes['acf']['normal']['high']['acf_roles']; unset( $wp_meta_boxes['acf']['normal']['high']['acf_roles'] ); array_splice( $wp_meta_boxes['acf']['normal']['high'], 1, 0, array( $roles_metabox ) ); } public function roles_metabox() { global $post, $wp_roles; $saved_roles = get_post_meta( $post->ID, 'roles', true ); $fields = apply_filters( 'acf/field_group/get_fields', array(), $post->ID ); ?>
|