本文整理汇总了PHP中WC_Admin_Settings::get_option方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Admin_Settings::get_option方法的具体用法?PHP WC_Admin_Settings::get_option怎么用?PHP WC_Admin_Settings::get_option使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Admin_Settings
的用法示例。
在下文中一共展示了WC_Admin_Settings::get_option方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: output
/**
* Outputs a custom textarea template in plugin options panel
*
* @since 1.0.0
* @return void
* @author Alberto Ruggiero
*/
public static function output($option)
{
$custom_attributes = array();
if (!empty($option['custom_attributes']) && is_array($option['custom_attributes'])) {
foreach ($option['custom_attributes'] as $attribute => $attribute_value) {
$custom_attributes[] = esc_attr($attribute) . '="' . esc_attr($attribute_value) . '"';
}
}
$option_value = WC_Admin_Settings::get_option($option['id'], $option['default']);
?>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php
echo esc_attr($option['id']);
?>
"><?php
echo esc_html($option['title']);
?>
</label>
</th>
<td class="forminp forminp-<?php
echo sanitize_title($option['type']);
?>
">
<textarea
name="<?php
echo esc_attr($option['id']);
?>
"
id="<?php
echo esc_attr($option['id']);
?>
"
style="<?php
echo esc_attr($option['css']);
?>
"
class="<?php
echo esc_attr($option['class']);
?>
"
<?php
echo implode(' ', $custom_attributes);
?>
><?php
echo esc_textarea($option_value);
?>
</textarea><br /><br />
<span class="description"><?php
echo $option['desc'];
?>
</span>
</td>
</tr>
<?php
}
示例2: load_options
/**
* Load user options into class
*
* @return void
*/
protected function load_options()
{
$this->enabled = $this->get_option('enabled');
$this->registration_enabled = WC_Admin_Settings::get_option('woocommerce_enable_signup_and_login_from_checkout') === 'yes' ? true : false;
$this->profiles_enabled = $this->registration_enabled && $this->get_option('enable_profiles') === 'yes';
$this->title = $this->get_option('title');
$this->description = $this->get_option('description');
$this->card_types = $this->get_option('card_types');
$this->mode = $this->get_option('mode', 'capture');
$this->sandbox = $this->get_option('sandbox');
$this->site = $this->get_option('site');
$this->env_key = $this->sandbox == 'no' ? 'production' : 'sandbox';
$port = $this->cc_ports[$this->env_key];
$this->api_credentials = array('url' => "https://{$this->site}.{$this->domain}:{$port}{$this->rest_path}", 'mid' => $this->get_option("{$this->env_key}_mid"), 'user' => $this->get_option("{$this->env_key}_user"), 'pass' => $this->get_option("{$this->env_key}_password"));
$this->verification = array('void_cvv' => $this->get_option('void_cvv'), 'void_avs' => $this->get_option('void_avs'));
}
示例3: hidden_field
public function hidden_field($value)
{
$option_value = WC_Admin_Settings::get_option($value['id'], $value['default']);
?>
<tr valign="top" style="display: none">
<th class="forminp forminp-image">
<input type="hidden" id="<?php
echo esc_attr($value['id']);
?>
" value="<?php
echo esc_attr($option_value);
?>
" name="<?php
echo esc_attr($value['id']);
?>
" />
</th>
</tr>
<?php
}
示例4: admin_fields_yith_ywzm_image_width
/**
* Create new Woocommerce admin field: yith_ywzm_image_width
*
* @access public
* @param array $value
* @return void
* @since 1.1.3
*/
public function admin_fields_yith_ywzm_image_width($value)
{
$width = WC_Admin_Settings::get_option($value['id'] . '[width]', $value['default']['width']);
$height = WC_Admin_Settings::get_option($value['id'] . '[height]', $value['default']['height']);
$crop = WC_Admin_Settings::get_option($value['id'] . '[crop]');
$crop = $crop == 'on' || $crop == '1' ? 1 : 0;
$crop = checked(1, $crop, false);
?>
<tr valign="top">
<th scope="row" class="titledesc"><?php
echo esc_html($value['title']);
?>
</th>
<td class="forminp image_width_settings">
<input name="<?php
echo esc_attr($value['id']);
?>
[width]" id="<?php
echo esc_attr($value['id']);
?>
-width" type="text" size="3" value="<?php
echo $width;
?>
" /> × <input name="<?php
echo esc_attr($value['id']);
?>
[height]" id="<?php
echo esc_attr($value['id']);
?>
-height" type="text" size="3" value="<?php
echo $height;
?>
" />px <span class="description"><?php
echo $value['desc'];
?>
</span>
<br>
<label><input name="<?php
echo esc_attr($value['id']);
?>
[crop]" id="<?php
echo esc_attr($value['id']);
?>
-crop" type="checkbox" <?php
echo $crop;
?>
/> <?php
_e('Do you want to hard crop the image?', 'woocommerce');
?>
</label>
</td>
</tr><?php
}
示例5: woocommerce_settings_get_option
/**
* Get a setting from the settings API.
*
* @param mixed $option
* @return string
*/
function woocommerce_settings_get_option($option_name, $default = '')
{
if (!class_exists('WC_Admin_Settings')) {
include 'class-wc-admin-settings.php';
}
return WC_Admin_Settings::get_option($option_name, $default);
}
示例6: ws_sendinblue_templates
/**
* SendinBlue templates on Email options section
*/
public function ws_sendinblue_templates()
{
$email_templates = array('ws_new_order_template' => '', 'ws_processing_order_template' => '', 'ws_refunded_order_template' => '', 'ws_cancelled_order_template' => '', 'ws_completed_order_template' => '', 'ws_new_account_template' => '');
$templates = WC_Sendinblue::$templates;
foreach ($email_templates as $key => $content) {
$option_value = WC_Admin_Settings::get_option($key, '0');
$email_templates[$key] = '<select name="' . $key . '" id="' . $key . '">';
$email_templates[$key] .= '<option value="0" > - Choose Template - </option>';
foreach ($templates as $id => $val) {
$email_templates[$key] .= '<option value="' . $id . '" ' . selected($option_value, $id, false) . '>' . $val['name'] . '</option>';
}
$email_templates[$key] .= '</select>';
}
?>
<table class="form-table">
<tbody><tr valign="top">
<th scope="row" class="titledesc">
<label for=""><?php
_e('SendinBlue Templates', 'wc_sendinblue');
?>
</label>
</th>
<td class="forminp">
<table class="form-ws-table">
<tr>
<td><label for="ws_new_order_template"><?php
_e('New order', 'wc_sendinblue');
?>
</label></td><td><?php
echo $email_templates['ws_new_order_template'];
?>
</td>
<td><label for="ws_processing_order_template"><?php
_e('Processing order', 'wc_sendinblue');
?>
</label></td><td><?php
echo $email_templates['ws_processing_order_template'];
?>
</td>
</tr>
<tr>
<td><label for="ws_refunded_order_template"><?php
_e('Refunded order', 'wc_sendinblue');
?>
</label></td><td><?php
echo $email_templates['ws_refunded_order_template'];
?>
</td>
<td><label for="ws_cancelled_order_template"><?php
_e('Cancelled order', 'wc_sendinblue');
?>
</label></td><td><?php
echo $email_templates['ws_cancelled_order_template'];
?>
</td>
</tr>
<tr>
<td><label for="ws_completed_order_template"><?php
_e('Completed order', 'wc_sendinblue');
?>
</label></td><td><?php
echo $email_templates['ws_completed_order_template'];
?>
</td>
<td><label for="ws_new_account_template"><?php
_e('New account', 'wc_sendinblue');
?>
</label></td><td><?php
echo $email_templates['ws_new_account_template'];
?>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
<?php
}
开发者ID:GaunYun,项目名称:woocommerce-sendinblue-newsletter-subscription,代码行数:83,代码来源:wc-sendinblue-settings.php
示例7: output_image_select
/**
* Output image select field
*/
public function output_image_select($value)
{
// Define the defaults
if (!isset($value['title_select'])) {
$value['title_select'] = __('Select', 'woocommerce-delivery-notes');
}
if (!isset($value['title_remove'])) {
$value['title_remove'] = __('Remove', 'woocommerce-delivery-notes');
}
// Get additional data fields
$field = WC_Admin_Settings::get_field_description($value);
$description = $field['description'];
$tooltip_html = $field['tooltip_html'];
$option_value = WC_Admin_Settings::get_option($value['id'], $value['default']);
$class_name = 'wcdn-image-select';
?>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php
echo esc_attr($value['id']);
?>
"><?php
echo esc_html($value['title']);
?>
<?php
echo $tooltip_html;
?>
</label>
</th>
<td class="forminp image_width_settings">
<input name="<?php
echo esc_attr($value['id']);
?>
" id="<?php
echo esc_attr($value['id']);
?>
" type="hidden" value="<?php
echo esc_attr($option_value);
?>
" class="<?php
echo $class_name;
?>
-image-id <?php
echo esc_attr($value['class']);
?>
" />
<div id="<?php
echo esc_attr($value['id']);
?>
_field" class="<?php
echo $class_name;
?>
-field <?php
echo esc_attr($value['class']);
?>
" style="<?php
echo esc_attr($value['css']);
?>
">
<span id="<?php
echo esc_attr($value['id']);
?>
_spinner" class="<?php
echo $class_name;
?>
-spinner spinner"></span>
<div id="<?php
echo esc_attr($value['id']);
?>
_attachment" class="<?php
echo $class_name;
?>
-attachment <?php
echo esc_attr($value['class']);
?>
">
<div class="thumbnail">
<div class="centered">
<?php
if (!empty($option_value)) {
?>
<?php
$this->create_image($option_value);
?>
<?php
}
?>
</div>
</div>
</div>
<div id="<?php
echo esc_attr($value['id']);
?>
_buttons" class="<?php
echo $class_name;
//.........这里部分代码省略.........
示例8: generate_iframe_src
public function generate_iframe_src($order_id = 0, $query_args = array())
{
/**
* If we do not have a valid array, make it so.
*/
if (!is_array($query_args)) {
$query_args = array();
}
/**
* Set the PROGRAM_ID, ORDER_ID, and INT args which are required for the URL
*/
$query_args['PROGRAM_ID'] = WC_Admin_Settings::get_option('woocommerce_ebay_affiliate_pid', '');
$query_args['ORDER_ID'] = $order_id;
$query_args['INT'] = 'DYNAMIC';
return add_query_arg($query_args, $this->endpoint);
}
开发者ID:blacksector,项目名称:woocommerce-ebay-enterprise-affiliates,代码行数:16,代码来源:woocommerce-ebay-enterprise-affiliates.php
示例9: get_sql
public function get_sql($account_customer_emails = '')
{
global $wpdb;
$identifier = get_option('woocommerce_crm_unique_identifier');
$display_name = get_option('woocommerce_crm_customer_name');
$woocommerce_crm_user_roles = get_option('woocommerce_crm_user_roles');
if (!$woocommerce_crm_user_roles || empty($woocommerce_crm_user_roles)) {
$woocommerce_crm_user_roles[] = 'customer';
}
$add_guest_customers = WC_Admin_Settings::get_option('woocommerce_crm_guest_customers', 'yes');
$user_role_filter = '';
foreach ($woocommerce_crm_user_roles as $value) {
if (!empty($user_role_filter)) {
$user_role_filter .= ' OR ';
}
$user_role_filter .= "customer.capabilities LIKE '%{$value}%'";
}
/******************/
$filter = '';
$join = '';
$inner = '';
$select = '';
/******************/
$select .= ', total_value.o_total as order_value';
$orders_status = get_option('woocommerce_crm_total_value');
if (!$orders_status || empty($orders_status)) {
$orders_status[] = 'wc-completed';
}
$orders_statuses = "'" . implode("','", $orders_status) . "'";
$order_types = "'" . implode("','", wc_get_order_types('order-count')) . "'";
if ($identifier == 'username_email') {
$new_sql = "SELECT IF( pmc.meta_value = 0, CONCAT(pmc.meta_value, '-', pmc_email.meta_value), pmc.meta_value) AS userUniqueID, pmc.meta_value as user_id, pmc_email.meta_value as user_email, SUM(pmc_total.meta_value) as o_total\n FROM {$wpdb->postmeta} as pmc\n LEFT JOIN {$wpdb->postmeta} pmc_email\n ON ( pmc.meta_key = '_customer_user' AND pmc_email.meta_key = '_billing_email' AND pmc.post_id = pmc_email.post_id)\n\n LEFT JOIN {$wpdb->postmeta} pmc_total\n ON ( pmc_total.meta_key = '_order_total' AND pmc.post_id = pmc_total.post_id) \n\n LEFT JOIN {$wpdb->posts} ps\n ON ( ps.ID = pmc.post_id) \n\n WHERE pmc.meta_key = '_customer_user'\n AND IF(pmc.meta_value = 0, pmc_email.meta_value, pmc.meta_value) != ''\n AND ps.post_status IN({$orders_statuses})\n AND ps.post_type IN ({$order_types})\n\n GROUP BY userUniqueID\n ";
$join .= "LEFT JOIN ({$new_sql}) total_value ON ( ( total_value.user_id != 0 AND total_value.user_id = customer.user_id) OR (total_value.user_email = customer.email AND (total_value.user_id = 0 OR total_value.user_id = '' ) ) )";
} else {
$new_sql = "SELECT pmc.meta_value as user_id, pmc_email.meta_value as user_email, SUM(pmc_total.meta_value) as o_total\n FROM {$wpdb->postmeta} as pmc_email\n LEFT JOIN {$wpdb->postmeta} pmc\n ON ( pmc.meta_key = '_customer_user' AND pmc_email.meta_key = '_billing_email' AND pmc.post_id = pmc_email.post_id)\n\n LEFT JOIN {$wpdb->postmeta} pmc_total\n ON ( pmc_total.meta_key = '_order_total' AND pmc.post_id = pmc_total.post_id) \n\n LEFT JOIN {$wpdb->posts} ps\n ON ( ps.ID = pmc.post_id) \n\n WHERE pmc_email.meta_key = '_billing_email'\n AND pmc_email.meta_value != ''\n AND pmc_email.meta_value IS NOT NULL\n AND ps.post_status IN({$orders_statuses})\n AND ps.post_type IN ({$order_types})\n\n GROUP BY user_email\n ";
$join .= "LEFT JOIN {$wpdb->usermeta} wp_users ON ( wp_users.user_id = customer.user_id AND wp_users.meta_key = 'billing_email')";
$join .= "LEFT JOIN ({$new_sql}) total_value ON ( (total_value.user_email = wp_users.meta_value AND wp_users.user_id = customer.user_id ) OR (total_value.user_email = customer.email AND (total_value.user_id = 0 OR total_value.user_id = '' ) ) )";
}
#echo '<textarea>'.$new_sql.'</textarea>'; die;
/******************/
if (!empty($account_customer_emails)) {
$emails = implode("','", $account_customer_emails);
$filter .= " AND customer.email IN ('{$emails}')";
}
/*****************/
if (isset($_REQUEST['group']) && !empty($_REQUEST['group'])) {
$group_id = $_REQUEST['group'];
$group_data = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}wc_crm_groups WHERE ID = {$group_id}");
if ($group_data[0]->group_type == 'static') {
$inner .= "\n inner join {$wpdb->prefix}wc_crm_groups_relationships groups_rel on (groups_rel.customer_email = customer.email AND groups_rel.group_id = {$group_id} )\n ";
} else {
if (isset($_REQUEST['group']) && !empty($_REQUEST['group'])) {
$group_id = $_REQUEST['group'];
$group_data = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}wc_crm_groups WHERE ID = {$group_id}");
if ($group_data[0]->group_type == 'dynamic') {
if (!empty($group_data[0]->group_total_spent)) {
$spent = $group_data[0]->group_total_spent;
$mark = $group_data[0]->group_total_spent_mark;
switch ($mark) {
case 'greater':
$mark = '>';
break;
case 'less':
$mark = '<';
break;
case 'greater_or_equal':
$mark = '>=';
break;
case 'less_or_equal':
$mark = '<=';
break;
default:
$mark = '=';
break;
}
#$filter .= " AND {$wpdb->prefix}wc_crm_customers.total_spent $mark $spent
#";
}
if (!empty($group_data[0]->group_user_role)) {
$group_user_role = $group_data[0]->group_user_role;
if ($group_user_role != 'any') {
if ($group_user_role == 'guest') {
$filter .= "AND user_id = 0\n ";
} else {
$filter .= "AND capabilities LIKE '%" . $group_user_role . "%'\n ";
}
}
}
if (!empty($group_data[0]->group_customer_status)) {
$group_customer_status = unserialize($group_data[0]->group_customer_status);
if (!empty($group_customer_status)) {
if (count($group_customer_status) > 1 || !empty($group_customer_status[0])) {
$filter .= "AND status IN( '" . implode("', '", $group_customer_status) . "' )\n ";
}
}
}
if (!empty($group_data[0]->group_order_status)) {
$group_order_status = unserialize($group_data[0]->group_order_status);
if (!empty($group_order_status)) {
if (count($group_order_status) > 1 || !empty($group_order_status[0])) {
//.........这里部分代码省略.........
示例10: user_roles_filter
public static function user_roles_filter()
{
global $wp_roles;
?>
<select name='_user_type' id='dropdown_user_type'>
<option value=""><?php
_e('Show all user roles', 'wc_crm');
?>
</option>
<?php
$woocommerce_crm_user_roles = get_option('wc_crm_user_roles');
if (!$woocommerce_crm_user_roles || empty($woocommerce_crm_user_roles)) {
$woocommerce_crm_user_roles[] = 'customer';
}
$_user_type = isset($_REQUEST['_user_type']) ? $_REQUEST['_user_type'] : '';
foreach ($wp_roles->role_names as $role => $name) {
$slug_name = strtolower($name);
if (!in_array($slug_name, $woocommerce_crm_user_roles)) {
continue;
}
?>
<option value="<?php
echo $slug_name;
?>
" <?php
selected($slug_name, $_user_type, true);
?>
><?php
echo $name;
?>
</option>
<?php
}
$add_guest_customers = WC_Admin_Settings::get_option('wc_crm_guest_customers', 'no');
if ($add_guest_customers == 'yes') {
?>
<option value="guest_user" <?php
selected('guest_user', $_user_type, true);
?>
>
<?php
_e('Guest', 'wc_crm');
?>
</option>
<?php
}
?>
</select>
<?php
}
示例11: get_group_settings
/**
* Get all settings in a group.
*
* @since 2.7.0
* @param string $group_id Group ID.
* @return array|WP_Error
*/
public function get_group_settings($group_id)
{
if (empty($group_id)) {
return new WP_Error('rest_setting_setting_group_invalid', __('Invalid setting group.', 'woocommerce'), array('status' => 404));
}
$settings = apply_filters('woocommerce_settings-' . $group_id, array());
if (empty($settings)) {
return new WP_Error('rest_setting_setting_group_invalid', __('Invalid setting group.', 'woocommerce'), array('status' => 404));
}
$filtered_settings = array();
foreach ($settings as $setting) {
$option_key = $setting['option_key'];
$setting = $this->filter_setting($setting);
$default = isset($setting['default']) ? $setting['default'] : '';
// Get the option value
if (is_array($option_key)) {
$option = get_option($option_key[0]);
$setting['value'] = isset($option[$option_key[1]]) ? $option[$option_key[1]] : $default;
} else {
$admin_setting_value = WC_Admin_Settings::get_option($option_key);
$setting['value'] = empty($admin_setting_value) ? $default : $admin_setting_value;
}
if ('multi_select_countries' === $setting['type']) {
$setting['options'] = WC()->countries->get_countries();
$setting['type'] = 'multiselect';
}
$filtered_settings[] = $setting;
}
return $filtered_settings;
}
示例12: select_page_field
public function select_page_field($value)
{
$args = array('name' => $value['id'], 'id' => $value['id'], 'sort_column' => 'menu_order', 'sort_order' => 'ASC', 'show_option_none' => ' ', 'class' => $value['class'], 'echo' => false, 'selected' => absint(WC_Admin_Settings::get_option($value['id'])));
if (isset($value['args'])) {
$args = wp_parse_args($value['args'], $args);
}
if ($value['desc_tip']) {
$value['desc_tip'] = $value['desc'];
}
// Custom attribute handling
$custom_attributes = array();
if (!empty($value['custom_attributes']) && is_array($value['custom_attributes'])) {
foreach ($value['custom_attributes'] as $attribute => $attribute_value) {
$custom_attributes[] = esc_attr($attribute) . '="' . esc_attr($attribute_value) . '"';
}
}
?>
<tr valign="top" class="single_select_page">
<th scope="row" class="titledesc"><?php
echo esc_html($value['title']);
?>
<?php
if (!empty($value['desc_tip'])) {
?>
<img class="help_tip" data-tip="<?php
echo esc_attr(wp_kses_post($value['desc_tip']));
?>
" src="<?php
echo WC()->plugin_url();
?>
/assets/images/help.png" height="16" width="16" />
<?php
}
?>
</th>
<td class="forminp">
<?php
echo str_replace(' id=', " data-placeholder='" . __('Select a page…', 'woocommerce') . "' " . implode(" ", $custom_attributes) . " style='" . $value['css'] . "' class='" . $value['class'] . "' id=", wp_dropdown_pages($args));
?>
</td>
</tr>
<?php
}
示例13: prepare_item_for_response
/**
* Prepare a single setting object for response.
*
* @since 2.7.0
* @param object $item Setting object.
* @param WP_REST_Request $request Request object.
* @return WP_REST_Response $response Response data.
*/
public function prepare_item_for_response($item, $request)
{
$data = $this->filter_setting($item);
$data['value'] = WC_Admin_Settings::get_option($data['id']);
$context = empty($request['context']) ? 'view' : $request['context'];
$data = $this->add_additional_fields_to_object($data, $request);
$data = $this->filter_response_by_context($data, $context);
$response = rest_ensure_response($data);
$response->add_links($this->prepare_links($data['id'], $request['group']));
return $response;
}
示例14: _e
?>
</a>
</h3>
<table class="wp-list widefat fixed striped">
<thead>
<tr>
<th><?php
_e('Name', 'woorule');
?>
</th>
<th colspan="2"><?php
_e('Enabled', 'woorule');
?>
</th>
</tr>
</thead>
<tbody>
<?php
foreach ($rules as $id => $value) {
echo '<tr>';
echo '<td>' . WC_Admin_Settings::get_option($value['name']['id'], 'Unnamed') . '</td>';
echo '<td>' . WC_Admin_Settings::get_option($value['enabled']['id'], 'no') . '</td>';
echo '<td><a href="' . $edit_url . $id . '">' . __('Edit', 'woorule') . '</a></td>';
echo '</tr>';
}
?>
</tbody>
</table>