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


PHP esc_url函数代码示例

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


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

示例1: 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

示例2: cherry_plugin_settings

 function cherry_plugin_settings()
 {
     global $wpdb;
     if (!function_exists('get_plugin_data')) {
         require_once ABSPATH . 'wp-admin/includes/plugin.php';
     }
     $upload_dir = wp_upload_dir();
     $plugin_data = get_plugin_data(plugin_dir_path(__FILE__) . 'cherry-plugin.php');
     //Cherry plugin constant variables
     define('CHERRY_PLUGIN_DIR', plugin_dir_path(__FILE__));
     define('CHERRY_PLUGIN_URL', plugin_dir_url(__FILE__));
     define('CHERRY_PLUGIN_DOMAIN', $plugin_data['TextDomain']);
     define('CHERRY_PLUGIN_DOMAIN_DIR', $plugin_data['DomainPath']);
     define('CHERRY_PLUGIN_VERSION', $plugin_data['Version']);
     define('CHERRY_PLUGIN_NAME', $plugin_data['Name']);
     define('CHERRY_PLUGIN_SLUG', plugin_basename(__FILE__));
     define('CHERRY_PLUGIN_DB', $wpdb->prefix . CHERRY_PLUGIN_DOMAIN);
     define('CHERRY_PLUGIN_REMOTE_SERVER', esc_url('http://tmbhtest.com/cherryframework.com/components_update/'));
     //Other constant variables
     define('CURRENT_THEME_DIR', get_stylesheet_directory());
     define('CURRENT_THEME_URI', get_stylesheet_directory_uri());
     define('UPLOAD_BASE_DIR', str_replace("\\", "/", $upload_dir['basedir']));
     define('UPLOAD_DIR', str_replace("\\", "/", $upload_dir['path'] . '/'));
     // if ( !defined('API_URL') ) {
     // 	define( 'API_URL', esc_url( 'http://updates.cherry.template-help.com/cherrymoto/v3/api/' ) );
     // }
     load_plugin_textdomain(CHERRY_PLUGIN_DOMAIN, false, dirname(plugin_basename(__FILE__)) . '/' . CHERRY_PLUGIN_DOMAIN_DIR);
     do_action('cherry_plugin_settings');
 }
开发者ID:drupalninja,项目名称:schome_org,代码行数:29,代码来源:cherry-plugin.php

示例3: 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

示例4: 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

示例5: widget

 /**
  * Displays the widget contents.
  */
 public function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     echo $args['before_widget'];
     if (!empty($title)) {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     $photos = $this->get_photos(array('username' => $instance['username'], 'count' => $instance['count'], 'tags' => $instance['tags']));
     if (is_wp_error($photos)) {
         echo $photos->get_error_message();
     } else {
         echo '<ul>';
         foreach ($photos as $photo) {
             $link = esc_url($photo->link);
             $src = esc_url($photo->media->m);
             $title = esc_attr($photo->title);
             $item = sprintf('<a href="%s"><img src="%s" alt="%s" /></a>', $link, $src, $title);
             $item = sprintf('<li>%s</li>', $item);
             echo $item;
         }
         echo '</ul>';
     }
     echo $args['after_widget'];
 }
开发者ID:SIB-Colombia,项目名称:biodiversidad_wp,代码行数:28,代码来源:flickr-widget.php

