/** * Setup constructor * * @return voidtax * @author Jonathan Davis **/ public function __construct() { parent::__construct(); switch ($this->pagename) { case 'pages': shopp_enqueue_script('jquery-tmpl'); shopp_enqueue_script('pageset'); $this->pages_ui(); break; case 'images': shopp_enqueue_script('jquery-tmpl'); shopp_enqueue_script('imageset'); shopp_localize_script('imageset', '$is', array('confirm' => __('Are you sure you want to remove this image preset?', 'Shopp'))); $this->images_ui(); break; case 'management': shopp_enqueue_script('jquery-tmpl'); shopp_enqueue_script('labelset'); shopp_localize_script('labelset', '$sl', array('prompt' => __('Are you sure you want to remove this order status label?', 'Shopp'))); break; case 'core': case 'setup': shopp_enqueue_script('setup'); break; } }
/** * Service constructor * * @return void * @author Jonathan Davis **/ public function __construct() { parent::__construct(); shopp_enqueue_script('calendar'); shopp_enqueue_script('daterange'); shopp_enqueue_script('reports'); add_filter('shopp_reports', array(__CLASS__, 'xreports')); add_action('load-' . $this->screen, array($this, 'loader')); }
/** * Setup constructor * * @return voidtax * @author Jonathan Davis **/ public function __construct() { parent::__construct(); switch ($this->pagename) { case 'taxes': shopp_enqueue_script('ocupload'); shopp_enqueue_script('jquery-tmpl'); shopp_enqueue_script('taxrates'); shopp_enqueue_script('suggest'); shopp_localize_script('taxrates', '$tr', array('confirm' => __('Are you sure you want to remove this tax rate?', 'Shopp'))); $this->subscreens = array('rates' => __('Rates', 'Shopp'), 'settings' => __('Settings', 'Shopp')); if (isset($_GET['sub'])) { $this->url = add_query_arg(array('sub' => esc_attr($_GET['sub'])), $this->url); } else { $_GET['sub'] = shopp_setting_enabled('taxes') ? 'rates' : 'settings'; } if (shopp_setting_enabled('taxes')) { $this->taxrate_ui(); } break; case 'advanced': shopp_enqueue_script('colorbox'); shopp_enqueue_script('system'); shopp_localize_script('system', '$sys', array('indexing' => __('Product Indexing', 'Shopp'), 'indexurl' => wp_nonce_url(add_query_arg('action', 'shopp_rebuild_search_index', admin_url('admin-ajax.php')), 'wp_ajax_shopp_rebuild_search_index'))); break; case 'storage': shopp_enqueue_script('jquery-tmpl'); shopp_enqueue_script('storage'); break; case 'shipping': shopp_enqueue_script('jquery-tmpl'); shopp_enqueue_script('shiprates'); shopp_localize_script('shiprates', '$ps', array('confirm' => __('Are you sure you want to remove this shipping rate?', 'Shopp'))); $this->subscreens = array('rates' => __('Rates', 'Shopp'), 'settings' => __('Settings', 'Shopp')); if (isset($_GET['sub'])) { $this->url = add_query_arg(array('sub' => esc_attr($_GET['sub'])), $this->url); } else { $_GET['sub'] = shopp_setting_enabled('taxes') ? 'rates' : 'settings'; } if (shopp_setting_enabled('shipping')) { $this->shipping_ui(); } break; case 'payments': default: shopp_enqueue_script('jquery-tmpl'); shopp_enqueue_script('payments'); shopp_localize_script('payments', '$ps', array('confirm' => __('Are you sure you want to remove this payment system?', 'Shopp'))); add_action("load-{$this->screen}", array($this, 'payments_help'), 20); $this->payments_ui(); break; } }
/** * Account constructor * * @return void * @author Jonathan Davis **/ public function __construct() { parent::__construct(); if (!empty($_GET['id'])) { wp_enqueue_script('postbox'); wp_enqueue_script('password-strength-meter'); shopp_enqueue_script('suggest'); shopp_enqueue_script('colorbox'); do_action('shopp_customer_editor_scripts'); add_action('admin_head', array($this, 'layout')); } else { add_action('admin_print_scripts', array($this, 'columns')); } do_action('shopp_customer_admin_scripts'); }
/** * Begins database updates * * @since 1.3.6 * * @return void **/ public function upgrades() { if (empty($_GET['action']) || 'shopp-upgrade' != $_GET['action']) { return; } // Prevent unauthorized users from upgrading (without giving admin's a chance to backup) if (!current_user_can('activate_plugins')) { return; } // Prevent outsiders from the upgrade process check_admin_referer('shopp-upgrade'); $Installer = new ShoppInstallation(); $Installer->upgrade(); $welcome = add_query_arg(array('page' => $this->Admin->pagename('welcome')), admin_url('admin.php')); Shopp::redirect($welcome, true); }
/** * Promote constructor * * @return void * @author Jonathan Davis **/ public function __construct() { parent::__construct(); $this->save(); if (!empty($_GET['id'])) { wp_enqueue_script('postbox'); shopp_enqueue_script('colorbox'); shopp_enqueue_script('calendar'); shopp_enqueue_script('suggest'); do_action('shopp_promo_editor_scripts'); add_action('admin_head', array($this, 'layout')); } else { add_action('admin_print_scripts', array($this, 'columns')); } do_action('shopp_promo_admin_scripts'); // @deprecated do_action('shopp_admin_discount_scripts'); $defaults = array('page' => false, 'action' => false, 'selected' => array()); $args = array_merge($defaults, $_GET); extract($args, EXTR_SKIP); if (!is_array($selected)) { $selected = array($selected); } $url = add_query_arg(array_merge($_GET, array('page' => $this->page)), admin_url('admin.php')); $f = array('action', 'selected', 's'); if ($this->page == $page && !empty($action)) { switch ($action) { case 'enable': ShoppPromo::enableset($selected); break; case 'disable': ShoppPromo::disableset($selected); break; case 'delete': ShoppPromo::deleteset($selected); break; case 'duplicate': $P = new ShoppPromo($selected[0]); $P->duplicate(); break; } $url = remove_query_arg($f, $url); wp_redirect($url); exit; } }
/** * Members constructor * * @return void * @author Jonathan Davis **/ function __construct() { parent::__construct(); if (!empty($_GET['id'])) { wp_enqueue_script('postbox'); wp_enqueue_script('jquery-ui-draggable'); shopp_enqueue_script('jquery-tmpl'); shopp_enqueue_script('suggest'); shopp_enqueue_script('search-select'); shopp_enqueue_script('membership-editor'); shopp_enqueue_script('colorbox'); do_action('shopp_membership_editor_scripts'); add_action('admin_head', array(&$this, 'layout')); } else { add_action('admin_print_scripts', array(&$this, 'columns')); } do_action('shopp_membership_admin_scripts'); }
/** * Service constructor * * @return void * @author Jonathan Davis **/ public function __construct() { parent::__construct(); if (isset($_GET['id'])) { wp_enqueue_script('postbox'); shopp_enqueue_script('colorbox'); shopp_enqueue_script('jquery-tmpl'); shopp_enqueue_script('orders'); shopp_localize_script('orders', '$om', array('co' => __('Cancel Order', 'Shopp'), 'mr' => __('Mark Refunded', 'Shopp'), 'pr' => __('Process Refund', 'Shopp'), 'dnc' => __('Do Not Cancel', 'Shopp'), 'ro' => __('Refund Order', 'Shopp'), 'cancel' => __('Cancel', 'Shopp'), 'rr' => __('Reason for refund', 'Shopp'), 'rc' => __('Reason for cancellation', 'Shopp'), 'mc' => __('Mark Cancelled', 'Shopp'), 'stg' => __('Send to gateway', 'Shopp'))); shopp_enqueue_script('address'); shopp_custom_script('address', 'var regions = ' . json_encode(Lookup::country_zones()) . ';'); add_action('load-' . $this->screen, array($this, 'workflow')); add_action('load-' . $this->screen, array($this, 'layout')); do_action('shopp_order_management_scripts'); } else { add_action('load-' . $this->screen, array($this, 'loader')); add_action('admin_print_scripts', array($this, 'columns')); } do_action('shopp_order_admin_scripts'); }
/** * Categorize constructor * * @return void * @author Jonathan Davis **/ public function __construct() { parent::__construct(); Shopping::restore('worklist', $this->worklist); if ('shopp-tags' == $_GET['page']) { wp_redirect(add_query_arg(array('taxonomy' => ProductTag::$taxon), admin_url('edit-tags.php'))); return; } if (!empty($_GET['id']) && !isset($_GET['a'])) { wp_enqueue_script('postbox'); wp_enqueue_script('swfupload-all'); if (user_can_richedit()) { wp_enqueue_script('editor'); wp_enqueue_script('quicktags'); add_action('admin_print_footer_scripts', 'wp_tiny_mce', 20); } shopp_enqueue_script('colorbox'); shopp_enqueue_script('editors'); shopp_enqueue_script('category-editor'); shopp_enqueue_script('priceline'); shopp_enqueue_script('ocupload'); shopp_enqueue_script('swfupload'); shopp_enqueue_script('shopp-swfupload-queue'); do_action('shopp_category_editor_scripts'); add_action('admin_head', array($this, 'layout')); } elseif (!empty($_GET['a']) && $_GET['a'] == 'arrange') { shopp_enqueue_script('category-arrange'); do_action('shopp_category_arrange_scripts'); add_action('admin_print_scripts', array($this, 'arrange_cols')); } elseif (!empty($_GET['a']) && $_GET['a'] == 'products') { shopp_enqueue_script('products-arrange'); do_action('shopp_category_products_arrange_scripts'); add_action('admin_print_scripts', array($this, 'products_cols')); } else { add_action('admin_print_scripts', array($this, 'columns')); } do_action('shopp_category_admin_scripts'); add_action('load-' . $this->screen, array($this, 'workflow')); }
function notes_meta_box($Purchase) { global $Notes; add_filter('shopp_order_note', 'esc_html'); add_filter('shopp_order_note', 'wptexturize'); add_filter('shopp_order_note', 'convert_chars'); add_filter('shopp_order_note', 'make_clickable'); add_filter('shopp_order_note', 'force_balance_tags'); add_filter('shopp_order_note', 'convert_smilies'); add_filter('shopp_order_note', 'wpautop'); ?> <form action="<?php echo ShoppAdminController::url(array('id' => $Purchase->id)); ?> " method="post"> <?php if (!empty($Notes->meta)) { ?> <table> <?php foreach ($Notes->meta as $Note) { $User = get_userdata($Note->value->author); ?> <tr> <th class="column-author column-username"><?php echo get_avatar($User->ID, 32); ?> <?php echo esc_html($User->display_name); ?> <br /> <span><?php echo _d(get_option('date_format'), $Note->created); ?> </span> <span><?php echo _d(get_option('time_format'), $Note->created); ?> </span></th> <td> <div id="note-<?php echo $Note->id; ?> "> <?php if ($Note->value->sent == 1) { ?> <p class="notesent"><?php _e('Sent to the Customer:', 'Shopp'); ?> </p> <?php } ?> <?php echo apply_filters('shopp_order_note', $Note->value->message); ?> </div> <p class="notemeta"> <span class="notectrls"> <button type="submit" name="delete-note[<?php echo $Note->id; ?> ]" value="delete" class="button-secondary deletenote"><small>Delete</small></button> <button type="button" name="edit-note[<?php echo $Note->id; ?> ]" value="edit" class="button-secondary editnote"><small>Edit</small></button> <?php do_action('shopp_order_note_controls'); ?> </span> </p> </td> </tr> <?php } ?> </table> <?php } ?> <div id="notation"> <p><label for="notes"><?php _e('New Note', 'Shopp'); ?> :</label><br /> <textarea name="note" id="note" cols="50" rows="10"></textarea></p> <?php do_action('shopp_order_new_note_ui'); ?> <p class="alignright"> <button type="button" name="cancel-note" value="cancel" id="cancel-note-button" class="button-secondary"><?php _e('Cancel', 'Shopp'); ?> </button> <button type="submit" name="save-note" value="save" class="button-primary"><?php _e('Save Note', 'Shopp'); ?> </button> </p> <div class="alignright options"> <input type="checkbox" name="send-note" id="send-note" value="1"> <label for="send-note"><?php _e('Send to customer', 'Shopp'); ?> </label> </div> </div> <p class="alignright" id="add-note"> <button type="button" name="add-note" value="add" id="add-note-button" class="button-secondary"><?php _e('Add Note', 'Shopp'); ?> </button></p> <br class="clear" /> </form> <?php }
public function loader($workflow = false) { if (!current_user_can('shopp_products')) { return; } add_screen_option('per_page', array('label' => __('Products Per Page', 'Shopp'), 'default' => 20, 'option' => 'edit_' . ShoppProduct::$posttype . '_per_page')); $per_page_option = get_current_screen()->get_option('per_page'); $defaults = array('cat' => false, 'paged' => 1, 'per_page' => $per_page_option['default'], 's' => '', 'sl' => '', 'matchcol' => '', 'view' => $this->view, 'is_inventory' => false, 'is_trash' => false, 'is_bestselling' => false, 'categories_menu' => false, 'inventory_menu' => false, 'lowstock' => 0, 'columns' => '', 'orderby' => '', 'order' => '', 'where' => array(), 'joins' => array()); $args = array_merge($defaults, $_GET); if (false !== ($user_per_page = get_user_option($per_page_option['option']))) { $args['per_page'] = $user_per_page; } extract($args, EXTR_SKIP); $url = ShoppAdminController::url($_GET); $subs = array('all' => array('label' => Shopp::__('All'), 'where' => array("p.post_status!='trash'")), 'published' => array('label' => Shopp::__('Published'), 'where' => array("p.post_status='publish'")), 'drafts' => array('label' => Shopp::__('Drafts'), 'where' => array("p.post_status='draft'")), 'onsale' => array('label' => Shopp::__('On Sale'), 'where' => array("s.sale='on' AND p.post_status != 'trash'")), 'featured' => array('label' => Shopp::__('Featured'), 'where' => array("s.featured='on' AND p.post_status != 'trash'")), 'bestselling' => array('label' => Shopp::__('Bestselling'), 'where' => array("p.post_status!='trash'", BestsellerProducts::threshold() . " < s.sold"), 'order' => 'bestselling'), 'inventory' => array('label' => Shopp::__('Inventory'), 'where' => array("s.inventory='on' AND p.post_status != 'trash'")), 'trash' => array('label' => Shopp::__('Trash'), 'where' => array("p.post_status='trash'"))); if (!shopp_setting_enabled('inventory')) { unset($subs['inventory']); } switch ($view) { case 'inventory': if (shopp_setting_enabled('inventory')) { $is_inventory = true; } else { Shopp::redirect(add_query_arg('view', null, $url), true); } break; case 'trash': $is_trash = true; break; case 'bestselling': $is_bestselling = true; break; } if ($is_inventory) { $per_page = 50; } $pagenum = absint($paged); $start = $per_page * ($pagenum - 1); $where = $subs[$this->view]['where']; if (!empty($s)) { $SearchResults = new SearchResults(array('search' => $s, 'nostock' => 'on', 'published' => 'off', 'paged' => -1)); $SearchResults->load(); $ids = array_keys($SearchResults->products); $where[] = "p.ID IN (" . join(',', $ids) . ")"; } if (!empty($cat)) { global $wpdb; $joins[$wpdb->term_relationships] = "INNER JOIN {$wpdb->term_relationships} AS tr ON (p.ID=tr.object_id)"; $joins[$wpdb->term_taxonomy] = "INNER JOIN {$wpdb->term_taxonomy} AS tt ON (tr.term_taxonomy_id=tt.term_taxonomy_id AND tt.term_id={$cat})"; if (-1 == $cat) { unset($joins[$wpdb->term_taxonomy]); $joins[$wpdb->term_relationships] = "LEFT JOIN {$wpdb->term_relationships} AS tr ON (p.ID=tr.object_id)"; $where[] = 'tr.object_id IS NULL'; } } // Detect custom taxonomies $taxonomies = array_intersect(get_object_taxonomies(ShoppProduct::$posttype), array_keys($_GET)); if (!empty($taxonomies)) { foreach ($taxonomies as $n => $taxonomy) { global $wpdb; $term = get_term_by('slug', $_GET[$taxonomy], $taxonomy); if (!empty($term->term_id)) { $joins[$wpdb->term_relationships . '_' . $n] = "INNER JOIN {$wpdb->term_relationships} AS tr{$n} ON (p.ID=tr{$n}.object_id)"; $joins[$wpdb->term_taxonomy . '_' . $n] = "INNER JOIN {$wpdb->term_taxonomy} AS tt{$n} ON (tr{$n}.term_taxonomy_id=tt{$n}.term_taxonomy_id AND tt{$n}.term_id={$term->term_id})"; } } } if (!empty($sl) && shopp_setting_enabled('inventory')) { switch ($sl) { case "ns": foreach ($where as &$w) { $w = str_replace("s.inventory='on'", "s.inventory='off'", $w); } $where[] = "s.inventory='off'"; break; case "oos": $where[] = "(s.inventory='on' AND s.stock = 0)"; break; case "ls": $ls = shopp_setting('lowstock_level'); if (empty($ls)) { $ls = '0'; } $where[] = "(s.inventory='on' AND s.lowstock != 'none')"; break; case "is": $where[] = "(s.inventory='on' AND s.stock > 0)"; } } $lowstock = shopp_setting('lowstock_level'); // Setup queries $pd = WPDatabaseObject::tablename(ShoppProduct::$table); $pt = ShoppDatabaseObject::tablename(ShoppPrice::$table); $ps = ShoppDatabaseObject::tablename(ProductSummary::$table); $orderdirs = array('asc', 'desc'); if (in_array($order, $orderdirs)) { $orderd = strtolower($order); } else { $orderd = 'asc'; } if (isset($subs[$this->view]['order'])) { $order = $subs[$this->view]['order']; } $ordercols = ''; switch ($orderby) { case 'name': $order = 'title'; if ('desc' == $orderd) { $order = 'reverse'; } break; case 'price': $order = 'lowprice'; if ('desc' == $orderd) { $order = 'highprice'; } break; case 'date': $order = 'newest'; if ('desc' == $orderd) { $order = 'oldest'; } break; case 'sold': $ordercols = 's.sold ' . $orderd; break; case 'gross': $ordercols = 's.grossed ' . $orderd; break; case 'inventory': $ordercols = 's.stock ' . $orderd; break; case 'sku': $ordercols = 'pt.sku ' . $orderd; break; } if (in_array($this->view, array('onsale', 'featured', 'inventory'))) { $joins[$ps] = "INNER JOIN {$ps} AS s ON p.ID=s.product"; } $loading = array('where' => $where, 'joins' => $joins, 'limit' => "{$start},{$per_page}", 'load' => array('categories', 'coverimages'), 'published' => false, 'order' => $order, 'nostock' => true); if (!empty($ordercols)) { unset($loading['order']); $loading['orderby'] = $ordercols; } if ($is_inventory) { // Override for inventory products $where[] = "(pt.context='product' OR pt.context='variation') AND pt.type != 'N/A'"; $loading = array('columns' => "pt.id AS stockid,IF(pt.context='variation',CONCAT(p.post_title,': ',pt.label),p.post_title) AS post_title,pt.sku AS sku,pt.stock AS stock", 'joins' => array_merge(array($pt => "LEFT JOIN {$pt} AS pt ON p.ID=pt.product"), $joins), 'where' => $where, 'groupby' => 'pt.id', 'orderby' => str_replace('s.', 'pt.', $ordercols), 'limit' => "{$start},{$per_page}", 'nostock' => true, 'published' => false); } // Override loading product meta and limiting by pagination in the workflow list if ($workflow) { unset($loading['limit']); $loading['ids'] = true; $loading['pagination'] = false; $loading['load'] = array(); } $this->products = new ProductCollection(); $this->products->load($loading); // Overpagination protection, redirect to page 1 if the requested page doesn't exist $num_pages = ceil($this->products->total / $per_page); if ($paged > 1 && $paged > $num_pages) { Shopp::redirect(add_query_arg('paged', null, $url)); } // Return a list of product keys for workflow list requests if ($workflow) { return $this->products->worklist(); } // Get sub-screen counts $subcounts = Shopp::cache_get('shopp_product_subcounts', 'shopp_admin'); if ($subcounts) { foreach ($subcounts as $name => $total) { if (isset($subs[$name])) { $subs[$name]['total'] = $total; } } } else { $subcounts = array(); foreach ($subs as $name => &$subquery) { $subquery['total'] = 0; $query = array('columns' => "count(*) AS total", 'table' => "{$pd} as p", 'joins' => array(), 'where' => array()); $query = array_merge($query, $subquery); $query['where'][] = "p.post_type='shopp_product'"; if (in_array($name, array('onsale', 'bestselling', 'featured', 'inventory'))) { $query['joins'][$ps] = "INNER JOIN {$ps} AS s ON p.ID=s.product"; } $query = sDB::select($query); $subquery['total'] = sDB::query($query, 'auto', 'col', 'total'); $subcounts[$name] = $subquery['total']; } Shopp::cache_set('shopp_product_subcounts', $subcounts, 'shopp_admin'); } $this->subs = $subs; }
public function __construct() { parent::__construct(); $uri = SHOPP_ADMIN_URI . '/styles'; shopp_enqueue_style('welcome'); }
/** * Routes the screen display to the page controller's screen handler. * * @since 1.4 * * @return void **/ public function route() { $this->Controller->screen(); }
$data = array('${lineid}' => (int) $_GET['editline'], '${itemname}' => $itemname, '${quantity}' => $Item->quantity, '${unitprice}' => money($Item->unitprice), '${total}' => money($Item->total)); echo ShoppUI::template($itemeditor, $data); } else { foreach ($columns as $column => $column_title) { $classes = array($column, "column-{$column}"); if (in_array($column, $hidden)) { $classes[] = 'hidden'; } ob_start(); switch ($column) { case 'items': ShoppProduct(new ShoppProduct($Item->product)); // @todo Find a way to make this more efficient by loading product slugs with load_purchased()? $viewurl = shopp('product.get-url'); $editurl = ShoppAdminController::url(array('id' => $Purchase->id, 'editline' => $id)); $rmvurl = ShoppAdminController::url(array('id' => $Purchase->id, 'rmvline' => $id)); $producturl = add_query_arg(array('page' => 'shopp-products', 'id' => $Item->product), admin_url('admin.php')); ?> <td class="<?php echo esc_attr(join(' ', $classes)); ?> "> <a href="<?php echo $producturl; ?> "> <?php $Product = new ShoppProduct($Item->product); $Product->load_data(array('images')); $Image = reset($Product->images); if (!empty($Image)) {
public function __construct() { parent::__construct(); $uri = SHOPP_ADMIN_URI . '/styles'; wp_enqueue_style('shopp.welcome', "{$uri}/welcome.css", array(), ShoppVersion::cache(), 'screen'); }