minimum_cap = $this->minimum_cap(); add_action( 'admin_init', array ( $this, 'init' ) ); add_action( 'admin_menu', array( $this, 'dashboard_hooks' ), 990 ); add_action( 'admin_notices', array( $this, 'version_nag' ) ); if ( is_multisite() ) { add_action( 'wpmu_options', array( $this, 'ms_settings' ) ); add_action( 'update_wpmu_options', array( $this, 'save_ms_settings' ) ); } } function init() { foreach ( array('anth_project', 'anth_part', 'anth_library_item', 'anth_imported_item') as $type ) { add_meta_box('anthologize', __( 'Anthologize', 'anthologize' ), array($this,'item_meta_box'), $type, 'side', 'high'); add_meta_box('anthologize-save', __( 'Save', 'anthologize' ), array($this,'meta_save_box'), $type, 'side', 'high'); remove_meta_box( 'submitdiv' , $type , 'normal' ); } add_action('save_post',array( $this, 'item_meta_save' )); do_action( 'anthologize_admin_init' ); } /** * Loads the minimum user capability for displaying the Anthologize menus * * When running Multisite, this function first checks to see whether the super admin has * allowed per-blog settings. * * For now, Anthologize pages are all-or-nothing. In the future, finer-grained access is * planned. In the meantime, feel free to filter this value in your own plugin. * * @package Anthologize * @since 0.6 */ function minimum_cap() { // If the super admin hasn't set a default, it'll fall back to manage_options, i.e. Administrators-only // Get the default cap if ( is_multisite() ) { $site_settings = get_site_option( 'anth_site_settings' ); $default_cap = !empty( $site_settings['minimum_cap'] ) ? $site_settings['minimum_cap'] : 'manage_options'; } else { $default_cap = 'manage_options'; } // Then use the default to set the minimum cap for this blog if ( !is_multisite() || empty( $site_settings['forbid_per_blog_caps'] ) ) { $blog_settings = get_option( 'anth_settings' ); $cap = !empty( $blog_settings['minimum_cap'] ) ? $blog_settings['minimum_cap'] : $default_cap; } else { $cap = $default_cap; } return apply_filters( 'anth_minimum_cap', $cap ); } /** * Adds Anthologize's plugin pages to the Dashboard * * Uses a somewhat hackish method, borrowed from BuddyPress, to get things in a nice order * * @package Anthologize * @since 0.3 */ function dashboard_hooks() { global $menu; // The default location of the Anthologize menu item. Anthologize needs an empty // space before and after it in order to display, so it might have to poke around // a bit to find room for itself $default_index = apply_filters( 'anth_default_menu_position', 55 ); while ( !empty( $menu[$default_index - 1] ) || !empty( $menu[$default_index ] ) || !empty( $menu[$default_index + 1] ) ) { $default_index++; } $separator = array( 0 => '', 1 => 'read', 2 => 'separator-anthologize', 3 => '', 4 => 'wp-menu-separator' ); $menu[$default_index - 1] = $separator; $menu[$default_index + 1] = $separator; $plugin_pages = array(); // Adds the top-level Anthologize Dashboard menu button $this->add_admin_menu_page( array( 'menu_title' => __( 'Anthologize', 'anthologize' ), 'page_title' => __( 'Anthologize', 'anthologize' ), 'access_level' => $this->minimum_cap, 'file' => 'anthologize', 'function' => array( $this, 'display' ), 'position' => $default_index ) ); // Creates the submenu items $plugin_pages[] = add_submenu_page( 'anthologize', __( 'My Projects', 'anthologize' ), __( 'My Projects','anthologize' ), $this->minimum_cap, 'anthologize', array ( $this, 'display' ) ); $plugin_pages[] = add_submenu_page( 'anthologize', __( 'New Project','anthologize' ), __('New Project','anthologize'), $this->minimum_cap, dirname( __FILE__ ) . '/class-new-project.php'); $plugin_pages[] = add_submenu_page( 'anthologize', __( 'Export Project', 'anthologize' ), __( 'Export Project', 'anthologize' ), $this->minimum_cap, dirname( __FILE__ ) . '/class-export-panel.php' ); $plugin_pages[] = add_submenu_page( 'anthologize', __( 'Import Content', 'anthologize' ), __( 'Import Content', 'anthologize' ), $this->minimum_cap, dirname( __FILE__ ) . '/class-import-feeds.php' ); $plugin_pages[] = add_submenu_page( 'anthologize', __( 'Settings', 'anthologize' ), __( 'Settings', 'anthologize' ), $this->minimum_cap, dirname( __FILE__ ) . '/class-settings.php' ); foreach ( $plugin_pages as $plugin_page ) { add_action( "admin_print_styles", array( $this, 'load_styles' ) ); add_action( "admin_print_scripts", array( $this, 'load_scripts' ) ); } } // Borrowed, with much love, from BuddyPress. Allows us to put Anthologize way up top. function add_admin_menu_page( $args = '' ) { global $menu, $admin_page_hooks, $_registered_pages; $defaults = array( 'page_title' => '', 'menu_title' => '', 'access_level' => 2, 'file' => false, 'function' => false, 'icon_url' => false, 'position' => 100 ); $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); $file = plugin_basename( $file ); $admin_page_hooks[$file] = sanitize_title( $menu_title ); $hookname = get_plugin_page_hookname( $file, '' ); if (!empty ( $function ) && !empty ( $hookname )) add_action( $hookname, $function ); if ( empty($icon_url) ) $icon_url = 'images/generic.png'; elseif ( is_ssl() && 0 === strpos($icon_url, 'http://') ) $icon_url = 'https://' . substr($icon_url, 7); do { $position++; } while ( !empty( $menu[$position] ) ); $menu[$position] = array ( $menu_title, $access_level, $file, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url ); unset( $menu[$position][5] ); $_registered_pages[$hookname] = true; return $hookname; } /** * Loads Anthologize's JS * * This needs a massive amount of cleanup * * @package Anthologize * @since 0.3 */ function load_scripts() { wp_enqueue_script( 'anthologize-js', WP_PLUGIN_URL . '/anthologize/js/project-organizer.js' ); wp_enqueue_script( 'jquery'); wp_enqueue_script( 'jquery-ui-core'); wp_enqueue_script( 'jquery-ui-sortable'); wp_enqueue_script( 'jquery-ui-draggable'); wp_enqueue_script( 'jquery-ui-datepicker', WP_PLUGIN_URL . '/anthologize/js/jquery-ui-datepicker.js'); wp_enqueue_script( 'jquery-cookie', WP_PLUGIN_URL . '/anthologize/js/jquery-cookie.js' ); wp_enqueue_script( 'blockUI-js', WP_PLUGIN_URL . '/anthologize/js/jquery.blockUI.js' ); wp_enqueue_script( 'anthologize_admin-js', WP_PLUGIN_URL . '/anthologize/js/anthologize_admin.js' ); wp_enqueue_script( 'anthologize-sortlist-js', WP_PLUGIN_URL . '/anthologize/js/anthologize-sortlist.js' ); wp_localize_script( 'anthologize-sortlist-js', 'anth_strings', array( 'append' => __( 'Append', 'anthologize' ), 'cancel' => __( 'Cancel', 'anthologize' ), 'commenter' => __( 'Commenter', 'anthologize' ), 'comment_content' => __( 'Comment Content', 'anthologize' ), 'comments' => __( 'Comments', 'anthologize' ), 'comments_explain' => __( 'Check the comments from the original post that you would like to include in your project.', 'anthologize' ), 'done' => __( 'Done', 'anthologize' ), 'edit' => __( 'Edit', 'anthologize' ), 'less' => __( 'less', 'anthologize' ), 'more' => __( 'more', 'anthologize' ), 'no_comments' => __( 'This post has no comments associated with it.', 'anthologize' ), 'preview' => __( 'Preview', 'anthologize' ), 'posted' => __( 'Posted', 'anthologize' ), 'remove' => __( 'Remove', 'anthologize' ), 'save' => __( 'Save', 'anthologize' ), 'select_all' => __( 'Select all', 'anthologize' ), 'select_none' => __( 'Select none', 'anthologize' ), ) ); } /** * Loads Anthologize's styles * * This should be optimized to load CSS only on Anthologize pages * * @package Anthologize * @since 0.3 */ function load_styles() { wp_enqueue_style( 'anthologize-css', WP_PLUGIN_URL . '/anthologize/css/project-organizer.css' ); wp_enqueue_style( 'jquery-ui-datepicker-css', WP_PLUGIN_URL . '/anthologize/css/jquery-ui-1.7.3.custom.css'); } /** * Loads the project organizer when an 'edit' parameter is passed with the url * * @package Anthologize * @since 0.3 * * @param int $project_id The id for the project being loaded */ function load_project_organizer( $project_id ) { require_once( dirname( __FILE__ ) . '/class-project-organizer.php' ); $project_organizer = new Anthologize_Project_Organizer( $project_id ); $project_organizer->display(); } /** * Displays error markup when a project is not found by the supplied ID * * @package Anthologize * @since 0.3 */ function display_no_project_id_message() { ?>

|
' . __('Project Details', 'anthologize') . ''; $controlActions[] = ''.__('Manage Parts', 'anthologize') . ''; $controlActions[] = ''.__('Delete Project', 'anthologize') . ''; ?> |
get_project_parts(); echo (is_array($parts) ? count($parts) : '0'); ?> | get_project_items(); echo count($items); ?> | post_date ) ) ?> |
|---|
Anthologize will not work with your version of WordPress. You are currently running version WordPress v%s, and Anthologize requires version 3.0 or greater. Please upgrade WordPress if you'd like to use Anthologize. ", 'buddypress' ), $wp_version ) ?>