本文整理汇总了PHP中_wp_specialchars函数的典型用法代码示例。如果您正苦于以下问题:PHP _wp_specialchars函数的具体用法?PHP _wp_specialchars怎么用?PHP _wp_specialchars使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_wp_specialchars函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_optionally_escapes_quotes
function test_optionally_escapes_quotes()
{
$source = "\"'hello!'\"";
$this->assertEquals('"'hello!'"', _wp_specialchars($source, 'single'));
$this->assertEquals(""'hello!'"", _wp_specialchars($source, 'double'));
$this->assertEquals('"'hello!'"', _wp_specialchars($source, true));
$this->assertEquals($source, _wp_specialchars($source));
}
示例2: layers_sanitize_js
function layers_sanitize_js($value = FALSE)
{
$safe_text = _wp_specialchars($value, ENT_QUOTES);
$safe_text = preg_replace('/&#(x)?0*(?(1)27|39);?/i', '"', stripslashes($safe_text));
$safe_text = str_replace("\r", '', $safe_text);
$safe_text = str_replace("\n", '\\n', addslashes($safe_text));
return trim($safe_text);
}
示例3: build_csp
public function build_csp()
{
$csp = $this->options['content_security_policy'];
if (!empty($this->options['csp_report_url'])) {
$csp .= "; report-uri ";
$csp .= $this->options['csp_report_url'];
}
$this->csp = _wp_specialchars(wp_check_invalid_utf8($csp), 'double');
if (!$this->options['enforce_csp']) {
$this->csp_type .= '-Report-Only';
}
}
示例4: display
/**
* (non-PHPdoc)
* @see \GTO\Framework\Posts\PostMetabox::display()
*
* @param \Ekko\Core\CoursePost $course
*/
public final function display($course, $metabox)
{
$complete = json_encode($course->complete);
?>
<input type="hidden" name="<?php
echo self::EKKO_COMPLETE;
?>
" value="<?php
echo _wp_specialchars($complete, ENT_QUOTES, 'UTF8', true);
?>
" />
<div class="ekko-bootstrap container-fluid">
<div ng-controller="CourseCompleteController">
<!--
<div class="row-fluid course-nav">
<div class="span12">
<h1 class="pull-left"><?php
esc_html_e('Course Completed', \Ekko\TEXT_DOMAIN);
?>
</h1>
</div>
</div>
-->
<div class="ekko-item">
<div class="navbar ekko-item-yellow">
<div class="navbar-inner">
<div class="container">
<div class="pull-left section-toggle" title="<?php
esc_attr_e('click to toggle', \Ekko\TEXT_DOMAIN);
?>
" ng-click="complete.active = !complete.active">
<span ng-class="{'icon-chevron-right':!complete.active, 'icon-chevron-down':complete.active}"></span>
</div>
<div class="brand"><?php
esc_html_e('Course Complete', \Ekko\TEXT_DOMAIN);
?>
</div>
</div>
</div>
<div collapse="!complete.active" ng-class="{in:icomplete.active}">
<div class="well">
<textarea ck-editor="ckeditor" ng-model="complete.message"></textarea>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
}
示例5: saving
public function saving(&$temp, $post_id, $val, $oval = null)
{
//$val not cleaned
if (is_array($val)) {
if (isset($val['img_url'])) {
if ('' != $val['img_url']) {
$val['img_url'] = _wp_specialchars($val['img_url']);
$val = array($this->ftype => $val);
array_push($temp, update_post_meta($post_id, $this->name, $val));
}
}
}
}
示例6: display
/**
* (non-PHPdoc)
* @see \GTO\Framework\Posts\PostMetabox::display()
*
* @param \Ekko\Core\CoursePost $course
* @param array|null $metabox
*/
public final function display($course, $metabox)
{
$lessons = json_encode($course->lessons);
?>
<input type="hidden" name="<?php
echo self::EKKO_LESSONS;
?>
" value="<?php
echo _wp_specialchars($lessons, ENT_QUOTES, 'UTF8', true);
?>
" />
<div class="ekko-bootstrap container-fluid">
<div ng-controller="CourseController">
<div class="row-fluid course-nav">
<div class="span12">
<h1 class="pull-left"><?php
esc_html_e('Course Content', \Ekko\TEXT_DOMAIN);
?>
</h1>
<div class="pull-right ekko-content-buttons">
<a class="btn btn-ekko" href ng-click="addItem( $ekko.lesson() )"><i class="icon-plus icon-white"></i> <?php
echo esc_html_x('Lesson', 'add lesson button', \Ekko\TEXT_DOMAIN);
?>
</a>
<a class="btn btn-pimp" href ng-click="addItem( $ekko.quiz() )"><i class="icon-plus icon-white"></i> <?php
echo esc_html_x('Quiz', 'add quiz button', \Ekko\TEXT_DOMAIN);
?>
</a>
</div>
</div>
</div>
<div class="course-items" ui-sortable="sortableOpts" ng-model="lessons">
<div ng-repeat="item in lessons" ng-include="'ekko-' + item.type" id="{{item.id}}"></div>
</div>
</div>
</div>
<?php
}
示例7: iphorm_upgrade_4
/**
* Updgrade fixes for versions before DB version 4 (plugin versions before 1.3.3)
*/
function iphorm_upgrade_4()
{
$forms = iphorm_get_all_forms();
foreach ($forms as $form) {
if (isset($form['conditional_recipients'])) {
foreach ($form['conditional_recipients'] as &$recipient) {
$crElement = iphorm_get_element_config($recipient['element'], $form);
if ($crElement['type'] == 'radio') {
$recipient['value'] = _wp_specialchars($recipient['value'], ENT_NOQUOTES);
}
}
}
foreach ($form['elements'] as &$element) {
// Go through the logic rules and escape the value if the element that the rule is referring to is a checkbox or radio element
if (isset($element['logic_rules']) && is_array($element['logic_rules'])) {
foreach ($element['logic_rules'] as &$logicRule) {
$lrElement = iphorm_get_element_config($logicRule['element_id'], $form);
if (in_array($lrElement['type'], array('checkbox', 'radio'))) {
$logicRule['value'] = _wp_specialchars($logicRule['value'], ENT_NOQUOTES);
}
}
}
if ($element['type'] == 'groupstart') {
// Escape Group title and description
$element['title'] = _wp_specialchars($element['title'], ENT_NOQUOTES);
$element['description'] = _wp_specialchars($element['description'], ENT_NOQUOTES);
} elseif (in_array($element['type'], array('radio', 'checkbox'))) {
// Escape options labels and values for radio and checkbox elements
foreach ($element['options'] as &$option) {
$option['label'] = _wp_specialchars($option['label'], ENT_NOQUOTES);
$option['value'] = _wp_specialchars($option['value'], ENT_NOQUOTES);
}
}
}
iphorm_save_form($form);
}
}
示例8: get_search_criteria
/**
* Parse search criteria for a entries search.
*
* array(
* 'search_field' => 1, // ID of the field
* 'search_value' => '', // Value of the field to search
* 'search_operator' => 'contains', // 'is', 'isnot', '>', '<', 'contains'
* 'show_only_approved' => 0 or 1 // Boolean
* )
*
* @param array $args Array of args
* @param int $form_id Gravity Forms form ID
* @return array Array of search parameters, formatted in Gravity Forms mode, using `status` key set to "active" by default, `field_filters` array with `key`, `value` and `operator` keys.
*/
public static function get_search_criteria($args, $form_id)
{
/**
* @filter `gravityview_fe_search_criteria` Modify the search criteria
* @see GravityView_Widget_Search::filter_entries Adds the default search criteria
* @param array $search_criteria Empty `field_filters` key
* @param int $form_id ID of the Gravity Forms form that is being searched
*/
$search_criteria = apply_filters('gravityview_fe_search_criteria', array('field_filters' => array()), $form_id);
$original_search_criteria = $search_criteria;
do_action('gravityview_log_debug', '[get_search_criteria] Search Criteria after hook gravityview_fe_search_criteria: ', $search_criteria);
// implicity search
if (!empty($args['search_value'])) {
// Search operator options. Options: `is` or `contains`
$operator = !empty($args['search_operator']) && in_array($args['search_operator'], array('is', 'isnot', '>', '<', 'contains')) ? $args['search_operator'] : 'contains';
$search_criteria['field_filters'][] = array('key' => rgget('search_field', $args), 'value' => _wp_specialchars($args['search_value']), 'operator' => $operator);
}
if ($search_criteria !== $original_search_criteria) {
do_action('gravityview_log_debug', '[get_search_criteria] Search Criteria after implicity search: ', $search_criteria);
}
// Handle setting date range
$search_criteria = self::process_search_dates($args, $search_criteria);
if ($search_criteria !== $original_search_criteria) {
do_action('gravityview_log_debug', '[get_search_criteria] Search Criteria after date params: ', $search_criteria);
}
// remove not approved entries
$search_criteria = self::process_search_only_approved($args, $search_criteria);
/**
* @filter `gravityview_status` Modify entry status requirements to be included in search results.
* @param string $status Default: `active`. Accepts all Gravity Forms entry statuses, including `spam` and `trash`
*/
$search_criteria['status'] = apply_filters('gravityview_status', 'active', $args);
return $search_criteria;
}
示例9: mla_prepare_bulk_edits
//.........这里部分代码省略.........
* Taxonomy Support
*/
$tax_inputs = array();
$tax_actions = array();
self::mla_debug_add("mla_prepare_bulk_edits( {$post_id} ) tax_input = " . var_export($request['tax_input'], true), MLA::MLA_DEBUG_CATEGORY_AJAX);
if (isset($request['tax_input']) && is_array($request['tax_input'])) {
foreach ($request['tax_input'] as $taxonomy => $terms) {
if (!empty($request['tax_action'])) {
$tax_action = $request['tax_action'][$taxonomy];
} else {
$tax_action = 'replace';
}
self::mla_debug_add("mla_prepare_bulk_edits( {$post_id}, {$taxonomy}, {$tax_action} ) terms = " . var_export($terms, true), MLA::MLA_DEBUG_CATEGORY_AJAX);
/*
* Ignore empty updates
*/
if ($hierarchical = is_array($terms)) {
if (false !== ($index = array_search(0, $terms))) {
unset($terms[$index]);
}
} else {
/*
* Parse out individual terms
*/
$comma = _x(',', 'tag_delimiter', 'media-library-assistant');
if (',' !== $comma) {
$tags = str_replace($comma, ',', $terms);
}
$fragments = explode(',', trim($terms, " \n\t\r\v,"));
$terms = array();
foreach ($fragments as $fragment) {
// WordPress encodes special characters, e.g., "&" as HTML entities in term names
if (MLATest::$wp_3dot5) {
$fragment = _wp_specialchars(trim(stripslashes_deep($fragment)));
} else {
$fragment = _wp_specialchars(trim(wp_unslash($fragment)));
}
if (!empty($fragment)) {
$terms[] = $fragment;
}
}
// foreach fragment
$terms = array_unique($terms);
}
if (empty($terms) && 'replace' != $tax_action) {
continue;
}
$post_terms = get_object_term_cache($post_id, $taxonomy);
if (false === $post_terms) {
$post_terms = wp_get_object_terms($post_id, $taxonomy);
wp_cache_add($post_id, $post_terms, $taxonomy . '_relationships');
}
$current_terms = array();
foreach ($post_terms as $new_term) {
if ($hierarchical) {
$current_terms[$new_term->term_id] = $new_term->term_id;
} else {
$current_terms[$new_term->name] = $new_term->name;
}
}
self::mla_debug_add("mla_prepare_bulk_edits( {$post_id}, {$taxonomy}, {$tax_action} ) current_terms = " . var_export($current_terms, true), MLA::MLA_DEBUG_CATEGORY_AJAX);
if ('add' == $tax_action) {
/*
* Add new terms; remove existing terms
*/
foreach ($terms as $index => $new_term) {
示例10: sitemap_url
/**
* Build the <url> tag for a given URL.
*
* @param array $url Array of parts that make up this entry
*
* @return string
*/
function sitemap_url($url)
{
// Create a DateTime object date in the correct timezone
if (isset($url['mod'])) {
$date = new DateTime($url['mod'], new DateTimeZone($this->get_timezone_string()));
} else {
$date = new DateTime(date('y-m-d H:i:s'), new DateTimeZone($this->get_timezone_string()));
}
$url['loc'] = htmlspecialchars($url['loc']);
$output = "\t<url>\n";
$output .= "\t\t<loc>" . $url['loc'] . "</loc>\n";
$output .= "\t\t<lastmod>" . $date->format('c') . "</lastmod>\n";
$output .= "\t\t<changefreq>" . $url['chf'] . "</changefreq>\n";
$output .= "\t\t<priority>" . str_replace(',', '.', $url['pri']) . "</priority>\n";
if (isset($url['images']) && (is_array($url['images']) && $url['images'] !== array())) {
foreach ($url['images'] as $img) {
if (!isset($img['src']) || empty($img['src'])) {
continue;
}
$output .= "\t\t<image:image>\n";
$output .= "\t\t\t<image:loc>" . esc_html($img['src']) . "</image:loc>\n";
if (isset($img['title']) && !empty($img['title'])) {
$output .= "\t\t\t<image:title><![CDATA[" . _wp_specialchars(html_entity_decode($img['title'], ENT_QUOTES, $this->charset)) . "]]></image:title>\n";
}
if (isset($img['alt']) && !empty($img['alt'])) {
$output .= "\t\t\t<image:caption><![CDATA[" . _wp_specialchars(html_entity_decode($img['alt'], ENT_QUOTES, $this->charset)) . "]]></image:caption>\n";
}
$output .= "\t\t</image:image>\n";
}
}
$output .= "\t</url>\n";
return $output;
}
示例11: clean_string
/**
* Cleans a string for XML display purposes.
*
* @since 1.2.1
*
* @link http://php.net/html-entity-decode#98697 Modified for WP from here.
*
* @param string $in The string to clean.
* @param int $offset Offset of the string to start the cleaning at.
*
* @return string Cleaned string.
*/
public function clean_string($in, $offset = null)
{
$out = trim($in);
$out = $this->strip_shortcodes($out);
$out = html_entity_decode($out, ENT_QUOTES, 'ISO-8859-15');
$out = html_entity_decode($out, ENT_QUOTES, get_bloginfo('charset'));
if (!empty($out)) {
$entity_start = strpos($out, '&', $offset);
if ($entity_start === false) {
// ideal
return _wp_specialchars($out);
} else {
$entity_end = strpos($out, ';', $entity_start);
if ($entity_end === false) {
return _wp_specialchars($out);
} elseif ($entity_end > $entity_start + 7) {
// und weiter gehts
$out = $this->clean_string($out, $entity_start + 1);
} else {
$clean = substr($out, 0, $entity_start);
$subst = substr($out, $entity_start + 1, 1);
// š => "s" / š => "_"
$clean .= $subst != '#' ? $subst : '_';
$clean .= substr($out, $entity_end + 1);
// und weiter gehts
$out = $this->clean_string($clean, $entity_start + 1);
}
}
}
return _wp_specialchars($out);
}
示例12: su_esc_editable_html
/**
* Escapes HTML. Double-encodes existing entities (ideal for editable HTML).
*
* @since 1.5
*
* @param string $str The string that potentially contains HTML.
* @return string The filtered string.
*/
function su_esc_editable_html($str)
{
return _wp_specialchars($str, ENT_QUOTES, false, true);
}
示例13: esc_attr
/**
* Escaping for HTML attributes.
*
* @since 2.8.0
*
* @param string $text
* @return string
*/
function esc_attr($text)
{
$safe_text = wp_check_invalid_utf8($text);
$safe_text = _wp_specialchars($safe_text, ENT_QUOTES);
return apply_filters('attribute_escape', $safe_text, $text);
}
示例14: create_select2_input
/**
* Creates a select2 input.
*
* @param array $args The arguments of the input.
*
* @return Ai1ec_File_Twig
*/
public function create_select2_input(array $args)
{
if (!isset($args['name'])) {
$args['name'] = $args['id'];
}
// Get tags.
$tags = get_terms('events_tags', array('orderby' => 'name', 'hide_empty' => 0));
// Build tags array to pass as JSON.
$tags_json = array();
foreach ($tags as $term) {
$tags_json[] = $term->name;
}
$tags_json = json_encode($tags_json);
$tags_json = _wp_specialchars($tags_json, 'single', 'UTF-8');
$loader = $this->_registry->get('theme.loader');
$select2_args = array('data-placeholder' => __('Tags (optional)', AI1EC_PLUGIN_NAME), 'class' => 'ai1ec-tags-selector span12', 'data-ai1ec-tags' => $tags_json);
$select2 = $loader->get_file('select2_input.twig', array('name' => $args['name'], 'id' => $args['id'], 'select2_args' => $select2_args), true);
return $select2;
}
示例15: esc_attr
/**
* Escaping for HTML attributes.
*
* @since 2.8.0
*
* @param string $text
* @return string
*/
function esc_attr($text)
{
$safe_text = wp_check_invalid_utf8($text);
$safe_text = _wp_specialchars($safe_text, ENT_QUOTES);
/**
* Filter a string cleaned and escaped for output in an HTML attribute.
*
* Text passed to esc_attr() is stripped of invalid or special characters
* before output.
*
* @since 2.0.6
*
* @param string $safe_text The text after it has been escaped.
* @param string $text The text prior to being escaped.
*/
return apply_filters('attribute_escape', $safe_text, $text);
}