示例6: gdlr_print_hotel_availability_item

 function gdlr_print_hotel_availability_item($settings = array())
 {
     $item_id = empty($settings['page-item-id']) ? '' : ' id="' . $settings['page-item-id'] . '" ';
     global $gdlr_spaces, $hotel_option;
     $margin = !empty($settings['margin-bottom']) && $settings['margin-bottom'] != $gdlr_spaces['bottom-blog-item'] ? 'margin-bottom: ' . $settings['margin-bottom'] . ';' : '';
     $margin_style = !empty($margin) ? ' style="' . $margin . '" ' : '';
     $current_date = current_time('Y-m-d');
     $next_date = date('Y-m-d', strtotime($current_date . "+1 days"));
     $value = array('gdlr-check-in' => $current_date, 'gdlr-night' => 1, 'gdlr-check-out' => $next_date, 'gdlr-room-number' => 1, 'gdlr-adult-number' => 1, 'gdlr-children-number' => 0);
     $ret = gdlr_get_item_title($settings);
     $ret .= '<div class="gdlr-hotel-availability-wrapper';
     if (!empty($hotel_option['enable-hotel-branch']) && $hotel_option['enable-hotel-branch'] == 'enable') {
         $ret .= ' gdlr-hotel-branches-enable';
     }
     $ret .= '" ' . $margin_style . $item_id . ' >';
     $ret .= '<form class="gdlr-hotel-availability gdlr-item" id="gdlr-hotel-availability" method="post" action="' . esc_url(add_query_arg(array($hotel_option['booking-slug'] => ''), home_url('/'))) . '" >';
     if (!empty($hotel_option['enable-hotel-branch']) && $hotel_option['enable-hotel-branch'] == 'enable') {
         $ret .= gdlr_get_reservation_branch_combobox(array('title' => __('Hotel Branches', 'gdlr-hotel'), 'slug' => 'gdlr-hotel-branches', 'id' => 'gdlr-hotel-branches', 'value' => ''));
     }
     $ret .= gdlr_get_reservation_datepicker(array('title' => __('Check In', 'gdlr-hotel'), 'slug' => 'gdlr-check-in', 'id' => 'gdlr-check-in', 'value' => $value['gdlr-check-in']));
     $ret .= gdlr_get_reservation_combobox(array('title' => __('Night', 'gdlr-hotel'), 'slug' => 'gdlr-night', 'id' => 'gdlr-night', 'value' => $value['gdlr-night']));
     $ret .= gdlr_get_reservation_datepicker(array('title' => __('Check Out', 'gdlr-hotel'), 'slug' => 'gdlr-check-out', 'id' => 'gdlr-check-out', 'value' => $value['gdlr-check-out']));
     $ret .= gdlr_get_reservation_combobox(array('title' => __('Adults', 'gdlr-hotel'), 'slug' => 'gdlr-adult-number', 'id' => '', 'value' => $value['gdlr-adult-number'], 'multiple' => true));
     $ret .= gdlr_get_reservation_combobox(array('title' => __('Children', 'gdlr-hotel'), 'slug' => 'gdlr-children-number', 'id' => '', 'value' => $value['gdlr-children-number'], 'multiple' => true));
     $ret .= '<div class="gdlr-hotel-availability-submit" >';
     $ret .= '<input type="hidden" name="hotel_data" value="1" >';
     $ret .= '<input type="hidden" name="gdlr-room-number" value="1" />';
     $ret .= '<input type="submit" class="gdlr-reservation-bar-button gdlr-button with-border" value="' . __('Check Availability', 'gdlr-hotel') . '" >';
     $ret .= '</div>';
     $ret .= '<div class="clear"></div>';
     $ret .= '</form>';
     $ret .= '</div>';
     return $ret;
 }
开发者ID:konstantin-pr,项目名称:ses215,代码行数:34,代码来源:page-builder-sync.php

示例7: aaron_highlights

function aaron_highlights()
{
    /* 
    * Frontpage Highlights
    */
    if (get_theme_mod('aaron_hide_highlight') == "") {
        for ($i = 1; $i < 10; $i++) {
            if (get_theme_mod('aaron_highlight' . $i . '_headline') or get_theme_mod('aaron_highlight' . $i . '_text') or get_theme_mod('aaron_highlight' . $i . '_icon') and get_theme_mod('aaron_highlight' . $i . '_icon') != "no-icon" or get_theme_mod('aaron_highlight' . $i . '_image')) {
                echo '<div class="highlights" style="background:' . get_theme_mod('aaron_highlight' . $i . '_bgcolor', '#fafafa') . ';">';
                if (get_theme_mod('aaron_highlight' . $i . '_icon') != "" and get_theme_mod('aaron_highlight' . $i . '_icon') != "no-icon" and get_theme_mod('aaron_highlight' . $i . '_image') == "") {
                    echo '<i aria-hidden="true" class="dashicons ' . esc_attr(get_theme_mod('aaron_highlight' . $i . '_icon')) . '"  style="color:' . get_theme_mod('aaron_highlight' . $i . '_textcolor', '#333333') . ';"></i>';
                }
                if (get_theme_mod('aaron_highlight' . $i . '_image') != "") {
                    echo '<img src="' . esc_url(get_theme_mod('aaron_highlight' . $i . '_image')) . '">';
                }
                if (get_theme_mod('aaron_highlight' . $i . '_link') != "") {
                    echo '<a href="' . esc_url(get_theme_mod('aaron_highlight' . $i . '_link')) . '">';
                }
                if (get_theme_mod('aaron_highlight' . $i . '_headline') != "") {
                    echo '<h2 style="color:' . get_theme_mod('aaron_highlight' . $i . '_textcolor', '#333333') . ';">' . esc_html(get_theme_mod('aaron_highlight' . $i . '_headline')) . '</h2>';
                }
                if (get_theme_mod('aaron_highlight' . $i . '_text') != "") {
                    echo '<p style="color:' . get_theme_mod('aaron_highlight' . $i . '_textcolor', '#333333') . ';">' . esc_html(get_theme_mod('aaron_highlight' . $i . '_text')) . '</p>';
                }
                if (get_theme_mod('aaron_highlight' . $i . '_link') != "") {
                    echo '</a>';
                }
                echo '</div>';
            }
        }
    }
}
开发者ID:samfu1994,项目名称:personalWeb,代码行数:32,代码来源:highlights.php

