/** * 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')); }
protected function row($item) { if (!APP_Item_Registry::is_registered($item['type'])) { return html('tr', array(), html('td', array('colspan' => '3', 'style' => 'font-style: italic;'), __('This item could not be recognized. It might be from another theme or an uninstalled plugin.', APP_TD))); } $ptype_obj = get_post_type_object($item['post']->post_type); $item_link = $ptype_obj->public ? html_link(get_permalink($item['post_id']), $item['post']->post_title) : ''; $cells = array(APP_Item_Registry::get_title($item['type']), appthemes_get_price($item['price'], $this->currency), $item_link); return html('tr', array(), $this->cells($cells)); }
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); }
/** * 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)); } }
protected function row($item) { if (!APP_Item_Registry::is_registered($item['type'])) { return ''; } $cells = array(APP_Item_Registry::get_title($item['type']), appthemes_get_price($item['price'], $this->currency)); return html($this->args['row_html'], array(), $this->cells($cells)); }
/** * Sends email with receipt to admin after completed purchase. * * @param object $order */ function cp_send_admin_receipt($order) { global $cp_options; if (is_admin() && !defined('DOING_AJAX')) { return; } $moderation = $cp_options->post_status != 'publish'; $items_html = ''; foreach ($order->get_items() as $item) { $ptype_obj = get_post_type_object($item['post']->post_type); if (!$ptype_obj->public) { continue; } if ($order->get_id() != $item['post']->ID) { $items_html .= html('p', html_link(get_permalink($item['post']->ID), $item['post']->post_title)); } else { $items_html .= html('p', APP_Item_Registry::get_title($item['type'])); } } $table = new APP_Order_Summary_Table($order); ob_start(); $table->show(); $table_output = ob_get_clean(); $content = ''; $content .= html('p', __('Dear Admin,', APP_TD)); $content .= html('p', __('You have received payment for the following items:', APP_TD)); $content .= $items_html; if ($moderation && $order->get_items(CP_ITEM_LISTING)) { $content .= html('p', __('Please review submitted ad listing, and approve it.', APP_TD)); } $content .= html('p', __('Order Summary:', APP_TD)); $content .= $table_output; $blogname = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES); $subject = sprintf(__('[%1$s] Received payment for order #%2$d', APP_TD), $blogname, $order->get_id()); $email = array('to' => get_option('admin_email'), 'subject' => $subject, 'message' => $content); $email = apply_filters('cp_email_admin_receipt', $email, $order); appthemes_send_email($email['to'], $email['subject'], $email['message']); }
public function test_is_registered_bad_id() { $this->setExpectedException('PHPUnit_Framework_Error_Warning'); APP_Item_Registry::is_registered(array('not-a-string')); }
/** * Retrieves the summary for a given Order. * * @since 3.5 */ function cp_get_the_order_summary($order, $output = 'plain') { $order_items = ''; $items = $order->get_items(); foreach ($items as $item) { if (!APP_Item_Registry::is_registered($item['type'])) { $item_title = __('Unknown', APP_TD); } else { $item_title = APP_Item_Registry::get_title($item['type']); } $item_html = 'html' == $output ? html('div', $item_title) : ($order_items ? ' / ' . $item_title : $item_title); $order_items .= $item_html; } if (!$order_items) { $order_items = '-'; } return $order_items; }
/** * @since 3.5 */ function get_order_summary_content($order, $checkout) { $order_items = $relist = ''; $items = $order->get_items(); $order_plan = cp_get_order_plan_data($order); $plan_type = $order_plan['type']; foreach ($items as $item) { if (!APP_Item_Registry::is_registered($item['type'])) { $item_title = __('Unknown', APP_TD); } else { $item_title = APP_Item_Registry::get_title($item['type']); } if ($item['type'] == $plan_type) { $item_title .= $relist; } $item_html = $order_items ? ' / ' . $item_title : $item_title; $order_items .= $item_html; } if (!$order_items) { $order_items = '-'; } return $order_items; }