当前位置: 首页>>代码示例>>PHP>>正文


PHP esc_attr函数代码示例

本文整理汇总了PHP中esc_attr函数的典型用法代码示例。如果您正苦于以下问题:PHP esc_attr函数的具体用法?PHP esc_attr怎么用?PHP esc_attr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了esc_attr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: vc_dropdown_form_field

/**
 * Dropdown(select with options) shortcode attribute type generator.
 *
 * @param $settings
 * @param $value
 *
 * @since 4.4
 * @return string - html string.
 */
function vc_dropdown_form_field($settings, $value)
{
    $output = '';
    $css_option = str_replace('#', 'hash-', vc_get_dropdown_option($settings, $value));
    $output .= '<select name="' . $settings['param_name'] . '" class="wpb_vc_param_value wpb-input wpb-select ' . $settings['param_name'] . ' ' . $settings['type'] . ' ' . $css_option . '" data-option="' . $css_option . '">';
    if (is_array($value)) {
        $value = isset($value['value']) ? $value['value'] : array_shift($value);
    }
    if (!empty($settings['value'])) {
        foreach ($settings['value'] as $index => $data) {
            if (is_numeric($index) && (is_string($data) || is_numeric($data))) {
                $option_label = $data;
                $option_value = $data;
            } elseif (is_numeric($index) && is_array($data)) {
                $option_label = isset($data['label']) ? $data['label'] : array_pop($data);
                $option_value = isset($data['value']) ? $data['value'] : array_pop($data);
            } else {
                $option_value = $data;
                $option_label = $index;
            }
            $selected = '';
            $option_value_string = (string) $option_value;
            $value_string = (string) $value;
            if ('' !== $value && $option_value_string === $value_string) {
                $selected = ' selected="selected"';
            }
            $option_class = str_replace('#', 'hash-', $option_value);
            $output .= '<option class="' . esc_attr($option_class) . '" value="' . esc_attr($option_value) . '"' . $selected . '>' . htmlspecialchars($option_label) . '</option>';
        }
    }
    $output .= '</select>';
    return $output;
}
开发者ID:severnrescue,项目名称:web,代码行数:42,代码来源:default_params.php

示例2: start_el

 function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0)
 {
     $indent = $depth ? str_repeat("\t", $depth) : '';
     $classes = empty($item->classes) ? array() : (array) $item->classes;
     $classes[] = 'menu-item-' . $item->ID;
     $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item, $args, $depth));
     /**
      * Change WP's default classes to match Foundation's required classes
      */
     $class_names = str_replace(array('menu-item-has-children'), array('has-submenu'), $class_names);
     // ==========================
     $class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : '';
     $id = apply_filters('nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args, $depth);
     $id = $id ? ' id="' . esc_attr($id) . '"' : '';
     $output .= $indent . '<li' . $id . $class_names . '>';
     $atts = array();
     $atts['title'] = !empty($item->attr_title) ? $item->attr_title : '';
     $atts['target'] = !empty($item->target) ? $item->target : '';
     $atts['rel'] = !empty($item->xfn) ? $item->xfn : '';
     $atts['href'] = !empty($item->url) ? $item->url : '';
     $atts = apply_filters('nav_menu_link_attributes', $atts, $item, $args, $depth);
     $attributes = '';
     foreach ($atts as $attr => $value) {
         if (!empty($value)) {
             $value = 'href' === $attr ? esc_url($value) : esc_attr($value);
             $attributes .= ' ' . $attr . '="' . $value . '"';
         }
     }
     $item_output = $args->before;
     $item_output .= '<a' . $attributes . '>';
     $item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after;
     $item_output .= '</a>';
     $item_output .= $args->after;
     $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
 }
开发者ID:andrewcroce,项目名称:TPL,代码行数:35,代码来源:offcanvas-walker.class.php

示例3: create_field

 function create_field($field)
 {
     // vars
     $o = array('id', 'class', 'name', 'value', 'placeholder');
     $e = '';
     // maxlength
     if ($field['maxlength'] !== "") {
         $o[] = 'maxlength';
     }
     // prepend
     if ($field['prepend'] !== "") {
         $field['class'] .= ' acf-is-prepended';
         $e .= '<div class="acf-input-prepend">' . $field['prepend'] . '</div>';
     }
     // append
     if ($field['append'] !== "") {
         $field['class'] .= ' acf-is-appended';
         $e .= '<div class="acf-input-append">' . $field['append'] . '</div>';
     }
     $e .= '<div class="acf-input-wrap">';
     $e .= '<input type="text"';
     foreach ($o as $k) {
         $e .= ' ' . $k . '="' . esc_attr($field[$k]) . '"';
     }
     $e .= ' />';
     $e .= '</div>';
     // return
     echo $e;
 }
