load_dependencies(); $this->set_locale(); $this->define_admin_hooks(); $this->define_public_hooks(); $this->set_meta_caps(); } /** * Load the required dependencies for this plugin. * * Create an instance of the loader which will be used to register the hooks * with WordPress. * * @since 1.0.0 * @access private */ private function load_dependencies() { /** * The class responsible for orchestrating the actions and filters of the * core plugin. */ require_once AEC_PLUGIN_DIR . 'includes/class-aec-loader.php'; /** * The class responsible for defining internationalization functionality * of the plugin. */ require_once AEC_PLUGIN_DIR . 'includes/class-aec-i18n.php'; /** * The class responsibe for managing custom capabilities. */ require_once AEC_PLUGIN_DIR . 'includes/class-aec-roles.php'; /** * Helper functions */ require_once AEC_PLUGIN_DIR . 'includes/helper-functions.php'; /** * The classes responsible for defining all actions that occur in the admin area. */ require_once AEC_PLUGIN_DIR . 'admin/class-aec-admin.php'; require_once AEC_PLUGIN_DIR . 'admin/class-aec-admin-events.php'; require_once AEC_PLUGIN_DIR . 'admin/class-aec-admin-categories.php'; require_once AEC_PLUGIN_DIR . 'admin/class-aec-admin-tags.php'; require_once AEC_PLUGIN_DIR . 'admin/class-aec-admin-venues.php'; require_once AEC_PLUGIN_DIR . 'admin/class-aec-admin-organizers.php'; require_once AEC_PLUGIN_DIR . 'admin/class-aec-admin-recurring-events.php'; require_once AEC_PLUGIN_DIR . 'admin/class-aec-admin-settings.php'; /** * The classes responsible for defining all actions that occur in the public-facing * side of the site. */ require_once AEC_PLUGIN_DIR . 'public/class-aec-public.php'; require_once AEC_PLUGIN_DIR . 'public/class-aec-public-categories.php'; require_once AEC_PLUGIN_DIR . 'public/class-aec-public-calendar.php'; require_once AEC_PLUGIN_DIR . 'public/class-aec-public-events.php'; require_once AEC_PLUGIN_DIR . 'public/class-aec-public-map.php'; require_once AEC_PLUGIN_DIR . 'public/class-aec-public-search.php'; require_once AEC_PLUGIN_DIR . 'public/class-aec-public-venues.php'; require_once AEC_PLUGIN_DIR . 'public/class-aec-public-organizers.php'; require_once AEC_PLUGIN_DIR . 'public/class-aec-public-tags.php'; require_once AEC_PLUGIN_DIR . 'public/class-aec-public-user.php'; $this->loader = new AEC_Loader(); } /** * Define the locale for this plugin for internationalization. * * @since 1.0.0 * @access private */ private function set_locale() { $plugin_i18n = new AEC_i18n(); $this->loader->add_action( 'init', $plugin_i18n, 'load_plugin_textdomain' ); } /** * Register all of the hooks related to the admin area functionality * of the plugin. * * @since 1.0.0 * @access private */ private function define_admin_hooks() { // Hooks common for all admin pages $plugin_admin = new AEC_Admin(); $this->loader->add_action( 'wp_loaded', $plugin_admin, 'manage_upgrades' ); $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); $this->loader->add_action( 'admin_menu', $plugin_admin, 'set_menu_order', 99 ); $this->loader->add_action( 'admin_notices', $plugin_admin, 'admin_notices' ); $this->loader->add_filter( 'admin_footer_text', $plugin_admin, 'admin_footer_text' ); // Hooks specific to events page $plugin_events = new AEC_Admin_Events(); $this->loader->add_action( 'init', $plugin_events, 'register_post_type' ); $this->loader->add_action( 'add_meta_boxes', $plugin_events, 'register_meta_boxes' ); $this->loader->add_action( 'save_post', $plugin_events, 'save_meta_boxes', 10, 2 ); $this->loader->add_action( 'restrict_manage_posts', $plugin_events, 'restrict_manage_posts' ); $this->loader->add_action( 'manage_aec_events_posts_custom_column', $plugin_events, 'manage_posts_custom_column', 10, 2 ); $this->loader->add_filter( 'parse_query', $plugin_events, 'parse_query' ); $this->loader->add_filter( 'manage_edit-aec_events_columns', $plugin_events, 'manage_posts_columns' ); // Hooks specific to categories page $plugin_categories = new AEC_Admin_Categories(); $this->loader->add_action( 'init', $plugin_categories, 'register_taxonomy' ); // Hooks specific to tags page $plugin_tags = new AEC_Admin_Tags(); $this->loader->add_action( 'init', $plugin_tags, 'register_taxonomy' ); // Hooks specific to venues page $plugin_venues = new AEC_Admin_Venues(); $this->loader->add_action( 'init', $plugin_venues, 'register_post_type' ); $this->loader->add_action( 'add_meta_boxes', $plugin_venues, 'register_meta_boxes' ); $this->loader->add_action( 'save_post', $plugin_venues, 'save_meta_boxes', 10, 2 ); $this->loader->add_action( 'manage_aec_venues_posts_custom_column', $plugin_venues, 'manage_posts_custom_column', 10, 2 ); $this->loader->add_filter( 'enter_title_here', $plugin_venues, 'change_title_text' ); $this->loader->add_filter( 'manage_edit-aec_venues_columns', $plugin_venues, 'manage_posts_columns' ); // Hooks specific to organizers page $plugin_organizers = new AEC_Admin_Organizers(); $this->loader->add_action( 'init', $plugin_organizers, 'register_post_type' ); $this->loader->add_action( 'add_meta_boxes', $plugin_organizers, 'register_meta_boxes' ); $this->loader->add_action( 'save_post', $plugin_organizers, 'save_meta_boxes', 10, 2 ); $this->loader->add_action( 'manage_aec_organizers_posts_custom_column', $plugin_organizers, 'manage_posts_custom_column', 10, 2 ); $this->loader->add_filter( 'enter_title_here', $plugin_organizers, 'change_title_text' ); $this->loader->add_filter( 'manage_edit-aec_organizers_columns', $plugin_organizers, 'manage_posts_columns' ); // Hooks specific to recurring events page $plugin_recurring_events = new AEC_Admin_Recurring_Events(); $this->loader->add_action( 'init', $plugin_recurring_events, 'register_post_type' ); $this->loader->add_action( 'add_meta_boxes', $plugin_recurring_events, 'register_meta_boxes' ); $this->loader->add_action( 'save_post', $plugin_recurring_events, 'save_meta_boxes', 10, 2 ); $this->loader->add_action( 'restrict_manage_posts', $plugin_recurring_events, 'restrict_manage_posts' ); $this->loader->add_action( 'manage_aec_recurring_events_posts_custom_column', $plugin_recurring_events, 'manage_posts_custom_column', 10, 2 ); $this->loader->add_filter( 'parse_query', $plugin_recurring_events, 'parse_query' ); $this->loader->add_filter( 'manage_edit-aec_recurring_events_columns', $plugin_recurring_events, 'manage_posts_columns' ); // Hooks specific to settings page $plugin_settings = new AEC_Admin_Settings(); $this->loader->add_action( 'admin_menu', $plugin_settings, 'add_settings_menu' ); $this->loader->add_action( 'admin_init', $plugin_settings, 'admin_init' ); } /** * Register all of the hooks related to the public-facing functionality * of the plugin. * * @since 1.0.0 * @access private */ private function define_public_hooks() { // Hooks common for all public facing functionality of the plugin $plugin_public = new AEC_Public(); $this->loader->add_action( 'init', $plugin_public, 'output_buffer' ); $this->loader->add_action( 'init', $plugin_public, 'add_rewrites' ); $this->loader->add_action( 'wp_loaded', $plugin_public, 'maybe_flush_rules' ); $this->loader->add_action( 'wp_head', $plugin_public, 'og_metatags' ); $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); // implement a filter for the post link title $this->loader->add_filter( 'the_title', $plugin_public, 'the_title', 99 ); $this->loader->add_filter( 'single_post_title', $plugin_public, 'the_title', 99 ); // implement a filter for the page title. Support WordPress < 4.4 $this->loader->add_filter( 'wp_title', $plugin_public, 'wp_title', 99, 3 ); // implement a filter for the page title. Support WordPress >= 4.4 $this->loader->add_filter( 'pre_get_document_title', $plugin_public, 'pre_get_document_title', 999 ); $this->loader->add_filter( 'document_title_parts', $plugin_public, 'document_title_parts' ); // Hooks specific to categor(ies) page $plugin_categories = new AEC_Public_Categories(); // Hooks specific calendar page $plugin_calendar = new AEC_Public_Calendar(); // Hooks specific event(s) page $plugin_events = new AEC_Public_Events(); $this->loader->add_filter( 'post_thumbnail_html', $plugin_events, 'post_thumbnail_html' ); $this->loader->add_filter( 'the_content', $plugin_events, 'the_content' ); // Hooks specific to map page $plugin_map = new AEC_Public_Map(); // Hooks specific to search results page $plugin_search = new AEC_Public_Search(); // Hooks specific single venue page $plugin_venues = new AEC_Public_Venues(); // Hooks specific organizer page $plugin_organizers = new AEC_Public_Organizers(); // Hooks specific to tag(s) page $plugin_tags = new AEC_Public_Tags(); // Hooks specific to user pages $plugin_user = new AEC_Public_User(); $this->loader->add_action( 'init', $plugin_user, 'manage_actions' ); $this->loader->add_action( 'wp_ajax_aec_public_delete_attachment', $plugin_user, 'ajax_callback_delete_attachment' ); $this->loader->add_action( 'wp_ajax_nopriv_aec_public_delete_attachment', $plugin_user, 'ajax_callback_delete_attachment' ); } /** * Map meta caps to primitive caps * * @since 1.6.0 * @access private */ private function set_meta_caps() { $plugin_roles = new AEC_Roles(); $this->loader->add_filter( 'map_meta_cap', $plugin_roles, 'meta_caps', 10, 4 ); } /** * Run the loader to execute all of the hooks with WordPress. * * @since 1.0.0 */ public function run() { $this->loader->run(); } /** * The reference to the class that orchestrates the hooks with the plugin. * * @since 1.0.0 * @return AEC_Loader Orchestrates the hooks of the plugin. */ public function get_loader() { return $this->loader; } }