本文整理汇总了PHP中sow_esc_url函数的典型用法代码示例。如果您正苦于以下问题:PHP sow_esc_url函数的具体用法?PHP sow_esc_url怎么用?PHP sow_esc_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sow_esc_url函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: video_code
function video_code($videos, $classes = array())
{
if (empty($videos)) {
return;
}
$video_element = '<video class="' . esc_attr(implode(',', $classes)) . '" autoplay loop muted>';
foreach ($videos as $video) {
if (empty($video['file']) && empty($video['url'])) {
continue;
}
if (empty($video['url'])) {
$video_file = wp_get_attachment_url($video['file']);
$video_element .= '<source src="' . sow_esc_url($video_file) . '" type="' . esc_attr($video['format']) . '">';
} else {
$args = '';
if (!empty($video['height'])) {
$args['height'] = $video['height'];
}
echo wp_oembed_get($video['url'], $args);
}
}
if (strpos($video_element, 'source') !== false) {
$video_element .= '</video>';
echo $video_element;
}
}
示例2: sow_carousel_get_next_posts_page
function sow_carousel_get_next_posts_page()
{
if (empty($_REQUEST['_widgets_nonce']) || !wp_verify_nonce($_REQUEST['_widgets_nonce'], 'widgets_action')) {
return;
}
$query = wp_parse_args(siteorigin_widget_post_selector_process_query($_GET['query']), array('post_status' => 'publish', 'posts_per_page' => 10, 'paged' => empty($_GET['paged']) ? 1 : $_GET['paged']));
$posts = new WP_Query($query);
ob_start();
while ($posts->have_posts()) {
$posts->the_post();
?>
<li class="sow-carousel-item">
<div class="sow-carousel-thumbnail">
<?php
if (has_post_thumbnail()) {
$img = wp_get_attachment_image_src(get_post_thumbnail_id(), 'sow-carousel-default');
?>
<a href="<?php
the_permalink();
?>
" style="background-image: url(<?php
echo sow_esc_url($img[0]);
?>
)">
<span class="overlay"></span>
</a>
<?php
} else {
?>
<a href="<?php
the_permalink();
?>
" class="sow-carousel-default-thumbnail"><span class="overlay"></span></a>
<?php
}
?>
</div>
<h3><a href="<?php
the_permalink();
?>
"><?php
the_title();
?>
</a></h3>
</li>
<?php
}
wp_reset_postdata();
$result = array('html' => ob_get_clean());
header('content-type: application/json');
echo json_encode($result);
exit;
}
示例3: render_frame_contents
function render_frame_contents($i, $frame)
{
// Clear out any empty background videos
if (!empty($frame['background_videos']) && is_array($frame['background_videos'])) {
for ($i = 0; $i < count($frame['background_videos']); $i++) {
if (empty($frame['background_videos'][$i]['file']) && empty($frame['background_videos'][$i]['url'])) {
unset($frame['background_videos'][$i]);
}
}
}
if (!empty($frame['foreground_image'])) {
$foreground_image = wp_get_attachment_image_src($frame['foreground_image'], 'full');
?>
<div class="sow-slider-image-container">
<div class="sow-slider-image-wrapper" style="<?php
if (!empty($foreground_image[1])) {
echo 'max-width: ' . intval($foreground_image[1]) . 'px';
}
?>
">
<?php
if (!empty($frame['url'])) {
echo '<a href="' . sow_esc_url($frame['url']) . '">';
}
echo wp_get_attachment_image($frame['foreground_image'], 'full');
if (!empty($frame['url'])) {
echo '</a>';
}
?>
</div>
</div>
<?php
} else {
if (empty($frame['background_videos'])) {
// We need to find another background
if (!empty($frame['url'])) {
echo '<a href="' . sow_esc_url($frame['url']) . '" ' . (!empty($frame['new_window']) ? 'target="_blank"' : '') . '>';
}
// Lets use the background image
echo wp_get_attachment_image($frame['background_image'], 'full');
if (!empty($frame['url'])) {
echo '</a>';
}
}
}
}
示例4: get_template_variables
function get_template_variables($instance, $args)
{
if (empty($instance)) {
return array();
}
$settings = $instance['settings'];
$mrkr_src = wp_get_attachment_image_src($instance['markers']['marker_icon']);
$styles = $this->get_styles($instance);
if ($settings['map_type'] == 'static') {
$src_url = $this->get_static_image_src($instance, $settings['width'], $settings['height'], !empty($styles) ? $styles['styles'] : array());
return array('src_url' => sow_esc_url($src_url));
} else {
$markers = $instance['markers'];
$directions_json = '';
if (!empty($instance['directions']['origin']) && !empty($instance['directions']['destination'])) {
if (empty($instance['directions']['waypoints'])) {
unset($instance['directions']['waypoints']);
}
$directions_json = json_encode(siteorigin_widgets_underscores_to_camel_case($instance['directions']));
}
return array('map_id' => md5($instance['map_center']), 'height' => $settings['height'], 'map_data' => array('address' => $instance['map_center'], 'zoom' => $settings['zoom'], 'scroll-zoom' => $settings['scroll_zoom'], 'draggable' => $settings['draggable'], 'marker-icon' => !empty($mrkr_src) ? $mrkr_src[0] : '', 'markers-draggable' => isset($markers['markers_draggable']) ? $markers['markers_draggable'] : '', 'marker-at-center' => $markers['marker_at_center'], 'marker-positions' => isset($markers['marker_positions']) ? json_encode($markers['marker_positions']) : '', 'map-name' => !empty($styles) ? $styles['map_name'] : '', 'map-styles' => !empty($styles) ? json_encode($styles['styles']) : '', 'directions' => $directions_json, 'api-key' => $instance['api_key_section']['api_key']));
}
}
示例5: wp_kses_post
$styles[] = 'height:auto';
}
if (!empty($instance['featured_full_width'])) {
$styles[] = 'width:100%';
}
$styles[] = 'display:block';
$post_title = wp_kses_post($instance['featured_title']);
$post_link = wp_kses_post($instance['featured_link_text']);
?>
<?php
if (!empty($instance['featured_image'])) {
?>
<div class="featured-block"> <a href="<?php
echo sow_esc_url($instance['featured_url']);
?>
" class="img-thumbnail" <?php
if ($instance['featured_new_window']) {
echo 'target="_blank"';
}
?>
><?php
}
?>
<img <?php
foreach ($attr as $n => $v) {
echo $n . '="' . esc_attr($v) . '" ';
}
?>
class="<?php
示例6: array
<?php
$classes = array('iw-so-button');
if (!empty($instance['styling']['hover'])) {
$classes[] = 'iw-so-button-hover';
}
if (!empty($instance['styling']['click'])) {
$classes[] = 'iw-so-button-click';
}
$button_attributes = array('class' => esc_attr(implode(' ', $classes)));
if (!empty($instance['new_window'])) {
$button_attributes['target'] = '_blank';
}
if (!empty($instance['url'])) {
$button_attributes['href'] = sow_esc_url($instance['url']);
}
if (!empty($instance['attributes']['id'])) {
$button_attributes['id'] = esc_attr($instance['attributes']['id']);
}
if (!empty($instance['attributes']['title'])) {
$button_attributes['title'] = esc_attr($instance['attributes']['title']);
}
if (!empty($instance['attributes']['onclick'])) {
$button_attributes['onclick'] = esc_attr($instance['attributes']['onclick']);
}
$icon_styles = array();
?>
<div class="iw-so-button-base">
<a <?php
foreach ($button_attributes as $name => $val) {
示例7: apply_filters
}
$attr = apply_filters('siteorigin_widgets_image_attr', $attr, $instance, $this);
$classes = array('so-widget-image');
if (!empty($title)) {
$attr['title'] = $title;
}
if (!empty($alt)) {
$attr['alt'] = $alt;
}
?>
<div class="sow-image-container">
<?php
if (!empty($url)) {
?>
<a href="<?php
echo sow_esc_url($url);
?>
" <?php
if ($new_window) {
echo 'target="_blank"';
}
?>
><?php
}
?>
<img <?php
foreach ($attr as $n => $v) {
echo $n . '="' . esc_attr($v) . '" ';
}
?>
class="<?php
示例8: foreach
echo $numberPosts;
?>
" data-items-desktop-small="3" data-items-tablet="2" data-items-mobile="1">
<?php
foreach ($instance['images'] as $i => $image) {
if (!empty($image['icon_image'])) {
$src = wp_get_attachment_image_src($image['icon_image'], $image['icon_size']);
if (!empty($src)) {
$attr = array('src' => $src[0], 'width' => $src[1], 'height' => $src[2]);
}
?>
<li class="item"><?php
if (!empty($image['more_url'])) {
?>
<a href="<?php
echo sow_esc_url($image['more_url']);
?>
" <?php
echo $image['new_window'] ? 'target="_blank"' : '';
?>
><?php
}
?>
<img <?php
foreach ($attr as $n => $v) {
echo $n . '="' . esc_attr($v) . '" ';
}
?>
alt=""><?php
if (!empty($image['more_url'])) {
?>
示例9: foreach
<div class="social-media-button-container">
<?php
foreach ($networks as $network) {
$classes = array();
if (!empty($instance['design']['hover'])) {
$classes[] = 'ow-button-hover';
}
$classes[] = "sow-social-media-button-" . sanitize_html_class($network['name']);
$classes[] = "sow-social-media-button";
$button_attributes = array('class' => esc_attr(implode(' ', $classes)), 'title' => sprintf(__('%s on %s', 'so-widgets-bundle'), get_bloginfo('name'), ucwords(str_replace('-', ' ', $network['name']))));
if (!empty($instance['design']['new_window'])) {
$button_attributes['target'] = '_blank';
}
if (!empty($network['url'])) {
$button_attributes['href'] = sow_esc_url($network['url']);
}
?>
<a <?php
foreach ($button_attributes as $name => $val) {
echo $name . '="' . esc_attr($val) . '" ';
}
?>
>
<span>
<?php
if (!empty($network['is_custom'])) {
echo '<!-- premium-' . $network['name'] . ' -->';
}
?>
<?php
示例10: esc_attr
$button_attributes['onclick'] = esc_attr($instance['attributes']['onclick']);
}
?>
<a <?php
foreach ($button_attributes as $name => $val) {
echo $name . '="' . $val . '" ';
}
?>
>
<span>
<?php
if (!empty($instance['button_icon']['icon'])) {
$attachment = wp_get_attachment_image_src($instance['button_icon']['icon']);
if (!empty($attachment)) {
$icon_styles[] = 'background-image: url(' . sow_esc_url($attachment[0]) . ')';
?>
<div class="sow-icon-image" style="<?php
echo implode('; ', $icon_styles);
?>
"></div><?php
}
} else {
$icon_styles = array();
if (!empty($instance['button_icon']['icon_color'])) {
$icon_styles[] = 'color: ' . $instance['button_icon']['icon_color'];
}
echo siteorigin_widget_get_icon($instance['button_icon']['icon_selected'], $icon_styles);
}
?>
示例11: sow_esc_url
<?php
echo '<div class="lrw-heading">
<' . $instance['heading_type'] . ' class="custom-heading heading-align' . ($instance['url_active'] == 'yes' && !empty($instance['url_settings']['hover']) ? ' has-hover' : '') . '">' . ($instance['url_active'] == 'yes' && $instance['url_settings']['url'] ? '<a class="heading-link" href="' . sow_esc_url($instance['url_settings']['url']) . '" ' . ($instance['url_settings']['new_window'] ? 'target="_blank"' : '') . '>' : '') . wp_kses_post($instance['title']) . ($instance['url_active'] == 'yes' && $instance['url_settings']['url'] ? '</a>' : '') . '</' . $instance['heading_type'] . '>' . '</div>';
示例12: form
/**
* Display the widget form.
*
* @param array $instance
* @return string|void
*/
public function form($instance)
{
$this->enqueue_scripts();
$instance = $this->modify_instance($instance);
$instance = $this->add_defaults($this->form_options(), $instance);
// Filter the instance specifically for the form
$instance = apply_filters('siteorigin_widgets_form_instance_' . $this->id_base, $instance, $this);
$form_id = 'siteorigin_widget_form_' . md5(uniqid(rand(), true));
$class_name = str_replace('_', '-', strtolower(get_class($this)));
if (empty($instance['_sow_form_id'])) {
$instance['_sow_form_id'] = uniqid();
}
?>
<div class="siteorigin-widget-form siteorigin-widget-form-main siteorigin-widget-form-main-<?php
echo esc_attr($class_name);
?>
" id="<?php
echo $form_id;
?>
" data-class="<?php
echo get_class($this);
?>
" style="display: none">
<?php
/* @var $field_factory SiteOrigin_Widget_Field_Factory */
$field_factory = SiteOrigin_Widget_Field_Factory::getInstance();
$fields_javascript_variables = array();
foreach ($this->form_options() as $field_name => $field_options) {
/* @var $field SiteOrigin_Widget_Field_Base */
$field = $field_factory->create_field($field_name, $field_options, $this);
$field->render(isset($instance[$field_name]) ? $instance[$field_name] : null, $instance);
$field_js_vars = $field->get_javascript_variables();
if (!empty($field_js_vars)) {
$fields_javascript_variables[$field_name] = $field_js_vars;
}
$field->enqueue_scripts();
$this->fields[$field_name] = $field;
}
?>
<input type="hidden" name="<?php
echo $this->get_field_name('_sow_form_id');
?>
" value="<?php
echo esc_attr($instance['_sow_form_id']);
?>
" class="siteorigin-widgets-form-id" />
</div>
<div class="siteorigin-widget-form-no-styles">
<p><strong><?php
_e('This widget has scripts and styles that need to be loaded before you can use it. Please save and reload your current page.', 'so-widgets-bundle');
?>
</strong></p>
<p><strong><?php
_e('You will only need to do this once.', 'so-widgets-bundle');
?>
</strong></p>
</div>
<?php
if ($this->widget_options['has_preview'] && !$this->is_customize_preview()) {
?>
<div class="siteorigin-widget-preview" style="display: none">
<a href="#" class="siteorigin-widget-preview-button button-secondary"><?php
_e('Preview', 'so-widgets-bundle');
?>
</a>
</div>
<?php
}
?>
<?php
if (!empty($this->widget_options['help'])) {
?>
<a href="<?php
echo sow_esc_url($this->widget_options['help']);
?>
" class="siteorigin-widget-help-link siteorigin-panels-help-link" target="_blank"><?php
_e('Help', 'so-widgets-bundle');
?>
</a>
<?php
}
?>
<script type="text/javascript">
( function($) {
if(typeof window.sow_field_javascript_variables == 'undefined') window.sow_field_javascript_variables = {};
window.sow_field_javascript_variables["<?php
echo get_class($this);
?>
"] = <?php
echo json_encode($fields_javascript_variables);
?>
//.........这里部分代码省略.........
示例13: render_field
//.........这里部分代码省略.........
?>
</label>
<?php
}
?>
<?php
break;
case 'media':
if (version_compare(get_bloginfo('version'), '3.5', '<')) {
printf(__('You need to <a href="%s">upgrade</a> to WordPress 3.5 to use media fields', 'siteorigin-widgets'), admin_url('update-core.php'));
break;
}
if (!empty($value)) {
if (is_array($value)) {
$src = $value;
} else {
$post = get_post($value);
$src = wp_get_attachment_image_src($value, 'thumbnail');
if (empty($src)) {
$src = wp_get_attachment_image_src($value, 'thumbnail', true);
}
}
} else {
$src = array('', 0, 0);
}
$choose_title = empty($field['choose']) ? __('Choose Media', 'siteorigin-widgets') : $field['choose'];
$update_button = empty($field['update']) ? __('Set Media', 'siteorigin-widgets') : $field['update'];
$library = empty($field['library']) ? 'image' : $field['library'];
?>
<div class="media-field-wrapper">
<div class="current">
<div class="thumbnail-wrapper">
<img src="<?php
echo sow_esc_url($src[0]);
?>
" class="thumbnail" <?php
if (empty($src[0])) {
echo "style='display:none'";
}
?>
/>
</div>
<div class="title"><?php
if (!empty($post)) {
echo esc_attr($post->post_title);
}
?>
</div>
</div>
<a href="#" class="media-upload-button" data-choose="<?php
echo esc_attr($choose_title);
?>
" data-update="<?php
echo esc_attr($update_button);
?>
" data-library="<?php
echo esc_attr($library);
?>
">
<?php
echo esc_html($choose_title);
?>
</a>
</div>
<a href="#" class="media-remove-button <?php
if (empty($value)) {
示例14: wp_get_attachment_image
echo $column_style;
?>
lsow-zero-margin">
<?php
echo wp_get_attachment_image($client['image'], 'full', false, array('class' => 'lsow-image full', 'alt' => $client['name']));
?>
<div class="lsow-client-name">
<?php
if (!empty($client['link'])) {
?>
<a href="<?php
echo sow_esc_url($client['link']);
?>
" title="<?php
echo esc_html($client['name']);
?>
" target="_blank"><?php
echo esc_html($client['name']);
?>
</a>
<?php
} else {
?>
<?php
echo esc_html($client['name']);
示例15: wp_kses_post
}
?>
<?php
echo wp_kses_post($feature['more_text']);
?>
<?php
if (!empty($feature['more_url'])) {
echo '</a>';
}
?>
</p>
<?php
}
?>
</div>
</div>
<?php
}
?>
<?php
$callout_section = $instance['callout_section'];
if ($callout_section['cta_link']) {
$callout_styles = array();
$btn_position = $callout_section['cta_alignment'];
$icon = siteorigin_widget_get_icon($callout_section['cta_icon'], ['font-size: 18px', 'color: #fff']);
$callout_styles[] = "float: {$btn_position}";
printf('<a class="read-more" href="%1$s" style="%3$s">' . $icon . '%2$s</a>', sow_esc_url($callout_section['cta_link']), $callout_section['cta_text'], implode('; ', $callout_styles));
}
?>
</div>