本文整理汇总了PHP中wp_specialchars函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_specialchars函数的具体用法?PHP wp_specialchars怎么用?PHP wp_specialchars使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_specialchars函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: title
function title()
{
if (is_category()) {
echo 'Category Archive for "';
single_cat_title();
echo '" | ';
bloginfo('name');
} elseif (is_tag()) {
echo 'Tag Archive for "';
single_tag_title();
echo '" | ';
bloginfo('name');
} elseif (is_archive()) {
wp_title('');
echo ' Archive | ';
bloginfo('name');
} elseif (is_search()) {
echo 'Search for "' . wp_specialchars($s) . '" | ';
bloginfo('name');
} elseif (is_home() || is_front_page()) {
bloginfo('name');
echo ' | ';
bloginfo('description');
} elseif (is_404()) {
echo 'Error 404 Not Found | ';
bloginfo('name');
} elseif (is_single()) {
wp_title('');
} else {
echo wp_title(' | ', false, right);
bloginfo('name');
}
}
开发者ID:indee,项目名称:indee-website,代码行数:33,代码来源:globals.func.php
示例2: wp_generate_product_tag_cloud
function wp_generate_product_tag_cloud($tags, $args = '')
{
global $wp_rewrite;
$defaults = array('smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45, 'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC');
$args = wp_parse_args($args, $defaults);
extract($args);
if (!$tags) {
return;
}
$counts = $tag_links = array();
foreach ((array) $tags as $tag) {
$counts[$tag->name] = $tag->count;
$tag_links[$tag->name] = get_product_tag_link($tag->term_id);
if (is_wp_error($tag_links[$tag->name])) {
return $tag_links[$tag->name];
}
$tag_ids[$tag->name] = $tag->term_id;
}
$min_count = min($counts);
$spread = max($counts) - $min_count;
if ($spread <= 0) {
$spread = 1;
}
$font_spread = $largest - $smallest;
if ($font_spread <= 0) {
$font_spread = 1;
}
$font_step = $font_spread / $spread;
// SQL cannot save you; this is a second (potentially different) sort on a subset of data.
if ('name' == $orderby) {
uksort($counts, 'strnatcasecmp');
} else {
asort($counts);
}
if ('DESC' == $order) {
$counts = array_reverse($counts, true);
}
$a = array();
$rel = is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ? ' rel="tag"' : '';
foreach ($counts as $tag => $count) {
$tag_id = $tag_ids[$tag];
$tag_link = clean_url($tag_links[$tag]);
$tag = str_replace(' ', ' ', wp_specialchars($tag));
$a[] = "<a href='{$tag_link}' class='tag-link-{$tag_id}' title='" . attribute_escape(sprintf(__('%d topics'), $count)) . "'{$rel} style='font-size: " . ($smallest + ($count - $min_count) * $font_step) . "{$unit};'>{$tag}</a>";
}
switch ($format) {
case 'array':
$return =& $a;
break;
case 'list':
$return = "<ul class='product_tag_cloud'>\n\t<li>";
$return .= join("</li>\n\t<li>", $a);
$return .= "</li>\n</ul>\n";
break;
default:
$return = join("\n", $a);
break;
}
return apply_filters('wp_generate_product_tag_cloud', $return, $tags, $args);
}
开发者ID:BGCX261,项目名称:zombie-craft-svn-to-git,代码行数:60,代码来源:tagging_functions.php
示例3: jj_ngg_jquery_carousel_shortcode_handler
function jj_ngg_jquery_carousel_shortcode_handler($atts)
{
$instance = array();
foreach ($atts as $att => $val) {
$instance[wp_specialchars($att)] = wp_specialchars($val);
}
// Set defaults
if (WPJJNGGJ_CAROUSEL_use_default($instance, 'html_id')) {
$instance['html_id'] = 'jcarousel';
}
if (WPJJNGGJ_CAROUSEL_use_default($instance, 'order')) {
$instance['order'] = 'random';
}
if (WPJJNGGJ_CAROUSEL_use_default($instance, 'scroll')) {
$instance['scroll'] = '1';
}
if (WPJJNGGJ_CAROUSEL_use_default($instance, 'visible')) {
$instance['visible'] = '1';
}
if (WPJJNGGJ_CAROUSEL_use_default($instance, 'wrap')) {
$instance['wrap'] = 'circular';
}
$instance['shortcode'] = '1';
ob_start();
the_widget("JJ_NGG_JQuery_Carousel", $instance, array());
$output = ob_get_contents();
ob_end_clean();
return $output;
}
开发者ID:blocher,项目名称:oneholyname,代码行数:29,代码来源:functions.php
示例4: apanel_gateways_html
public function apanel_gateways_html($atts, $content)
{
// global $wp_widget_factory;
//
// extract(shortcode_atts(array(
// 'widget_name' => FALSE
// ), $atts));
//
// $widget_name = wp_specialchars($widget_name);
//
// if (!is_a($wp_widget_factory->widgets[$widget_name], 'WP_Widget')):
// $wp_class = 'WP_Widget_'.ucwords(strtolower($class));
//
// if (!is_a($wp_widget_factory->widgets[$wp_class], 'WP_Widget')):
// return '<p>'.sprintf(__("%s: Widget class not found. Make sure this widget exists and the class name is correct"),'<strong>'.$class.'</strong>').'</p>';
// else:
// $class = $wp_class;
// endif;
// endif;
$widget_name = wp_specialchars('Skc_Apanel_Gateways_Widget');
ob_start();
the_widget($widget_name, $instance, array('widget_id' => 'arbitrary-instance-' . $id, 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => ''));
$output = ob_get_contents();
ob_end_clean();
return $output;
}
开发者ID:Krakt,项目名称:skc-plugin,代码行数:26,代码来源:apanelgateways.php
示例5: thematic_search_form
function thematic_search_form($echo = true)
{
$search_form = "\n" . "\t";
$search_form .= '<form id="searchbox" method="get" action="' . get_bloginfo('home') . '">';
$search_form .= "\n" . "\t" . "\t";
$search_form .= '<div>';
$search_form .= "\n" . "\t" . "\t" . "\t";
if (is_search()) {
$search_form .= '<input id="s" name="s" type="search" placeholder="' . wp_specialchars(stripslashes($_GET['s']), true) . '" size="32" tabindex="1" />';
} else {
$value = __('To search, type and hit enter', 'thematic');
$value = apply_filters('search_field_value', $value);
$search_form .= '<input id="s" name="s" type="text" value="' . $value . '" onfocus="if (this.value == \'' . $value . '\') {this.value = \'\';}" onblur="if (this.value == \'\') {this.value = \'' . $value . '\';}" size="32" tabindex="1" />';
}
$search_form .= "\n" . "\t" . "\t" . "\t";
$search_submit = '<input id="searchsubmit" name="searchsubmit" type="submit" value="' . __('Search', 'thematic') . '" tabindex="2" />';
$search_form .= apply_filters('thematic_search_submit', $search_submit);
$search_form .= "\n" . "\t" . "\t";
$search_form .= '</div>';
$search_form .= "\n" . "\t";
$search_form .= '</form>';
if ($echo) {
echo apply_filters('thematic_search_form', $search_form);
} else {
return apply_filters('thematic_search_form', $search_form);
}
}
开发者ID:jentanbernardus,项目名称:Thematic-html5boilerplate,代码行数:27,代码来源:widgets-extensions.php
示例6: pdf24Plugin_widgetControl
function pdf24Plugin_widgetControl()
{
if ($_POST['pdf24PluginSubmit']) {
update_option('pdf24Plugin_sbpStyle', $_POST['pdf24Plugin-sbpStyle']);
update_option('pdf24Plugin_widgetTitle', $_POST['pdf24Plugin-widget-title']);
}
$styleParms = pdf24Plugin_getStyleParams('pdf24Plugin_sbpStyle', 'styles/sbp');
?>
<p style="text-align:left; line-height: 100%;">
<label for="pdf24Plugin-widget-title" style="line-height:25px;display:block;">
<?php
_e('Title:');
?>
<br />
<input style="width:100%" type="text" id="pdf24Plugin-widget-title" name="pdf24Plugin-widget-title" value="<?php
echo wp_specialchars(pdf24Plugin_getWidgetTitle(), true);
?>
" />
</label>
<label for="pdf24Plugin-sbpStyle" style="line-height:25px;display:block;">
<?php
_e('Style:');
?>
<br />
<select id="pdf24Plugin-sbpStyle" name="pdf24Plugin-sbpStyle">
<?php
echo $styleParms['options'];
?>
</select>
</label>
<input type="hidden" name="pdf24PluginSubmit" id="pdf24PluginSubmit" value="1" />
</p>
<?php
}
开发者ID:besimhu,项目名称:legacy,代码行数:35,代码来源:widgetControl.php
示例7: widget_subpagehierarchy_page_rows
function widget_subpagehierarchy_page_rows($headpage, $parent = 0, $level = 0, $pages = 0)
{
global $wpdb, $class, $post;
if (!$pages) {
$pages = $wpdb->get_results("SELECT * FROM {$wpdb->posts} WHERE post_status = 'static' ORDER BY menu_order");
}
if ($pages) {
foreach ($pages as $post) {
start_wp();
if ($post->post_parent == $parent) {
$post->post_title = wp_specialchars($post->post_title);
$pad = str_repeat('—', $level);
$id = $post->ID;
if ($id == $headpage) {
$selectString = ' selected';
} else {
unset($selectString);
}
$class = 'alternate' == $class ? '' : 'alternate';
echo ' <option value="' . $post->ID . '"' . $selectString . ">{$pad}" . $post->post_title . "</option>\n";
widget_subpagehierarchy_page_rows($headpage, $id, $level + 1, $pages);
}
}
} else {
return false;
}
}
开发者ID:64kbytes,项目名称:stayinba,代码行数:27,代码来源:ldpagehierarchy.php
示例8: the_content_rss
function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
$content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = apply_filters('the_content_rss', $content);
if ( $cut && !$encode_html )
$encode_html = 2;
if ( 1== $encode_html ) {
$content = wp_specialchars($content);
$cut = 0;
} elseif ( 0 == $encode_html ) {
$content = make_url_footnote($content);
} elseif ( 2 == $encode_html ) {
$content = strip_tags($content);
}
if ( $cut ) {
$blah = explode(' ', $content);
if ( count($blah) > $cut ) {
$k = $cut;
$use_dotdotdot = 1;
} else {
$k = count($blah);
$use_dotdotdot = 0;
}
for ( $i=0; $i<$k; $i++ )
$excerpt .= $blah[$i].' ';
$excerpt .= ($use_dotdotdot) ? '...' : '';
$content = $excerpt;
}
$content = str_replace(']]>', ']]>', $content);
echo $content;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:30,代码来源:feed.php
示例9: __construct
function __construct()
{
global $email, $opt, $tml;
$this->post_author = __("Thank Me Later", "thankmelater");
$this->post_date = date("Y-m-d H:i:s");
$this->guid = get_bloginfo('url') . "?tmloptout";
$this->post_title = __("E-mail Preferences", "thankmelater");
$this->post_content = '<form method="get" action="' . htmlspecialchars(get_bloginfo('url')) . '">';
$this->post_content .= '<input type="hidden" name="tmloptout" value="" />';
$this->post_content .= '<p>' . sprintf(__("This page allows you to opt-out or subscribe to 'Thank Me Later' e-mails. These are e-mails sent when you leave a comment at %s.", "thankmelater"), wp_specialchars(get_bloginfo("name"))) . '</p>';
if ($email) {
$this->post_content .= '<input type="hidden" name="email" value="' . attribute_escape($email) . '" />';
$this->post_content .= '<p>' . sprintf(__("Your e-mail address: <strong>%s</strong>", "thankmelater"), wp_specialchars($email)) . '</p>';
if ($opt) {
$this->post_content .= '<p>' . __("You are currently <strong>subscribed</strong> to receive e-mails. Click 'Opt Out' if you wish to opt-out of these e-mails:", "thankmelater") . '</p>';
$this->post_content .= '<input type="hidden" name="opt" value="0" />';
$this->post_content .= '<p><input type="submit" value="' . __("Opt Out", "thankmelater") . '" name="submit" style="font-weight: bold;" /></p>';
} else {
$this->post_content .= '<p>' . __("You are <strong>not subscribed</strong> to receive e-mails. Click 'Opt In' if you wish to receive e-mails again:", "thankmelater") . '</p>';
$this->post_content .= '<input type="hidden" name="opt" value="1" />';
$this->post_content .= '<p><input type="submit" value="' . __("Opt In", "thankmelater") . '" name="submit" style="font-weight: bold;" /></p>';
}
} else {
$this->post_content .= '<p>' . sprintf(__("Your e-mail address: <strong>%s</strong>", "thankmelater"), '<input type="text" name="email" value="" />') . '</p>';
$this->post_content .= '<p><input type="submit" value="' . __("Get Preferences »", "thankmelater") . '" name="submit" style="font-weight: bold;" /></p>';
}
// don't allow opt outs
if (!$tml->get_option("allow_opt_out")) {
$this->post_content = "<p>" . __("Sorry, this feature is disabled.", "thankmelater") . "</p>";
}
}
开发者ID:niko-lgdcom,项目名称:archives,代码行数:31,代码来源:opt_out.php
示例10: ufandshands_widget_shortcode
function ufandshands_widget_shortcode($atts)
{
global $wp_widget_factory;
extract(shortcode_atts(array('widget_name' => FALSE, 'title' => '', 'numberofposts' => '3', 'showexcerpt' => 1, 'showthumbnails' => 1, 'showdate' => 1, 'showrssicon' => 1, 'specific_category_id' => ''), $atts));
$widget_name = wp_specialchars($widget_name);
if (!is_a($wp_widget_factory->widgets[$widget_name], 'WP_Widget')) {
$wp_class = 'WP_Widget_' . ucwords(strtolower($class));
if (!is_a($wp_widget_factory->widgets[$wp_class], 'WP_Widget')) {
return '<p>' . sprintf(__("%s: Widget class not found. Make sure this widget exists and the class name is correct"), '<strong>' . $class . '</strong>') . '</p>';
} else {
$class = $wp_class;
}
}
$instance = '&title=' . $title;
$instance .= '&numberofposts=' . $numberofposts;
$instance .= '&showexcerpt=' . $showexcerpt;
$instance .= '&showthumbnails=' . $showthumbnails;
$instance .= '&showdate=' . $showdate;
$instance .= '&showrssicon=' . $showrssicon;
$instance .= '&specific_category_id=' . $specific_category_id;
// $instance .= '&='.$;
ob_start();
the_widget($widget_name, $instance, array('widget_id' => 'arbitrary-instance-' . $id, 'before_widget' => '<div class="widget_body">', 'after_widget' => '</div>', 'before_title' => '<h3>', 'after_title' => '</h3>'));
$output = ob_get_contents();
ob_end_clean();
return $output;
}
开发者ID:sezj,项目名称:ufl-template-responsive,代码行数:27,代码来源:shortcodes.php
示例11: thematic_search_form
function thematic_search_form($echo = true)
{
global $my_shortname;
$search_form = "\n" . "\t";
$search_form .= '<form id="searchbox" method="get" action="' . get_bloginfo('home') . '" role="search">';
$search_form .= "\n" . "\t" . "\t";
$search_form .= '<div>';
$search_form .= "\n" . "\t" . "\t" . "\t";
if (is_search()) {
$search_form .= '<input id="s" name="s" type="search" placeholder="' . wp_specialchars(stripslashes($_GET['s']), true) . '" size="32" tabindex="1" autofocus>';
} else {
$value = __('Type to Find', $my_shortname);
$value = apply_filters('search_field_value', $value);
$search_form .= '<input id="s" name="s" type="search" placeholder="' . $value . '" size="32" tabindex="1">';
}
$search_form .= "\n" . "\t" . "\t" . "\t";
$search_submit = '<input id="searchsubmit" name="searchsubmit" type="submit" value="' . __('go', $my_shortname) . '" tabindex="2">';
$search_form .= apply_filters('thematic_search_submit', $search_submit);
$search_form .= "\n" . "\t" . "\t";
$search_form .= '</div>';
$search_form .= "\n" . "\t";
$search_form .= '</form>';
if ($echo) {
echo apply_filters('thematic_search_form', $search_form);
} else {
return apply_filters('thematic_search_form', $search_form);
}
}
开发者ID:sams,项目名称:Thematic-html5boilerplate,代码行数:28,代码来源:widgets-extensions.php
示例12: admin_filter_action
function admin_filter_action($string, $action)
{
if (strpos($string, '?') === false) {
return $string .= "?action={$action}";
} else {
return $string .= wp_specialchars("&action={$action}");
}
}
开发者ID:mroussel,项目名称:flatpress,代码行数:8,代码来源:main.php
示例13: cargopress_title
function cargopress_title() {
if ( is_single() ) { single_post_title(); }
elseif ( is_home() || is_front_page() ) { bloginfo('name'); print ' | '; bloginfo('description'); get_page_number(); }
elseif ( is_page() ) { single_post_title(''); }
elseif ( is_search() ) { bloginfo('name'); print ' | Search results for ' . wp_specialchars($s); get_page_number(); }
elseif ( is_404() ) { bloginfo('name'); print ' | Not Found'; }
else { bloginfo('name'); wp_title('|'); get_page_number(); }
}
开发者ID:nebirhos,项目名称:cargopress,代码行数:8,代码来源:functions.php
示例14: admin_getpanellink
function admin_getpanellink($page, $action, $command = '')
{
$link = BLOG_BASEURL . 'admin.php?p=' . $page . '&action=' . $action;
if ($command) {
$link .= '&' . $command;
}
return wp_specialchars(apply_filter('admin_panel_link', $link, $page, $action, $command));
}
开发者ID:mroussel,项目名称:flatpress,代码行数:8,代码来源:core.administration.php
示例15: start_el
function start_el(&$output, $category, $depth, $args)
{
extract($args);
$input_id = $this->input_id . '-' . $category->term_id;
$output .= "\n" . '<li id="' . $this->li_id . '">';
$output .= '<label for="' . $input_id . '" class="selectit">';
$output .= '<input value="' . $category->term_id . '" type="checkbox" name="' . $this->input_name . '[' . $category->term_id . ']" id="' . $input_id . '"' . (in_array($category->term_id, $selected_cats) ? ' checked="checked"' : "") . '/> ' . wp_specialchars(apply_filters('the_category', $category->name)) . '</label>';
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:8,代码来源:avh-ec.widgets.php
示例16: wpsq_display_quiz
function wpsq_display_quiz($quizzes, $options = null)
{
?>
<div class="wrap">
<div class="tablenav" style="height:80px">
<form name="searchform" id="searchform" action="admin.php" method="get">
<input type="hidden" name="page" value="slick-quiz" />
<fieldset><legend>Search Quiz Title…</legend>
<input type="text" name="search" id="search" value="<?php
echo $options['search'];
?>
" size="17" />
<input type="submit" value="Filter »" class="button-secondary" />
</fieldset>
<p>How to set up the Quiz ?<br>
Copy and Paste the quizID (ex: [wpsq-quiz=1]) into your TITLE <b>and</b> BODY field on a Post/Page.<br />
And then Your quiz will be set up automatically.</p>
</form>
</div>
<br style="clear:both;" />
<table class="widefat">
<thead>
<tr>
<th scope="col"><div style="text-align: center">QuizID</div></th>
<th scope="col">Title</th>
<th scope="col"></th>
<th scope="col"></th>
</tr>
</thead>
<tbody id="the-list">
<?php
$cnt = 0;
foreach ($quizzes as $quiz) {
$link = "admin.php?page=wpsq-addedit&task=delete&quiz_id=" . $quiz->quiz_id;
echo "<tr " . ($cnt % 2 == 0 ? ' class="alternate"' : '') . ">\n";
echo "<th scope=\"row\" style=\"text-align: center\" width=\"100\">[wpsq-quiz=" . $quiz->quiz_id . "]</th>\n";
echo "<td width=\"300\">" . wp_specialchars($quiz->quiz_title) . "</td>\n";
echo "<td width=\"50\"><a href=\"admin.php?page=wpsq-addedit&task=edit&quiz_id=" . $quiz->quiz_id . "\" class=\"edit\">Edit</a></td>\n";
echo "<td width=\"50\"><a href=\"" . $link . "\" class=\"delete\" >Delete</a></td>\n";
echo "</tr>\n";
}
?>
</tbody>
</table>
<div class="tablenav">
<br class="clear"/>
</div>
</div>
<?php
}
开发者ID:kh411d,项目名称:wordpress_slick_quiz,代码行数:56,代码来源:wpsq-manage-quiz.php
示例17: mystique_xtranav_icons
function mystique_xtranav_icons($nav_extra)
{
if (get_mystique_option('xtranav_twitter')) {
$nav_extra .= '<a href="http://twitter.com/' . wp_specialchars(get_mystique_option('xtranav_twitter')) . '" class="nav-extra twitter" title="' . __("Follow me on Twitter", "mystique") . '"><span>' . __("Follow me on Twitter", "mystique") . '</span></a>';
}
if (get_mystique_option('xtranav_rss')) {
$nav_extra .= '<a href="' . wp_specialchars(get_mystique_option('xtranav_rss')) . '" class="nav-extra rss" title="' . __("RSS Feeds", "mystique") . '"><span>' . __("RSS Feeds", "mystique") . '</span></a>';
}
return $nav_extra;
}
开发者ID:nottombrown,项目名称:vlab,代码行数:10,代码来源:xtra-nav.php
示例18: vicuna_tag_cloud
/**
* Display a tag clouds.
*/
function vicuna_tag_cloud($args = '')
{
global $wp_rewrite;
$defaults = array('levels' => 6, 'orderby' => 'name', 'order' => 'ASC', 'exclude' => '', 'include' => '');
$args = wp_parse_args($args, $defaults);
$tags = get_tags(array_merge($args, array('orderby' => 'count', 'order' => 'ASC')));
// Always query top tags
if (empty($tags)) {
return;
}
extract($args);
if (!$tags) {
return;
}
$counts = $tag_links = array();
foreach ((array) $tags as $tag) {
$counts[$tag->name] = $tag->count;
$tag_links[$tag->name] = get_tag_link($tag->term_id);
if (is_wp_error($tag_links[$tag->name])) {
return $tag_links[$tag->name];
}
$tag_ids[$tag->name] = $tag->term_id;
}
$min_count = min($counts);
$step = (int) ((max($counts) - $min_count) / $levels) + 1;
if ($step <= 1) {
$step = 1;
}
// SQL cannot save you; this is a second (potentially different) sort on a subset of data.
if ('name' == $orderby) {
uksort($counts, 'strnatcasecmp');
} else {
asort($counts);
}
if ('DESC' == $order) {
$counts = array_reverse($counts, true);
}
$a = array();
$rel = is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ? ' rel="tag"' : '';
foreach ($counts as $tag => $count) {
$tag_id = $tag_ids[$tag];
$tag_link = clean_url($tag_links[$tag]);
$level = $levels - (int) (($count - $min_count) / $step);
$tag = str_replace(' ', ' ', wp_specialchars($tag));
$a[] = "<li class=\"level" . $level . "\"><a href=\"{$tag_link}\" title=\"" . attribute_escape(sprintf(__('%d Entries', 'vicuna'), $count)) . "\"{$rel}>{$tag}</a></li>";
}
$return = "<ul class=\"tagCloud\">\n\t";
$return .= join("\n\t", $a);
$return .= "\n</ul>\n";
if (is_wp_error($return)) {
return false;
} else {
echo apply_filters('vicuna_tag_cloud', $return, $tags, $args);
}
}
开发者ID:nakaji0213,项目名称:wp.vicuna.ext,代码行数:58,代码来源:tag.php
示例19: fup_upload_action
function fup_upload_action()
{
global $action, $fup_key;
if ($action == 'upload') {
if (!is_array($_FILES['image']['error'])) {
return;
}
global $from_tab, $post_id, $style;
if (!$from_tab) {
$from_tab = 'upload';
}
check_admin_referer('inlineuploading');
global $post_id, $post_title, $post_content;
if (!current_user_can('upload_files')) {
wp_die(__('You are not allowed to upload files.', 'fup') . " <a href='" . get_option('siteurl') . "/wp-admin/upload.php?style=" . attribute_escape($style . "&tab=browse-all&post_id={$post_id}") . "'>" . __('Browse Files', 'fup') . '</a>');
}
$overrides = array('action' => 'upload');
$errors = array();
$successed = array();
foreach ($_FILES['image']['error'] as $key => $value) {
if ($value == 4) {
$errors[] = "File {$key}(" . wp_specialchars($_FILES['image']['name'][$key]) . "): " . __("No file was uploaded.", 'fup');
continue;
}
$the_file = array('name' => $_FILES['image']['name'][$key], 'type' => $_FILES['image']['type'][$key], 'tmp_name' => $_FILES['image']['tmp_name'][$key], 'error' => $_FILES['image']['error'][$key], 'size' => $_FILES['image']['size'][$key]);
$file = wp_handle_upload($the_file, $overrides);
if (isset($file['error'])) {
$errors[] = "File {$key}: " . $file['error'];
continue;
}
$url = $file['url'];
$type = $file['type'];
$file = $file['file'];
$filename = basename($file);
// Construct the attachment array
$attachment = array('post_title' => $post_title[$key] ? $post_title[$key] : $filename, 'post_content' => $post_content[$key], 'post_type' => 'attachment', 'post_parent' => $post_id, 'post_mime_type' => $type, 'guid' => $url);
$fup_key = $key;
// Resize image and create thumbnail if applicable
fup_resize_and_thumbnail($file);
// Save the data
$id = wp_insert_attachment($attachment, $file, $post_id);
wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $file));
$successed[] = $filename;
}
if (empty($successed)) {
wp_die(implode('<br />', $errors) . "<br /><a href='" . get_option('siteurl') . "/wp-admin/upload.php?style={$style}&tab={$from_tab}&post_id={$post_id}'>" . __('Back to Image Uploading', 'fup') . '</a>');
}
if (count($successed) > 1) {
wp_redirect(get_option('siteurl') . "/wp-admin/upload.php?style={$style}&tab=browse&post_id={$post_id}");
} else {
wp_redirect(get_option('siteurl') . "/wp-admin/upload.php?style={$style}&tab=browse&action=view&ID={$id}&post_id={$post_id}");
}
die;
}
}
开发者ID:64kbytes,项目名称:stayinba,代码行数:55,代码来源:flexible-upload-wp21.php
示例20: start_el
function start_el(&$output, $page, $depth, $args)
{
extract($args);
$checked = "";
if ($selected_cats === true || in_array($page->ID, $selected_cats)) {
$checked = ' checked="checked"';
}
$output .= "\n<li>";
$output .= '<label class="selectit"><input value="' . $page->ID;
$output .= '" type="checkbox" name="' . $fieldName . '" id="in-page-' . $page->ID . '"';
$output .= $checked . '/> ';
$output .= wp_specialchars(apply_filters('the_title', $page->post_title)) . '</label>';
}
开发者ID:soska,项目名称:dte,代码行数:13,代码来源:misc.classes.php
注:本文中的wp_specialchars函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论