full name. */ public $tables; /** @var assignment_desk_install $installer handles install-time tasks. */ public $installer; // Controllers /** @var assignment_desk_index_controller $index_controller serves the activity feed views. */ public $index_controller; /** * @var assignment_desk_assignment_controller $assignment_controller serves the editor's assignment-management views. */ public $assignment_controller; /** * @var assignment_desk_contributor_controller $contributor_controller serves the contributor profile and assignment views. */ public $contributor_controller; // Widgets /** * @var assignment_desk_dashboard_widgets $dashboard_widgets provides the widget. */ public $dashboard_widgets; /** * Constructor */ function __construct(){ global $wpdb; // Language Setup $locale = get_locale(); $mo = dirname(__FILE__) . "/languages/" . $this->localizationDomain . "-".$locale.".mo"; load_textdomain($this->localizationDomain, $mo); // Initialize the options $this->getOptions(); // Database table names. $this->tables = array( 'pitch_votes' => $wpdb->prefix . $this->table_prefix . 'pitch_votes', 'event' => $wpdb->prefix . $this->table_prefix . "event" ); $this->installer = new assignment_desk_install(); // Controllers for WP Admin views. $this->index_controller = new assignment_desk_index_controller(); $this->assignment_controller = new assignment_desk_assignment_controller(); $this->contributor_controller = new assignment_desk_contributor_controller(); // Widgets $this->dashboard_widgets = new assignment_desk_dashboard_widgets(); $this->custom_user_types = new ad_custom_taxonomy('user_type', 'user', array( 'hierarchical' => false, 'label' => __('User Contributor Level')) ); $this->custom_user_roles = new ad_custom_taxonomy('user_post_role', 'user', array( 'label' => __('User Post Role'),) ); $this->custom_pitch_statuses = new ad_custom_taxonomy('pitch_status', 'post', array('label' => __('Pitch Statuses'), 'show_meta_box' => false, )); $this->public_controller = new ad_public_controller(); add_action('admin_menu', array(&$this, 'add_admin_menu_items')); } // Actions that happen only on activate. function activate_plugin() { $this->installer->setup_db(); $this->public_controller->flush_rewrite_rules(); } /** * Retrieves the plugin options from the database. * @return array */ function getOptions() { //Don't forget to set up the default options if (!$theOptions = get_option($this->optionsName)) { $theOptions = array('default'=>'options'); update_option($this->optionsName, $theOptions); } $this->options = $theOptions; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //There is no return here, because you should use the $this->options variable!!! //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! } /** * Saves the admin options to the database. */ function save_admin_options(){ return update_option($this->optionsName, $this->options); } /** * Adds our CSS to the admin pages */ function add_admin_css() { echo ""; } /** * Adds our JS to the admin pages */ function add_admin_js() { 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('jquery-autocomplete-js', ASSIGNMENT_DESK_URL .'js/jquery.autocomplete.min.js', array('jquery')); wp_enqueue_script('edit_flow-post_comments-js', EDIT_FLOW_URL.'js/post_comment.js', array('jquery')); } /** * Adds menu items for the plugin */ function add_admin_menu_items() { // This is the button in the admin menu. add_menu_page('Assignment Desk', 'Assignment Desk', 'edit_posts', 'assignment_desk-menu', array(&$this->index_controller, 'dispatch')); // Add "Activity" for contributors and higher. $activity_page = add_submenu_page('assignment_desk-menu', 'Activity', 'Activity', 'edit_posts', 'assignment_desk-index', array(&$this->index_controller, 'dispatch')); $pitches_page = add_submenu_page('edit.php', __('Pitches'), __('Pitches'), 5, 'assignment_desk-pitches', array(&$this, 'link_to_pitches')); // Add "Your Content" for contributors and higher. add_submenu_page('assignment_desk-menu', 'Your Content', 'Your Content', 'edit_posts', 'assignment_desk-contributor', array(&$this->contributor_controller, 'dispatch')); // Add Assignments sub-menu for Editors $assignments_page = add_submenu_page('assignment_desk-menu', 'Assignments', 'Assignments', 5, 'assignment_desk-assignments', array(&$this->assignment_controller, 'dispatch')); /* Using registered $assignments_page handle to hook script load */ add_action('admin_print_scripts-' . $assignments_page, array(&$this, 'add_admin_js')); // Add Settings sub-menu page for Editors add_submenu_page('assignment_desk-menu', 'Settings', 'Settings', 5, 'assignment_desk-settings', array(&$this, 'admin_settings_page')); } /** * This function currently doesn't work. We need to figure out how to link into the edit.php * page and pass the post_status=pitch flag. */ function link_to_pitches(){ $_GET['post_status'] = 'pitch'; include(ABSPATH . 'wp-admin/edit.php'); } /** * Adds settings/options page */ function admin_settings_page() { if($_POST['assignment_desk_save']){ if (! wp_verify_nonce($_POST['_wpnonce'], 'assignment_desk-update-options') ) { die('Whoops! There was a problem with the data you posted. Please go back and try again.'); } $this->options['google_api_key'] = wp_kses($_POST['google_api_key'], $allowedtags); $this->options['assignment_desk_twitter_hash'] = wp_kses($_POST['assignment_desk_twitter_hash'], $allowedtags); if(substr($this->options['assignment_desk_twitter_hash'], 0, 1) != "#"){ echo '
Success! Your changes were sucessfully saved!