开发者ID:gjaya79,项目名称:urdailynews,代码行数:29,代码来源:text.php

示例4: start_el

 function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0)
 {
     global $wp_query;
     $indent = $depth ? str_repeat("\t", $depth) : '';
     $class_names = $value = '';
     $classes = empty($item->classes) ? array() : (array) $item->classes;
     $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item));
     $class_names = ' class="' . esc_attr($class_names) . '"';
     $output .= $indent . '<li id="shopkeeper-menu-item-' . $item->ID . '"' . $value . $class_names . '>';
     $attributes = !empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) . '"' : '';
     $attributes .= !empty($item->target) ? ' target="' . esc_attr($item->target) . '"' : '';
     $attributes .= !empty($item->xfn) ? ' rel="' . esc_attr($item->xfn) . '"' : '';
     $attributes .= !empty($item->url) ? ' href="' . esc_attr($item->url) . '"' : '';
     $prepend = '';
     $append = '';
     //$description  = ! empty( $item->description ) ? '<span>'.esc_attr( $item->description ).'</span>' : '';
     if ($depth != 0) {
         $description = $append = $prepend = "";
     }
     $item_output = $args->before;
     $item_output .= '<a' . $attributes . '>';
     $item_output .= $args->link_before . $prepend . apply_filters('the_title', $item->title, $item->ID) . $append;
     //$item_output .= $description.$args->link_after;
     //$item_output .= ' '.$item->background_url.'</a>';
     $item_output .= '</a>';
     $item_output .= $args->after;
     $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
     apply_filters('walker_nav_menu_start_lvl', $item_output, $depth, $args->background_url = $item->background_url);
 }
开发者ID:hamaianhnhi,项目名称:shopkeeper148,代码行数:29,代码来源:custom_walker.php

示例5: submenu_items

 /**
  * Add Menu Cart to menu
  * 
  * @return menu items including cart
  */
 public function submenu_items()
 {
     $get_cart = jigoshop_cart::get_cart();
     $submenu_items = '';
     //see jigoshop/widgets/cart.php
     if (count($get_cart) > 0) {
         foreach ($get_cart as $cart_item_key => $values) {
             $_product = $values['data'];
             if ($_product->exists() && $values['quantity'] > 0) {
                 $item_thumbnail = has_post_thumbnail($_product->id) ? get_the_post_thumbnail($_product->id, 'shop_tiny') : jigoshop_get_image_placeholder('shop_tiny');
                 $item_name = $_product->get_title();
                 // Not used: Displays variations and cart item meta
                 $item_meta = jigoshop_cart::get_item_data($values);
                 $item_quantity = esc_attr($values['quantity']);
                 $item_price = $_product->get_price_html();
                 // Item permalink
                 $item_permalink = esc_attr(get_permalink($_product->id));
                 $submenu_items[] = array('item_thumbnail' => $item_thumbnail, 'item_name' => $item_name, 'item_quantity' => $item_quantity, 'item_price' => $item_price, 'item_permalink' => $item_permalink);
             }
         }
     } else {
         $submenu_items = '';
     }
     return $submenu_items;
 }
开发者ID:Atlas-Solutions-Group,项目名称:wp-menu-cart-pro,代码行数:30,代码来源:wpmenucart-jigoshop-pro.php

示例6: form_count

    /**
     * Output the Admin-Form for the active rule.
     *
     * @since  4.6
     * @param  mixed $data Rule-data which was saved via the save_() handler.
     */
    protected function form_count($data)
    {
        $count = absint($data);
        if ($count < 1) {
            $count = 1;
        }
        ?>
		<label for="po-max-count">
			<?php 
        _e('Display PopUp this often:', PO_LANG);
        ?>
		</label>
		<input type="number"
			id="po-max-count"
			class="inp-small"
			name="po_rule_data[count]"
			min="1"
			max="999"
			maxlength="3"
			placeholder="10"
			value="<?php 
        echo esc_attr(absint($count));
        ?>
" />
		<?php 
    }
开发者ID:nullality,项目名称:FEWD-SEA-7,代码行数:32,代码来源:class-popup-rule-popup.php

