Example #1
0
/**
 * wpsc_admin_pages function, all the definitons of admin pages are stores here.
 * No parameters, returns nothing
 *
 * Fairly standard wordpress plugin API stuff for adding the admin pages, rearrange the order to rearrange the pages
 * The bits to display the options page first on first use may be buggy, but tend not to stick around long enough to be identified and fixed
 * if you find bugs, feel free to fix them.
 *
 * If the permissions are changed here, they will likewise need to be changed for the other sections of the admin that either use ajax
 * or bypass the normal download system.
 */
function wpsc_admin_pages()
{
    // Code to enable or disable the debug page
    if (isset($_GET['wpsc_activate_debug_page'])) {
        if ('true' == $_GET['wpsc_activate_debug_page']) {
            $_SESSION['wpsc_activate_debug_page'] = true;
        } else {
            if ('false' == $_GET['wpsc_activate_debug_page']) {
                $_SESSION['wpsc_activate_debug_page'] = false;
            }
        }
    }
    // Add to Dashboard
    $page_hooks[] = $purchase_log_page = add_submenu_page('index.php', __('Store Sales', 'wpsc'), __('Store Sales', 'wpsc'), 'administrator', 'wpsc-sales-logs', 'wpsc_display_sales_logs');
    if (wpsc_show_update_link()) {
        $page_hooks[] = add_submenu_page('index.php', __('Update Store', 'wpsc'), __('Store Update', 'wpsc'), 'administrator', 'wpsc-update', 'wpsc_display_update_page');
    }
    $page_hooks[] = add_submenu_page('index.php', __('Store Upgrades', 'wpsc'), __('Store Upgrades', 'wpsc'), 'administrator', 'wpsc-upgrades', 'wpsc_display_upgrades_page');
    // Set the base page for Products
    $products_page = 'edit.php?post_type=wpsc-product';
    $page_hooks[] = $edit_coupons_page = add_submenu_page($products_page, __('Coupons', 'wpsc'), __('Coupons', 'wpsc'), 'administrator', 'wpsc-edit-coupons', 'wpsc_display_coupons_page');
    // Add Settings pages
    $page_hooks[] = $edit_options_page = add_options_page(__('Store Settings', 'wpsc'), __('Store', 'wpsc'), 'administrator', 'wpsc-settings', 'wpsc_display_settings_page');
    add_action('admin_print_scripts-' . $edit_options_page, 'wpsc_print_admin_scripts');
    // Debug Page
    if (defined('WPSC_ADD_DEBUG_PAGE') && WPSC_ADD_DEBUG_PAGE == true || isset($_SESSION['wpsc_activate_debug_page']) && true == $_SESSION['wpsc_activate_debug_page']) {
        $page_hooks[] = add_options_page(__('Store Debug', 'wpsc'), __('Store Debug', 'wpsc'), 'administrator', 'wpsc-debug', 'wpsc_debug_page');
    }
    $header = '<p><strong>' . __('For More Information', 'wpsc') . '</strong></p>';
    add_contextual_help('toplevel_page_wpsc-sales-logs', $header . __("<a target='_blank' href='http://getshopped.org/resources/docs/building-your-store/sales/'>About the Sales Page</a>", 'wpsc'));
    add_contextual_help('toplevel_page_wpsc-edit-products', $header . __("<a target='_blank' href='http://getshopped.org/resources/docs/building-your-store/products'>About the Products Page</a>", 'wpsc'));
    add_contextual_help('products_page_wpsc-edit-groups', $header . __("<a target='_blank' href='http://getshopped.org/resources/docs/building-your-store/categories/'>About the Categories Page</a>", 'wpsc'));
    add_contextual_help('products_page_edit-tags', $header . __("<a target='_blank' href='http://getshopped.org/resources/docs/building-your-store/variations/'>About the Variations Page</a>", 'wpsc'));
    add_contextual_help('settings_page_wpsc-settings', $header . __("<a target='_blank' href='http://getshopped.org/resources/docs/store-settings/general/'>General Settings</a><br /> <a target='_blank' href='http://getshopped.org/resources/docs/store-settings/checkout/'>Checkout Options</a> <br />", 'wpsc'));
    add_contextual_help('products_page_wpsc-edit-coupons', $header . __("<a target='_blank' href='http://getshopped.org/resources/docs/building-your-store/marketing'>Marketing Options</a><br />", 'wpsc'));
    $page_hooks = apply_filters('wpsc_additional_pages', $page_hooks, $products_page);
    do_action('wpsc_add_submenu');
    // Include the javascript and CSS for this page
    // This is so important that I can't even express it in one line
    foreach ($page_hooks as $page_hook) {
        add_action('load-' . $page_hook, 'wpsc_admin_include_css_and_js_refac');
        switch ($page_hook) {
            case $edit_options_page:
                add_action('load-' . $page_hook, 'wpsc_admin_include_optionspage_css_and_js');
                break;
            case $purchase_log_page:
                add_action('admin_head', 'wpsc_product_log_rss_feed');
                break;
            case $edit_coupons_page:
                add_action('load-' . $page_hook, 'wpsc_admin_include_coupon_js');
                break;
        }
    }
    // Some updating code is run from here, is as good a place as any, and better than some
    if (null == get_option('wpsc_trackingid_subject') && null == get_option('wpsc_trackingid_message')) {
        update_option('wpsc_trackingid_subject', __('Product Tracking Email', 'wpsc'));
        update_option('wpsc_trackingid_message', __("Track & Trace means you may track the progress of your parcel with our online parcel tracker, just login to our website and enter the following Tracking ID to view the status of your order.\n\nTracking ID: %trackid%\n", 'wpsc'));
    }
    return;
}
Example #2
0
/**
 * wpsc_admin_pages function, all the definitons of admin pages are stores here.
 * No parameters, returns nothing
 *
 * Fairly standard wordpress plugin API stuff for adding the admin pages, rearrange the order to rearrange the pages
 * The bits to display the options page first on first use may be buggy, but tend not to stick around long enough to be identified and fixed
 * if you find bugs, feel free to fix them.
 *
 * If the permissions are changed here, they will likewise need to be changed for the other sections of the admin that either use ajax
 * or bypass the normal download system.
 *
 * @access public
 *
 * @uses wpsc_show_update_link()    Decides whether or not to show the update link
 * @uses add_submenu_page()         Adds a WordPress submenu page
 * @uses apply_filters()            Calls wpsc_upgrades_cap allows hooking caps for adiministrator
 * @uses apply_filters()            Calls wpsc_coupon_cap allows filtering for the coupon caps
 * @uses add_options_page()         Adds a submenu to the settings page
 * @uses add_action()               Calls 'admin_print_scripts.$edit_options_page prints out WPEC admin scripts
 * @uses apply_filters()            Calls 'wpsc_additional_pages' Passes the page_hooks and product_page URL
 * @uses do_action()                Calls 'wpsc_add_submenu' Allows you to hook in to the WPEC menu
 * @uses update_option()            Updates option given key and value
 */
