87 lines
2.3 KiB
PHP
87 lines
2.3 KiB
PHP
<?php
|
|
/**
|
|
* Plugin Name: THALIM HAL Importer
|
|
* Plugin URI: https://thalim.fr
|
|
* Description: Import publications from HAL for the THALIM lab (structure_s:THALIM)
|
|
* Version: 2.0.0
|
|
* Author: THALIM Dev
|
|
* Author URI: https://thalim.fr
|
|
* License: GPL v2 or later
|
|
* Text Domain: thalim-hal-importer
|
|
*/
|
|
|
|
// Prevent direct access
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
// Plugin constants
|
|
define('THALIM_HAL_VERSION', '2.0.0');
|
|
define('THALIM_HAL_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
|
define('THALIM_HAL_PLUGIN_URL', plugin_dir_url(__FILE__));
|
|
|
|
// HAL API configuration
|
|
define('THALIM_HAL_API_BASE', 'https://api.archives-ouvertes.fr/search/');
|
|
define('THALIM_HAL_STRUCT_ID', 254015); // THALIM lab structure ID
|
|
define('THALIM_HAL_DOC_TYPES', ['ART', 'COUV', 'OUV', 'COMM', 'ISSUE', 'PROCEEDINGS', 'THESE', 'HDR', 'SON', 'VIDEO']);
|
|
|
|
/**
|
|
* Main plugin class - minimal bootstrap
|
|
*/
|
|
class Thalim_HAL_Importer {
|
|
|
|
private static $instance = null;
|
|
|
|
public static function get_instance() {
|
|
if (self::$instance === null) {
|
|
self::$instance = new self();
|
|
}
|
|
return self::$instance;
|
|
}
|
|
|
|
private function __construct() {
|
|
$this->load_dependencies();
|
|
$this->init_hooks();
|
|
}
|
|
|
|
private function load_dependencies() {
|
|
require_once THALIM_HAL_PLUGIN_DIR . 'includes/class-hal-api.php';
|
|
require_once THALIM_HAL_PLUGIN_DIR . 'includes/class-admin-page.php';
|
|
require_once THALIM_HAL_PLUGIN_DIR . 'includes/class-importer.php';
|
|
}
|
|
|
|
private function init_hooks() {
|
|
add_action('admin_menu', [$this, 'add_admin_menu']);
|
|
}
|
|
|
|
public function add_admin_menu() {
|
|
add_management_page(
|
|
'HAL Import',
|
|
'HAL Import',
|
|
'edit_others_posts',
|
|
'thalim-hal-importer',
|
|
[$this, 'render_admin_page']
|
|
);
|
|
}
|
|
|
|
public function render_admin_page() {
|
|
$admin_page = new Thalim_HAL_Admin_Page();
|
|
$admin_page->render();
|
|
}
|
|
}
|
|
|
|
// Activation hook
|
|
register_activation_hook(__FILE__, function() {
|
|
add_option('thalim_hal_version', THALIM_HAL_VERSION);
|
|
});
|
|
|
|
// Deactivation hook
|
|
register_deactivation_hook(__FILE__, function() {
|
|
delete_transient('thalim_hal_preview_data');
|
|
});
|
|
|
|
// Initialize plugin
|
|
add_action('plugins_loaded', function() {
|
|
Thalim_HAL_Importer::get_instance();
|
|
});
|