Beispiel #1
0
/**
 * Setups coupons.
 *
 * @return void
 */
function appthemes_coupons_setup()
{
    // Check for right version of Theme
    if (!class_exists('APP_Item_Registry')) {
        if (!appthemes_coupon_is_network_activated()) {
            add_action('admin_notices', 'appthemes_coupon_display_version_warning');
        }
        return;
    }
    if (is_admin()) {
        if (!class_exists('APP_Item_Registry')) {
            add_action('admin_notices', 'appthemes_coupon_display_version_warning');
            return;
        }
        require_once dirname(__FILE__) . '/coupons-meta-class.php';
        require_once dirname(__FILE__) . '/coupons-admin.php';
        new APP_Coupon_Details();
    }
    appthemes_coupons_register_post_type();
    if (defined('VA_VERSION') && version_compare(VA_VERSION, '1.2', '<')) {
        // Register Action Hooks for Vantage less than 1.2
        add_action('va_after_purchase_listing_new_form', 'appthemes_coupon_add_field');
        add_filter('va_listing_validate_purchase_fields', 'appthemes_coupons_validate_field');
        add_action('va_create_listing_order', 'appthemes_coupon_add_coupon', 11);
    } else {
        // Register Action Hooks
        add_action('appthemes_purchase_fields', 'appthemes_coupon_add_field');
        add_filter('appthemes_validate_purchase_fields', 'appthemes_coupons_validate_field');
        add_action('appthemes_create_order', 'appthemes_coupon_add_coupon', 11);
    }
    add_filter('appthemes_order_item_posts_types', 'appthemes_coupon_add_ptype');
    add_action('admin_menu', 'appthemes_coupons_add_menu', 11);
    add_filter('post_updated_messages', 'appthemes_coupons_update_messages');
    APP_Item_Registry::register(APPTHEMES_COUPON_PTYPE, new APP_JIT_Text('appthemes_coupon_text'));
}
Beispiel #2
0
function appthemes_load_items()
{
    extract(appthemes_payments_get_args(), EXTR_SKIP);
    if (!empty($items)) {
        foreach ($items as $item) {
            if (!isset($item['type']) || !isset($item['title'])) {
                continue;
            }
            if (!isset($item['meta'])) {
                $item['meta'] = array();
            }
            APP_Item_Registry::register($item['type'], $item['title'], $item['meta']);
        }
    }
}
/**
 * Sets up the order system
 * @return void
 */
