本文整理汇总了PHP中links_add_target函数的典型用法代码示例。如果您正苦于以下问题:PHP links_add_target函数的具体用法?PHP links_add_target怎么用?PHP links_add_target使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了links_add_target函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_normalize_whitespace
/**
* Validate the normalize_whitespace function
*
* @dataProvider get_input_output
*/
function test_normalize_whitespace($content, $target, $tags, $exp_str)
{
if (true === is_null($target)) {
$this->assertEquals($exp_str, links_add_target($content));
} elseif (true === is_null($tags)) {
$this->assertEquals($exp_str, links_add_target($content, $target));
} else {
$this->assertEquals($exp_str, links_add_target($content, $target, $tags));
}
}
示例2: create_link
/**
* If incoming link is empty, then get_site_url() is used instead.
*/
public static function create_link($link, $title = null, $target = null, $return_as_tag = true)
{
if (empty($link)) {
$link = get_site_url();
}
if (preg_match('#^\\d+$#', $link)) {
$permalink = get_permalink($link);
$tag_title = get_the_title($link);
if (empty($title)) {
$title = $tag_title;
}
$tag = '<a href="';
$tag .= $permalink;
$tag .= '" title="';
$tag .= $tag_title;
$tag .= '">';
$tag .= $title;
$tag .= '</a>';
} else {
$orig_link = empty($title) ? $link : $title;
$do_http = true;
if (0 === strpos($link, '/')) {
$do_http = false;
}
if ($do_http && 0 === preg_match('#https?://#', $link)) {
$link = 'http://' . $link;
}
$permalink = $link;
$tag = '<a href="';
$tag .= $permalink;
$tag .= '">';
$tag .= $orig_link;
$tag .= '</a>';
}
if (!empty($target) && is_string($target)) {
$tag = links_add_target($tag, $target);
}
if ($return_as_tag) {
return $tag;
} else {
return array('link' => $permalink, 'tag' => $tag);
}
}
示例3: custom_meta_box_field
/**
* recives data about a form field and spits out the proper html
*
* @param array $field array with various bits of information about the field
* @param string|int|bool|array $meta the saved data for this field
* @param array $repeatable if is this for a repeatable field, contains parant id and the current integar
*
* @return string html for the field
*/
function custom_meta_box_field($field, $meta = NULL, $repeatable = NULL)
{
if (!($field || is_array($field))) {
return;
}
// get field data
$type = isset($field['type']) ? $field['type'] : NULL;
$label = isset($field['label']) ? $field['label'] : NULL;
$desc = isset($field['desc']) ? '<span class="description">' . links_add_target(make_clickable($field['desc'])) . '</span>' : NULL;
$place = isset($field['place']) ? $field['place'] : NULL;
$size = isset($field['size']) ? $field['size'] : NULL;
$post_type = isset($field['post_type']) ? $field['post_type'] : NULL;
$options = isset($field['options']) ? $field['options'] : NULL;
$settings = isset($field['settings']) ? $field['settings'] : NULL;
$repeatable_fields = isset($field['repeatable_fields']) ? $field['repeatable_fields'] : NULL;
if (isset($field['default'])) {
if (empty($meta)) {
$meta = $field['default'];
}
}
// the id and name for each field
$id = $name = isset($field['id']) ? $field['id'] : NULL;
if ($repeatable) {
$name = $repeatable[0] . '[' . $repeatable[1] . '][' . $id . ']';
$id = $repeatable[0] . '_' . $repeatable[1] . '_' . $id;
}
switch ($type) {
// basic
case 'text':
case 'tel':
case 'email':
default:
echo '<input type="' . $type . '" name="' . esc_attr($name) . '" id="' . esc_attr($id) . '" value="' . esc_attr($meta) . '" class="regular-text" size="30" />
<br />' . $desc;
break;
case 'url':
echo '<input type="' . $type . '" name="' . esc_attr($name) . '" id="' . esc_attr($id) . '" value="' . esc_url($meta) . '" class="regular-text" size="30" />
<br />' . $desc;
break;
case 'number':
echo '<input type="' . $type . '" name="' . esc_attr($name) . '" id="' . esc_attr($id) . '" value="' . intval($meta) . '" class="regular-text" size="30" />
<br />' . $desc;
break;
// textarea
// textarea
case 'textarea':
echo '<textarea name="' . esc_attr($name) . '" id="' . esc_attr($id) . '" cols="60" rows="4">' . esc_textarea($meta) . '</textarea>
<br />' . $desc;
break;
// editor
// editor
case 'editor':
echo wp_editor($meta, $id, $settings) . '<br />' . $desc;
break;
// checkbox
// checkbox
case 'checkbox':
echo '<input type="checkbox" name="' . esc_attr($name) . '" id="' . esc_attr($id) . '" ' . checked($meta, TRUE, FALSE) . ' value="1" />
<label for="' . esc_attr($id) . '">' . $desc . '</label>';
break;
// select, chosen
// select, chosen
case 'select':
case 'select2':
echo '<select name="' . esc_attr($name) . '" id="' . esc_attr($id) . '"', $type == 'select2' ? ' class="select2"' : '', isset($multiple) && $multiple == TRUE ? ' multiple="multiple"' : '', '>
<option value="">Select One</option>';
// Select One
foreach ($options as $key => $option) {
echo '<option' . selected($meta, $key, FALSE) . ' value="' . $key . '">' . $option . '</option>';
}
echo '</select><br />' . $desc;
break;
// radio
// radio
case 'radio':
echo '<ul class="meta_box_items">';
foreach ($options as $key => $option) {
echo '<li>
<input type="radio" name="' . esc_attr($name) . '" id="' . esc_attr($id) . '-' . $key . '" value="' . $key . '" ' . checked($meta, $key, FALSE) . ' />
<label for="' . esc_attr($id) . '-' . $key . '">' . $option . '</label></li>';
}
echo '</ul>' . $desc;
break;
// checkbox_group
// checkbox_group
case 'checkbox_group':
echo '<ul class="meta_box_items">';
foreach ($options as $option) {
echo '<li><input type="checkbox" value="' . $option['value'] . '" name="' . esc_attr($name) . '[]" id="' . esc_attr($id) . '-' . $option['value'] . '"', is_array($meta) && in_array($option['value'], $meta) ? ' checked="checked"' : '', ' />
<label for="' . esc_attr($id) . '-' . $option['value'] . '">' . $option['label'] . '</label></li>';
}
//.........这里部分代码省略.........
示例4: format
public function format()
{
$this->tweet = links_add_target(make_clickable(esc_html($this->resource->text)));
$this->tweet = preg_replace_callback('/(^|[^0-9A-Z&\\/]+)(#|\\xef\\xbc\\x83)([0-9A-Z_]*[A-Z_]+[a-z0-9_\\xc0-\\xd6\\xd8-\\xf6\\xf8\\xff]*)/iu', 'Sneek\\Twitter\\Presenter::hashtag', $this->tweet);
$this->tweet = preg_replace_callback('/([^a-zA-Z0-9_]|^)([@\\xef\\xbc\\xa0]+)([a-zA-Z0-9_]{1,20})(\\/[a-zA-Z][a-zA-Z0-9\\x80-\\xff-]{0,79})?/u', 'Sneek\\Twitter\\Presenter::username', $this->tweet);
}
示例5: aihr_notice_license
function aihr_notice_license($post_type, $settings_id, $free_name, $purchase_url, $item_name, $product_id = null, $license = null, $disable_license_notice = null)
{
if ($disable_license_notice) {
return;
}
if (empty($post_type)) {
$link = get_admin_url() . 'options-general.php?page=' . $settings_id;
} else {
$link = get_admin_url() . 'edit.php?post_type=' . $post_type . '&page=' . $settings_id;
}
$text = __('<a href="%1$s">%2$s > Settings</a>, <em>Premium</em> tab, <em>License Key</em>');
$settings_link = sprintf($text, $link, $free_name);
$link = esc_url('https://nodedesk.zendesk.com/hc/en-us/articles/202333071');
$text = __('<a href="%s">Where\'s my license key?</a>');
$faq_link = sprintf($text, $link);
$link = esc_url($purchase_url);
$text = __('<a href="%1$s">Purchase</a>');
$buy_link = sprintf($text, $link, $item_name);
$renew_link = '';
if (!empty($license)) {
$link = parse_url($purchase_url);
$link = $link['host'];
$text = __('%1$s/checkout/?edd_license_key=%2$s&download_id=%3$s');
$renew_url = sprintf($text, $link, $license, $product_id);
$link = esc_url($renew_url);
$text = __('<a href="%1$s">Renew</a> or ');
$renew_link = sprintf($text, $link, $item_name);
}
$text = sprintf(__('Plugin "%1$s" requires license activation for software updates and support. Please activate the license via %2$s. See %3$s for help. Alternately, %5$s%4$s a %1$s license.'), $item_name, $settings_link, $faq_link, $buy_link, $renew_link);
$text = links_add_target($text, '_blank');
aihr_notice_error($text);
}
示例6: install_plugin_information
//.........这里部分代码省略.........
?>
</a><?php
}
break;
}
?>
</p>
<?php
}
?>
<h2 class="mainheader"><?php
_e('FYI');
?>
</h2>
<ul>
<?php
if (!empty($api->version)) {
?>
<li><strong><?php
_e('Version:');
?>
</strong> <?php
echo $api->version;
?>
</li>
<?php
}
if (!empty($api->author)) {
?>
<li><strong><?php
_e('Author:');
?>
</strong> <?php
echo links_add_target($api->author, '_blank');
?>
</li>
<?php
}
if (!empty($api->last_updated)) {
?>
<li><strong><?php
_e('Last Updated:');
?>
</strong> <span title="<?php
echo $api->last_updated;
?>
"><?php
printf(__('%s ago'), human_time_diff(strtotime($api->last_updated)));
?>
</span></li>
<?php
}
if (!empty($api->requires)) {
?>
<li><strong><?php
_e('Requires WordPress Version:');
?>
</strong> <?php
printf(__('%s or higher'), $api->requires);
?>
</li>
<?php
}
if (!empty($api->tested)) {
?>
<li><strong><?php
示例7: chat_message_send
function chat_message_send()
{
$reply_data = array();
$reply_data['errorStatus'] = false;
$reply_data['errorText'] = '';
if (!isset($_POST['chat_messages']) || !count($_POST['chat_messages'])) {
$reply_data['errorText'] = "chat_messages missing";
$reply_data['errorStatus'] = true;
wp_send_json($reply_data);
die;
}
// Double check the user's authentication. Seems some users can login with multiple tabs. If they log out of one tab they
// should not be able to post via the other tab.
if (!isset($this->chat_auth['type'])) {
$reply_data['errorText'] = "Unknown user type";
$reply_data['errorStatus'] = true;
wp_send_json($reply_data);
die;
}
foreach ($_POST['chat_messages'] as $chat_id => $chat_messages) {
if (!isset($this->chat_sessions[$chat_id])) {
continue;
}
if (!is_array($chat_messages) || !count($chat_messages)) {
continue;
}
$chat_session = $this->chat_sessions[$chat_id];
if (!isset($reply_data['chat_messages'][$chat_id])) {
$reply_data['chat_messages'][$chat_id] = array();
}
foreach ($chat_messages as $chat_message_idx => $chat_message) {
$reply_data['chat_messages'][$chat_id][$chat_message_idx] = false;
//$chat_message = urldecode($chat_message);
$chat_message = stripslashes($chat_message);
// Replace the chr(10) Line feed (not the chr(13) carraige return) with a placeholder. Will be replaced with
// real <br /> after filtering This is done so when we convert text within [code][/code] the <br /> are not
// converted to entities. Because we want the code to be formatted
$chat_message = str_replace(chr(10), "[[CR]]", $chat_message);
// In case the user entered HTML <code></code> instead of [code][/code]
$chat_message = str_replace("<code>", "[code]", $chat_message);
$chat_message = str_replace("</code>", "[/code]", $chat_message);
// We also can accept backtick quoted text and convert to [code][/code]
$chat_message = preg_replace('/`(.*?)`/', '[code]$1[/code]', $chat_message);
// Now split out the [code][/code] sections.
//preg_match_all("|\[code\](.*)\[/code\]|s", $chat_message, $code_out);
preg_match_all("~\\[code\\](.+?)\\[/code\\]~si", $chat_message, $code_out);
if ($code_out && is_array($code_out) && is_array($code_out[0]) && count($code_out[0])) {
foreach ($code_out[0] as $code_idx => $code_str_original) {
if (!isset($code_out[1][$code_idx])) {
continue;
}
// Here we replace our [code][/code] block or text in the message with placeholder [code-XXX] where XXX
// is the index (0,1,2,3, etc.) Again we do this because in the next step we will strip out all HTML not
// allowed. We want to protect any HTML within the code block
// which will be converted to HTML entities after the filtering.
$chat_message = str_replace($code_str_original, '[code-' . $code_idx . ']', $chat_message);
}
}
// First strip all the tags!
$allowed_protocols = array();
$allowed_html = array();
$chat_message = wp_kses($chat_message, $allowed_html, $allowed_protocols);
// Not needed since we remove all HTML from the message. For now.
//$chat_message = balanceTags($chat_message);
// If the user enters something that liiks like a link (http://, ftp://, etc) it will be made clickable
// in that is will be wrapped in an anchor, etc. The the link tarket will be set so clicking it will open
// in a new window
$chat_message = links_add_target(make_clickable($chat_message));
// Now that we can filtered the text outside the [code][/code] we want to convert the code section HTML to entities since it
// will be viewed that way by other users.
if ($code_out && is_array($code_out) && is_array($code_out[0]) && count($code_out[0])) {
foreach ($code_out[0] as $code_idx => $code_str_original) {
if (!isset($code_out[1][$code_idx])) {
continue;
}
$code_str_replace = "<code>" . htmlentities2($code_out[1][$code_idx], ENT_QUOTES | ENT_XHTML) . "</code>";
$chat_message = str_replace('[code-' . $code_idx . ']', $code_str_replace, $chat_message);
}
}
// Finally convert any of our CR placeholders to HTML breaks.
$chat_message = str_replace("[[CR]]", '<br />', $chat_message);
// Just as a precaution. After processing we may end up with double breaks. So we convert to single.
$chat_message = str_replace("<br /><br />", '<br />', $chat_message);
// End message filtering
if ($chat_message == '') {
continue;
}
// Truncate the message IF the max length is set
if (!wpmudev_chat_is_moderator($chat_session)) {
if ($chat_session['row_message_input_length'] > 0 && strlen($chat_message) > $chat_session['row_message_input_length']) {
$chat_message = substr($chat_message, 0, $chat_session['row_message_input_length']);
}
}
// Process bad words, if enabled
if ($chat_session['blocked_words_active'] == "enabled") {
$chat_message = str_ireplace($this->_chat_options['banned']['blocked_words'], $this->_chat_options['banned']['blocked_words_replace'], $chat_message);
}
$ret = $this->chat_session_send_message($chat_message, $chat_session);
if (!empty($ret)) {
$reply_data['chat_messages'][$chat_id][$chat_message_idx] = true;
//.........这里部分代码省略.........
示例8: info
protected static function info($plugin)
{
global $tab;
require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
define('IFRAME_REQUEST', true);
try {
if (Sputnik::account_is_linked()) {
$account = Sputnik::get_account();
$api = Sputnik::get_plugin($plugin, $account->ID);
} else {
$api = Sputnik::get_plugin($plugin);
}
} catch (Exception $e) {
status_header(500);
iframe_header(__('Plugin Install', 'wpsc'));
echo $e->getMessage();
iframe_footer();
die;
}
$plugins_allowedtags = array('a' => array('href' => array(), 'title' => array(), 'target' => array()), 'abbr' => array('title' => array()), 'acronym' => array('title' => array()), 'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(), 'div' => array(), 'p' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(), 'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(), 'img' => array('src' => array(), 'class' => array(), 'alt' => array()));
$plugins_section_titles = array('description' => _x('Description', 'Plugin installer section title', 'wpsc'), 'installation' => _x('Installation', 'Plugin installer section title', 'wpsc'), 'faq' => _x('FAQ', 'Plugin installer section title', 'wpsc'), 'screenshots' => _x('Screenshots', 'Plugin installer section title', 'wpsc'), 'changelog' => _x('Changelog', 'Plugin installer section title', 'wpsc'), 'other_notes' => _x('Other Notes', 'Plugin installer section title', 'wpsc'));
//Sanitize HTML
$api->sections = isset($api->sections) ? (array) $api->sections : array();
$api->author = links_add_target($api->author, '_blank');
foreach ($api->sections as $section_name => $content) {
$api->sections[$section_name] = wp_kses($content, $plugins_allowedtags);
}
$api->screenshots = (array) $api->screenshots;
foreach ($api->screenshots as &$data) {
if (!isset($data->caption) || !isset($data->location)) {
continue;
}
$data->caption = wp_kses($data->caption, $plugins_allowedtags);
$data->location = esc_url($data->location, array('http', 'https'));
}
unset($data);
foreach (array('version', 'requires', 'tested', 'homepage', 'downloaded', 'slug', 'requires_wpec', 'tested_wpec') as $key) {
if (isset($api->{$key})) {
$api->{$key} = wp_kses($api->{$key}, $plugins_allowedtags);
}
}
$section = isset($_REQUEST['section']) ? stripslashes($_REQUEST['section']) : 'description';
//Default to the Description tab, Do not translate, API returns English.
if (empty($section) || !isset($api->sections[$section]) && ($section !== 'screenshots' || empty($api->screenshots))) {
$section = array_shift($section_titles = array_keys((array) $api->sections));
}
global $body_id;
$body_id = 'sputnik-plugin-information';
iframe_header(__('Plugin Install', 'wpsc'));
?>
<div class="alignleft fyi">
<h1><?php
echo $api->name;
?>
</h1>
<?php
if (!empty($api->download_link) && (current_user_can('install_plugins') || current_user_can('update_plugins'))) {
?>
<p class="action-button">
<?php
$status = self::install_status($api);
switch ($status['status']) {
case 'purchase':
default:
if ($status['url']) {
echo '<a href="' . $status['url'] . '" target="_parent" id="' . $plugin . '" class="button-primary buy">' . sprintf(__('<span>$%.2f</span> Buy & Install', 'wpsc'), $api->price) . '</a>';
}
break;
case 'install':
if ($status['url']) {
echo '<a href="' . $status['url'] . '" class="button-primary install" title="' . __('You have already purchased, install now', 'wpsc') . '">' . __('Install Now', 'wpsc') . '</a>';
}
break;
case 'update_available':
if ($status['url']) {
echo '<a href="' . $status['url'] . '" class="button-primary install">' . __('Install Update Now', 'wpsc') . '</a>';
}
break;
case 'newer_installed':
echo '<a>' . sprintf(__('Newer Version (%s) Installed', 'wpsc'), $status['version']) . '</a>';
break;
case 'latest_installed':
echo '<a>' . __('Latest Version Installed', 'wpsc') . '</a>';
break;
}
?>
</p>
<?php
}
echo "<div id='plugin-information-header'>\n";
echo "<ul id='sidemenu'>\n";
foreach ((array) $api->sections as $section_name => $content) {
if (isset($plugins_section_titles[$section_name])) {
$title = $plugins_section_titles[$section_name];
} else {
$title = ucwords(str_replace('_', ' ', $section_name));
}
$class = $section_name == $section ? ' class="current"' : '';
$href = add_query_arg(array('tab' => $tab, 'section' => $section_name));
$href = esc_url($href);
//.........这里部分代码省略.........
示例9: wprc_install_plugin_information
//.........这里部分代码省略.........
if (isset($api->rauth) && $api->rauth == false) {
?>
<p><?php
_e('Authorization Failed!', 'installer');
?>
</p>
<?php
}
?>
<h2 class="mainheader"><?php
/* translators: For Your Information */
_e('FYI');
?>
</h2>
<ul>
<?php
if (!empty($api->version)) {
?>
<li><strong><?php
_e('Version:', 'installer');
?>
</strong> <?php
echo $api->version;
?>
</li>
<?php
}
if (!empty($api->author)) {
?>
<li><strong><?php
_e('Author:', 'installer');
?>
</strong> <?php
echo links_add_target($api->author, '_blank');
?>
</li>
<?php
}
if (!empty($api->last_updated)) {
?>
<li><strong><?php
_e('Last Updated:', 'installer');
?>
</strong> <span title="<?php
echo $api->last_updated;
?>
"><?php
printf(__('%s ago', 'installer'), human_time_diff(strtotime($api->last_updated)));
?>
</span></li>
<?php
}
if (!empty($api->requires)) {
?>
<li><strong><?php
_e('Requires WordPress Version:', 'installer');
?>
</strong> <?php
printf(__('%s or higher', 'installer'), $api->requires);
?>
</li>
<?php
}
if (!empty($api->tested)) {
?>
<li><strong><?php
示例10: get_plugin_item
public static function get_plugin_item($plugin, $popup_id, $plugin_default_checked)
{
?>
<div class="oneandone-selectable-item">
<h3 class="oneandone-plugin-type"><?php
echo self::get_category_name($plugin->category);
?>
</h3>
<div class="oneandone-plugin-description" onclick="showBox(<?php
echo htmlspecialchars(json_encode($popup_id));
?>
, '')">
<?php
echo $plugin->short_description;
?>
</div>
<span class="oneandone-plugin-more-details" onclick="showBox(<?php
echo htmlspecialchars(json_encode($popup_id));
?>
, '')">
<?php
esc_html_e('More information', '1and1-wordpress-wizard');
?>
</span>
<h3 class="oneandone-plugin-name"><?php
echo $plugin->name;
?>
</h3>
<div class="oneandone-install-checkbox<?php
echo $plugin_default_checked == true ? ' checked' : '';
?>
">
<label for="plugin-<?php
echo $plugin->slug;
?>
">
<input id="plugin-<?php
echo $plugin->slug;
?>
" name="plugins[]" value="<?php
echo $plugin->slug;
?>
" type="checkbox" <?php
echo $plugin_default_checked == true ? 'checked' : '';
?>
>
<?php
_e('Install', '1and1-wordpress-wizard');
?>
</label>
</div>
<div id="<?php
echo $popup_id;
?>
" style="display:none">
<h3 class="oneandone-popup-plugin-name"><?php
echo $plugin->name;
?>
</h3>
<h4 class="oneandone-popup-plugin-author"><?php
printf(esc_html('By %s', '1and1-wordpress-wizard'), $plugin->author);
?>
</h4>
<div><?php
echo links_add_target($plugin->description, '_blank');
?>
</div>
</div>
</div>
<?php
}
示例11: process_chat_actions
//.........这里部分代码省略.........
// We also can accept backtick quoted text and convert to [code][/code]
$chat_message = preg_replace('/`(.*?)`/', '[code]$1[/code]', $chat_message);
// Now split out the [code][/code] sections.
//preg_match_all("|\[code\](.*)\[/code\]|s", $chat_message, $code_out);
preg_match_all("~\\[code\\](.+?)\\[/code\\]~si", $chat_message, $code_out);
if ($code_out && is_array($code_out) && is_array($code_out[0]) && count($code_out[0])) {
foreach ($code_out[0] as $code_idx => $code_str_original) {
if (!isset($code_out[1][$code_idx])) {
continue;
}
// Here we replace our [code][/code] block or text in the message with placeholder [code-XXX] where XXX
// is the index (0,1,2,3, etc.) Again we do this because in the next step we will strip out all HTML not
// allowed. We want to protect any HTML within the code block
// which will be converted to HTML entities after the filtering.
$chat_message = str_replace($code_str_original, '[code-' . $code_idx . ']', $chat_message);
}
}
// First strip all the tags!
$allowed_protocols = array();
$allowed_html = array();
/*
$allowed_html = array( 'a' => array('href' => array()),
'br' => array(),
'em' => array(),
'strong' => array(),
'strike' => array(),
'blockquote' => array()
);
*/
$chat_message = wp_kses($chat_message, $allowed_html, $allowed_protocols);
// If the user enters something that liiks like a link (http://, ftp://, etc) it will be made clickable
// in that is will be wrapped in an anchor, etc. The the link tarket will be set so clicking it will open
// in a new window
$chat_message = links_add_target(make_clickable($chat_message));
// Now that we can filtered the text outside the [code][/code] we want to convert the code section HTML to entities since it
// will be viewed that way by other users.
if ($code_out && is_array($code_out) && is_array($code_out[0]) && count($code_out[0])) {
foreach ($code_out[0] as $code_idx => $code_str_original) {
if (!isset($code_out[1][$code_idx])) {
continue;
}
$code_str_replace = "<code>" . htmlentities2($code_out[1][$code_idx], ENT_QUOTES | ENT_XHTML) . "</code>";
$chat_message = str_replace('[code-' . $code_idx . ']', $code_str_replace, $chat_message);
}
}
// Finally convert any of our CR placeholders to HTML breaks.
$chat_message = str_replace("[[CR]]", '<br />', $chat_message);
// Just as a precaution. After processing we may end up with double breaks. So we convert to single.
$chat_message = str_replace("<br /><br />", '<br />', $chat_message);
// End message filtering
if ($chat_message == '') {
continue;
}
// Truncate the message IF the max length is set
if (!wpmudev_chat_is_moderator($chat_session)) {
if ($chat_session['row_message_input_length'] > 0 && strlen($chat_message) > $chat_session['row_message_input_length']) {
$chat_message = substr($chat_message, 0, $chat_session['row_message_input_length']);
}
}
// Process bad words
if ($this->_chat_options['banned']['blocked_words_active'] == "enabled" && $chat_session['blocked_words_active'] == "enabled") {
$chat_message = str_ireplace($this->_chat_options['banned']['blocked_words'], $this->_chat_options['banned']['blocked_words_replace'], $chat_message);
}
/*
// Save for later. We had a request to support latex via chat
if (preg_match('/\[latex\](.*)\[\/latex\]/', $chat_message, $match)) {
示例12: extract
<?php
/**
* Display the textarea field type
*
* Use wpautop() to format paragraphs, as expected, instead of line breaks like Gravity Forms displays by default.
*
* @package GravityView
* @subpackage GravityView/templates/fields
*/
$gravityview_view = GravityView_View::getInstance();
extract($gravityview_view->getCurrentField());
if (!empty($field_settings['trim_words'])) {
$excerpt_more = apply_filters('excerpt_more', ' ' . '[…]');
$value = wp_trim_words($value, $field_settings['trim_words'], $excerpt_more);
}
if (!empty($field_settings['make_clickable'])) {
$value = make_clickable($value);
}
if (!empty($field_settings['new_window'])) {
$value = links_add_target($value);
}
echo wpautop($value);
示例13: hw_install_module_information
/**
* Display plugin information in dialog box form.
* @hook install_plugins_pre_plugin-information
*/
function hw_install_module_information()
{
global $tab;
if (empty($_REQUEST['module'])) {
return;
}
$api = modules_api('module_information', array('slug' => wp_unslash($_REQUEST['module']), 'is_ssl' => is_ssl(), 'fields' => array('banners' => true, 'reviews' => true, 'downloaded' => false, 'active_installs' => true)));
//for testing
$api = (object) array('name' => 'HW YARPP', 'version' => '1.0', 'author' => 'hoangweb', 'slug' => 'hw-yarpp', 'last_updated' => time());
if (is_wp_error($api)) {
wp_die($api);
}
$plugins_section_titles = array('description' => _x('Description', 'Plugin installer section title'), 'installation' => _x('Installation', 'Plugin installer section title'));
$section = 'description';
// Default to the Description tab,
$_tab = 'plugin-information';
//esc_attr( $tab ); because avaiable exists css for 'plugin-information'
iframe_header(__('HW Module Install'));
echo '<div id="plugin-information-scrollable">';
echo "<div id='{$_tab}-title' class=''><div class='vignette'></div><h2>{$api->name}</h2></div>";
//tabs
echo "<div id='{$_tab}-tabs' class=''>\n";
echo "<a href='#' class=''>Tab</a>";
echo "<a href='#' class=''>Tab 1</a>";
echo "</div>\n";
$date_format = __('M j, Y @ H:i');
$last_updated_timestamp = strtotime($api->last_updated);
?>
<div id="<?php
echo $_tab;
?>
-content" class='<?php
?>
'>
<!-- right info -->
<div class="fyi">
<ul>
<?php
if (!empty($api->version)) {
?>
<li><strong><?php
_e('Version:');
?>
</strong> <?php
echo $api->version;
?>
</li>
<?php
}
if (!empty($api->author)) {
?>
<li><strong><?php
_e('Author:');
?>
</strong> <?php
echo links_add_target($api->author, '_blank');
?>
</li>
<?php
}
if (!empty($api->last_updated)) {
?>
<li><strong><?php
_e('Last Updated:');
?>
</strong> <span title="<?php
echo esc_attr(date_i18n($date_format, $last_updated_timestamp));
?>
">
<?php
printf(__('%s ago'), human_time_diff($last_updated_timestamp));
?>
</span></li>
<?php
}
if (!empty($api->slug) && empty($api->external)) {
?>
<li><a target="_blank" href="https://develop.hoangweb.com/plugins/<?php
echo $api->slug;
?>
/"><?php
_e('Hoangweb.com Plugin Page »');
?>
</a></li>
<?php
}
?>
</ul>
</div>
<!-- tabs content -->
<div id="section-holder" class="wrap">
<?php
if (!empty($api->sections)) {
foreach ((array) $api->sections as $section_name => $content) {
$content = links_add_base_url($content, 'https://develop.hoangweb.com/modules/' . $api->slug . '/');
$content = links_add_target($content, '_blank');
//.........这里部分代码省略.........
示例14: new_message_ajax_handler
public function new_message_ajax_handler()
{
global $wpdb;
$quick_chat_messages_table_name = $wpdb->prefix . 'quick_chat_messages';
if ($this->user_status != 0) {
$_POST['message'] = wp_kses(trim(stripslashes(substr($_POST['message'], 0, $this->options['message_maximum_number_chars']))), '');
} else {
$_POST['message'] = wp_kses(trim(stripslashes($_POST['message'])), '');
}
if ($this->no_participation == 0 && $_POST['message'] != '') {
if ($this->user_status != 0) {
$_POST['message'] = $this->filter($_POST['message'], isset($this->options['replace_inside_bad_words']) ? true : false);
}
if (isset($this->options['hyperlinks'])) {
$_POST['message'] = links_add_target(make_clickable($_POST['message']));
}
$wpdb->query('INSERT INTO ' . $quick_chat_messages_table_name . ' (wpid, room, timestamp, alias, status, ip, message) VALUES ( "' . $this->user_id . '", "' . esc_sql($_POST['room']) . '", NOW(), "' . ($_POST['sys_mes'] == 'true' ? 'quick_chat' : esc_sql($this->user_name)) . '", ' . $this->user_status . ', "' . $this->user_ip . '", "' . esc_sql($_POST['message']) . '");');
}
$response = json_encode(array('no_participation' => $this->no_participation));
header("Content-Type: application/json");
echo $response;
exit;
}
示例15: filterCommentText
/**
* Spruces up the comment text when displaying a comment.
*
* Chat messages are stored as comments in the WordPress database
* so this filter takes the text (typically a single line) and
* adds some basic expected functionality like turning links to
* images into inline images, and parsing simple markdown.
*
* @link https://developer.wordpress.org/reference/hooks/comment_text/
*
* @uses Parsedown::text()
* @uses links_add_target()
*
* @param string $comment_text
*
* @return string
*/
public static function filterCommentText($comment_text)
{
// Detect any URLs that point to recognized images, and embed them.
$pat = '!(?:([^:/?#\\s]+):)?(?://([^/?#]*))?([^?#\\s]*\\.(jpe?g|JPE?G|gif|GIF|png|PNG))(?:\\?([^#]*))?(?:#(.*))?!';
$rep = '<a href="$0"><img src="$0" alt="[' . sprintf(esc_attr__('%1$s image from %2$s', 'buoy'), '.$4 ', '$2') . ']" style="max-width:100%;" /></a>';
$comment_text = preg_replace($pat, $rep, $comment_text);
// Finally, parse the result as markdown for more formatting
if (!class_exists('Parsedown')) {
require_once dirname(__FILE__) . '/includes/vendor/wp-screen-help-loader/vendor/parsedown/Parsedown.php';
}
$comment_text = Parsedown::instance()->text($comment_text);
return links_add_target($comment_text);
}