本文整理汇总了PHP中Shopp::_x方法的典型用法代码示例。如果您正苦于以下问题:PHP Shopp::_x方法的具体用法?PHP Shopp::_x怎么用?PHP Shopp::_x使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shopp
的用法示例。
在下文中一共展示了Shopp::_x方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: unsupported
/**
* Detects if Shopp is unsupported in the current hosting environment
*
* @author Jonathan Davis
* @since 1.1
*
* @return boolean True if requirements are missing, false if no errors were detected
**/
public static function unsupported()
{
if (defined('SHOPP_UNSUPPORTED')) {
return SHOPP_UNSUPPORTED;
}
$activation = false;
if (isset($_GET['action']) && isset($_GET['plugin'])) {
$activation = 'activate' == $_GET['action'];
if ($activation) {
$plugin = $_GET['plugin'];
if (function_exists('check_admin_referer')) {
check_admin_referer('activate-plugin_' . $plugin);
}
}
}
$errors = array();
// Check PHP version
if (version_compare(PHP_VERSION, '5.2.4', '<')) {
array_push($errors, 'phpversion', 'php524');
}
// Check WordPress version
if (version_compare(get_bloginfo('version'), '3.5', '<')) {
array_push($errors, 'wpversion', 'wp35');
}
// Check for GD
if (!function_exists('gd_info')) {
$errors[] = 'gdsupport';
} elseif (!array_keys(gd_info(), array('JPG Support', 'JPEG Support'))) {
$errors[] = 'jpgsupport';
}
if (empty($errors)) {
if (!defined('SHOPP_UNSUPPORTED')) {
define('SHOPP_UNSUPPORTED', false);
}
return false;
}
$plugin_path = dirname(__FILE__);
// Manually load text domain for translated activation errors
$languages_path = str_replace('\\', '/', $plugin_path . '/lang');
load_plugin_textdomain('Shopp', false, $languages_path);
// Define translated messages
$_ = array('header' => Shopp::_x('Shopp Activation Error', 'Shopp activation error'), 'intro' => Shopp::_x('Sorry! Shopp cannot be activated for this WordPress install.', 'Shopp activation error'), 'phpversion' => sprintf(Shopp::_x('Your server is running PHP %s!', 'Shopp activation error'), PHP_VERSION), 'php524' => Shopp::_x('Shopp requires PHP 5.2.4+.', 'Shopp activation error'), 'wpversion' => sprintf(Shopp::_x('This site is running WordPress %s!', 'Shopp activation error'), get_bloginfo('version')), 'wp35' => Shopp::_x('Shopp requires WordPress 3.5.', 'Shopp activation error'), 'gdsupport' => Shopp::_x('Your server does not have GD support! Shopp requires the GD image library with JPEG support for generating gallery and thumbnail images.', 'Shopp activation error'), 'jpgsupport' => Shopp::_x('Your server does not have JPEG support for the GD library! Shopp requires JPEG support in the GD image library to generate JPEG images.', 'Shopp activation error'), 'nextstep' => sprintf(Shopp::_x('Try contacting your web hosting provider or server administrator to upgrade your server. For more information about the requirements for running Shopp, see the %sShopp Documentation%s', 'Shopp activation error'), '<a href="' . ShoppSupport::DOCS . 'system-requirements">', '</a>'), 'continue' => Shopp::_x('Return to Plugins page', 'Shopp activation error'));
if ($activation) {
$string = '<h1>' . $_['header'] . '</h1><p>' . $_['intro'] . '</h1></p><ul>';
foreach ((array) $errors as $error) {
if (isset($_[$error])) {
$string .= "<li>{$_[$error]}</li>";
}
}
$string .= '</ul><p>' . $_['nextstep'] . '</p><p><a class="button" href="' . admin_url('plugins.php') . '">← ' . $_['continue'] . '</a></p>';
wp_die($string);
}
if (!function_exists('deactivate_plugins')) {
require ABSPATH . 'wp-admin/includes/plugin.php';
}
$plugin = basename($plugin_path) . __FILE__;
deactivate_plugins($plugin, true);
$phperror = '';
if (is_array($errors) && !empty($errors)) {
foreach ($errors as $error) {
if (isset($_[$error])) {
$phperror .= $_[$error] . ' ';
}
trigger_error($phperror, E_USER_WARNING);
}
}
if (!defined('SHOPP_UNSUPPORTED')) {
define('SHOPP_UNSUPPORTED', true);
}
return true;
}
示例2: load
//.........这里部分代码省略.........
// Must init taxable above addons roll-up #2825
$this->taxable = array();
}
// Re-init during ShoppCart::change() loads #2922
// Product has variants
if (Shopp::str_true($Product->variants) && empty($this->variants)) {
$this->variants($Product->prices);
}
// Product has Addons
if (Shopp::str_true($Product->addons)) {
if (!empty($this->addons)) {
// Compute addon differences
$addons = array_diff($addons, array_keys($this->addons));
}
$this->addons($this->addonsum, $addons, $Product->prices);
}
if (isset($Price->id)) {
$this->option = $this->mapprice($Price);
}
$this->sku = $Price->sku;
$this->type = $Price->type;
$this->sale = Shopp::str_true($Product->sale);
$this->freeshipping = isset($Price->freeshipping) ? $Price->freeshipping : false;
$baseprice = roundprice($this->sale ? $Price->promoprice : $Price->price);
$this->unitprice = $baseprice + $this->addonsum;
if (shopp_setting_enabled('taxes')) {
if (Shopp::str_true($Price->tax)) {
$this->taxable[] = $baseprice;
}
$this->istaxed = array_sum($this->taxable) > 0;
$this->includetax = shopp_setting_enabled('tax_inclusive');
if (isset($Product->excludetax) && Shopp::str_true($Product->excludetax)) {
$this->includetax = false;
}
}
if ('Donation' == $this->type) {
$this->donation = $Price->donation;
}
$this->inventory = Shopp::str_true($Price->inventory) && shopp_setting_enabled('inventory');
$this->data = stripslashes_deep(esc_attrs($data));
// Handle Recurrences
if ($this->has_recurring()) {
$this->subprice = $this->unitprice;
$this->recurrences();
if ($this->is_recurring() && $this->has_trial()) {
$trial = $this->trial();
$this->unitprice = $trial['price'];
}
} else {
// Remove subscription labels in case they were set earlier
unset($this->data[Shopp::_x('Subscription', 'Subscription terms label')]);
unset($this->data[Shopp::_x('Trial Period', 'Item trial period label')]);
}
// Map out the selected menu name and option
if (Shopp::str_true($Product->variants)) {
$selected = explode(',', $this->option->options);
$s = 0;
$variants = isset($Product->options['v']) ? $Product->options['v'] : $Product->options;
foreach ((array) $variants as $i => $menu) {
foreach ((array) $menu['options'] as $option) {
if ($option['id'] == $selected[$s]) {
$this->variant[$menu['name']] = $option['name'];
break;
}
}
$s++;
}
}
$this->packaging = Shopp::str_true(shopp_product_meta($Product->id, 'packaging'));
if (!empty($Price->download)) {
$this->download = $Price->download;
}
$this->shipped = 'Shipped' == $Price->type;
if ($this->shipped) {
$dimensions = array('weight' => 0, 'length' => 0, 'width' => 0, 'height' => 0);
if (Shopp::str_true($Price->shipping)) {
$this->shipfee = $Price->shipfee;
if (isset($Price->dimensions)) {
$dimensions = array_merge($dimensions, $Price->dimensions);
}
} else {
$this->freeshipping = true;
}
if (isset($Product->addons) && Shopp::str_true($Product->addons)) {
$this->addons($dimensions, $addons, $Product->prices, 'dimensions');
$this->addons($this->shipfee, $addons, $Product->prices, 'shipfee');
}
foreach ($dimensions as $dimension => $value) {
$this->{$dimension} = $value;
}
if (isset($Product->processing) && Shopp::str_true($Product->processing)) {
if (isset($Product->minprocess)) {
$this->processing['min'] = $Product->minprocess;
}
if (isset($Product->maxprocess)) {
$this->processing['max'] = $Product->maxprocess;
}
}
}
}