setup_globals(); $this->includes(); $this->setup_actions(); } /** * Set up the admin hooks, actions and filters * * @since Achievements (3.0) */ private function setup_actions() { // Bail to prevent interfering with the deactivation process if ( dpa_is_deactivation() ) return; // If the plugin's been activated network-wide, only load the admin stuff on the DPA_DATA_STORE site if ( is_multisite() && dpa_is_running_networkwide() && get_current_blog_id() !== DPA_DATA_STORE ) return; // General Actions // Add menu item to settings menu add_action( 'dpa_admin_menu', array( $this, 'admin_menus' ) ); // Add settings add_action( 'dpa_register_admin_settings', array( $this, 'register_admin_settings' ) ); // Column headers add_filter( 'manage_achievement_posts_columns', 'dpa_achievement_posts_columns' ); // Columns (in page row) add_action( 'manage_posts_custom_column', 'dpa_achievement_custom_column', 10, 2 ); // Sortable columns add_filter( 'manage_edit-achievement_sortable_columns', 'dpa_achievement_sortable_columns' ); // Metabox actions add_action( 'save_post', 'dpa_achievement_metabox_save' ); // Contextual Help add_action( 'load-edit.php', 'dpa_achievement_index_contextual_help' ); add_action( 'load-post-new.php', 'dpa_achievement_new_contextual_help' ); add_action( 'load-post.php', 'dpa_achievement_new_contextual_help' ); // Messages add_filter( 'post_updated_messages', 'dpa_achievement_feedback_messages' ); // Allow plugins to modify these actions do_action_ref_array( 'dpa_admin_loaded', array( &$this ) ); } /** * Include required files * * @since Achievements (3.0) */ private function includes() { if ( ! class_exists( 'WP_List_Table' ) ) require( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); if ( ! class_exists( 'WP_Users_List_Table' ) ) require( ABSPATH . 'wp-admin/includes/class-wp-users-list-table.php' ); // Supported plugins screen require( $this->admin_dir . 'functions.php' ); require( $this->admin_dir . 'supported-plugins.php' ); // Users screen require( $this->admin_dir . 'class-dpa-users-list-table.php' ); require( $this->admin_dir . 'users.php' ); } /** * Set admin globals * * @since Achievements (3.0) */ private function setup_globals() { $this->admin_dir = trailingslashit( achievements()->includes_dir . 'admin' ); // Admin path $this->admin_url = trailingslashit( achievements()->includes_url . 'admin' ); // Admin URL $this->css_url = trailingslashit( $this->admin_url . 'css' ); // Admin CSS URL $this->images_url = trailingslashit( $this->admin_url . 'images' ); // Admin images URL $this->javascript_url = trailingslashit( $this->admin_url . 'js' ); // Admin javascript URL } /** * Add wp-admin menus * * @since Achievements (3.0) */ public function admin_menus() { $hooks = array(); // About add_dashboard_page( __( 'Welcome to Achievements', 'dpa' ), __( 'Welcome to Achievements', 'dpa' ), $this->minimum_capability, 'achievements-about', array( $this, 'about_screen' ) ); remove_submenu_page( 'index.php', 'achievements-about' ); // "Users" menu $hooks[] = add_submenu_page( 'edit.php?post_type=achievement', __( 'Achievements — Users', 'dpa' ), _x( 'Users', 'admin menu title', 'dpa' ), $this->minimum_capability, 'achievements-users', 'dpa_admin_screen_users' ); // "Supported Plugins" menu $hooks[] = add_submenu_page( 'edit.php?post_type=achievement', __( 'Achievements — Supported Plugins', 'dpa' ), __( 'Supported Plugins', 'dpa' ), $this->minimum_capability, 'achievements-plugins', 'dpa_supported_plugins' ); foreach( $hooks as $hook ) { // Hook into early actions to register custom CSS and JS add_action( "admin_print_styles-$hook", array( $this, 'enqueue_styles' ) ); add_action( "admin_print_scripts-$hook", array( $this, 'enqueue_scripts' ) ); // Hook into early actions to register contextual help and screen options add_action( "load-$hook", array( $this, 'screen_options' ) ); } // Actions for the edit.php?post_type=achievement index screen add_action( 'load-edit.php', array( $this, 'enqueue_index_styles' ) ); // Add/save custom profile field on the edit user screen add_action( 'edit_user_profile', array( $this, 'add_profile_fields' ) ); add_action( 'show_user_profile', array( $this, 'add_profile_fields' ) ); add_action( 'edit_user_profile_update', array( $this, 'save_profile_fields' ) ); add_action( 'personal_options_update', array( $this, 'save_profile_fields' ) ); // Remove the "categories" submenu from inside the achievement post type menu remove_submenu_page( 'edit.php?post_type=' . dpa_get_achievement_post_type(), 'edit-tags.php?taxonomy=category&post_type=' . dpa_get_achievement_post_type() ); } /** * Hook into early actions to register contextual help and screen options * * @since Achievements (3.0) */ public function screen_options() { // Only load up styles if we're on an Achievements admin screen if ( ! DPA_Admin::is_admin_screen() ) return; // "Supported Plugins" screen if ( 'achievements-plugins' === $_GET['page'] ) dpa_supported_plugins_on_load(); elseif ( 'achievements-users' === $_GET['page'] ) dpa_admin_screen_users_on_load(); } /** * Enqueue CSS for our custom admin screens * * @since Achievements (3.0) */ public function enqueue_styles() { // Only load up styles if we're on an Achievements admin screen if ( ! DPA_Admin::is_admin_screen() ) return; $rtl = is_rtl() ? '-rtl' : ''; // "Supported Plugins" screen if ( 'achievements-plugins' === $_GET['page'] ) wp_enqueue_style( 'dpa_admin_css', trailingslashit( $this->css_url ) . "supportedplugins{$rtl}.css", array(), '20120722' ); // Achievements "users" screen elseif ( 'achievements-users' === $_GET['page'] ) wp_enqueue_style( 'dpa_admin_users_css', trailingslashit( $this->css_url ) . "users{$rtl}.css", array(), '20130113' ); } /** * Enqueue CSS for the edit.php?post_type=achievement index screen * * @since Achievements (3.3) */ public function enqueue_index_styles() { // Only load up styles if we're on an Achievements admin screen if ( ! DPA_Admin::is_admin_screen() ) return; wp_enqueue_style( 'dpa_admin_index_css', trailingslashit( $this->css_url ) . 'admin-editindex.css', array(), '20130423' ); } /** * Enqueue JS for our custom admin screens * * @since Achievements (3.0) */ public function enqueue_scripts() { // Only load up scripts if we're on an Achievements admin screen if ( ! DPA_Admin::is_admin_screen() ) return; // "Supported Plugins" screen if ( 'achievements-plugins' === $_GET['page'] ) { wp_enqueue_script( 'dpa_socialite', trailingslashit( $this->javascript_url ) . 'socialite-min.js', array(), '20120722', true ); wp_enqueue_script( 'tablesorter_js', trailingslashit( $this->javascript_url ) . 'jquery-tablesorter-min.js', array( 'jquery' ), '20120722', true ); wp_enqueue_script( 'dpa_sp_admin_js', trailingslashit( $this->javascript_url ) . 'supportedplugins-min.js', array( 'jquery', 'dpa_socialite', 'dashboard', 'postbox' ), '20120722', true ); // Add thickbox for the 'not installed' links on the List view add_thickbox(); } } /** * Register the settings * * @since Achievements (3.0) */ public function register_admin_settings() { // Only do stuff if we're on an Achievements admin screen if ( ! DPA_Admin::is_admin_screen() ) return; // Fire an action for Achievements plugins to register their custom settings do_action( 'dpa_register_admin_settings' ); } /** * Add the 'User Points' box to Edit User page, and a list of the user's current achievements. * * @param object $user * @since Achievements (3.0) */ public function add_profile_fields( $user ) { if ( ! is_super_admin() ) return; ?>
awards and events. Award achievements have to be manually given out by a site admin, and event achievements are awarded automatically when its criteria has been met. Learn more about achievement types.', 'dpa' ); ?>
Getting Started guide will walk you through this easy process.', 'dpa' ); ?>
WordPress.org support forum. We’d love to find out how you’re using Achievements, so be sure to drop by and tell us!', 'dpa' ), esc_url( 'http://wordpress.org/support/plugin/achievements' ) ); ?>
Edit in the publish module and select Private. Remember to save your changes!', 'dpa' ); ?>
WP-PostRatings plugin adds a star rating system to your site’s posts and pages (and much more!). Typically, it’s used as fun way to gather feedback about your content from your site’s users.', 'dpa' ), esc_url( 'http://wordpress.org/plugins/wp-postratings/' ) ); ?>
bbPress and BuddyPress.', 'dpa' ), esc_url( 'http://bbpress.org/' ), esc_url( 'http://buddypress.org/' ) ); ?>