localizationDomain . "-".$locale.".mo"; load_textdomain($this->localizationDomain, $mo); /** * Instantiate all of our classes before running initialization on each! * @todo All initialization should be abstracted to an 'init' function instead of in the constructor */ $this->custom_taxonomies = new ad_custom_taxonomies(); $this->user = new ad_user(); $this->post = new ad_post(); $this->manage_posts = new ad_manage_posts(); $this->settings = new ad_settings(); $this->public_views = new ad_public_views(); $this->dashboard_widgets = new ad_dashboard_widgets(); /** * Store form messages */ $_REQUEST['assignment_desk_messages'] = array(); /** * Provide an easy way to access Assignment Desk settings w/o querying database every time */ $this->general_options = get_option($this->get_plugin_option_fullname('general')); $this->pitch_form_options = get_option($this->get_plugin_option_fullname('pitch_form')); $this->public_facing_options = get_option($this->get_plugin_option_fullname('public_facing')); } /** * Initialize various bits and pieces of functionality */ function init() { $this->custom_taxonomies->init(); $this->user->init_user(); if ( is_admin() ) { add_action( 'admin_menu', array(&$this, 'add_admin_menu_items')); add_action( 'admin_menu', array(&$this->custom_taxonomies, 'remove_assignment_status_post_meta_box') ); $this->manage_posts->init(); $this->dashboard_widgets->init(); $this->post->init(); } else if (!is_admin()) { $this->public_views->init(); } } /** * Initialize the plugin for the admin */ function admin_init() { $this->add_admin_assets(); $this->settings->init(); } /** * Check to see whether this is the first time AD has been activated. * Call the activate() or activate_once() method of each component that has work to do at * activation time. */ function activate_plugin() { // This is an upgrade or re-activation if ( $this->general_options['ad_installed_once'] == 'on' ){ // Custom Taxonomies $this->custom_taxonomies->init(); $this->custom_taxonomies->activate(); // Another Component } // This is the first time we've ever activated the plugin. else { // Custom Taxonomies $this->custom_taxonomies->init(); $this->custom_taxonomies->activate(); $this->custom_taxonomies->activate_once(); $this->settings->setup_defaults(); // Another Component // Update the settings so we don't go through the install-time routines on upgrade/re-activation $this->general_options = get_option($this->get_plugin_option_fullname('general')); $this->general_options['ad_installed_once'] = 'on'; update_option($this->get_plugin_option_fullname('general'), $this->general_options); } } /** * Utility function */ function get_plugin_option_fullname( $name ) { return $this->options_group . $name; } /** * Check to see if Edit Flow is activated */ function edit_flow_exists() { if ( class_exists('edit_flow') ) { return true; } else { return false; } } /** * Check to see if Co-Authors Plus is activated */ function coauthors_plus_exists() { if ( class_exists('coauthors_plus') ) { return true; } else { return false; } } /** * Adds our CSS to the admin pages */ function add_admin_assets() { // Enqueue stylesheets wp_enqueue_style('ad-admin-css', ASSIGNMENT_DESK_URL.'css/admin.css', null, ASSIGMENT_DESK_VERSION, 'all'); // Enqueue necessary scripts wp_enqueue_script('tiny_mce'); wp_enqueue_script('wp-ajax-response'); wp_enqueue_script('jquery-truncator-js', ASSIGNMENT_DESK_URL .'js/jquery.truncator.js', array('jquery')); wp_enqueue_script('ad-admin-js', ASSIGNMENT_DESK_URL .'js/admin.js', array('jquery'), ASSIGMENT_DESK_VERSION); } /** * Adds menu items for the plugin */ function add_admin_menu_items() { /** * Top-level Assignment Desk menu goes to Settings * @permissions Edit posts or higher */ add_menu_page( 'Assignment Desk', 'Assignment Desk', $this->define_admin_permissions, $this->top_level_page, array(&$this->settings, 'general_settings')); /** * Pitch Form settings page */ add_submenu_page( $this->top_level_page, 'Pitch Form', 'Pitch Form', $this->define_admin_permissions, $this->pitch_form_settings_page, array(&$this->settings, 'pitch_form_settings')); /** * Public-Facing settings page */ add_submenu_page( $this->top_level_page, 'Public-Facing', 'Public-Facing', $this->define_admin_permissions, $this->public_facing_settings_page, array(&$this->settings, 'public_facing_settings')); /** * WordPress taxonomy view for editing Pitch Statuses */ add_submenu_page( $this->top_level_page, 'Assignment Statuses', 'Assignment Statuses', $this->define_editor_permissions, 'edit-tags.php?taxonomy='.$this->custom_taxonomies->assignment_status_label); /** * WordPress taxonomy view for editing User Types */ add_submenu_page( $this->top_level_page, 'User Types', 'User Types', $this->define_editor_permissions, 'edit-tags.php?taxonomy='.$this->custom_taxonomies->user_type_label); /** * WordPress taxonomy view for editing User Roles */ add_submenu_page( $this->top_level_page, 'User Roles', 'User Roles', $this->define_editor_permissions, 'edit-tags.php?taxonomy='.$this->custom_taxonomies->user_role_label); } } //End Class } //End if class exists statement global $assignment_desk; $assignment_desk = new assignment_desk(); // Core hooks to initialize the plugin add_action('init', array(&$assignment_desk,'init')); add_action('admin_init', array(&$assignment_desk,'admin_init')); // Hook to perform action when plugin activated register_activation_hook(ASSIGNMENT_DESK_FILE_PATH, array(&$assignment_desk, 'activate_plugin'));