function appthemes_setup_orders()
{
    $args = array('labels' => array('name' => __('Orders', APP_TD), 'singular_name' => __('Order', APP_TD), 'add_new' => __('Add New', APP_TD), 'add_new_item' => __('Add New Order', APP_TD), 'edit_item' => __('Edit Order', APP_TD), 'new_item' => __('New Order', APP_TD), 'view_item' => __('View Order', APP_TD), 'search_items' => __('Search Orders', APP_TD), 'not_found' => __('No orders found', APP_TD), 'not_found_in_trash' => __('No orders found in Trash', APP_TD), 'parent_item_colon' => __('Parent Order:', APP_TD), 'menu_name' => __('Orders', APP_TD)), 'hierarchical' => false, 'supports' => array('author', 'custom-fields'), 'public' => true, 'show_ui' => true, 'show_in_menu' => 'app-payments', 'rewrite' => array('slug' => 'order'));
    register_post_type(APPTHEMES_ORDER_PTYPE, apply_filters('appthemes_order_ptype_args', $args));
    $statuses = array(APPTHEMES_ORDER_PENDING => _n_noop('Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>', APP_TD), APPTHEMES_ORDER_FAILED => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', APP_TD), APPTHEMES_ORDER_COMPLETED => _n_noop('Completed <span class="count">(%s)</span>', 'Completed <span class="count">(%s)</span>', APP_TD), APPTHEMES_ORDER_ACTIVATED => _n_noop('Activated <span class="count">(%s)</span>', 'Activated <span class="count">(%s)</span>', APP_TD));
    foreach ($statuses as $status => $translate_string) {
        register_post_status($status, array('public' => true, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => $translate_string));
    }
    $args = appthemes_payments_get_args();
    $initial_ptypes = $args['items_post_types'];
    if (!is_array($initial_ptypes)) {
        $initial_ptypes = array($initial_ptypes);
    }
    $post_types = apply_filters('appthemes_order_item_posts_types', $initial_ptypes);
    $post_types[] = APPTHEMES_ORDER_PTYPE;
    p2p_register_connection_type(array('name' => APPTHEMES_ORDER_CONNECTION, 'from' => APPTHEMES_ORDER_PTYPE, 'to' => $post_types, 'cardinality' => 'many-to-many', 'admin_box' => false, 'prevent_duplicates' => false, 'self_connections' => true));
    APP_Item_Registry::register('_regional-tax', __('Regional Taxes', APP_TD), array(), 99);
}
Beispiel #4
0
/**
 * Setups packages.
 *
 * @return void
 */
function cp_packages_setup()
{
    // Listing Packages
    $labels = array('name' => __('Ad Packs', APP_TD), 'singular_name' => __('Ad Pack', APP_TD), 'add_new' => __('Add New', APP_TD), 'add_new_item' => __('Add New Pack', APP_TD), 'edit_item' => __('Edit Pack', APP_TD), 'new_item' => __('New Pack', APP_TD), 'view_item' => __('View Pack', APP_TD), 'search_items' => __('Search Packs', APP_TD), 'not_found' => __('No Packs found', APP_TD), 'not_found_in_trash' => __('No Packs found in Trash', APP_TD), 'parent_item_colon' => __('Parent Pack:', APP_TD), 'menu_name' => __('Ad Packs', APP_TD));
    $args = array('labels' => $labels, 'hierarchical' => false, 'supports' => array('page-attributes'), 'public' => false, 'capability_type' => 'page', 'show_ui' => true, 'show_in_menu' => false);
    register_post_type(CP_PACKAGE_LISTING_PTYPE, $args);
    $listing_packages = new WP_Query(array('post_type' => CP_PACKAGE_LISTING_PTYPE, 'nopaging' => 1));
    foreach ($listing_packages->posts as $listing_package) {
        APP_Item_Registry::register($listing_package->post_name, sprintf(__('Package: %s', APP_TD), $listing_package->post_title));
    }
    // Membership Packages
    $labels = array('name' => __('Membership Packs', APP_TD), 'singular_name' => __('Membership Pack', APP_TD), 'add_new' => __('Add New', APP_TD), 'add_new_item' => __('Add New Pack', APP_TD), 'edit_item' => __('Edit Pack', APP_TD), 'new_item' => __('New Pack', APP_TD), 'view_item' => __('View Pack', APP_TD), 'search_items' => __('Search Packs', APP_TD), 'not_found' => __('No Packs found', APP_TD), 'not_found_in_trash' => __('No Packs found in Trash', APP_TD), 'parent_item_colon' => __('Parent Pack:', APP_TD), 'menu_name' => __('Membership Packs', APP_TD));
    $args = array('labels' => $labels, 'hierarchical' => false, 'supports' => array('page-attributes'), 'public' => false, 'capability_type' => 'page', 'show_ui' => true, 'show_in_menu' => false);
    register_post_type(CP_PACKAGE_MEMBERSHIP_PTYPE, $args);
    $membership_packages = new WP_Query(array('post_type' => CP_PACKAGE_MEMBERSHIP_PTYPE, 'nopaging' => 1));
    foreach ($membership_packages->posts as $membership_package) {
        APP_Item_Registry::register($membership_package->post_name, sprintf(__('Membership: %s', APP_TD), $membership_package->post_title));
    }
}
Beispiel #5
0
 public function test_register_error_bad_id()
 {
     $this->setExpectedException('PHPUnit_Framework_Error_Warning');
     APP_Item_Registry::register(array('not-a-string'), 'Title', array('key' => 'data'));
 }