110 lines
3.1 KiB
PHP
110 lines
3.1 KiB
PHP
<?php
|
|
/**
|
|
* Plugin Name: Hi-School Slide Manager
|
|
* Plugin URI: https://hi-school.com/slide-manager
|
|
* Description: Multi-site slide management system for Hi-School websites. Allows staff to create and schedule slides on the main site, display them as headers on companion sites via REST API, with advanced preview and editing capabilities.
|
|
* Version: 1.1.1
|
|
* Author: Hi-School Development Team
|
|
* Author URI: https://hi-school.com
|
|
* License: GPL v2 or later
|
|
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
|
* Text Domain: hi-school-slide-manager
|
|
* Domain Path: /languages
|
|
* Network: false
|
|
* Requires at least: 5.0
|
|
* Tested up to: 6.4
|
|
* Requires PHP: 7.4
|
|
*/
|
|
|
|
// Prevent direct access
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit( 'Direct access forbidden.' );
|
|
}
|
|
|
|
// Plugin constants
|
|
define( 'HSSM_VERSION', '1.1.1' );
|
|
define( 'HSSM_PLUGIN_FILE', __FILE__ );
|
|
define( 'HSSM_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
|
define( 'HSSM_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
|
define( 'HSSM_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
|
|
|
// Database table names (if needed for future features)
|
|
// define( 'HSSM_SLIDES_TABLE', 'hssm_slides' );
|
|
// define( 'HSSM_SITES_TABLE', 'hssm_companion_sites' );
|
|
|
|
// Include core files
|
|
require_once HSSM_PLUGIN_DIR . 'includes/class-hssm-autoloader.php';
|
|
require_once HSSM_PLUGIN_DIR . 'includes/class-hssm-main.php';
|
|
|
|
/**
|
|
* Plugin activation hook
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
function hssm_activate() {
|
|
// Create custom capability
|
|
$admin_role = get_role( 'administrator' );
|
|
if ( $admin_role ) {
|
|
$admin_role->add_cap( 'hssm_manage_slides' );
|
|
}
|
|
|
|
// Also add to editor role
|
|
$editor_role = get_role( 'editor' );
|
|
if ( $editor_role ) {
|
|
$editor_role->add_cap( 'hssm_manage_slides' );
|
|
}
|
|
|
|
// Flush rewrite rules to ensure our CPT permalinks work
|
|
flush_rewrite_rules();
|
|
}
|
|
register_activation_hook( __FILE__, 'hssm_activate' );
|
|
|
|
/**
|
|
* Plugin deactivation hook
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
function hssm_deactivate() {
|
|
// Remove custom capability
|
|
$admin_role = get_role( 'administrator' );
|
|
if ( $admin_role ) {
|
|
$admin_role->remove_cap( 'hssm_manage_slides' );
|
|
}
|
|
|
|
$editor_role = get_role( 'editor' );
|
|
if ( $editor_role ) {
|
|
$editor_role->remove_cap( 'hssm_manage_slides' );
|
|
}
|
|
|
|
// Flush rewrite rules
|
|
flush_rewrite_rules();
|
|
}
|
|
register_deactivation_hook( __FILE__, 'hssm_deactivate' );
|
|
|
|
/**
|
|
* Initialize the Hi-School Slide Manager plugin
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
function hssm_init() {
|
|
// Check if we're on the main site (this plugin should only run on main site)
|
|
if ( is_multisite() && ! is_main_site() ) {
|
|
return;
|
|
}
|
|
|
|
// Initialize autoloader
|
|
HSSM_Autoloader::init();
|
|
|
|
// Get the main plugin instance and initialize
|
|
$hssm = HSSM_Main::get_instance();
|
|
$hssm->init();
|
|
}
|
|
|
|
// Hook into WordPress
|
|
add_action( 'plugins_loaded', 'hssm_init' );
|
|
|
|
// Activation and deactivation hooks
|
|
register_activation_hook( __FILE__, array( 'HSSM_Main', 'activate' ) );
|
|
register_deactivation_hook( __FILE__, array( 'HSSM_Main', 'deactivate' ) );
|
|
register_uninstall_hook( __FILE__, array( 'HSSM_Main', 'uninstall' ) );
|