本文整理汇总了PHP中Shopp::object方法的典型用法代码示例。如果您正苦于以下问题:PHP Shopp::object方法的具体用法?PHP Shopp::object怎么用?PHP Shopp::object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shopp
的用法示例。
在下文中一共展示了Shopp::object方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: plugin
/**
* Boot up the core plugin
*
* @author Jonathan Davis
* @since 1.3
*
* @return void
**/
public static function plugin()
{
global $Shopp;
// Provide global for backwards compatibility
$Shopp = Shopp::object();
do_action('shopp_loaded');
}
示例2: shopp_register_collection
/**
* Registers a smart collection of products
*
* @api
* @since 1.2
*
* @param string $name Class name of the smart collection
* @return void
**/
function shopp_register_collection($name = '')
{
if (empty($name)) {
shopp_debug(__FUNCTION__ . " failed: Collection name required.");
return false;
}
$Shopp = Shopp::object();
$namespace = apply_filters('shopp_smart_collections_slug', SmartCollection::$namespace);
$permastruct = SmartCollection::$taxon;
$slugs = SmartCollection::slugs($name);
$slug = $slugs[0];
$Shopp->Collections[$slug] = $name;
do_action('shopp_register_collection', $name, $slug);
$slugs = SmartCollection::slugs($name);
add_rewrite_tag("%{$permastruct}%", "([^/]+)");
add_permastruct($permastruct, ShoppPages()->baseslug() . "/{$namespace}/%shopp_collection%", false);
add_filter($permastruct . '_rewrite_rules', array('ProductCollection', 'pagerewrites'));
$apicall = create_function('$result, $options, $O', 'ShoppCollection( new ' . $name . '($options) );
return ShoppStorefrontThemeAPI::category($result, $options, $O);');
foreach ((array) $slugs as $collection) {
$collection = str_replace(array('-', '_'), '', $collection);
// Sanitize slugs
add_filter('shopp_themeapi_storefront_' . $collection . 'products', $apicall, 10, 3);
// @deprecated
add_filter('shopp_themeapi_storefront_' . $collection . 'collection', $apicall, 10, 3);
}
// Add special default permalink handling for collection URLs (only add it once)
global $wp_rewrite;
if (!$wp_rewrite->using_permalinks() && false === has_filter('term_link', array('SmartCollection', 'defaultlinks'))) {
add_filter('term_link', array('SmartCollection', 'defaultlinks'), 10, 3);
}
}
示例3: widget
function widget($args, $options)
{
$Shopp = Shopp::object();
extract($args);
$title = $before_title . $options['title'] . $after_title;
unset($options['title']);
$content = shopp('storefront', 'get-sideproduct', $options);
if (empty($content)) {
return false;
}
echo $before_widget . $title . $content . $after_widget;
}
示例4: widget
function widget($args, $options)
{
$Shopp = Shopp::object();
extract($args);
$title = $before_title . $options['title'] . $after_title;
unset($options['title']);
if (empty(ShoppCollection()->id)) {
return false;
}
$menu = shopp(ShoppCollection(), 'get-section-list', $options);
echo $before_widget . $title . $menu . $after_widget;
}
示例5: widget
function widget($args, $options)
{
$Shopp = Shopp::object();
if (!empty($args)) {
extract($args);
}
if (empty($options['title'])) {
$options['title'] = "Product Tags";
}
$title = $before_title . $options['title'] . $after_title;
$tagcloud = shopp('catalog', 'get-tagcloud', $options);
echo $before_widget . $title . $tagcloud . $after_widget;
}
示例6: widget
function widget($args, $options)
{
$Shopp = Shopp::object();
if (!empty($args)) {
extract($args);
}
if (empty($options['title'])) {
$options['title'] = __('Shop Search', 'Shopp');
}
$title = $before_title . $options['title'] . $after_title;
$content = shopp('catalog', 'get-searchform');
echo $before_widget . $title . $content . $after_widget;
}
示例7: screen
public function screen()
{
$Shopp = Shopp::object();
if (!current_user_can('shopp_settings_checkout')) {
wp_die(__('You do not have sufficient permissions to access this page.'));
}
$purchasetable = ShoppDatabaseObject::tablename(ShoppPurchase::$table);
$next = sDB::query("SELECT IF ((MAX(id)) > 0,(MAX(id)+1),1) AS id FROM {$purchasetable} LIMIT 1");
$next_setting = shopp_setting('next_order_id');
if ($next->id > $next_setting) {
$next_setting = $next->id;
}
$term_recount = false;
if (!empty($_POST['save'])) {
check_admin_referer('shopp-setup-management');
$next_order_id = $_POST['settings']['next_order_id'] = intval($_POST['settings']['next_order_id']);
if ($next_order_id >= $next->id) {
if (sDB::query("ALTER TABLE {$purchasetable} AUTO_INCREMENT=" . sDB::escape($next_order_id))) {
$next_setting = $next_order_id;
}
}
$_POST['settings']['order_shipfee'] = Shopp::floatval($_POST['settings']['order_shipfee']);
// Recount terms when this setting changes
if (isset($_POST['settings']['inventory']) && $_POST['settings']['inventory'] != shopp_setting('inventory')) {
$term_recount = true;
}
shopp_set_formsettings();
$this->notice(Shopp::__('Management settings saved.'), 'notice', 20);
}
if ($term_recount) {
$taxonomy = ProductCategory::$taxon;
$terms = get_terms($taxonomy, array('hide_empty' => 0, 'fields' => 'ids'));
if (!empty($terms)) {
wp_update_term_count_now($terms, $taxonomy);
}
}
$states = array(__('Map the label to an order state:', 'Shopp') => array_merge(array('' => ''), Lookup::txnstatus_labels()));
$statusLabels = shopp_setting('order_status');
$statesLabels = shopp_setting('order_states');
$reasonLabels = shopp_setting('cancel_reasons');
if (empty($reasonLabels)) {
$reasonLabels = array(__('Not as described or expected', 'Shopp'), __('Wrong size', 'Shopp'), __('Found better prices elsewhere', 'Shopp'), __('Product is missing parts', 'Shopp'), __('Product is defective or damaaged', 'Shopp'), __('Took too long to deliver', 'Shopp'), __('Item out of stock', 'Shopp'), __('Customer request to cancel', 'Shopp'), __('Item discontinued', 'Shopp'), __('Other reason', 'Shopp'));
}
$promolimit = array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '15', '20', '25');
$lowstock = shopp_setting('lowstock_level');
if (empty($lowstock)) {
$lowstock = 0;
}
include $this->ui('management.php');
}
示例8: updates
public function updates()
{
$CatalogPage = ShoppPages()->get('catalog');
$catalog_slug = $CatalogPage->slug();
$defaults = ShoppPages()->settings();
$this->form['storefront_pages'] = array_merge($defaults, $this->form('storefront_pages'));
shopp_set_formsettings();
// Re-register page, collection, taxonomies and product rewrites
// so that the new slugs work immediately
$Shopp = Shopp::object();
$Shopp->pages();
$Shopp->collections();
$Shopp->taxonomies();
$Shopp->products();
// If the catalog slug changes
// $hardflush is false (soft flush... plenty of fiber, no .htaccess update needed)
$hardflush = ShoppPages()->baseslug() != $catalog_slug;
flush_rewrite_rules($hardflush);
}
示例9: deactivate
/**
* Resets plugin data when deactivated
*
* @author Jonathan Davis
* @since 1.1
*
* @return void
**/
public function deactivate()
{
$Shopp = Shopp::object();
// Update rewrite rules (cleanup Shopp rewrites)
remove_action('shopp_init', array($Shopp, 'pages'));
remove_filter('rewrite_rules_array', array($Shopp, 'rewrites'));
flush_rewrite_rules();
shopp_set_setting('data_model', '');
if (function_exists('get_site_transient')) {
$plugin_updates = get_site_transient('update_plugins');
} else {
$plugin_updates = get_transient('update_plugins');
}
unset($plugin_updates->response[SHOPP_PLUGINFILE]);
if (function_exists('set_site_transient')) {
set_site_transient('update_plugins', $plugin_updates);
} else {
set_transient('update_plugins', $plugin_updates);
}
return true;
}
示例10: addons
public static function addons($meta, $plugin)
{
if (SHOPP_PLUGINFILE != $plugin) {
return $meta;
}
$Shopp = Shopp::object();
$builtin = array('Shopp2Checkout', 'ShoppPayPalStandard', 'ShoppOfflinePayment', 'ShoppTestMode', 'FreeOption', 'ItemQuantity', 'ItemRates', 'OrderAmount', 'OrderRates', 'OrderWeight', 'PercentageAmount', 'DBStorage', 'FSStorage');
$builtin = array_flip($builtin);
$modules = array_merge($Shopp->Gateways->modules, $Shopp->Shipping->modules, $Shopp->Storage->modules);
$installed = array_diff_key($modules, $builtin);
if (empty($installed)) {
return $meta;
}
$label = Shopp::_mi('**Add-ons:**');
foreach ($installed as $addon) {
$entry = array($label, $addon->name, $addon->version);
if ($label) {
$label = '';
}
$meta[] = trim(join(' ', $entry));
}
return $meta;
}
示例11: shopp_admin_add_submenu
/**
* Add a sub-menu to a Shopp menu
*
* @api
* @since 1.3
*
* @param string $label The translated label to use for the menu
* @param string $page The Shopp-internal menu page name (plugin prefix will be automatically added)
* @param string $menu The Shopp-internal menu page name to append the submenu to
* @param mixed $handler The callback handler to use to handle the page
* @param string $access The access capability required to see the menu
* @return integer The position the menu was added
**/
function shopp_admin_add_submenu($label, $page, $menu = null, $handler = false, $access = null)
{
$Admin = ShoppAdmin();
if (is_null($menu)) {
$Admin->mainmenu();
}
if (is_null($access)) {
$access = 'none';
}
// Restrict access by default
if (false === $handler) {
$handler = array(Shopp::object()->Flow, 'admin');
}
if (!is_callable($handler)) {
shopp_debug(__FUNCTION__ . " failed: The specified callback handler is not valid.");
return false;
}
$menupage = add_submenu_page($menu, $label, $label, $access, $page, $handler);
$Admin->menu($page, $menupage);
$Admin->addtab($page, $menu);
do_action("shopp_add_menu_{$page}");
return $menupage;
}
示例12: prepare_items
public function prepare_items()
{
$active = (array) shopp_setting('active_shipping');
$Shopp = Shopp::object();
$Shipping = $Shopp->Shipping;
$Shipping->settings();
// Load all installed shipping modules for settings UIs
$Shipping->ui();
// Setup setting UIs
$settings = array();
// Registry of loaded settings for table-based shipping rates for JS
$this->items = array();
// Registry for activated shipping rate modules
$this->installed = array();
// Registry of available shipping modules installed
foreach ($Shipping->active as $name => $Module) {
if (version_compare($Shipping->modules[$name]->since, '1.2') == -1) {
continue;
}
// Skip 1.1 modules, they are incompatible
$default_name = strtolower($name);
$fullname = $Module->methods();
$this->installed[$name] = $fullname;
if ($Module->ui->tables) {
$defaults[$default_name] = $Module->ui->settings();
$defaults[$default_name]['name'] = $fullname;
$defaults[$default_name]['label'] = Shopp::__('Shipping Method');
}
if (array_key_exists($name, $active)) {
$ModuleSetting = $active[$name];
} else {
continue;
}
// Not an activated shipping module, go to the next one
$Entry = new StdClass();
$Entry->id = sanitize_title_with_dashes($name);
$Entry->label = $Shipping->modules[$name]->name;
$Entry->type = $Shipping->modules[$name]->name;
$Entry->setting = $name;
if ($this->request('id') == $Entry->setting) {
$Entry->editor = $Module->ui();
}
// Setup shipping service shipping rate entries and settings
if (!is_array($ModuleSetting)) {
$Entry->destinations = array($Shipping->active[$name]->destinations);
$this->items[$name] = $Entry;
continue;
}
// Setup shipping calcualtor shipping rate entries and settings
foreach ($ModuleSetting as $id => $m) {
$Entry->setting = "{$name}-{$id}";
$Entry->settings = shopp_setting($Entry->setting);
if ($this->request('id') == $Entry->setting) {
$Entry->editor = $Module->ui();
}
if (isset($Entry->settings['label'])) {
$Entry->label = $Entry->settings['label'];
}
$Entry->destinations = array();
$min = $max = false;
if (isset($Entry->settings['table']) && is_array($Entry->settings['table'])) {
foreach ($Entry->settings['table'] as $tablerate) {
$destination = false;
$d = ShippingSettingsUI::parse_location($tablerate['destination']);
if (!empty($d['zone'])) {
$Entry->destinations[] = $d['zone'] . ' (' . $d['countrycode'] . ')';
} elseif (!empty($d['area'])) {
$Entry->destinations[] = $d['area'];
} elseif (!empty($d['country'])) {
$Entry->destinations[] = $d['country'];
} elseif (!empty($d['region'])) {
$Entry->destinations[] = $d['region'];
}
}
if (!empty($Entry->destinations)) {
$Entry->destinations = array_keys(array_flip($Entry->destinations));
}
// Combine duplicate destinations
}
$this->items[$Entry->setting] = $Entry;
$settings[$Entry->setting] = shopp_setting($Entry->setting);
$settings[$Entry->setting]['id'] = $Entry->setting;
$settings[$Entry->setting] = array_merge($defaults[$default_name], $settings[$Entry->setting]);
if (isset($settings[$Entry->setting]['table'])) {
usort($settings[$Entry->setting]['table'], array('ShippingFramework', '_sorttier'));
foreach ($settings[$Entry->setting]['table'] as &$r) {
if (isset($r['tiers'])) {
usort($r['tiers'], array('ShippingFramework', '_sorttier'));
}
}
}
}
// end foreach ( $ModuleSetting )
}
// end foreach ( $Shipping->active )
$this->set_pagination_args(array('total_items' => count($this->items), 'total_pages' => 1));
$postcodes = ShoppLookup::postcodes();
foreach ($postcodes as &$postcode) {
$postcode = !empty($postcode);
}
//.........这里部分代码省略.........
示例13: layout
/**
* Provides overall layout for the order manager interface
*
* Makes use of WordPress postboxes to generate panels (box) content
* containers that are customizable with drag & drop, collapsable, and
* can be toggled to be hidden or visible in the interface.
*
* @author Jonathan Davis
* @return
**/
public function layout()
{
$Shopp = Shopp::object();
$Admin =& $Shopp->Flow->Admin;
ShoppUI::register_column_headers($this->screen, apply_filters('shopp_order_manager_columns', array('items' => __('Items', 'Shopp'), 'qty' => __('Quantity', 'Shopp'), 'price' => __('Price', 'Shopp'), 'total' => __('Total', 'Shopp'))));
include $this->ui('events.php');
include $this->ui('ui.php');
do_action('shopp_order_manager_layout');
}
示例14: storage_ui
public function storage_ui()
{
$Shopp = Shopp::object();
$Shopp->Storage->settings();
$Shopp->Storage->ui();
}
示例15: is_shopp_smart_collection
/**
* Determines if the current request is for a registered dynamic Shopp collection
*
* NOTE: This function will not identify PHP loaded collections, it only
* compares the page request, meaning using is_shopp_collection on the catalog landing
* page, even when the landing page (catalog.php) template loads the CatalogProducts collection
* will return false, because CatalogProducts is loaded in the template and not directly
* from the request.
*
* @api
* @since 1.2
*
* @param WP_Query $wp_query (optional) will use the global wp_query by default if false, or the WP_Query object to evaluation
* @return boolean
**/
function is_shopp_smart_collection($wp_query = false)
{
if (false === $wp_query) {
global $wp_the_query;
$wp_query =& $wp_the_query;
}
$slug = $wp_query->get('shopp_collection');
if (empty($slug)) {
return false;
}
$Shopp = Shopp::object();
foreach ((array) $Shopp->Collections as $Collection) {
$slugs = SmartCollection::slugs($Collection);
if (in_array($slug, $slugs)) {
return true;
}
}
return false;
}