144 lines
4.4 KiB
PHP
144 lines
4.4 KiB
PHP
|
|
<?php
|
||
|
|
namespace RomhackPlaza;
|
||
|
|
|
||
|
|
defined( '\ABSPATH' ) || exit;
|
||
|
|
|
||
|
|
class Plugin {
|
||
|
|
|
||
|
|
/**
|
||
|
|
* If the RomhackPlaza theme is enabled or not.
|
||
|
|
* @var bool
|
||
|
|
*/
|
||
|
|
public bool $main_theme_enabled = false;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Children created class.
|
||
|
|
* ADD PREFIX FOR EACH STIUATION (Except if it's a direct child and unique, like Customizer)
|
||
|
|
*
|
||
|
|
* Extenders : extend_
|
||
|
|
* Overriders : override_
|
||
|
|
* Ajax elements : ajax_
|
||
|
|
* ...
|
||
|
|
*
|
||
|
|
* @var array
|
||
|
|
*/
|
||
|
|
public array $children = [];
|
||
|
|
|
||
|
|
/* ---
|
||
|
|
* [INFO] Some children have their own separated attribute if there are frequently used.
|
||
|
|
--- */
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Setting object.
|
||
|
|
* @var Settings
|
||
|
|
*/
|
||
|
|
final public Settings $settings;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Custom post types elements.
|
||
|
|
* @var Registrars\Custom_Post_Types
|
||
|
|
*/
|
||
|
|
final public Registrars\Custom_Post_Types $cpt;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Taxonomies elements.
|
||
|
|
* @var Registrars\Taxonomies
|
||
|
|
*/
|
||
|
|
final public Registrars\Taxonomies $tax;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Post status elements.
|
||
|
|
* @var Registrars\Custom_Post_Status
|
||
|
|
*/
|
||
|
|
final public Registrars\Custom_Post_Status $post_status;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* User roles functions.
|
||
|
|
* @var Overrides\Capabilities
|
||
|
|
*/
|
||
|
|
final public Overrides\Capabilities $user_roles;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* New plugin element, setup it.
|
||
|
|
*/
|
||
|
|
public function __construct() {
|
||
|
|
|
||
|
|
add_action( 'after_setup_theme', [ $this, 'setup_after_theme' ] );
|
||
|
|
return $this;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Extenders setup directly after construct.
|
||
|
|
* @return Plugin
|
||
|
|
*/
|
||
|
|
public function setup_extenders_direct(): Plugin {
|
||
|
|
|
||
|
|
$this->settings = new Settings();
|
||
|
|
$this->cpt = new Registrars\Custom_Post_Types();
|
||
|
|
$this->tax = new Registrars\Taxonomies();
|
||
|
|
$this->post_status = new Registrars\Custom_Post_Status();
|
||
|
|
$this->user_roles = new Overrides\Capabilities();
|
||
|
|
|
||
|
|
$this->children['extend_save_post'] = new Extenders\Post\Save_Post();
|
||
|
|
$this->children['extend_post_properties'] = new Extenders\Post\Properties();
|
||
|
|
|
||
|
|
$this->children['extend_acf_pro'] = new Extenders\Advanced_Custom_Fields_Pro();
|
||
|
|
|
||
|
|
$this->children['override_post_announcements'] = new Overrides\Post_Announcements();
|
||
|
|
|
||
|
|
$this->children['extend_admin_pages'] = new Extenders\Admin\Pages();
|
||
|
|
$this->children['extend_submissions'] = new Extenders\Submissions();
|
||
|
|
$this->children['extend_discord'] = new Extenders\Discord_Notification();
|
||
|
|
$this->children['extend_notifications'] = new Extenders\User_Notifications();
|
||
|
|
$this->children['extend_admin_scripts'] = new Extenders\Admin_Scripts();
|
||
|
|
|
||
|
|
// Ajax requests
|
||
|
|
$this->children['ajax_submissions_save_entry'] = new Extenders\Ajax\Submissions_Save_Entry();
|
||
|
|
$this->children['ajax_reserve_post_id'] = new Extenders\Ajax\Reserve_Post_ID();
|
||
|
|
$this->children['ajax_set_favorite_server'] = new Extenders\Ajax\Set_Favorite_Server();
|
||
|
|
$this->children['ajax_search_game_term'] = new Extenders\Ajax\Search_Game_Term();
|
||
|
|
$this->children['ajax_search_author_term'] = new Extenders\Ajax\Search_Author_Term();
|
||
|
|
$this->children['ajax_search_user'] = new Extenders\Ajax\Search_User();
|
||
|
|
$this->children['ajax_notifications_unread'] = new Extenders\Ajax\Notifications_Unread_To_Read();
|
||
|
|
$this->children['ajax_notifications_reply'] = new Extenders\Ajax\Notifications_Reply();
|
||
|
|
$this->children['ajax_notifications_contact'] = new Extenders\Ajax\Notifications_Contact();
|
||
|
|
$this->children['ajax_submit_notification'] = new Extenders\Ajax\Submit_Notification();
|
||
|
|
|
||
|
|
return $this;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Just after theme loaded.
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
public function setup_after_theme() {
|
||
|
|
$this->main_theme_enabled = $this->_is_theme_enabled();
|
||
|
|
$this->setup_extenders_after_theme();
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Setup hooks that need to be loaded after the theme is loaded and ensure it's the good one.
|
||
|
|
* @return $this
|
||
|
|
*/
|
||
|
|
public function setup_extenders_after_theme(): Plugin {
|
||
|
|
|
||
|
|
$this->children['extend_timber'] = new Extenders\Timber();
|
||
|
|
$this->children['extend_dashboard'] = new Extenders\Admin\Dashboard();
|
||
|
|
|
||
|
|
return $this;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Check if the RomhackPlaza plugin is enabled or not.
|
||
|
|
* @return bool
|
||
|
|
*/
|
||
|
|
private function _is_theme_enabled(): bool {
|
||
|
|
|
||
|
|
return class_exists( 'RomhackPlaza\Theme' ) || defined( 'ROMHACKPLAZA_THEME' );
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|