本文整理汇总了PHP中selected函数的典型用法代码示例。如果您正苦于以下问题:PHP selected函数的具体用法?PHP selected怎么用?PHP selected使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了selected函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hybrid_meta_box_post_display_template
/**
* Displays the post template meta box.
*
* @since 1.2.0
* @access public
* @param object $object
* @param array $box
* @return void
*/
function hybrid_meta_box_post_display_template($post, $box)
{
$templates = hybrid_get_post_templates($post->post_type);
$post_template = hybrid_get_post_template($post->ID);
wp_nonce_field(basename(__FILE__), 'hybrid-post-template-nonce');
?>
<p>
<select name="hybrid-post-template" class="widefat">
<option value=""></option>
<?php
foreach ($templates as $label => $template) {
?>
<option value="<?php
echo esc_attr($template);
?>
" <?php
selected($post_template, $template);
?>
><?php
echo esc_html($label);
?>
</option>
<?php
}
?>
</select>
</p>
<?php
}
示例2: downloads_by_category
/**
* downloads_by_category function.
*
* @access public
* @param int $show_counts (default: 1)
* @param int $hierarchical (default: 1)
* @param int $show_uncategorized (default: 1)
* @param string $orderby (default: '')
* @return void
*/
public function downloads_by_category($show_counts = 1, $hierarchical = 1, $show_uncategorized = 1, $orderby = '')
{
global $typenow, $wp_query;
if ($typenow != 'dlm_download') {
return;
}
include_once 'class-dlm-category-walker.php';
$r = array();
$r['pad_counts'] = 1;
$r['hierarchical'] = $hierarchical;
$r['hide_empty'] = 1;
$r['show_count'] = $show_counts;
$r['selected'] = isset($wp_query->query['dlm_download_category']) ? $wp_query->query['dlm_download_category'] : '';
$r['menu_order'] = false;
if ($orderby == 'order') {
$r['menu_order'] = 'asc';
} elseif ($orderby) {
$r['orderby'] = $orderby;
}
$terms = get_terms('dlm_download_category', $r);
if (!$terms) {
return;
}
$output = "<select name='dlm_download_category' id='dropdown_dlm_download_category'>";
$output .= '<option value="" ' . selected(isset($_GET['dlm_download_category']) ? $_GET['dlm_download_category'] : '', '', false) . '>' . __('Select a category', 'download-monitor') . '</option>';
$output .= $this->walk_category_dropdown_tree($terms, 0, $r);
$output .= "</select>";
echo $output;
}
示例3: socialeyes_theme_settings_style_box
function socialeyes_theme_settings_style_box()
{
?>
<p><label><?php
_e('Stylesheet', 'genesis');
?>
:
<select name="<?php
echo GENESIS_SETTINGS_FIELD;
?>
[style_selection]">
<option style="padding-right:10px;" value=""><?php
_e('Blue');
?>
</option>
<option style="padding-right:10px;" value="social-pink" <?php
selected('social-pink', genesis_get_option('style_selection'));
?>
><?php
_e('Pink');
?>
</option>
</select>
</label></p>
<p><span class="description">Please select the Social Eyes color style from the drop down list and save your settings.</span></p>
<?php
}
示例4: rum_post_cta_meta_box_list
function rum_post_cta_meta_box_list()
{
global $post;
// store global post object for later resetting after our query
// using wp_reset_postdata() doesn't work so we are manually resetting the global
$post_old = $post;
// initialize variables
$options = '';
// get plugin option array and store in a variable
$plugin_option_array = get_option('rum_post_cta_plugin_options');
// fetch values from the plugin option variable array
$post_cta_post_type = $plugin_option_array['post_type'];
// retrieve the custom meta box value
$post_cta_id = get_post_meta($post->ID, 'rum_post_cta_id', true);
// set query arguments
$args = array('post_type' => $post_cta_post_type, 'nopaging' => true);
// execute the query
$cta_post_query = new WP_Query($args);
// The Loop
while ($cta_post_query->have_posts()) {
$cta_post_query->the_post();
$post_title = get_the_title();
$post_ID = get_the_id();
$options .= '<option value="' . esc_attr($post_ID) . '" ' . selected($post_cta_id, $post_ID) . '>' . $post_title . '</option>';
}
// restore the global $post variable of the main query loop
// wp_reset_postdata(); doesn't work so we are manually resetting it back
// restore global post object
$post = $post_old;
setup_postdata($post);
return $options;
}
示例5: display
public function display()
{
$this->echoOptionHeader();
?>
<select name="<?php
echo $this->getID();
?>
"><?php
foreach ($this->settings['options'] as $value => $label) {
// this is if we have option groupings
if (is_array($label)) {
?>
<optgroup label="<?php
echo $value;
?>
"><?php
foreach ($label as $subValue => $subLabel) {
printf("<option value=\"%s\" %s>%s</option>", $subValue, selected($this->getValue(), $subValue, false), $subLabel);
}
?>
</optgroup><?php
// this is for normal list of options
} else {
printf("<option value=\"%s\" %s>%s</option>", $value, selected($this->getValue(), $value, false), $label);
}
}
?>
</select><?php
$this->echoOptionFooter();
}
示例6: wpce_app_render
function wpce_app_render()
{
$app = get_option('wpce_app');
$apps = wpce_apps();
?>
<select name="wpce_app" style="width: 300px;">
<option value="">Select an app</option>
<?php
foreach ($apps as $slug => $name) {
?>
<option value="<?php
echo $slug;
?>
" <?php
selected($app, $slug);
?>
><?php
echo $name;
?>
</option>
<?php
}
?>
</select>
<?php
}
示例7: date_dropdown
/**
* Date dropdown
*/
function date_dropdown($limit = 0, $name = '', $table = '', $column = '', $id = '', $field = '', $bool = '')
{
if ($id != '') {
$bind = [":id" => $id];
$array = [];
$q = DB::inst()->select($table, "{$column} = :id", "", "*", $bind);
foreach ($q as $r) {
$array[] = $r;
}
$date = explode("-", $r[$field]);
}
/*years*/
$html_output = ' <select name="' . $name . 'Year"' . $bool . ' class="selectpicker form-control" data-style="btn-info" data-size="10" data-live-search="true">' . "\n";
$html_output .= ' <option value=""> </option>' . "\n";
for ($year = 2000; $year <= date("Y") - $limit; $year++) {
$html_output .= ' <option value="' . sprintf("%04s", $year) . '"' . selected(sprintf("%04s", $year), $date[0], false) . '>' . sprintf("%04s", $year) . '</option>' . "\n";
}
$html_output .= ' </select>' . "\n";
/*months*/
$html_output .= ' <select name="' . $name . 'Month"' . $bool . ' class="selectpicker form-control" data-style="btn-info" data-size="10" data-live-search="true">' . "\n";
$html_output .= ' <option value=""> </option>' . "\n";
$months = array("", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
for ($month = 1; $month <= 12; $month++) {
$html_output .= ' <option value="' . sprintf("%02s", $month) . '"' . selected(sprintf("%02s", $month), $date[1], false) . '>' . $months[$month] . '</option>' . "\n";
}
$html_output .= ' </select>' . "\n";
/*days*/
$html_output .= ' <select name="' . $name . 'Day"' . $bool . ' class="selectpicker form-control" data-style="btn-info" data-size="10" data-live-search="true">' . "\n";
$html_output .= ' <option value=""> </option>' . "\n";
for ($day = 1; $day <= 31; $day++) {
$html_output .= ' <option value="' . sprintf("%02s", $day) . '"' . selected(sprintf("%02s", $day), $date[2], false) . '>' . sprintf("%02s", $day) . '</option>' . "\n";
}
$html_output .= ' </select>' . "\n";
return $html_output;
}
示例8: render_content
/**
* Render the content on the theme customizer page
*/
public function render_content()
{
if (empty($this->tags)) {
return false;
}
?>
<label>
<span class="customize-control-title"><?php
echo esc_html($this->label);
?>
</span>
<select name="<?php
echo esc_attr($this->id);
?>
" id="<?php
echo esc_attr($this->id);
?>
">
<?php
foreach ($this->tags as $tag) {
printf('<option value="%s" %s>%s</option>', $tag->term_id, selected($this->value(), $tag->term_id, false), $tag->name);
}
?>
</select>
</label>
<?php
}
示例9: render
/**
* Render this field.
*
* @access public
*/
public function render()
{
$field_value = $this->get_value();
?>
<select name="<?php
echo $this->get_id();
?>
" id="<?php
echo $this->get_id();
?>
" class="postform">
<?php
foreach ($this->get_options() as $value => $text) {
?>
<option value="<?php
echo esc_attr($value);
?>
" <?php
selected($field_value, $value);
echo $this->render_required();
?>
><?php
echo $text;
?>
</option>
<?php
}
?>
</select>
<?php
$this->render_help();
}
示例10: field
/**
* draw field on post edit form
* you can use $this->instance, $this->entry
*/
function field($args, $instance = array())
{
extract($args);
$values = array();
// prepare options array
$v = explode("\n", $this->instance['settings']);
foreach ($v as $val) {
$val = trim($val);
if (strpos($val, '|') !== FALSE) {
$a = explode('|', $val);
$values[$a[0]] = $a[1];
} elseif (!empty($val)) {
$values[$val] = $val;
}
}
echo $before_widget;
echo $before_title . $this->instance['title'] . $after_title;
echo '<div class="select-field">';
echo '<select name="' . $this->get_field_name('val') . '" id="' . $this->get_field_id('val') . '" style="width: 47%;">';
echo '<option value="">' . __('Select One', JCF_TEXTDOMAIN) . '</option>';
foreach ((array) $values as $key => $val) {
echo '<option value="' . esc_attr($val) . '" ' . selected($val, $this->entry, false) . '>' . esc_html(ucfirst($key)) . '</option>' . "\n";
}
echo '</select>' . "\n";
echo '</div>';
if ($this->instance['description'] != '') {
echo '<p class="description">' . $this->instance['description'] . '</p>';
}
echo $after_widget;
}
示例11: sosimple_text_color_mb_field
/**
* Text Color
*/
function sosimple_text_color_mb_field($post_id)
{
$field_name = 'text_color';
$value = get_post_meta($post_id, $field_name, true);
?>
<p>
<label for="<?php
echo esc_attr($field_name);
?>
"><strong><?php
_e('Text Color', 'sosimple');
?>
</strong></label><br />
<select name="<?php
echo esc_attr($field_name);
?>
" id="<?php
echo esc_attr($field_name);
?>
" class="widefat">
<?php
$options = array('text-dark' => __('Dark Text', 'sosimple'), 'text-light' => __('Light Text', 'sosimple'));
foreach ($options as $option => $label) {
printf('<option value="%1$s" %3$s>%2$s</option>', esc_attr($option), esc_html($label), selected($value, $option, false));
}
?>
</select>
</p>
<?php
}
示例12: wcasv_condition_operator
/**
* Operator drop down.
*
* Display a list of operators.
*
* @since 1.0.0
*
* @param mixed $id ID of the current condition.
* @param mixed $group Group the (condition) operator belongs to.
* @param string $current_value Current operator value.
*/
function wcasv_condition_operator($id, $group = 0, $current_value = '==')
{
$operators = array('==' => __('Equal to', 'woocommerce-advanced-shipping-validation'), '!=' => __('Not equal to', 'woocommerce-advanced-shipping-validation'), '>=' => __('Greater or equal to', 'woocommerce-advanced-shipping-validation'), '<=' => __('Less or equal to ', 'woocommerce-advanced-shipping-validation'));
$operators = apply_filters('woocommerce_Advanced_Shipping_Validation_operators', $operators);
?>
<span class='wcasv-operator-wrap wcasv-operator-wrap-<?php
echo absint($id);
?>
'>
<select class='wcasv-operator' name='conditions[<?php
echo absint($group);
?>
][<?php
echo absint($id);
?>
][operator]'><?php
foreach ($operators as $key => $value) {
?>
<option value='<?php
echo esc_attr($key);
?>
' <?php
selected($key, $current_value);
?>
><?php
echo esc_html($value);
?>
</option><?php
}
?>
</select>
</span><?php
}
开发者ID:gelther,项目名称:advanced-shipping-validation-for-woocommerce,代码行数:46,代码来源:condition-operators.php
示例13: wc_display_yotpo_settings
function wc_display_yotpo_settings($success_type = false)
{
$yotpo_settings = get_option('yotpo_settings', wc_yotpo_get_degault_settings());
$app_key = $yotpo_settings['app_key'];
$secret = $yotpo_settings['secret'];
$language_code = $yotpo_settings['language_code'];
$widget_tab_name = $yotpo_settings['widget_tab_name'];
if (empty($yotpo_settings['app_key'])) {
if ($success_type == 'b2c') {
wc_yotpo_display_message('We have sent you a confirmation email. Please check and click on the link to get your app key and secret token to fill out below.', true);
} else {
wc_yotpo_display_message('Set your API key in order the Yotpo plugin to work correctly', false);
}
}
$google_tracking_params = '&utm_source=yotpo_plugin_woocommerce&utm_medium=header_link&utm_campaign=woocommerce_customize_link';
if (!empty($yotpo_settings['app_key']) && !empty($yotpo_settings['secret'])) {
$dashboard_link = '<a href="https://api.yotpo.com/users/b2blogin?app_key=' . $yotpo_settings['app_key'] . '&secret=' . $yotpo_settings['secret'] . $google_tracking_params . '" target="_blank">Yotpo Dashboard.</a></div>';
} else {
$dashboard_link = "<a href='https://www.yotpo.com/?login=true{$google_tracking_params}' target='_blank'>Yotpo Dashboard.</a></div>";
}
$read_only = isset($_POST['log_in_button']) || $success_type == 'b2c' ? '' : 'readonly';
$cradentials_location_explanation = isset($_POST['log_in_button']) ? "<tr valign='top'> \t\n\t\t \t\t\t\t\t\t\t\t\t\t\t\t\t\t<th scope='row'><p class='description'>To get your api key and secret token <a href='https://www.yotpo.com/?login=true' target='_blank'>log in here</a> and go to your account settings.</p></th>\n\t \t\t \t\t\t\t\t\t\t </tr>" : '';
$submit_past_orders_button = $yotpo_settings['show_submit_past_orders'] ? "<input type='submit' name='yotpo_past_orders' value='Submit past orders' class='button-secondary past-orders-btn' " . disabled(true, empty($app_key) || empty($secret), false) . ">" : '';
$settings_html = "<div class='wrap'>" . screen_icon() . "<h2>Yotpo Settings</h2>\t\t\t\t\t\t \n\t\t\t <h4>To customize the look and feel of the widget, and to edit your Mail After Purchase settings, just head to the " . $dashboard_link . "</h4>\n\t\t\t <form method='post' id='yotpo_settings_form'>\n\t\t\t \t<table class='form-table'>" . wp_nonce_field('yotpo_settings_form') . "<fieldset>\n\t <tr valign='top'>\n\t \t<th scope='row'><div>If you would like to choose a set language, please type the 2-letter language code here. You can find the supported langauge codes <a class='y-href' href='http://support.yotpo.com/entries/21861473-Languages-Customization-' target='_blank'>here.</a></div></th>\n\t \t<td><div><input type='text' class='yotpo_language_code_text' name='yotpo_widget_language_code' maxlength='5' value='{$language_code}'/></div></td>\n\t </tr>\n\t\t\t \t <tr valign='top'> \t\n\t\t \t<th scope='row'><div>For multiple-language sites, mark this check box. This will choose the language according to the user's site language.</div></th>\n\t \t<td><input type='checkbox' name='yotpo_language_as_site' value='1' " . checked(1, $yotpo_settings['yotpo_language_as_site'], false) . "/></td>\t \n\t </tr>\n\t\t\t\t\t <tr valign='top'>\n\t\t \t\t <th scope='row'><div>Disable native reviews system:</div></th>\n\t\t \t\t <td><input type='checkbox' name='disable_native_review_system' value='1' " . checked(1, $yotpo_settings['disable_native_review_system'], false) . " /></td>\n\t\t \t\t </tr>\t \t \n\t \t <tr valign='top'>\t\t\t\n\t\t\t\t <th scope='row'><div>Select widget location</div></th>\n\t\t\t\t <td>\n\t\t\t\t <select name='yotpo_widget_location' class='yotpo-widget-location'>\n\t\t\t\t \t <option value='footer' " . selected('footer', $yotpo_settings['widget_location'], false) . ">Page footer</option>\n\t\t\t \t\t <option value='tab' " . selected('tab', $yotpo_settings['widget_location'], false) . ">Tab</option>\n\t\t\t \t <option value='other' " . selected('other', $yotpo_settings['widget_location'], false) . ">Other</option>\n\t\t\t\t </select>\n\t\t \t\t </td>\n\t\t \t\t </tr>\n\t\t \t\t <tr valign='top' class='yotpo-widget-location-other-explain'>\n \t\t<th scope='row'><p class='description'>In order to locate the widget in a custome location open 'wp-content/plugins/woocommerce/templates/content-single-product.php' and add the following line <code>wc_yotpo_show_widget();</code> in the requested location.</p></th>\t \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t </tr>\n\t\t \t\t <tr valign='top' class='yotpo-widget-tab-name'>\n\t\t \t\t <th scope='row'><div>Select tab name:</div></th>\n\t\t \t\t <td><div><input type='text' name='yotpo_widget_tab_name' value='{$widget_tab_name}' /></div></td>\n\t\t \t\t </tr>\n\t\t \t\t {$cradentials_location_explanation}\n\t\t\t\t\t <tr valign='top'>\n\t\t \t\t <th scope='row'><div>App key:</div></th>\n\t\t \t\t <td><div class='y-input'><input id='app_key' type='text' name='yotpo_app_key' value='{$app_key}' {$read_only} '/></div></td>\n\t\t \t\t </tr>\n\t\t\t\t\t <tr valign='top'>\n\t\t \t\t <th scope='row'><div>Secret token:</div></th>\n\t\t \t\t <td><div class='y-input'><input id='secret' type='text' name='yotpo_oauth_token' value='{$secret}' {$read_only} '/></div></td>\n\t\t \t\t </tr>\t\n\t\t \t\t <tr valign='top'>\n\t\t \t\t <th scope='row'><p class='description'>Yotpo's Bottom Line shows the star rating of the product and the number of reviews for the product. <a href='http://support.yotpo.com/entries/24467793-What-is-the-Yotpo-Bottomline-' target='_blank'>learn more.</a></p></th>\t\t \t\t \n\t\t \t\t </tr>\t\t\t\t \t \n\t\t\t\t\t <tr valign='top'>\n\t\t \t\t <th scope='row'><div>Enable bottom line in product page:</div></th>\n\t\t \t\t <td><input type='checkbox' name='yotpo_bottom_line_enabled_product' value='1' " . checked(1, $yotpo_settings['bottom_line_enabled_product'], false) . " /></td>\n\t\t \t\t </tr>\t\t\t\t\t \t \n\t\t\t\t\t <tr valign='top'>\n\t\t \t\t <th scope='row'><div>Enable bottom line in category page:</div></th>\n\t\t \t\t <td><input type='checkbox' name='yotpo_bottom_line_enabled_category' value='1' " . checked(1, $yotpo_settings['bottom_line_enabled_category'], false) . " />\t\t \t\t \n\t\t \t\t </td>\n\t\t \t\t </tr>\t\t\t\t\t \t \n\t\t </fieldset>\n\t\t </table></br>\t\t\t \t\t\n\t\t <div class='buttons-container'>\n\t\t <button type='button' id='yotpo-export-reviews' class='button-secondary' " . disabled(true, empty($app_key) || empty($secret), false) . ">Export Reviews</button>\n\t\t\t\t<input type='submit' name='yotpo_settings' value='Update' class='button-primary' id='save_yotpo_settings'/>{$submit_past_orders_button}\n\t\t\t </br></br><p class='description'>*Learn <a href='http://support.yotpo.com/entries/24454261-Exporting-reviews-for-Woocommerce' target='_blank'>how to export your existing reviews</a> into Yotpo.</p>\n\t\t\t</div>\n\t\t </form>\n\t\t <iframe name='yotpo_export_reviews_frame' style='display: none;'></iframe>\n\t\t <form action='' method='get' target='yotpo_export_reviews_frame' style='display: none;'>\n\t\t\t<input type='hidden' name='download_exported_reviews' value='true' />\n\t\t\t<input type='submit' value='Export Reviews' class='button-primary' id='export_reviews_submit'/>\n\t\t </form> \n\t\t</div>";
echo $settings_html;
}
示例14: bnfw_render_users_dropdown
/**
* Render users dropdown.
*
* @since 1.3.6
*/
function bnfw_render_users_dropdown($selected_users)
{
global $wp_roles;
?>
<optgroup label="User Roles">
<?php
$roles = $wp_roles->get_names();
foreach ($roles as $role) {
$selected = selected(true, in_array('role-' . $role, $selected_users), false);
echo '<option value="role-', $role, '" ', $selected, '>', $role, '</option>';
}
?>
</optgroup>
<optgroup label="Users">
<?php
$user_count = count_users();
// if there are more than 100 users then use AJAX to load them dynamically.
// So just get only the selected users
if (count($selected_users) > 0 && $user_count['total_users'] > 100) {
$users = get_users(array('include' => $selected_users, 'order_by' => 'email', 'fields' => array('ID', 'user_login')));
} else {
$users = get_users(array('order_by' => 'email', 'number' => 100, 'fields' => array('ID', 'user_login')));
}
foreach ($users as $user) {
$selected = selected(true, in_array($user->ID, $selected_users), false);
echo '<option value="', $user->ID, '" ', $selected, '>', $user->user_login, '</option>';
}
}
示例15: print_media_templates
/**
* Outputs a view template which can be used with wp.media.template
*/
function print_media_templates()
{
$default_gallery_type = apply_filters('jetpack_default_gallery_type', 'default');
?>
<script type="text/html" id="tmpl-jetpack-gallery-settings">
<label class="setting">
<span><?php
_e('Type', 'themepacific_gallery');
?>
</span>
<select class="type" name="type" data-setting="type">
<?php
foreach ($this->gallery_types as $value => $caption) {
?>
<option value="<?php
echo esc_attr($value);
?>
" <?php
selected($value, $default_gallery_type);
?>
><?php
echo esc_html($caption);
?>
</option>
<?php
}
?>
</select>
</label>
</script>
<?php
}