本文整理汇总了PHP中wp_parse_args函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_parse_args函数的具体用法?PHP wp_parse_args怎么用?PHP wp_parse_args使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_parse_args函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: form
/**
* Render form
*
* @since 0.1.0
*
* @param Lsx_Properties_Widget $instance Class instance
*/
function form($instance)
{
$instance = wp_parse_args((array) $instance, array('title' => '', 'order' => '', 'limit' => '', 'featured' => false, 'slider' => false));
$title = strip_tags($instance['title']);
$limit = strip_tags($instance['limit']);
$isrand = '';
if ($instance['order'] == 'rand') {
$isrand = 'selected="selected"';
}
$isrecent = '';
if ($instance['order'] == 'order_recent') {
$isrecent = 'selected="selected"';
}
echo "<p><label for=\" " . $this->get_field_id('title') . "\">" . __('Title', 'happybeds-properties') . ": <input class=\"widefat\" id=\"" . $this->get_field_id('title') . "\" name=\"" . $this->get_field_name('title') . "\" type=\"text\" value=\"" . esc_attr($title) . "\" /></label></p>\r\n";
echo "<p><label for=\" " . $this->get_field_id('limit') . "\">" . __('Limit', 'happybeds-properties') . ": <input id=\"" . $this->get_field_id('limit') . "\" name=\"" . $this->get_field_name('limit') . "\" type=\"number\" value=\"" . esc_attr($limit) . "\" /></label></p>\r\n";
$featured = '';
if (!empty($instance['featured'])) {
$featured = 'checked="checked"';
}
echo "<p><label for=\"" . $this->get_field_id('featured') . "\">" . __('Show Featured Only', 'happybeds-properties') . ": <input id=\"" . $this->get_field_id('featured') . "\" " . $featured . " type=\"checkbox\" name=\"" . $this->get_field_name('featured') . "\" ></label>\r\n";
$slider = '';
if (!empty($instance['slider'])) {
$slider = 'checked="checked"';
}
echo "<p><label for=\" " . $this->get_field_id('order') . "\">" . __('Order', 'happybeds-properties') . ": </label><select style=\"width:100%;\" name=\"" . $this->get_field_name('order') . "\">\r\n";
echo "<option value=\"\"></option>\r\n";
echo "<option value=\"rand\" " . $isrand . "\">" . __('Random', 'happybeds-properties') . "</option>\r\n";
echo "<option value=\"order_recent\" " . $isrecent . ">" . __('Recent', 'happybeds-properties') . "</option>\r\n";
echo "</select></p>\r\n";
echo "<p><label for=\"" . $this->get_field_id('slider') . "\">" . __('Show as Slider', 'happybeds-properties') . ": <input id=\"" . $this->get_field_id('slider') . "\" " . $slider . " type=\"checkbox\" name=\"" . $this->get_field_name('slider') . "\" ></label>\r\n";
}
示例2: normalize_field
/**
* Add default value for 'taxonomy' field
*
* @param $field
*
* @return array
*/
static function normalize_field($field)
{
$default_args = array('hide_empty' => false);
// Set default args
$field['options']['args'] = !isset($field['options']['args']) ? $default_args : wp_parse_args($field['options']['args'], $default_args);
$tax = get_taxonomy($field['options']['taxonomy']);
$field['placeholder'] = empty($field['placeholder']) ? sprintf(__('Select a %s', 'framework'), $tax->labels->singular_name) : $field['placeholder'];
switch ($field['options']['type']) {
case 'select_advanced':
$field = RWMB_Select_Advanced_Field::normalize_field($field);
break;
case 'checkbox_list':
case 'checkbox_tree':
$field = RWMB_Checkbox_List_Field::normalize_field($field);
break;
case 'select':
case 'select_tree':
$field = RWMB_Select_Field::normalize_field($field);
break;
default:
$field['options']['type'] = 'select';
$field = RWMB_Select_Field::normalize_field($field);
}
if (in_array($field['options']['type'], array('checkbox_tree', 'select_tree'))) {
if (isset($field['options']['args']['parent'])) {
$field['options']['parent'] = $field['options']['args']['parent'];
unset($field['options']['args']['parent']);
} else {
$field['options']['parent'] = 0;
}
}
$field['field_name'] = "{$field['id']}[]";
return $field;
}
示例3: form
/**
* Create the necessary form to customize the widget.
*
* @uses title @since 0.1
*
* @author Nate Jacobs
* @since 0.1
*
* @param array
*/
public function form($instance)
{
$instance = wp_parse_args((array) $instance, array('title' => __('Brickset Themes', 'bs_api')));
$title = esc_attr($instance['title']);
?>
<p>
<label for="<?php
echo $this->get_field_id('title');
?>
"><?php
_e('Title', 'bs_api');
?>
:</label>
<input class="widefat" id="<?php
echo $this->get_field_id('title');
?>
" name="<?php
echo $this->get_field_name('title');
?>
" type="text" value="<?php
echo $title;
?>
">
</p>
<?php
}
示例4: parse_settings
public static function parse_settings($editor_id, $settings)
{
$set = wp_parse_args($settings, array('wpautop' => true, 'media_buttons' => true, 'textarea_name' => $editor_id, 'textarea_rows' => 20, 'tabindex' => '', 'tabfocus_elements' => ':prev,:next', 'editor_css' => '', 'editor_class' => '', 'teeny' => false, 'dfw' => false, 'tinymce' => true, 'quicktags' => true));
self::$this_tinymce = $set['tinymce'] && user_can_richedit();
self::$this_quicktags = (bool) $set['quicktags'];
if (self::$this_tinymce) {
self::$has_tinymce = true;
}
if (self::$this_quicktags) {
self::$has_quicktags = true;
}
if (empty($set['editor_height'])) {
return $set;
}
if ('content' === $editor_id) {
// A cookie (set when a user resizes the editor) overrides the height.
$cookie = (int) get_user_setting('ed_size');
// Upgrade an old TinyMCE cookie if it is still around, and the new one isn't.
if (!$cookie && isset($_COOKIE['TinyMCE_content_size'])) {
parse_str($_COOKIE['TinyMCE_content_size'], $cookie);
$cookie = $cookie['ch'];
}
if ($cookie) {
$set['editor_height'] = $cookie;
}
}
if ($set['editor_height'] < 50) {
$set['editor_height'] = 50;
} elseif ($set['editor_height'] > 5000) {
$set['editor_height'] = 5000;
}
return $set;
}
示例5: __construct
/**
* Constructor method for the UI_Stepper class.
*
* @since 4.0.0
*/
function __construct($args = array())
{
$this->defaults_settings['id'] = 'cherry-ui-stepper-' . uniqid();
$this->settings = wp_parse_args($args, $this->defaults_settings);
add_action('admin_enqueue_scripts', array(__CLASS__, 'enqueue_assets'));
self::enqueue_assets();
}
示例6: form
function form($instance)
{
$defaults = array('title' => '', 'link' => '');
$instance = wp_parse_args($instance, $defaults);
extract($instance);
?>
<p class="description">
<label for="<?php
echo $this->get_field_id('title');
?>
">
Title (optional)
<?php
echo aq_field_input('title', $block_id, $title, $size = 'full');
?>
</label>
</p>
<p class="description">
<label for="<?php
echo $this->get_field_id('link');
?>
">
Link Download (optional)
<?php
echo aq_field_input('link', $block_id, $link, $size = 'full');
?>
</label>
</p>
<?php
}
示例7: mm_ux_log
function mm_ux_log($args = array())
{
$url = "https://ssl.google-analytics.com/collect";
global $title;
if (empty($_SERVER['REQUEST_URI'])) {
return;
}
$path = explode('wp-admin', $_SERVER['REQUEST_URI']);
if (empty($path) || empty($path[1])) {
$path = array("", " ");
}
$defaults = array('v' => '1', 'tid' => 'UA-39246514-3', 't' => 'pageview', 'cid' => md5(get_option('siteurl')), 'uid' => md5(get_option('siteurl') . get_current_user_id()), 'cn' => 'mojo_wp_plugin', 'cs' => 'mojo_wp_plugin', 'cm' => 'plugin_admin', 'ul' => get_locale(), 'dp' => $path[1], 'sc' => '', 'ua' => @$_SERVER['HTTP_USER_AGENT'], 'dl' => $path[1], 'dh' => get_option('siteurl'), 'dt' => $title, 'ec' => '', 'ea' => '', 'el' => '', 'ev' => '');
if (isset($_SERVER['REMOTE_ADDR'])) {
$defaults['uip'] = $_SERVER['REMOTE_ADDR'];
}
$params = wp_parse_args($args, $defaults);
$test = get_transient('mm_test', '');
if (isset($test['key']) && isset($test['name'])) {
$params['cm'] = $params['cm'] . "_" . $test['name'] . "_" . $test['key'];
}
//use test account for testing
if (defined('WP_DEBUG') && WP_DEBUG) {
$params['tid'] = 'UA-19617272-27';
}
$z = wp_rand(0, 1000000000);
$query = http_build_query(array_filter($params));
$args = array('body' => $query, 'method' => 'POST', 'blocking' => false);
$url = add_query_arg(array('z' => $z), $url);
wp_remote_post($url, $args);
}
示例8: get_valid_layout
function get_valid_layout($layout = array())
{
// parse
$layout = wp_parse_args($layout, array('key' => uniqid(), 'name' => '', 'label' => '', 'display' => 'block', 'sub_fields' => array(), 'min' => '', 'max' => ''));
// return
return $layout;
}
示例9: render
/**
* Field Render Function.
*
* Takes the vars and outputs the HTML for the field in the settings
*
* @since ReduxFramework 3.0.0
*/
function render()
{
if (empty($this->field['min'])) {
$this->field['min'] = 0;
} else {
$this->field['min'] = intval($this->field['min']);
}
if (empty($this->field['max'])) {
$this->field['max'] = intval($this->field['min']) + 1;
} else {
$this->field['max'] = intval($this->field['max']);
}
if (empty($this->field['step']) || $this->field['step'] > $this->field['max']) {
$this->field['step'] = 1;
} else {
$this->field['step'] = intval($this->field['step']);
}
if (empty($this->value) && !empty($this->field['default']) && intval($this->field['min']) >= 1) {
$this->value = intval($this->field['default']);
}
if (empty($this->value) && intval($this->field['min']) >= 1) {
$this->value = intval($this->field['min']);
}
if (empty($this->value)) {
$this->value = 0;
}
// Extra Validation
if ($this->value < $this->field['min']) {
$this->value = intval($this->field['min']);
} else {
if ($this->value > $this->field['max']) {
$this->value = intval($this->field['max']);
}
}
$params = array('id' => '', 'min' => '', 'max' => '', 'step' => '', 'val' => '', 'default' => '');
$params = wp_parse_args($this->field, $params);
$params['val'] = $this->value;
// Don't allow input edit if there's a step
$readonly = "";
if (isset($this->field['edit']) && $this->field['edit'] == false) {
$readonly = ' readonly="readonly"';
}
// Use javascript globalization, better than any other method.
global $wp_scripts;
$data = $wp_scripts->get_data('redux-field-spinner-js', 'data');
if (!empty($data)) {
// Adding to the previous localize script object
if (!is_array($data)) {
$data = json_decode(str_replace('var reduxSpinners = ', '', substr($data, 0, -1)), true);
}
foreach ($data as $key => $value) {
$localized_data[$key] = $value;
}
$wp_scripts->add_data('redux-field-spinner-js', 'data', '');
}
$localized_data[$this->field['id']] = $params;
wp_localize_script('redux-field-spinner-js', 'reduxSpinners', $localized_data);
echo '<input type="text" name="' . $this->args['opt_name'] . '[' . $this->field['id'] . ']" id="' . $this->field['id'] . '" value="' . $this->value . '" class="mini spinner-input' . $this->field['class'] . '"' . $readonly . '/>';
echo '<div id="' . $this->field['id'] . '-spinner" class="redux_spinner" rel="' . $this->field['id'] . '"></div>';
}
示例10: __construct
/**
* Construct function that set message and default args
* @param string $msg
* @param array $args
*/
public function __construct($msg, $args = '')
{
$defaults = array('type' => 'error', 'where' => 'header', 'auto_close' => true, 'delay' => '5');
$this->args = wp_parse_args($args, $defaults);
$this->msg = $msg;
$this->run();
}
示例11: wpsr_digg
function wpsr_digg($args = '')
{
global $post;
$details = wpsr_get_post_details();
$def_url = $details['permalink'];
$def_title = $details['title'];
$defaults = array('output' => 'button', 'url' => $def_url, 'title' => $def_title, 'type' => 'DiggMedium', 'text' => __('Digg this', 'wpsr'), 'image' => WPSR_PUBLIC_URL . 'buttons/digg-bt.png', 'params' => '');
$args = wp_parse_args($args, $defaults);
extract($args, EXTR_SKIP);
$digg_processed = "\n<!-- Start WP Socializer Plugin - Digg Button -->\n";
switch ($output) {
// Display the ordinary button
case 'button':
$digg_processed .= '<a class="DiggThisButton ' . $type . '" href="http://digg.com/submit?url=' . urlencode($url) . '&title=' . urlencode($title) . '" ' . $params . '></a>';
break;
// Display the Image format
// Display the Image format
case 'image':
$digg_processed .= '<a href="http://digg.com/submit?url=' . urlencode($url) . '&title=' . urlencode($title) . '" ' . $params . '><img src="' . $image . '" alt="Digg!" /></a>';
break;
// Display the Text format
// Display the Text format
case 'text':
$digg_processed .= '<a href="http://digg.com/submit?url=' . urlencode($url) . '&title=' . urlencode($title) . '" ' . $params . '>' . $text . '</a>';
break;
}
$digg_processed .= "\n<!-- End WP Socializer Plugin - Digg Button -->\n";
return $digg_processed;
}
示例12: __construct
/**
* __construct function.
*
* @access public
* @return void
*/
public function __construct($args)
{
global $NF_Pushover;
$defaults = array('parent_slug' => 'options-general.php', 'page_title' => $NF_Pushover->name, 'menu_title' => $NF_Pushover->name, 'capability' => 'manage_options', 'menu_slug' => $NF_Pushover->token, 'default_tab' => isset($NF_Pushover->default_tab) ? $NF_Pushover->default_tab : '', 'screen_icon' => 'options-general');
$this->args = wp_parse_args($args, $defaults);
add_action('admin_menu', array($this, 'register_settings_screen'));
}
示例13: woo_enforce_defaults
function woo_enforce_defaults($instance)
{
$defaults = $this->woo_get_settings();
$instance = wp_parse_args($instance, $defaults);
if ($instance['limit'] < 1) {
$instance['limit'] = 1;
} elseif ($instance['limit'] > 10) {
$instance['limit'] = 10;
}
$instance['width'] = absint($instance['width']);
if ($instance['width'] < 1) {
$instance['width'] = $defaults['width'];
}
$instance['height'] = absint($instance['height']);
if ($instance['height'] < 1) {
$instance['height'] = $defaults['height'];
}
if ($instance['sorting'] != 'random') {
$instance['sorting'] = $defaults['sorting'];
}
if (!in_array($instance['size'], array('s', 'm', 't'))) {
$instance['size'] = $defaults['size'];
}
if ($instance['type'] != 'group') {
$instance['type'] = $defaults['type'];
}
return $instance;
}
示例14: getForm
/**
* Returns HTML settings form. Should be a collection of <tr> elements containing two columns.
*
* @return string HTML snippet
*/
function getForm()
{
global $wpdb;
$shipping = wp_parse_args(get_option('flat_rates'), array('southisland' => '', 'northisland' => '', 'continental' => '', 'all' => '', 'local' => '', 'northamerica' => '', 'southamerica' => '', 'asiapacific' => '', 'europe' => '', 'africa' => ''));
$output = "<tr><td colspan='2'>";
$output .= "<table>";
$output .= "<tr><th colspan='2'><strong>" . __('Base Local', 'wp-e-commerce') . "</strong></th></tr>";
switch (get_option('base_country')) {
case 'NZ':
$output .= $this->settings_form_shipping_price_field('southisland', __('South Island', 'wp-e-commerce'), $shipping['southisland']);
$output .= $this->settings_form_shipping_price_field('northisland', __('North Island', 'wp-e-commerce'), $shipping['northisland']);
break;
case 'US':
$output .= $this->settings_form_shipping_price_field('continental', __('Continental 48 States', 'wp-e-commerce'), $shipping['continental']);
$output .= $this->settings_form_shipping_price_field('all', __('All 50 States', 'wp-e-commerce'), $shipping['all']);
break;
default:
$output .= $this->settings_form_shipping_price_field('local', __('Domestic', 'wp-e-commerce'), $shipping['local']);
break;
}
$output .= "<tr><th colspan='2'><strong>" . __('Base International', 'wp-e-commerce') . "</strong></th></tr>";
$output .= $this->settings_form_shipping_price_field('northamerica', __('North America', 'wp-e-commerce'), $shipping['northamerica']);
$output .= $this->settings_form_shipping_price_field('southamerica', __('South America', 'wp-e-commerce'), $shipping['southamerica']);
$output .= $this->settings_form_shipping_price_field('asiapacific', __('Asia and Pacific', 'wp-e-commerce'), $shipping['asiapacific']);
$output .= $this->settings_form_shipping_price_field('europe', __('Europe', 'wp-e-commerce'), $shipping['europe']);
$output .= $this->settings_form_shipping_price_field('africa', __('Africa', 'wp-e-commerce'), $shipping['africa']);
$output .= "</table>";
$output .= "<br /><p class='description'>" . __('If you do not wish to ship to a particular region, leave the field blank. To offer free shipping to a region, enter 0.', 'wp-e-commerce') . "</p>";
$output .= "</td></tr>";
return $output;
}
示例15: hybrid_register_sidebars
/**
* Registers the default framework dynamic sidebars based on the sidebars the theme has added support
* for using add_theme_support().
*
* @since 0.7.0
* @access private
* @uses register_sidebar() Registers a sidebar with WordPress.
* @link http://codex.wordpress.org/Function_Reference/register_sidebar
* @return void
*/
function hybrid_register_sidebars()
{
/* Get the theme-supported sidebars. */
$supported_sidebars = get_theme_support('hybrid-core-sidebars');
/* If the theme doesn't add support for any sidebars, return. */
if (!is_array($supported_sidebars[0])) {
return;
}
/* Get the available core framework sidebars. */
$core_sidebars = hybrid_get_sidebars();
/* Loop through the supported sidebars. */
foreach ($supported_sidebars[0] as $sidebar) {
/* Make sure the given sidebar is one of the core sidebars. */
if (isset($core_sidebars[$sidebar])) {
/* Set up some default sidebar arguments. */
$defaults = array('before_widget' => '<div id="%1$s" class="widget %2$s widget-%2$s"><div class="widget-wrap widget-inside">', 'after_widget' => '</div></div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>');
/* Allow developers to filter the default sidebar arguments. */
$defaults = apply_filters(hybrid_get_prefix() . '_sidebar_defaults', $defaults, $sidebar);
/* Parse the sidebar arguments and defaults. */
$args = wp_parse_args($core_sidebars[$sidebar], $defaults);
/* If no 'id' was given, use the $sidebar variable and sanitize it. */
$args['id'] = isset($args['id']) ? sanitize_key($args['id']) : sanitize_key($sidebar);
/* Allow developers to filter the sidebar arguments. */
$args = apply_filters(hybrid_get_prefix() . '_sidebar_args', $args, $sidebar);
/* Register the sidebar. */
register_sidebar($args);
}
}
}