示例7: square_posted_on

 /**
  * Prints HTML with meta information for the current post-date/time and author.
  */
 function square_posted_on()
 {
     $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
     if (get_the_time('U') !== get_the_modified_time('U')) {
         $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
     }
     $time_string = sprintf($time_string, esc_attr(get_the_date('c')), esc_html(get_the_date()), esc_attr(get_the_modified_date('c')), esc_html(get_the_modified_date()));
     $posted_on = sprintf(esc_html_x('%s', 'post date', 'square'), '<a href="' . esc_url(get_permalink()) . '" rel="bookmark">' . $time_string . '</a>');
     $byline = sprintf(esc_html_x('by %s', 'post author', 'square'), '<span class="author vcard"><a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '">' . esc_html(get_the_author()) . '</a></span>');
     $comment_count = get_comments_number();
     // get_comments_number returns only a numeric value
     if (comments_open()) {
         if ($comment_count == 0) {
             $comments = __('No Comments', 'square');
         } elseif ($comment_count > 1) {
             $comments = $comment_count . __(' Comments', 'square');
         } else {
             $comments = __('1 Comment', 'square');
         }
         $comment_link = '<a href="' . get_comments_link() . '">' . $comments . '</a>';
     } else {
         $comment_link = __(' Comment Closed', 'square');
     }
     echo '<span class="posted-on"><i class="fa fa-clock-o"></i>' . $posted_on . '</span><span class="byline"> ' . $byline . '</span><span class="comment-count"><i class="fa fa-comments-o"></i>' . $comment_link . "</span>";
     // WPCS: XSS OK.
 }
开发者ID:jgcopple,项目名称:drgaryschwantz,代码行数:29,代码来源:template-tags.php

示例8: xfac_get_avatar

function xfac_get_avatar($avatar = '', $id_or_email, $size = 96, $default = '', $alt = '')
{
    if (is_numeric($id_or_email)) {
        $wpUserId = (int) $id_or_email;
    } elseif (is_string($id_or_email) && ($user = get_user_by('email', $id_or_email))) {
        $wpUserId = $user->ID;
    } elseif (is_object($id_or_email) && !empty($id_or_email->user_id)) {
        $wpUserId = (int) $id_or_email->user_id;
    }
    if (empty($wpUserId)) {
        // cannot figure out the user id...
        return $avatar;
    }
    $apiRecords = xfac_user_getRecordsByUserId($wpUserId);
    if (empty($apiRecords)) {
        // no api records
        return $avatar;
    }
    $apiRecord = reset($apiRecords);
    if (empty($apiRecord->profile['links']['avatar'])) {
        // no avatar?
        return $avatar;
    }
    $avatar = $apiRecord->profile['links']['avatar'];
    $size = (int) $size;
    if (empty($alt)) {
        $alt = get_the_author_meta('display_name', $wpUserId);
    }
    $author_class = is_author($wpUserId) ? ' current-author' : '';
    $avatar = "<img alt='" . esc_attr($alt) . "' src='" . esc_url($avatar) . "' class='avatar avatar-{$size}{$author_class} photo' height='{$size}' width='{$size}' />";
    return $avatar;
}
开发者ID:billyprice1,项目名称:bdApi,代码行数:32,代码来源:avatar.php

示例9: siteorigin_widget_get_icon

/**
 * @param $icon_value
 * @param bool $icon_styles
 *
 * @return bool|string
 */
function siteorigin_widget_get_icon($icon_value, $icon_styles = false)
{
    if (empty($icon_value)) {
        return false;
    }
    list($family, $icon) = explode('-', $icon_value, 2);
    if (empty($family) || empty($icon)) {
        return false;
    }
    static $widget_icon_families;
    static $widget_icons_enqueued = array();
    if (empty($widget_icon_families)) {
        $widget_icon_families = apply_filters('siteorigin_widgets_icon_families', array());
    }
    if (empty($widget_icon_families[$family]) || empty($widget_icon_families[$family]['icons'][$icon])) {
        return false;
    }
    if (empty($widget_icons_enqueued[$family]) && !empty($widget_icon_families[$family]['style_uri'])) {
        if (!wp_style_is('siteorigin-widget-icon-font-' . $family)) {
            wp_enqueue_style('siteorigin-widget-icon-font-' . $family, $widget_icon_families[$family]['style_uri']);
        }
        return '<span class="sow-icon-' . esc_attr($family) . '" data-sow-icon="' . $widget_icon_families[$family]['icons'][$icon] . '" ' . (!empty($icon_styles) ? 'style="' . implode('; ', $icon_styles) . '"' : '') . '></span>';
    } else {
        return false;
    }
}
开发者ID:spielhoelle,项目名称:amnesty,代码行数:32,代码来源:base.php

示例10: render_content

    /**
     * Renders the control's content.
     *
     * @since 3.9.0
     * @access public
     */
    public function render_content()
    {
        $id = 'reorder-widgets-desc-' . str_replace(array('[', ']'), array('-', ''), $this->id);
        ?>
		<button type="button" class="button-secondary add-new-widget" aria-expanded="false" aria-controls="available-widgets">
			<?php 
        _e('Add a Widget');
        ?>
		</button>
		<button type="button" class="button-link reorder-toggle" aria-label="<?php 
        esc_attr_e('Reorder widgets');
        ?>
" aria-describedby="<?php 
        echo esc_attr($id);
        ?>
">
			<span class="reorder"><?php 
        _ex('Reorder', 'Reorder widgets in Customizer');
        ?>
</span>
			<span class="reorder-done"><?php 
        _ex('Done', 'Cancel reordering widgets in Customizer');
        ?>
</span>
		</button>
		<p class="screen-reader-text" id="<?php 
        echo esc_attr($id);
        ?>
"><?php 
        _e('When in reorder mode, additional controls to reorder widgets will be available in the widgets list above.');
        ?>
</p>
		<?php 
    }
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:40,代码来源:class-wp-widget-area-customize-control.php

示例11: jigoshop_product_tag

function jigoshop_product_tag($attributes)
{
    global $paged;
    $jigoshop_options = Jigoshop_Base::get_options();
    $attributes = shortcode_atts(array('tag' => '', 'per_page' => $jigoshop_options->get('jigoshop_catalog_per_page'), 'columns' => $jigoshop_options->get('jigoshop_catalog_columns'), 'orderby' => $jigoshop_options->get('jigoshop_catalog_sort_orderby'), 'order' => $jigoshop_options->get('jigoshop_catalog_sort_direction'), 'pagination' => false, 'tax_operator' => 'IN'), $attributes);
    if (isset($_REQUEST['tag'])) {
        $attributes['tag'] = $_REQUEST['tag'];
    }
    /** Operator validation. */
    if (!in_array($attributes['tax_operator'], array('IN', 'NOT IN', 'AND'))) {
        $tax_operator = 'IN';
    }
    /** Multiple category values. */
    if (!empty($slug)) {
        $slug = explode(',', esc_attr($slug));
        $slug = array_map('trim', $slug);
    }
    $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $attributes['per_page'], 'orderby' => $attributes['orderby'], 'order' => $attributes['order'], 'paged' => $paged, 'meta_query' => array(array('key' => 'visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')), 'tax_query' => array(array('taxonomy' => 'product_tag', 'field' => 'slug', 'terms' => $attributes['tag'], 'operator' => $attributes['tax_operator'])));
    query_posts($args);
    ob_start();
    jigoshop_get_template_part('loop', 'shop');
    if ($attributes['pagination']) {
        do_action('jigoshop_pagination');
    }
    wp_reset_query();
    return ob_get_clean();
}
开发者ID:ashik968,项目名称:digiplot,代码行数:27,代码来源:product_tag.php

