*/ class Reuna_Glossario_Admin { /** * The ID of this plugin. * * @since 1.0.0 * @access private * @var string $plugin_name The ID of this plugin. */ private $plugin_name; /** * The version of this plugin. * * @since 1.0.0 * @access private * @var string $version The current version of this plugin. */ private $version; /** * Initialize the class and set its properties. * * @since 1.0.0 * @param string $plugin_name The name of this plugin. * @param string $version The version of this plugin. */ public function __construct( $plugin_name, $version ) { $this->plugin_name = $plugin_name; $this->version = $version; } /** * Register the stylesheets for the admin area. * * @since 1.0.0 */ public function enqueue_styles() { wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/reuna-glossario-admin.css', [], $this->version, 'all' ); } /** * Register the JavaScript for the admin area. * * @since 1.0.0 */ public function enqueue_scripts() { } /** * Register the custom post type to contain the Glossario. * * @since 1.0.0 */ public function register_glossario_post_type() { register_extended_post_type('glossario', [ 'hierarchical' => false, 'public' => false, 'show_ui' => true, 'show_in_rest' => false, 'labels' => [ 'name' => 'Glossário', 'singular_name' => 'Termo', 'new_item' => 'Novo termo', 'add_new' => 'Novo termo', 'add_new_item' => 'Adicionar novo termo', 'view_item' => 'Ver termo', 'search_items' => 'Pesquisar termos', 'not_found' => 'Nenhum termo encontrado', 'not_found_in_trash' => 'Nenhum termo encontrado na lixeira', 'all_items' => 'Todos os termos', 'menu_name' => 'Glossário', ], 'supports' => [ 'title', 'editor', 'author', 'custom_fields', 'revisions', ], 'menu_icon' => 'dashicons-book', ]); } /** * Display the shortcode associated to a Glossario post below its title * in the edit screen. * * @since 1.0.0 */ public function display_term_shortcode_after_title($post) { if (get_post_type($post) !== 'glossario') { return; } require (plugin_dir_path(__FILE__) . 'partials/shortcode-metabox.php'); } /** * Add the post_title_like argument to WP_Query * * @since 1.0.0 */ public function wp_query_by_post_title_like($where, $wp_query) { global $wpdb; $post_title_like = $wp_query->get('post_title_like'); if ($post_title_like) { $where .= ' AND ' . $wpdb->posts . '.post_title LIKE \'' . esc_sql( $wpdb->esc_like( $post_title_like ) ) . '\''; } return $where; } }