示例8: hybrid_excerpt_more

/**
 * Filters the excerpt more output with internationalized text and a link to the post.
 *
 * @since  2.0.0
 * @access public
 * @param  string  $text
 * @return string
 */
function hybrid_excerpt_more($text)
{
    if (0 !== strpos($text, '<a')) {
        $text = sprintf(' <a href="%s" class="more-link">%s</a>', esc_url(get_permalink()), trim($text));
    }
    return $text;
}
开发者ID:KL-Kim,项目名称:my-theme,代码行数:15,代码来源:functions-filters.php

示例9: latex_render

function latex_render($latex, $fg, $bg, $s = 0)
{
    $url = "//s0.wp.com/latex.php?latex=" . urlencode($latex) . "&bg=" . $bg . "&fg=" . $fg . "&s=" . $s;
    $url = esc_url($url);
    $alt = str_replace('\\', '&#92;', esc_attr($latex));
    return '<img src="' . $url . '" alt="' . $alt . '" title="' . $alt . '" class="latex" />';
}
开发者ID:briancompton,项目名称:knightsplaza,代码行数:7,代码来源:latex.php

示例10: widget

    function widget($args, $instance)
    {
        extract($args);
        $title = empty($instance['title']) ? '' : strip_tags($instance['title']);
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        if (dt_theme_option('general', 'show-sociables')) {
            ?>
					<ul class="dt-sc-social-icons"><?php 
            $socials = dt_theme_option('social');
            if ($socials != null) {
                foreach ($socials as $social) {
                    $link = esc_url($social['link']);
                    $icon = esc_attr($social['icon']);
                    echo "<li class='" . substr($icon, 3) . "'>";
                    echo "<a class='fa {$icon}' href='{$link}'></a>";
                    echo "</li>";
                }
            } else {
                echo "<div class='error message'><span class='icon'></span>" . __('Please add social icons in general settings.', 'iamd_text_domain') . "</div>";
            }
            ?>
					</ul><?php 
        } else {
            echo "<div class='error message'><span class='icon'></span>" . __('Please enable social icons in general settings.', 'iamd_text_domain') . "</div>";
        }
        echo $after_widget;
    }
开发者ID:h3rodev,项目名称:sometheme,代码行数:30,代码来源:social_widget.php

示例11: remote_viewing_section

    /**
     * Renders Remote Viewing portion of Plugin Settings Page
     *
     * @since 1.0
     *
     * @return void
     */
    static function remote_viewing_section()
    {
        $value = get_option('simple_system_status_remote_url');
        $url = home_url() . '/?simple_system_status=' . $value;
        ?>
		<p><?php 
        _e('Users with this URL can view a plain-text version of your System Status.<br />This link can be handy in support forums, as access to this information can be removed after you receive the help you need.<br />Generating a new URL will safely void access to all who have the existing URL.', WC_QD_TXT);
        ?>
</p>
		<p><input type="text" readonly="readonly" class="sss-url sss-url-text" onclick="this.focus();this.select()" value="<?php 
        echo esc_url($url);
        ?>
" title="<?php 
        _e('To copy the System Status, click below then press Ctrl + C (PC) or Cmd + C (Mac).', WC_QD_TXT);
        ?>
" />&nbsp;&nbsp;<a href="<?php 
        echo esc_url($url);
        ?>
" target="_blank" class="sss-tiny sss-url-text-link"><?php 
        _e('test url', WC_QD_TXT);
        ?>
</a></p>
		<p class="submit">
			<input type="submit" onClick="return false;" class="button-secondary" name="generate-new-url" value="<?php 
        _e('Generate New URL', WC_QD_TXT);
        ?>
" />
		</p>
		<?php 
    }
