plugin = $plugin; add_action('admin_enqueue_scripts', [$this, 'admin_enqueue_scripts']); } public function admin_enqueue_scripts($hook) { if($hook == "users.php"){ $this->enqueueUsersTable(); } } public function enqueueUsersTable(){ $info = include $this->plugin->getPath("/build/users-table.asset.php"); wp_enqueue_script( Plugin::HANDLE_USERS_TABLE_JS, $this->plugin->getUrl( "/build/users-table.js"), $info["dependencies"], $info["version"], true ); wp_localize_script( Plugin::HANDLE_USERS_TABLE_JS, "AdditionalAuthors", [ "postsUrl" => admin_url("edit.php"), "ajaxUrl" => admin_url('admin-ajax.php'), "action" => Ajax::ACTION_COUNT_POSTS, "nonce" => wp_create_nonce(Ajax::NONCE_ACTION), ] ); } public function enqueueMetaBox($config){ wp_enqueue_style( Plugin::HANDLE_META_BOX_CSS, $this->plugin->getUrl("/build/meta-box.css"), [], filemtime($this->plugin->getPath("/build/meta-box.css")) ); $info = include $this->plugin->getPath("/build/meta-box.asset.php"); wp_enqueue_script( Plugin::HANDLE_META_BOX_JS, $this->plugin->getUrl("/build/meta-box.js"), $info["dependencies"], $info["version"], true ); wp_localize_script( Plugin::HANDLE_META_BOX_JS, 'AdditionalAuthors', $config ); } public function enqueueGutenberg(){ wp_enqueue_style( Plugin::HANDLE_GUTENBERG_CSS, $this->plugin->getUrl( "/build/gutenberg.css"), [], filemtime($this->plugin->getPath("/build/gutenberg.css")) ); $info = include $this->plugin->getPath("/build/gutenberg.asset.php"); wp_enqueue_script( Plugin::HANDLE_GUTENBERG_JS, $this->plugin->getUrl("/build/gutenberg.js"), $info["dependencies"], $info["version"] ); $users = get_users( apply_filters( Plugin::FILTER_META_BOX_GET_USERS, array( 'role__in' => ['author', 'editor', 'administrator'], 'orderby' => 'display_name', // No user_login: it is the account's login name, the editor UI // never displays it, and core only exposes it to users who may // list users. 'fields' => array( 'ID', 'display_name', 'user_nicename', ), ) ) ); wp_localize_script( Plugin::HANDLE_GUTENBERG_JS, "AdditionalAuthors", [ "users" => $users, "selected" => $this->plugin->database->get_author_ids( get_the_ID()), "i18n" => array( "label" => __( 'Additional Authors', Plugin::DOMAIN ), "add_author" => __( 'Add author', Plugin::DOMAIN ), "search_placeholder" => __( 'Search author…', Plugin::DOMAIN ), "search_404" => __( 'No author found.', Plugin::DOMAIN ), "move_up" => __( 'Move up', Plugin::DOMAIN ), "move_down" => __( 'Move down', Plugin::DOMAIN ), "remove" => __( 'Remove', Plugin::DOMAIN ), ), ] ); } }