本文整理汇总了PHP中shopp_debug函数的典型用法代码示例。如果您正苦于以下问题:PHP shopp_debug函数的具体用法?PHP shopp_debug怎么用?PHP shopp_debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shopp_debug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
public static function login($result)
{
$Customer = ShoppOrder()->Customer;
if ($Customer->loggedin()) {
return $result;
}
$accounts = shopp_setting('account_system');
$pleaselogin = ' ' . Shopp::__('If you have an account with us, please login now.');
// This specific !isset condition checks if the loginname is not provided
// If no loginname is provided, but an account system is used, we need to
// generate a new login name for the customer
if ('wordpress' == $accounts && !isset($_POST['loginname'])) {
ShoppLoginGenerator::object();
$_POST['loginname'] = ShoppLoginGenerator::name();
if (apply_filters('shopp_login_required', empty($_POST['loginname']))) {
return shopp_add_error(Shopp::__('A login could not be created with the information you provided. Enter a different name or email address.') . $pleaselogin);
}
shopp_debug('Login set to ' . $_POST['loginname'] . ' for WordPress account creation.');
}
// Validate unique email address for new account
if (in_array($accounts, array('wordpress', 'shopp')) && !$Customer->session(ShoppCustomer::GUEST)) {
$ShoppCustomer = new ShoppCustomer($_POST['email'], 'email');
if (apply_filters('shopp_email_exists', 'wordpress' == $accounts ? email_exists($_POST['email']) : $ShoppCustomer->exists())) {
return shopp_add_error(Shopp::__('The email address you entered is already in use. Enter a different email address to create a new account.') . $pleaselogin);
}
}
// Validate WP login
if (isset($_POST['loginname'])) {
if (apply_filters('shopp_login_required', empty($_POST['loginname']))) {
return shopp_add_error(Shopp::__('You must enter a login name for your account.'));
}
if (apply_filters('shopp_login_valid', !validate_username($_POST['loginname']))) {
$sanitized = sanitize_user($_POST['loginname'], true);
$illegal = array_diff(str_split($_POST['loginname']), str_split($sanitized));
return shopp_add_error(Shopp::__('The login name provided includes invalid characters: %s', esc_html(join(' ', $illegal))));
}
if (apply_filters('shopp_login_exists', username_exists($_POST['loginname']))) {
return shopp_add_error(Shopp::__('"%s" is already in use. Enter a different login name to create a new account.', esc_html($_POST['loginname'])) . $pleaselogin);
}
}
return $result;
}
示例2: 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;
}
示例3: shopp_cart_item_addons_count
/**
* Returns the number of addons added to the cartitem.
*
* @api
*
* @param $itemkey
* @return bool|int
*/
function shopp_cart_item_addons_count($itemkey)
{
if (false === $itemkey) {
shopp_debug(__FUNCTION__ . " failed: itemkey parameter required.");
return false;
}
if (!($item = shopp_cart_item($itemkey))) {
shopp_debug(__FUNCTION__ . " failed: no such item {$itemkey}");
return false;
}
if (false === ($addons = shopp_cart_item_addons($itemkey))) {
return false;
// Debug message will already have been generated in shopp_cart_item_addons()
}
return (int) count($addons);
}
示例4: preload
/**
* Loads session data from another session into this one
*
* Used to access third-party session data. This only happens when
* a payment system uses server-to-server communication that needs
* session-specific information about the customer or transaction.
*
* @since 1.3.6
*
* @param string $session The session ID to load
* @return bool True if successful, false otherwise
*/
public function preload($session)
{
if (!$this->exists($session)) {
trigger_error('Could not reload the specified session.');
return false;
}
$this->destroy();
$this->open();
$this->load($session);
$this->cook();
shopp_debug('Session started ' . str_repeat('-', 64));
return true;
}
示例5: shopp_rmv_product_download
/**
* shopp_rmv_product_download
*
* Remove a product download asset
*
* @api
* @since 1.2
*
* @param int $download the product asset id
* @return bool true on success, false on failure
**/
function shopp_rmv_product_download($download)
{
if (empty($download)) {
shopp_debug(__FUNCTION__ . ' failed: download parameter required.');
return false;
}
$File = new ProductDownload($download);
if (empty($File->id)) {
shopp_debug(__FUNCTION__ . " failed: No such product download with id {$download}.");
return false;
}
return $File->delete();
}
示例6: is_shopp_page
/**
* Determines if the requested page is a Shopp page or if it matches a given Shopp page
*
* Also checks to see if the current loaded query is a Shopp product or product taxonomy.
*
* @api
* @since 1.0
*
* @param string $page (optional) System page name ID for the correct ShoppStorefront page {@see ShoppPages class}
* @param WP_Query $wp_query (optional) will use the global wp_query by default if false, or the provided WP_Query object
* @return boolean
**/
function is_shopp_page($page = false, $wp_query = false)
{
if (false === $wp_query) {
global $wp_the_query;
$wp_query = $wp_the_query;
}
if (empty($wp_query->query_vars)) {
shopp_debug('Conditional is_shopp_page functions do not work before the WordPress query is run. Before then, they always return false.');
}
$is_shopp_page = false;
$Page = ShoppPages()->requested();
if (false === $page) {
// Check if the current request is a shopp page request
// Product and collection pages are considered a Shopp page request
if (is_shopp_product($wp_query) || $wp_query->get('post_type') == ShoppProduct::$posttype) {
$is_shopp_page = true;
}
if (is_shopp_collection($wp_query)) {
$is_shopp_page = true;
}
if (false !== $Page) {
$is_shopp_page = true;
}
} elseif (false !== $Page) {
// Check if the given shopp page name is the current request
if ($Page->name() == $page) {
$is_shopp_page = true;
}
}
return $is_shopp_page;
}
示例7: content
public function content($content)
{
global $wp_query;
// Test that this is the main query and it is a catalog page
if (!$wp_query->is_main_query() || !is_catalog_frontpage()) {
return $content;
}
shopp_debug('Displaying catalog page request: ' . $_SERVER['REQUEST_URI']);
ob_start();
locate_shopp_template(array('catalog.php'), true);
$content = ob_get_clean();
return apply_filters('shopp_catalog_template', $content);
}
示例8: load
public function load(array $options = array())
{
$thisclass = get_class($this);
$slug = isset($this->slug) ? $this->slug : sanitize_key($thisclass);
$Storefront = ShoppStorefront();
$Shopping = ShoppShopping();
$Processing = new ShoppProduct();
$summary_table = ShoppDatabaseObject::tablename(ProductSummary::$table);
$defaults = array('columns' => false, 'useindex' => false, 'joins' => array(), 'where' => array(), 'groupby' => false, 'orderby' => false, 'having' => array(), 'limit' => false, 'order' => false, 'page' => false, 'paged' => false, 'nostock' => null, 'pagination' => true, 'published' => true, 'ids' => false, 'adjacent' => false, 'product' => false, 'load' => array('coverimages'), 'inventory' => false, 'taxquery' => false, 'debug' => false);
$loading = array_merge($defaults, $options);
$loading = apply_filters("shopp_collection_load_options", $loading);
$loading = apply_filters("shopp_{$slug}_collection_load_options", $loading);
extract($loading);
// Setup pagination
$this->paged = false;
$this->pagination = false === $paged ? shopp_setting('catalog_pagination') : $paged;
$page = false === $page ? get_query_var('paged') : $page;
$this->page = (int) $page > 0 || preg_match('/(0\\-9|[A-Z])/', $page) ? $page : 1;
// Hard product limit per category to keep resources "reasonable"
$hardlimit = apply_filters('shopp_category_products_hardlimit', 1000);
// Enforce the where parameter as an array
if (!is_array($where)) {
return shopp_debug('The "where" parameter for ' . __METHOD__ . ' must be formatted as an array.');
}
// Inventory filtering
if (shopp_setting_enabled('inventory') && (is_null($nostock) && !shopp_setting_enabled('outofstock_catalog') || !is_null($nostock) && !Shopp::str_true($nostock))) {
$where[] = "( s.inventory='off' OR (s.inventory='on' AND s.stock > 0) )";
}
if (Shopp::str_true($published)) {
$where[] = "p.post_status='publish'";
}
// Multiple taxonomy queries
if (is_array($taxquery)) {
$tqdefaults = array('relation' => 'AND', 'include_children' => true);
$taxquery = array_merge($tqdefaults, $taxquery);
$TQ = new WP_Tax_Query($taxquery);
$sql = $TQ->get_sql($Processing->_table, 'ID');
unset($TQ);
$joins['taxquery'] = self::taxquery($sql['join']);
$where[] = self::taxquery($sql['where']);
}
// Sort Order
if (!$orderby) {
$titlesort = "p.post_title ASC";
$defaultsort = empty($order) ? $titlesort : $order;
// Define filterable built-in sort methods (you're welcome)
$sortmethods = apply_filters('shopp_collection_sort_methods', array('bestselling' => "s.sold DESC,{$titlesort}", 'highprice' => "maxprice DESC,{$titlesort}", 'lowprice' => "minprice ASC,{$titlesort}", 'newest' => "p.post_date DESC,{$titlesort}", 'oldest' => "p.post_date ASC,{$titlesort}", 'random' => "RAND(" . crc32($Shopping->session) . ")", 'chaos' => "RAND(" . time() . ")", 'reverse' => "p.post_title DESC", 'title' => $titlesort, 'custom' => is_subclass_of($this, 'ProductTaxonomy') ? "tr.term_order ASC,{$titlesort}" : $defaultsort, 'recommended' => is_subclass_of($this, 'ProductTaxonomy') ? "tr.term_order ASC,{$titlesort}" : $defaultsort, 'default' => $defaultsort));
// Handle valid user browsing sort change requests
if (isset($_REQUEST['sort']) && !empty($_REQUEST['sort']) && array_key_exists(strtolower($_REQUEST['sort']), $sortmethods)) {
$Storefront->browsing['sortorder'] = strtolower($_REQUEST['sort']);
}
// Collect sort setting sources (Shopp admin setting, User browsing setting, programmer specified setting)
$sortsettings = array(shopp_setting('default_product_order'), isset($Storefront->browsing['sortorder']) ? $Storefront->browsing['sortorder'] : false, !empty($order) ? $order : false);
// Go through setting sources to determine most applicable setting
$sorting = 'title';
foreach ($sortsettings as $setting) {
if (!empty($setting) && isset($sortmethods[strtolower($setting)])) {
$sorting = strtolower($setting);
}
}
$orderby = $sortmethods[$sorting];
}
if (empty($orderby)) {
$orderby = 'p.post_title ASC';
}
// Pagination
if (empty($limit)) {
if ($this->pagination > 0 && is_numeric($this->page) && Shopp::str_true($pagination)) {
if (!$this->pagination || $this->pagination < 0) {
$this->pagination = $hardlimit;
}
$start = $this->pagination * ($this->page - 1);
$limit = "{$start},{$this->pagination}";
} else {
$limit = $hardlimit;
}
$limited = false;
// Flag that the result set does not have forced limits
} else {
$limited = true;
}
// The result set has forced limits
// Core query components
// Load core product data and product summary columns
$cols = array('p.ID', 'p.post_title', 'p.post_name', 'p.post_excerpt', 'p.post_status', 'p.post_date', 'p.post_modified', 's.modified AS summed', 's.sold', 's.grossed', 's.maxprice', 's.minprice', 's.ranges', 's.taxed', 's.stock', 's.lowstock', 's.inventory', 's.featured', 's.variants', 's.addons', 's.sale');
if ($ids) {
$cols = array('p.ID');
}
$columns = "SQL_CALC_FOUND_ROWS " . join(',', $cols) . ($columns !== false ? ',' . $columns : '');
$table = "{$Processing->_table} AS p";
$where[] = "p.post_type='" . ShoppProduct::posttype() . "'";
$joins[$summary_table] = "LEFT OUTER JOIN {$summary_table} AS s ON s.product=p.ID";
$options = compact('columns', 'useindex', 'table', 'joins', 'where', 'groupby', 'having', 'limit', 'orderby');
// Alphabetic pagination
if ('alpha' === $pagination || preg_match('/(0\\-9|[A-Z])/', $page)) {
// Setup Roman alphabet navigation
$alphanav = array_merge(array('0-9'), range('A', 'Z'));
$this->alpha = array_combine($alphanav, array_fill(0, count($alphanav), 0));
// Setup alphabetized index query
$a = $options;
//.........这里部分代码省略.........
示例9: valid
public function valid()
{
if (!$this->order()) {
// boolean false and 0 are both invalid
shopp_debug('PayPal messsage invalid. Missing or invalid "invoice" field.');
return false;
}
if (false === $this->txnid() && false === $this->txnorigin()) {
shopp_debug('PayPal messsage invalid. Missing txn_id or parent_txn_id.');
return false;
}
return true;
}
示例10: check_admin_referer
?>
<?php
check_admin_referer('shopp_upgrade_notice');
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
$homeurl = wp_specialchars_decode(get_option('home'), ENT_QUOTES);
$admin = get_bloginfo('admin_email');
$site = parse_url($homeurl);
$_ = array();
$_[] = 'From: "' . $blogname . '" <' . shopp_setting('merchant_email') . '>';
$_[] = 'To: ' . $admin;
$_[] = sprintf('Subject: Shopp Upgraded on %s', $site['host']);
$_[] = '';
$_[] = sprintf(__('The Shopp installation on %1$s has been upgraded to %2$s and requires a database upgrade. Please login to %1$s and perform the upgrade by deactivating and reactivating the Shopp plugin.', 'Shopp'), $homeurl, ShoppVersion::release());
$message = apply_filters('shopp_upgrade_notice_message', join("\n", $_));
if (Shopp::email($message)) {
shopp_debug('A Shopp upgrade notification was sent.');
}
Shopp::_em('### Upgrade Notice Sent
An upgrade notice has been sent to the site administrator.');
?>
<?php
} else {
?>
<div class="error"><?php
Shopp::_em('### Contact Your Site Administrator
You will need to notify a site administrator to perform the upgrade.');
?>
</div>
示例11: shopp_rmv_customer_address
/**
* Remove an address
*
* @api
* @since 1.2
*
* @param int $address the address id to remove
* @return bool true on success, false on failure
**/
function shopp_rmv_customer_address($address = false)
{
if (!$address) {
shopp_debug(__FUNCTION__ . " failed: Missing address id parameter.");
return false;
}
$Address = new ShoppAddress($address);
if (empty($Address->id)) {
shopp_debug(__FUNCTION__ . " failed: No such address with id {$address}.");
return false;
}
return $Address->delete();
}
示例12: calculate
/**
* @deprecated Do not use
**/
public function calculate()
{
shopp_debug(__CLASS__ . ' is a deprecated class. Use the Theme API instead.');
return false;
}
示例13: encrypt
/**
* Encrypts the session data.
*
* The session data is passed by reference and will be encrypted
* if the stars are aligned (the secured flag is set over an SSL
* connection with a valid encryption key).
*
* The security key is kept on the client-side as a secure cookie
* so that the server only ever touches it for a short time.
*
* @param array $data The session data to encrypt
* @return void
**/
private function encrypt(&$data)
{
if (!$this->secured()) {
return;
}
if (!is_ssl()) {
return;
}
if (!($key = $this->securekey())) {
return;
}
shopp_debug('Cart saving in secure mode!');
$secure = self::ENCRYPTION . sDB::query("SELECT AES_ENCRYPT('{$data}','{$key}') AS data", 'auto', 'col', 'data');
$db = sDB::object();
$data = $db->api->escape($secure);
}
示例14: __construct
/**
* Builds a shipping option from a configured/calculated
* shipping rate array
*
* Example:
* new ShippingOption(array(
* 'name' => 'Name of Shipping Rate Method',
* 'slug' => 'rate-method-slug',
* 'amount' => 0.99,
* 'delivery' => '1d-2d',
* 'items' => array(
* 0 => 0.99,
* 1 => 0.50
* )
* ));
*
* @author Jonathan Davis
* @since 1.1
*
* @param array $rate The calculated shipping rate
* @param boolean $estimate Flag to be included/excluded from estimates
* @return void
**/
public function __construct(array $rate, $estimate = true)
{
if (!isset($rate['slug'])) {
// Fire off an error if the slug is not provided
return !shopp_debug('A slug (string) value is required in the $rate array parameter when constructing a new ShoppShiprateService');
}
$this->name = $rate['name'];
$this->slug = $rate['slug'];
$this->amount = $rate['amount'];
$this->estimate = $estimate;
if (!empty($rate['delivery'])) {
$this->delivery = $rate['delivery'];
}
if (!empty($rate['items'])) {
$this->items = $rate['items'];
}
}
示例15: create_wpuser
/**
* Create a new WordPress user associated with this customer
*
* @author Jonathan Davis
* @since 1.3
*
* @return boolean True if successful, false otherwise
**/
public function create_wpuser()
{
if (empty($this->loginname)) {
return false;
}
if (!validate_username($this->loginname)) {
shopp_add_error(Shopp::__('This login name is invalid because it uses illegal characters. Valid login names include: letters, numbers, spaces, . - @ _'));
return false;
}
if (username_exists($this->loginname)) {
shopp_add_error(Shopp::__('The login name is already registered. Please choose another login name.'));
return false;
}
if (empty($this->password)) {
$this->password = wp_generate_password(12, true);
}
// Create the WordPress account
$wpuser = wp_insert_user(array('user_login' => $this->loginname, 'user_pass' => $this->password, 'user_email' => $this->email, 'display_name' => $this->firstname . ' ' . $this->lastname, 'nickname' => $this->firstname, 'first_name' => $this->firstname, 'last_name' => $this->lastname));
if (!$wpuser) {
return false;
}
// Link the WP user ID to this customer record
$this->wpuser = $wpuser;
if (isset($this->passhash)) {
global $wpdb;
$wpdb->update($wpdb->users, array('user_pass' => $this->passhash), array('ID' => $wpuser));
}
if (apply_filters('shopp_notify_new_wpuser', true)) {
// Send email notification of the new account
$password = isset($this->passhash) ? '*******' : $this->password;
// Only include generated passwords
wp_new_user_notification($wpuser, $password);
}
shopp_debug(sprintf('Successfully created the WordPress user "%s" for the Shopp account.', $this->loginname));
// Set the WP user created flag
$this->session(self::WPUSER, true);
return true;
}