<?php
|
|
|
|
/**
|
|
* The admin-specific functionality of the plugin.
|
|
*
|
|
* @link https://horizontes.info
|
|
* @since 1.0.0
|
|
*
|
|
* @package Reuna_Glossario
|
|
* @subpackage Reuna_Glossario/admin
|
|
*/
|
|
|
|
/**
|
|
* The admin-specific functionality of the plugin.
|
|
*
|
|
* Defines the plugin name, version, and two examples hooks for how to
|
|
* enqueue the admin-specific stylesheet and JavaScript.
|
|
*
|
|
* @package Reuna_Glossario
|
|
* @subpackage Reuna_Glossario/admin
|
|
* @author Horizontes Coop. <contato@horizontes.info>
|
|
*/
|
|
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()
|
|
{
|
|
}
|
|
|
|
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',
|
|
|
|
]);
|
|
}
|
|
|
|
public function display_term_shortcode_after_title()
|
|
{
|
|
global $post;
|
|
require (plugin_dir_path(__FILE__) . 'partials/shortcode-metabox.php');
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|