本文整理汇总了PHP中utf8_uri_encode函数的典型用法代码示例。如果您正苦于以下问题:PHP utf8_uri_encode函数的具体用法?PHP utf8_uri_encode怎么用?PHP utf8_uri_encode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了utf8_uri_encode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: VietCoding_sanitize_title_with_dashes
function VietCoding_sanitize_title_with_dashes($title)
{
$title = vi2en($title);
$title = strip_tags($title);
// Preserve escaped octets.
$title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title);
// Remove percent signs that are not part of an octet.
$title = str_replace('%', '', $title);
// Restore octets.
$title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title);
$title = remove_accents($title);
if (seems_utf8($title)) {
if (function_exists('mb_strtolower')) {
$title = mb_strtolower($title, 'UTF-8');
}
$title = utf8_uri_encode($title, 200);
}
$title = strtolower($title);
$title = preg_replace('/&.+?;/', '', $title);
// kill entities
$title = str_replace('.', '-', $title);
$title = preg_replace('/[^%a-z0-9 _-]/', '', $title);
$title = preg_replace('/\\s+/', '-', $title);
$title = preg_replace('|-+|', '-', $title);
$title = trim($title, '-');
$title = vi2en($title);
return $title;
}
示例2: format_uri
/**
* Format URI
*
* Formats a category uri.
*
* @param string $cat_uri The uri name
* @uses check_uri
* @uses remove_accents
* @uses seems_utf8
* @uses utf8_uri_encode
* @uses format_uri
* @return string A cleaned uri
*/
function format_uri($cat_uri, $i = 0, $cat_id = false)
{
$cat_uri = strip_tags($cat_uri);
// Preserve escaped octets.
$cat_uri = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $cat_uri);
// Remove percent signs that are not part of an octet.
$cat_uri = str_replace('%', '', $cat_uri);
// Restore octets.
$cat_uri = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $cat_uri);
$cat_uri = remove_accents($cat_uri);
if (seems_utf8($cat_uri)) {
if (function_exists('mb_strtolower')) {
$cat_uri = mb_strtolower($cat_uri, 'UTF-8');
}
$cat_uri = utf8_uri_encode($cat_uri, 200);
}
$cat_uri = strtolower($cat_uri);
$cat_uri = preg_replace('/&.+?;/', '', $cat_uri);
// kill entities
$cat_uri = preg_replace('/[^%a-z0-9 _-]/', '', $cat_uri);
$cat_uri = preg_replace('/\\s+/', '-', $cat_uri);
$cat_uri = preg_replace('|-+|', '-', $cat_uri);
$cat_uri = trim($cat_uri, '-');
if ($i > 0) {
$cat_uri = $cat_uri . "-" . $i;
}
if (!$this->check_uri($cat_uri, $cat_id)) {
$i++;
$cat_uri = $this->format_uri($cat_uri, $i);
}
return $cat_uri;
}
示例3: sanitize_title_with_accented
function sanitize_title_with_accented($title, $raw_title = '', $context = 'display')
{
$title = strip_tags($title);
// Preserve escaped octets.
$title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title);
// Remove percent signs that are not part of an octet.
$title = str_replace('%', '', $title);
// Restore octets.
$title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title);
if (seems_utf8($title)) {
if (function_exists('mb_strtolower')) {
$title = mb_strtolower($title, 'UTF-8');
}
$title = utf8_uri_encode($title, 1000);
}
$title = strtolower($title);
$title = preg_replace('/&.+?;/', '', $title);
// kill entities
$title = str_replace('.', '-', $title);
if ('save' == $context) {
// Convert nbsp, ndash and mdash to hyphens
$title = str_replace(array('%c2%a0', '%e2%80%93', '%e2%80%94'), '-', $title);
// Strip these characters entirely
$title = str_replace(array('%c2%a1', '%c2%bf', '%c2%ab', '%c2%bb', '%e2%80%b9', '%e2%80%ba', '%e2%80%98', '%e2%80%99', '%e2%80%9c', '%e2%80%9d', '%e2%80%9a', '%e2%80%9b', '%e2%80%9e', '%e2%80%9f', '%c2%a9', '%c2%ae', '%c2%b0', '%e2%80%a6', '%e2%84%a2', '%c2%b4', '%cb%8a', '%cc%81', '%cd%81', '%cc%80', '%cc%84', '%cc%8c'), '', $title);
// Convert times to x
$title = str_replace('%c3%97', 'x', $title);
}
$title = preg_replace('/[^%a-z0-9 _-]/', '', $title);
$title = preg_replace('/\\s+/', '-', $title);
$title = preg_replace('|-+|', '-', $title);
$title = trim($title, '-');
return urldecode($title);
}
示例4: update_bc_video
/**
* Updates Metadata to the Brightcove API
*
* @param array $sanitized_post_data . This should be sanitized POST data
*
* @return bool|WP_Error
*/
public function update_bc_video($sanitized_post_data)
{
global $bc_accounts;
$video_id = BC_Utility::sanitize_id($sanitized_post_data['video_id']);
if (array_key_exists('name', $sanitized_post_data) && '' !== $sanitized_post_data['name']) {
$update_data['name'] = utf8_uri_encode(sanitize_text_field($sanitized_post_data['name']));
}
if (array_key_exists('description', $sanitized_post_data) && !empty($sanitized_post_data['description'])) {
$update_data['description'] = BC_Utility::sanitize_payload_item($sanitized_post_data['description']);
}
if (array_key_exists('long_description', $sanitized_post_data) && !empty($sanitized_post_data['long_description'])) {
$update_data['long_description'] = BC_Utility::sanitize_payload_item($sanitized_post_data['long_description']);
}
if (array_key_exists('tags', $sanitized_post_data) && !empty($sanitized_post_data['tags'])) {
// Convert tags string to an array.
$update_data['tags'] = array_map('trim', explode(',', $sanitized_post_data['tags']));
}
$bc_accounts->set_current_account($sanitized_post_data['account']);
$request = $this->cms_api->video_update($video_id, $update_data);
$bc_accounts->restore_default_account();
/**
* If we had any tags in the update, add them to the tags collection if we don't already track them.
*/
if (array_key_exists('tags', $update_data) && is_array($update_data['tags']) && count($update_data['tags'])) {
$existing_tags = $this->tags->get_tags();
$new_tags = array_diff($update_data['tags'], $existing_tags);
if (count($new_tags)) {
$this->tags->add_tags($new_tags);
}
}
if (is_wp_error($request) || $request === false) {
return false;
}
return true;
}
示例5: update_bc_playlist
/**
* Updates Metadata to the Brightcove API
*
* @param array $sanitized_post_data This should be sanitized POST data.
*
* @return bool|WP_Error
*/
public function update_bc_playlist($sanitized_post_data)
{
global $bc_accounts;
if (!wp_verify_nonce($_POST['nonce'], '_bc_ajax_search_nonce')) {
return false;
}
$playlist_id = BC_Utility::sanitize_id($sanitized_post_data['playlist_id']);
$update_data = array('type' => 'EXPLICIT');
if (array_key_exists('name', $sanitized_post_data) && '' !== $sanitized_post_data['name']) {
$update_data['name'] = utf8_uri_encode(sanitize_text_field($sanitized_post_data['name']));
}
if (array_key_exists('playlist_videos', $sanitized_post_data) && !empty($sanitized_post_data['playlist_videos'])) {
$update_data['video_ids'] = BC_Utility::sanitize_payload_item($sanitized_post_data['playlist_videos']);
}
$bc_accounts->set_current_account($sanitized_post_data['account']);
$request = $this->cms_api->playlist_update($playlist_id, $update_data);
$bc_accounts->restore_default_account();
if (is_wp_error($request) || false === $request) {
return false;
}
if (is_array($request) && isset($request['id'])) {
return true;
}
return true;
}
示例6: update_bc_playlist
/**
* Updates Metadata to the Brightcove API
*
* @param array $sanitized_post_data . This should be sanitized POST data
*
* @return bool|WP_Error
*/
public function update_bc_playlist($sanitized_post_data)
{
global $bc_accounts;
if (!wp_verify_nonce($_POST['nonce'], '_bc_ajax_search_nonce')) {
return false;
}
$playlist_id = BC_Utility::sanitize_id($sanitized_post_data['playlist_id']);
$update_data = array('type' => 'EXPLICIT');
if (array_key_exists('name', $sanitized_post_data) && '' !== $sanitized_post_data['name']) {
$update_data['name'] = utf8_uri_encode(sanitize_text_field($sanitized_post_data['name']));
}
if (array_key_exists('playlist_videos', $sanitized_post_data) && !empty($sanitized_post_data['playlist_videos'])) {
$update_data['video_ids'] = BC_Utility::sanitize_payload_item($sanitized_post_data['playlist_videos']);
}
$bc_accounts->set_current_account($sanitized_post_data['account']);
$request = $this->cms_api->playlist_update($playlist_id, $update_data);
$bc_accounts->restore_default_account();
if (is_wp_error($request) || $request === false) {
return false;
}
if (is_array($request) && isset($request['id'])) {
if (true === $this->add_or_update_wp_playlist($request)) {
return true;
}
$error_message = esc_html__('The Playlist failed to sync with WordPress', 'brightcove');
BC_Logging::log(sprintf('WORDPRESS PLAYLIST SYNC: %s', $error_message));
return new WP_Error('playlist-wp-sync-error', $error_message);
}
return true;
}
示例7: st_auto_post_slug
/**
* WordPress の投稿スラッグを自動的に生成する
*/
function st_auto_post_slug($slug, $post_ID, $post_status, $post_type)
{
if (preg_match('/(%[0-9a-f]{2})+/', $slug)) {
$slug = utf8_uri_encode($post_type) . '-' . $post_ID;
}
return $slug;
}
示例8: cf_sanitize_ids
function cf_sanitize_ids($t)
{
$t = strip_tags($t);
$t = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $t);
$t = str_replace('%', '', $t);
$t = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $t);
$t = remove_accents($t);
if (seems_utf8($t)) {
$t = utf8_uri_encode($t, 200);
}
$t = preg_replace('/&.+?;/', '', $t);
// kill entities
$t = preg_replace('/\\s+/', '-', $t);
$t = preg_replace('|-+|', '-', $t);
$t = preg_replace("|'|", '-', $t);
$t = trim($t, '-');
$t = str_replace('[', '', $t);
$t = str_replace(']', '', $t);
return $t;
}
示例9: slugify
/**
* Slugify title, replacing whitespace and a few other characters with dashes.
*
* Limits the output to alphanumeric characters, underscore (_) and dash (-).
* Whitespace becomes a dash.
*
*
* @param string $title The title to be sanitized.
* @param string $raw_title Optional. Not used.
* @param string $context Optional. The operation for which the string is sanitized.
* @return string The sanitized title.
*/
function slugify($title, $raw_title = '', $context = 'display')
{
$title = strip_tags($title);
// Preserve escaped octets.
$title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title);
// Remove percent signs that are not part of an octet.
$title = str_replace('%', '', $title);
// Restore octets.
$title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title);
if (seems_utf8($title)) {
if (function_exists('mb_strtolower')) {
$title = mb_strtolower($title, 'UTF-8');
}
$title = utf8_uri_encode($title, 200);
}
$title = strtolower($title);
$title = preg_replace('/&.+?;/', '', $title);
// kill entities
$title = str_replace('.', '-', $title);
if ('save' == $context) {
// nbsp, ndash and mdash
$title = str_replace(array('%c2%a0', '%e2%80%93', '%e2%80%94'), '-', $title);
// iexcl and iquest
$title = str_replace(array('%c2%a1', '%c2%bf'), '', $title);
// angle quotes
$title = str_replace(array('%c2%ab', '%c2%bb', '%e2%80%b9', '%e2%80%ba'), '', $title);
// curly quotes
$title = str_replace(array('%e2%80%98', '%e2%80%99', '%e2%80%9c', '%e2%80%9d'), '', $title);
// copy, reg, deg, hellip and trade
$title = str_replace(array('%c2%a9', '%c2%ae', '%c2%b0', '%e2%80%a6', '%e2%84%a2'), '', $title);
}
$title = preg_replace('/[^%a-z0-9 _-]/', '', $title);
$title = preg_replace('/\\s+/', '-', $title);
$title = preg_replace('|-+|', '-', $title);
$title = trim($title, '-');
return $title;
}
示例10: ita_sanitize_title
function ita_sanitize_title($title)
{
$title = strip_tags($title);
// Preserve escaped octets.
$title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title);
// Remove percent signs that are not part of an octet.
$title = str_replace('%', '', $title);
// Restore octets.
$title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title);
$title = remove_accents($title);
if (seems_utf8($title)) {
$title = utf8_uri_encode($title, 200);
}
$title = preg_replace('/&.+?;/', '', $title);
// kill entities
$title = preg_replace('/[^%a-zA-Z0-9 ()_-]/', '', $title);
$title = preg_replace('/\\s+/', '_', $title);
$title = preg_replace('|-+|', '-', $title);
$title = trim($title, '-');
return $title;
}
示例11: get_avatar_url
function get_avatar_url($user_id)
{
$avatar = get_avatar($user_id);
if (preg_match("/src=['\"](.*?)['\"]/i", $avatar, $matches)) {
return utf8_uri_encode($matches[1]);
}
}
示例12: do_action
<?php
}
/* xmlsf_news_tags_after action hook */
do_action('xmlsf_news_tags_after');
?>
</news:news>
<?php
if (!empty($options['image']) && $xmlsf->get_images('news')) {
foreach ($xmlsf->get_images() as $image) {
if (empty($image['loc'])) {
continue;
}
?>
<image:image>
<image:loc><?php
echo utf8_uri_encode($image['loc']);
?>
</image:loc>
<?php
if (!empty($image['title'])) {
?>
<image:title><![CDATA[<?php
echo str_replace(']]>', ']]>', $image['title']);
?>
]]></image:title>
<?php
}
if (!empty($image['caption'])) {
?>
<image:caption><![CDATA[<?php
echo str_replace(']]>', ']]>', $image['caption']);
示例13: location_query_arg
function location_query_arg($link)
{
if (isset($_GET['location']) && $_GET['location']) {
$link = add_query_arg('location', urlencode(utf8_uri_encode($_GET['location'])), $link);
}
return $link;
}
示例14: test_output_is_not_longer_than_optional_length_argument
/**
* @dataProvider data
*/
function test_output_is_not_longer_than_optional_length_argument($utf8, $unused_for_this_test)
{
$max_length = 30;
$this->assertTrue(strlen(utf8_uri_encode($utf8, $max_length)) <= $max_length);
}
示例15: _truncate_post_slug
/**
* Truncate a post slug.
*
* @since 3.6.0
* @access private
*
* @see utf8_uri_encode()
*
* @param string $slug The slug to truncate.
* @param int $length Optional. Max length of the slug. Default 200 (characters).
* @return string The truncated slug.
*/
function _truncate_post_slug($slug, $length = 200)
{
if (strlen($slug) > $length) {
$decoded_slug = urldecode($slug);
if ($decoded_slug === $slug) {
$slug = substr($slug, 0, $length);
} else {
$slug = utf8_uri_encode($decoded_slug, $length);
}
}
return rtrim($slug, '-');
}