function wpsc_admin_pages()
{
    // Code to enable or disable the debug page
    if (isset($_GET['wpsc_activate_debug_page'])) {
        if ('true' == $_GET['wpsc_activate_debug_page']) {
            $_SESSION['wpsc_activate_debug_page'] = true;
        } else {
            if ('false' == $_GET['wpsc_activate_debug_page']) {
                $_SESSION['wpsc_activate_debug_page'] = false;
            }
        }
    }
    // Add to Dashboard
    // $page_hooks[] = $purchase_log_page = add_submenu_page( 'index.php', __( 'Store Sales', 'wpsc' ), __( 'Store Sales', 'wpsc' ), 'administrator', 'wpsc-sales-logs', 'wpsc_display_sales_logs' );
    if (wpsc_show_update_link()) {
        $page_hooks[] = add_submenu_page('index.php', __('Update Store', 'wpsc'), __('Store Update', 'wpsc'), 'administrator', 'wpsc-update', 'wpsc_display_update_page');
    }
    $store_upgrades_cap = apply_filters('wpsc_upgrades_cap', 'administrator');
    $page_hooks[] = add_submenu_page('index.php', __('Store Upgrades', 'wpsc'), __('Store Upgrades', 'wpsc'), $store_upgrades_cap, 'wpsc-upgrades', 'wpsc_display_upgrades_page');
    $purchase_logs_cap = apply_filters('wpsc_purchase_logs_cap', 'administrator');
    $page_hooks[] = $purchase_logs_page = add_submenu_page('index.php', __('Store Sales', 'wpsc'), __('Store Sales', 'wpsc'), $purchase_logs_cap, 'wpsc-purchase-logs', 'wpsc_display_purchase_logs_page');
    // Set the base page for Products
    $products_page = 'edit.php?post_type=wpsc-product';
    $manage_coupon_cap = apply_filters('wpsc_coupon_cap', 'administrator');
    $page_hooks[] = $edit_coupons_page = add_submenu_page($products_page, __('Coupons', 'wpsc'), __('Coupons', 'wpsc'), $manage_coupon_cap, 'wpsc-edit-coupons', 'wpsc_display_coupons_page');
    // Add Settings pages
    $page_hooks[] = $edit_options_page = add_options_page(__('Store Settings', 'wpsc'), __('Store', 'wpsc'), 'administrator', 'wpsc-settings', 'wpsc_display_settings_page');
    add_action('admin_print_scripts-' . $edit_options_page, 'wpsc_print_admin_scripts');
    // Debug Page
    if (defined('WPSC_ADD_DEBUG_PAGE') && WPSC_ADD_DEBUG_PAGE == true || isset($_SESSION['wpsc_activate_debug_page']) && true == $_SESSION['wpsc_activate_debug_page']) {
        $page_hooks[] = add_options_page(__('Store Debug', 'wpsc'), __('Store Debug', 'wpsc'), 'administrator', 'wpsc-debug', 'wpsc_debug_page');
    }
    $page_hooks = apply_filters('wpsc_additional_pages', $page_hooks, $products_page);
    do_action('wpsc_add_submenu');
    // Include the javascript and CSS for this page
    // This is so important that I can't even express it in one line
    foreach ($page_hooks as $page_hook) {
        add_action('load-' . $page_hook, 'wpsc_admin_include_css_and_js_refac');
        switch ($page_hook) {
            case $edit_options_page:
                add_action('load-' . $page_hook, 'wpsc_admin_include_optionspage_css_and_js');
                break;
            case $purchase_logs_page:
                add_action('admin_head', 'wpsc_product_log_rss_feed');
                add_action('load-' . $page_hook, 'wpsc_admin_include_purchase_logs_css_and_js');
                break;
            case $edit_coupons_page:
                add_action('load-' . $page_hook, 'wpsc_admin_include_coupon_js');
                break;
        }
    }
    // Some updating code is run from here, is as good a place as any, and better than some
    if (null == get_option('wpsc_trackingid_subject') && null == get_option('wpsc_trackingid_message')) {
        update_option('wpsc_trackingid_subject', __('Product Tracking Email', 'wpsc'));
        update_option('wpsc_trackingid_message', __("Track & Trace means you may track the progress of your parcel with our online parcel tracker, just login to our website and enter the following Tracking ID to view the status of your order.\n\nTracking ID: %trackid%\n", 'wpsc'));
    }
    add_action('load-' . $edit_options_page, 'wpsc_load_settings_page', 1);
    // only load the purchase log list table and page classes when it's necessary
    // also, the WPSC_Purchase_Logs_List_Table needs to be initializied before admin_header.php
    // is loaded, therefore wpsc_load_purchase_logs_page needs to do this as well
    add_action('load-' . $purchase_logs_page, 'wpsc_load_purchase_logs_page', 1);
    // Help tabs
    add_action('load-' . $edit_options_page, 'wpsc_add_help_tabs');
    add_action('load-' . $purchase_logs_page, 'wpsc_add_help_tabs');
    add_action('load-' . $edit_coupons_page, 'wpsc_add_help_tabs');
    add_action('load-edit.php', 'wpsc_add_help_tabs');
    add_action('load-post.php', 'wpsc_add_help_tabs');
    add_action('load-post-new.php', 'wpsc_add_help_tabs');
    add_action('load-edit-tags.php', 'wpsc_add_help_tabs');
}