示例12: render_content

    /**
     * Display the font control.
     *
     * @since 1.0.0
     */
    function render_content()
    {
        $v = $this->value();
        $values = json_decode($v);
        wp_enqueue_script('json2');
        $font_options = isset($this->font_options) ? $this->font_options : array();
        ?>

		<?php 
        if ($this->show_label && !empty($this->label)) {
            ?>
			<span class="customize-control-title themify-control-title"><?php 
            echo esc_html($this->label);
            ?>
</span>
		<?php 
        }
        ?>

		<?php 
        $this->render_fonts($values, $font_options);
        ?>

		<input <?php 
        $this->link();
        ?>
 value='<?php 
        echo esc_attr($v);
        ?>
' type="hidden" class="<?php 
        echo esc_attr($this->type);
        ?>
_control themify-customizer-value-field"/>
	<?php 
    }
开发者ID:tchataigner,项目名称:palette,代码行数:40,代码来源:class-fonts-control.php

示例13: render

 /**
  * Render the shortcode
  * @param  array $args     Shortcode paramters
  * @param  string $content Content between shortcode
  * @return string          HTML output
  */
 function render($args, $content = '')
 {
     $defaults = Magee_Core::set_shortcode_defaults(array('url' => '', 'number' => 3, 'class' => '', 'id' => ''), $args);
     extract($defaults);
     self::$args = $defaults;
     $html = '';
     //$html = '<h2>'._e( 'Recent news from Some-Other Blog:', 'my-text-domain' ).'<h2>';
     if ($url !== '') {
         include_once ABSPATH . WPINC . '/feed.php';
         $rss = fetch_feed(esc_url($url));
         $maxitems = 0;
         if (!is_wp_error($rss)) {
             $maxitems = $rss->get_item_quantity(esc_attr($number));
             $rss_items = $rss->get_items(0, $maxitems);
         }
         $html = '<ul class="' . esc_attr($class) . '" id="' . esc_attr($id) . '">';
         if ($maxitems == 0) {
             $html .= '<li>' . _e('No items', 'magee-shortcodes') . '</li>';
         } else {
             foreach ($rss_items as $item) {
                 $html .= '<li>';
                 $html .= '<a target="_blank" href="' . esc_url($item->get_permalink()) . '" ';
                 $html .= 'title="' . __('Posted ' . $item->get_date('j F Y | g:i a'), 'magee-shortcodes') . '">';
                 $html .= $item->get_title();
                 $html .= '</a>';
                 $html .= '</li>';
             }
         }
         $html .= '</ul>';
     }
     return $html;
 }