开发者ID:bestmazzo,项目名称:woocomerce-quick-donation,代码行数:37,代码来源:viewer.php

示例12: lp_thumbnail_metabox

function lp_thumbnail_metabox()
{
    global $post;
    $template = get_post_meta($post->ID, 'lp-selected-template', true);
    $template = apply_filters('lp_selected_template', $template);
    $permalink = get_permalink($post->ID);
    $datetime = the_modified_date('YmjH', null, null, false);
    $permalink = $permalink . '?dt=' . $datetime;
    if (in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1'))) {
        if (file_exists(LANDINGPAGES_UPLOADS_PATH . $template . '/thumbnail.png')) {
            $thumbnail = LANDINGPAGES_UPLOADS_URLPATH . $template . '/thumbnail.png';
        } else {
            $thumbnail = LANDINGPAGES_URLPATH . 'templates/' . $template . '/thumbnail.png';
        }
    } else {
        $thumbnail = 'http://s.wordpress.com/mshots/v1/' . urlencode(esc_url($permalink)) . '?w=250';
    }
    $permalink = apply_filters('lp_live_screenshot_url', $permalink);
    ?>
	<div >
		<div class="inside" style='margin-left:-8px;'>
			<table>
				<tr>
					<td>
						<?php 
    echo "<a href='{$permalink}' target='_blank' ><img src='{$thumbnail}' style='width:250px;height:250px;' title='" . __('Preview this theme', 'landing-pages') . " ,  ({$template})'></a>";
    ?>
					</td>
				</tr>
			</table>

		</div>
	</div>
	<?php 
}
开发者ID:m-godefroid76,项目名称:devrestofactory,代码行数:35,代码来源:module.metaboxes.php

示例13: ebor_call_to_action_block_shortcode

/**
 * The Shortcode
 */
function ebor_call_to_action_block_shortcode($atts, $content = null)
{
    extract(shortcode_atts(array('title' => '', 'url' => '', 'button_text' => '', 'target' => '_blank'), $atts));
    $output = '
		<div class="cta-text-basic row">
			<div class="container-fluid">
				<div class="row">
					<div class="col-sm-12">
						<hr>
					</div>
				</div><!--end of row-->
				<div class="row">
					<div class="col-md-9 col-sm-8">
						<h3>' . $title . '</h3>
					</div>
					<div class="col-md-3 col-sm-4 text-right text-left-xs">
						<a href="' . esc_url($url) . '" class="btn" target="' . esc_attr($target) . '">
							<span class="btn__text">
								' . $button_text . '
							</span>
							<i class="ion-arrow-right-c"></i>
						</a>
					</div>
				</div><!--end of row-->
			</div><!--end of container-->
		</div>
	';
    return $output;
}
开发者ID:tommusrhodus,项目名称:Ebor-Framework,代码行数:32,代码来源:vc_cta_block.php

示例14: wen_business_custom_customize_enqueue_scripts

function wen_business_custom_customize_enqueue_scripts()
{
    wp_register_script('wen_business_customizer_button', get_template_directory_uri() . '/assets/js/customizer-button.js', array('customize-controls'), '20130508', true);
    $data = array('updrade_button_text' => __('Upgrade To Pro', 'wen-business'), 'updrade_button_link' => esc_url('http://catchthemes.com/themes/wen-business-pro'));
    wp_localize_script('wen_business_customizer_button', 'WEN_Business_Customizer_Object', $data);
    wp_enqueue_script('wen_business_customizer_button');
}
开发者ID:suskr50,项目名称:sc-profile,代码行数:7,代码来源:customizer.php

示例15: get_archives_link

 /**
  * @internal
  * @param string $url
  * @param string $text
  * @return mixed
  */
 protected function get_archives_link($url, $text)
 {
     $ret = array();
     $ret['text'] = $ret['title'] = $ret['name'] = wptexturize($text);
     $ret['url'] = $ret['link'] = esc_url(TimberURLHelper::prepend_to_url($url, $this->base));
     return $ret;
 }
开发者ID:sdunham,项目名称:sustainable,代码行数:13,代码来源:timber-archives.php


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