开发者ID:JasonAJames,项目名称:jasonajamescom,代码行数:38,代码来源:class-rss-feed.php

示例14: html

        /**
         * Get field HTML
         *
         * @param mixed $meta
         * @param array $field
         *
         * @return string
         */
        static function html($meta, $field)
        {
            if (!is_array($meta)) {
                $meta = array($meta);
            }
            $options = array();
            foreach ($field['options'] as $value => $label) {
                $options[] = array('value' => $value, 'label' => $label);
            }
            // Input field that triggers autocomplete.
            // This field doesn't store field values, so it doesn't have "name" attribute.
            // The value(s) of the field is store in hidden input(s). See below.
            $html = sprintf('<input type="text" class="rwmb-autocomplete" id="%s" data-name="%s" data-options="%s" size="%s">', $field['id'], $field['field_name'], esc_attr(json_encode($options)), $field['size']);
            $html .= '<div class="rwmb-autocomplete-results">';
            // Each value is displayed with label and 'Delete' option
            // The hidden input has to have ".rwmb-*" class to make clone work
            $tpl = '
				<div class="rwmb-autocomplete-result">
					<div class="label">%s</div>
					<div class="actions">%s</div>
					<input type="hidden" class="rwmb-autocomplete-value" name="%s" value="%s">
				</div>
			';
            foreach ($field['options'] as $value => $label) {
                if (in_array($value, $meta)) {
                    $html .= sprintf($tpl, $label, __('Delete', 'meta-box'), $field['field_name'], $value);
                }
            }
            $html .= '</div>';
            // .rwmb-autocomplete-results
            return $html;
        }
开发者ID:zruiz,项目名称:NG,代码行数:40,代码来源:autocomplete.php

示例15: cg_woocommerce_size_guide

    function cg_woocommerce_size_guide()
    {
        global $cg_options;
        $protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https:" : "http:";
        $size_guide_title = '';
        if (isset($cg_options['product_size_guide_title'])) {
            $size_guide_title = $cg_options['product_size_guide_title'];
        }
        ?>

        <?php 
        if ($size_guide_title) {
            $cg_options['product_size_guide']['url'] = $protocol . str_replace(array('http:', 'https:'), '', $cg_options['product_size_guide']['url']);
            ?>
            <div class="cg-size-guide-wrap">
                <div class="icon cg-icon-cloth-hanger"></div>
                <div class="cg-size-guide">
                    <a href="<?php 
            echo esc_url($cg_options['product_size_guide']['url']);
            ?>
">
            <?php 
            echo esc_attr($size_guide_title);
            ?>
                    </a>
                </div>
            </div>


        <?php 
        }
    }
开发者ID:renatodex,项目名称:submundo-blogstore,代码行数:32,代码来源:woocommerce-config.php


注:本文中的esc_attr函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。