本文整理汇总了PHP中get_catname函数的典型用法代码示例。如果您正苦于以下问题:PHP get_catname函数的具体用法?PHP get_catname怎么用?PHP get_catname使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_catname函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _cat_row
function _cat_row($category, $level, $name_override = false)
{
global $class;
$pad = str_repeat('— ', $level);
if (current_user_can('manage_categories')) {
$edit = "<a href='categories.php?action=edit&cat_ID={$category->term_id}' class='edit'>" . __('Edit') . "</a></td>";
$default_cat_id = (int) get_option('default_category');
if ($category->term_id != $default_cat_id) {
$edit .= "<td><a href='" . wp_nonce_url("categories.php?action=delete&cat_ID={$category->term_id}", 'delete-category_' . $category->term_id) . "' onclick=\"return deleteSomething( 'cat', {$category->term_id}, '" . js_escape(sprintf(__("You are about to delete the category '%s'.\nAll posts that were only assigned to this category will be assigned to the '%s' category.\nAll links that were only assigned to this category will be assigned to the '%s' category.\n'OK' to delete, 'Cancel' to stop."), $category->name, get_catname($default_cat_id), get_catname($default_link_cat_id))) . "' );\" class='delete'>" . __('Delete') . "</a>";
} else {
$edit .= "<td style='text-align:center'>" . __("Default");
}
} else {
$edit = '';
}
$class = defined('DOING_AJAX') && DOING_AJAX || " class='alternate'" == $class ? '' : " class='alternate'";
$category->count = number_format_i18n($category->count);
$posts_count = $category->count > 0 ? "<a href='edit.php?cat={$category->term_id}'>{$category->count}</a>" : $category->count;
$output = "<tr id='cat-{$category->term_id}'{$class}>\n\t\t<th scope='row' style='text-align: center'>{$category->term_id}</th>\n\t\t<td>" . ($name_override ? $name_override : $pad . ' ' . $category->name) . "</td>\n\t\t<td>{$category->description}</td>\n\t\t<td align='center'>{$posts_count}</td>\n\t\t<td>{$edit}</td>\n\t</tr>\n";
return apply_filters('cat_row', $output);
}
示例2: display_entry
function display_entry($post)
{
$category = get_catname($post->category);
?>
<h3><?php
echo $post->title;
?>
</h3>
<a href="<?php
echo 'http://127.0.0.1/blog/show_cat.php?id=' . $post->category;
?>
"><p><?php
echo $category;
?>
</p></a>
<p><?php
echo $post->body;
?>
</p>
<?php
echo "<hr>";
}
示例3: getAllCats
function getAllCats($force = false)
{
/*
* gets all published site categories (same format as getAllTags)
*/
if (is_null($this->_allcats) || $force) {
global $wpdb;
$q = "SELECT p2c.category_id AS cat_id, COUNT(p2c.rel_id) AS numposts,\r\n UNIX_TIMESTAMP(max(p.post_date_gmt)) + '" . get_option('gmt_offset') . "' AS last_post_date,\r\n UNIX_TIMESTAMP(max(p.post_date_gmt)) AS last_post_date_gmt\r\n FROM {$wpdb->post2cat} p2c\r\n INNER JOIN {$wpdb->posts} p ON p2c.post_id=p.id\r\n WHERE (p.post_status='publish' OR p.post_status='static')\r\n AND p.post_date_gmt<='" . gmdate("Y-m-d H:i:s", time()) . "'\r\n GROUP BY p2c.category_id\r\n ORDER BY numposts DESC ";
$results = $wpdb->get_results($q);
$allcats = array();
if (!is_null($results) && is_array($results)) {
foreach ($results as $cat) {
$catname = get_catname($cat->cat_id);
$allcats[$catname] = array('name' => get_catname($cat->cat_id), 'count' => $cat->numposts, 'link' => get_category_link((int) $cat->cat_id));
}
}
$this->_allcats =& $allcats;
}
return $this->_allcats;
}
示例4: get_catname
case 'delete-page' :
$id = (int) $_POST['id'];
if ( !current_user_can('edit_post', $id) ) {
die('-1');
}
if ( wp_delete_post($id) ) {
die('1');
} else die('0');
break;
case 'delete-cat' :
if ( !current_user_can('manage_categories') )
die ('-1');
$id = (int) $_POST['id'];
$cat_name = get_catname($cat_ID);
if ( wp_delete_category($id) )
die('1');
else die('0');
break;
case 'delete-comment' :
$id = (int) $_POST['id'];
if ( !$comment = get_comment($id) )
die('0');
if ( !current_user_can('edit_post', $comment->comment_post_ID) )
die('-1');
if ( wp_delete_comment($comment->comment_ID) ) {
die('1');
示例5: cfgp_clone_post_on_publish
function cfgp_clone_post_on_publish($post_id, $post)
{
global $wpdb;
/* Allow for draft, pending, trash as well as publish - a published post can transition into these */
if (!in_array($post->post_status, array('publish', 'draft', 'pending', 'trash'))) {
return;
}
/* Get the Shadow Blog's ID */
$cfgp_blog_id = cfgp_get_shadow_blog_id();
/* Get the current blog's id */
$current_blog_id = $wpdb->blogid;
/* Check to see if we're inserting the post, or updating an existing */
$clone_post_id = cfgp_are_we_inserting($post->ID);
/* Get all the post_meta for current post */
$all_post_meta = get_post_custom($post->ID);
/* Grab the Permalink of the post, so the shadow blog knows how to get back to the post */
$permalink = get_permalink($post->ID);
switch_to_blog($cfgp_blog_id);
/************
* POST WORK *
************/
$old_post_id = $post->ID;
$clone_id = cfgp_do_the_post($post, $clone_post_id);
$post->ID = $old_post_id;
/****************
* CATEGORY WORK *
****************/
/* Grab category names that the current post belongs to. */
if (isset($_POST['post_category']) && is_array($_POST['post_category']) && count($_POST['post_category']) > 0) {
/* Post has categories */
$cur_cats = $_POST['post_category'];
} else {
/* Post doesn't have any categories, assign to 'Uncategorized' */
$cur_cats = array(get_cat_ID('Uncategorized'));
}
/* We have id's, now get the names */
foreach ($cur_cats as $cat) {
$cur_cats_names[] = get_catname($cat);
}
/* Add categories to clone post */
$cat_results = cfgp_do_categories($clone_id, $cur_cats_names);
/***********
* TAG WORK *
***********/
/* tags changed in 2.8, so we need to see if we're >= 2.8 */
global $wp_version;
if (version_compare($wp_version, '2.8', '>=')) {
$tags = $_POST['tax_input']['post_tag'];
} else {
$tags = $_POST['tags_input'];
}
/* Add tags to clone post */
$tag_results = cfgp_do_tags($clone_id, $tags);
/******************
* MORE TAXONOMIES *
******************/
do_action('cfgp_clone_post_taxonomies', compact('clone_id', 'post'));
/*****************
* POST META WORK *
*****************/
/* Add original post's postmeta to clone post */
$post_meta_results = apply_filters('cfgp_do_post_meta', array(), $clone_id, $current_blog_id, $all_post_meta, $permalink, $old_post_id);
restore_current_blog();
/* Add post_meta to the original
* post of the clone's post id */
update_post_meta($post->ID, '_cfgp_clone_id', $clone_id);
/* This is a handy array of results, for troubleshooting
* they're not returned on post publish, but can be put
* out to the error log */
$single_post_results[] = array('original_post' => $post->ID, 'clone_id' => $clone_id, 'cat_results' => $cat_results, 'tag_results' => $tag_results, 'post_meta_results' => $post_meta_results);
}
示例6: archive_header
function archive_header($before = '', $after = '')
{
global $post, $orderby, $month, $previous, $siteurl, $blogfilename, $archiveheadstart, $archiveheadend, $category_name;
$orderby = explode(' ', $orderby);
$orderby = $orderby[0];
if ('date' == $orderby || empty($orderby)) {
$thismonth = mysql2date('m', $post->post_date);
$thisyear = mysql2date('Y', $post->post_date);
$thisdate = $thisyear . $thismonth;
if ($thisdate != $previous) {
$thismonth = mysql2date('m', $post->post_date);
$output .= '<strong><br/><a href="' . get_month_link($thisyear, $thismonth) . '">' . $thisyear . '年' . $month[$thismonth] . '</a></strong>';
}
$previous = $thisdate;
} elseif ('title' == $orderby) {
$thisletter = ucfirst(mb_substr($post->yomi, 0, 1, $GLOBALS['blog_charset']));
if ($thisletter > "ん") {
$thisletter = "漢字";
}
if ($thisletter != $previous) {
$output .= "<br/>" . $thisletter;
}
$previous = $thisletter;
} elseif ('category' == $orderby) {
$thiscategory = $category_name;
if ($thiscategory != $previous) {
$output .= '<br/><strong><a href="' . get_category_link(false, $thiscategory) . '">' . get_catname($thiscategory) . '</a></strong>';
}
$previous = $thiscategory;
}
if (!empty($output)) {
$output = $before . $output . $after . NL;
echo $output;
}
}
示例7: get_all_category_ids
}
$cats = get_all_category_ids();
if (!$cats) {
echo "<p align='center'><strong>No Categories Found</strong></p>";
return;
}
?>
<fieldset class='move_options'>
<table width="100%" cellpadding="3" cellspacing="3" style="text-align: left; vertical-align: top;">
<form method='POST'>
<tr class="alternate"><th width="75%">Category</th><th width="25%">Destination</th></tr>
<input type='hidden' name='wpadp_move_options' value='update'>
<?php
foreach ($cats as $i => $value) {
echo "<tr>";
$catname = get_catname($cats[$i]);
if ($cats[$i] == $selCat) {
$preMod = "<strong>";
$postMod = "</strong>";
$checked = "checked='checked'";
} else {
$preMod = "";
$postMod = "";
$checked = "";
}
echo "<td>{$preMod}{$catname}{$postMod}</td>";
echo "<td><input type='radio' name='{$inputName}' value='{$cats[$i]}' {$checked}></td>";
echo "</tr>";
}
?>
<tr><td align='right' colspan='2'><input type='submit' name='submit' value='Update Options'></td></tr>
示例8: archive_header
function archive_header($before = '', $after = '')
{
$GLOBALS['orderby'] = explode(' ', $GLOBALS['orderby']);
$GLOBALS['orderby'] = $GLOBALS['orderby'][0];
if ('date' == $GLOBALS['orderby'] || empty($GLOBALS['orderby'])) {
$thismonth = mysql2date('m', $GLOBALS['post']->post_date);
$thisyear = mysql2date('Y', $GLOBALS['post']->post_date);
$thisdate = $thisyear . $thismonth;
if ($thisdate != $GLOBALS['previous']) {
$thismonth = mysql2date('m', $GLOBALS['post']->post_date);
$monthstr = ereg_replace('%MONTH', $GLOBALS['month'][zeroise($thismonth, 2)], $GLOBALS['wp_month_format']);
$monthstr = ereg_replace('%YEAR', sprintf("%d", $thisyear), $monthstr);
$output = '<strong><br/><a href="' . get_month_link($thisyear, $thismonth) . '">' . $monthstr . '</a></strong>';
}
$GLOBALS['previous'] = $thisdate;
} elseif ('title' == $GLOBALS['orderby']) {
if (_LANGCODE == 'ja') {
$thisletter = ucfirst(mb_substr($GLOBALS['post']->yomi, 0, 1, $GLOBALS['blog_charset']));
if ($thisletter > "ん") {
$thisletter = "漢字";
}
} else {
$thisletter = ucfirst(substr($GLOBALS['post']->yomi, 0, 1));
}
if (empty($GLOBALS['previous']) || $thisletter != $GLOBALS['previous']) {
$output = "<br/>" . $thisletter;
}
$GLOBALS['previous'] = $thisletter;
} elseif ('category' == $GLOBALS['orderby']) {
$thiscategory = $GLOBALS['category_name'];
if ($thiscategory != $GLOBALS['previous']) {
$output = '<br/><strong><a href="' . get_category_link(false, $thiscategory) . '">' . get_catname($thiscategory) . '</a></strong>';
}
$GLOBALS['previous'] = $thiscategory;
}
if (!empty($output)) {
$output = $before . $output . $after . NL;
echo $output;
}
}
示例9: bm_caticons_adminicons
/**
* Display the icons panel in Icons tab
* @author Brahim MACHKOURI
*/
function bm_caticons_adminicons()
{
// I took some of the code from categories.php of WordPress 2.5 and modified it a little
global $wpdb;
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
if (isset($_GET['deleteit']) && isset($_GET['delete'])) {
$action = 'bulk-delete';
}
switch ($action) {
case 'update-category-icon':
$cat_ID = (int) $_GET['cat_ID'];
$priority = $_REQUEST['ig_priority'];
$icon = $_REQUEST['ig_icon'];
$small_icon = $_REQUEST['ig_small_icon'];
if ($wpdb->get_var($wpdb->prepare("SELECT cat_id FROM {$wpdb->ig_caticons} WHERE cat_id='{$cat_ID}'"))) {
$wpdb->query($wpdb->prepare("UPDATE {$wpdb->ig_caticons} SET priority='{$priority}', icon='{$icon}', small_icon='{$small_icon}' WHERE cat_id='{$cat_ID}'"));
} else {
$wpdb->query($wpdb->prepare("INSERT INTO {$wpdb->ig_caticons} (cat_id, priority, icon, small_icon) VALUES ('{$cat_ID}', '{$priority}', '{$icon}', '{$small_icon}')"));
}
break;
case 'delete':
$cat_ID = (int) $_GET['cat_ID'];
if (!is_admin() || !current_user_can('manage_categories')) {
wp_die(__('Are you trying to cheat ?', 'category_icons'));
}
$cat_name = get_catname($cat_ID);
$request = "DELETE FROM {$wpdb->ig_caticons} WHERE cat_id='{$cat_ID}'";
if (false === $wpdb->query($wpdb->prepare($request))) {
wp_die(__('Error in Category Icons', 'category_icons') . ' : ' . $request);
}
break;
case 'bulk-delete':
if (!is_admin() || !current_user_can('manage_categories')) {
wp_die(__('You are not allowed to delete category icons.', 'category_icons'));
}
foreach ((array) $_GET['delete'] as $cat_ID) {
$cat_name = get_catname($cat_ID);
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->ig_caticons} WHERE cat_id='{$cat_ID}'"));
}
break;
}
switch ($action) {
case 'edit':
$cat_ID = (int) $_GET['cat_ID'];
$category = get_category_to_edit($cat_ID);
list($priority, $icon, $small_icon) = bm_caticons_get_icons($cat_ID);
?>
<div class="wrap">
<h2><?php
_e('Select Category Icons', 'category_icons');
?>
</h2>
<form method="post" name="caticons-form1" action="">
<?php
wp_nonce_field('caticons-nonce');
?>
<input type="hidden" name="ig_module" value="caticons" />
<input type="hidden" name="ig_tab" value="icons" />
<input type="hidden" name="action" value="update-category-icon" />
<table border="0" class="form-table">
<tr>
<th scope="row" style="vertical-align:text-top;"><?php
_e('Category ID', 'category_icons');
?>
</th>
<td colspan="2" ><?php
echo $cat_ID;
?>
</td>
</tr>
<tr>
<th scope="row" style="vertical-align:text-top;"><?php
_e('Name', 'category_icons');
?>
</th>
<td colspan="2"><?php
echo $category->name;
?>
</td>
</tr>
<tr>
<th scope="row" class="num" style="vertical-align:text-top;"><?php
_e('Priority', 'category_icons');
?>
</th>
<td colspan="2">
<input type="text" name="ig_priority" size="5" value="<?php
echo $priority;
?>
" />
</td>
</tr>
<tr>
<th scope="row" style="vertical-align:text-top;"><?php
_e('Icon', 'category_icons');
?>
//.........这里部分代码省略.........
示例10: archive_header
function archive_header(&$post, $before = '', $after = '')
{
static $previous = '';
if (test_param('orderby')) {
$orderby = explode(' ', get_param('orderby'));
$orderby = $orderby[0];
} else {
$orderby = '';
}
switch ($orderby) {
case 'title':
if (_LANGCODE == 'ja') {
$thisletter = ucfirst(mb_substring($post->yomi, 0, 1, $GLOBALS['blog_charset']));
if ($thisletter > "¤ó") {
$thisletter = "´Á»ú";
}
} else {
$thisletter = ucfirst(substr($post->yomi, 0, 1));
}
if ($thisletter == "") {
$thisletter = _WP_POST_NOTITLE;
}
if ($previous === '' || $thisletter !== $previous) {
$output = "<br/>" . $thisletter;
}
$previous = $thisletter;
break;
case 'category':
$thiscategory = $post->cat_ID;
if ($thiscategory != $previous) {
$output = '<br/><strong><a href="' . get_category_link(false, $thiscategory) . '">' . get_catname($thiscategory) . '</a></strong>';
}
$previous = $thiscategory;
break;
case 'author':
$thisauthor = $post->post_author;
if ($thisauthor != $previous) {
$output = '<br/><strong><a href="' . get_author_link(false, $thisauthor) . '">' . the_author('', false) . '</a></strong>';
}
$previous = $thisauthor;
break;
case 'date':
case '':
$thismonth = mysql2date('m', $post->post_date);
$thisyear = mysql2date('Y', $post->post_date);
$thisdate = $thisyear . $thismonth;
if ($thisdate != $previous) {
$monthstr = format_month(sprintf("%d", $thisyear), $GLOBALS['month'][zeroise($thismonth, 2)]);
$output = '<strong><br/><a href="' . get_month_link($thisyear, $thismonth) . '">' . $monthstr . '</a></strong>';
}
$previous = $thisdate;
break;
}
if (!empty($output)) {
$output = $before . $output . $after . "\n";
echo $output;
}
}
示例11: get_catname
<dl>
<dd><a target="_blank" href="<?php
echo $v['url'];
?>
">
<img src="<?php
echo $v['thumb'];
?>
" alt="<?php
echo $v['title'];
?>
" style="opacity: 1;"><?php
echo $v['title'];
?>
</a><span><?php
echo get_catname($v[catid]);
?>
</span>
</dd>
</dl>
<?php
$n++;
}
}
unset($n);
?>
<!------content------>
</div>
</div>
</div>
示例12: cat_rows
</th>
</tr>
</thead>
<tbody id="the-list">
<?php
cat_rows();
?>
</tbody>
</table>
</div>
<?php
if (current_user_can('manage_categories')) {
?>
<div class="wrap">
<p><?php
printf(__('<strong>Note:</strong><br />Deleting a category does not delete the posts and links in that category. Instead, posts in the deleted category are set to the category <strong>%s</strong> and links are set to <strong>%s</strong>.'), get_catname(get_option('default_category')), get_catname(get_option('default_link_category')));
?>
</p>
</div>
<?php
include 'edit-category-form.php';
}
?>
<?php
break;
}
include 'admin-footer.php';
示例13: pp_admin_projects
function pp_admin_projects()
{
global $user_identity;
$title = __('Edit Projects', 'prologue-projects');
if (!($project_category_id = pp_get_category_id('projects'))) {
?>
<div class="wrap nosubsub">
<?php
screen_icon();
?>
<h2>
<?php
echo wp_specialchars($title);
?>
</h2>
<div id="message" class="updated"><p><?php
_e('You must <a href="admin.php?page=prologue-projects-settings">assign an existing category</a> as the container for all projects.', 'prologue-projects');
?>
</p></div>
</div>
<?php
return;
}
global $action;
wp_reset_vars(array('action'));
if (isset($_GET['action']) && isset($_GET['delete']) && ('delete' == $_GET['action'] || 'delete' == $_GET['action2'])) {
$action = 'bulk-delete';
}
switch ($action) {
case 'addproject':
check_admin_referer('add-project');
if (!current_user_can('manage_categories')) {
wp_die(__('Cheatin’ uh?', 'prologue-projects'));
}
if (pp_insert_project($_POST)) {
wp_redirect('admin.php?page=prologue-projects&message=1#addproject');
} else {
wp_redirect('admin.php?page=prologue-projects&message=4#addproject');
}
exit;
break;
case 'delete':
$project_ID = (int) $_GET['project_ID'];
check_admin_referer('delete-project_' . $project_ID);
if (!current_user_can('manage_categories')) {
wp_die(__('Cheatin’ uh?', 'prologue-projects'));
}
$project_name = get_catname($project_ID);
// Don't delete the default cats.
if ($project_ID == get_option('default_category')) {
wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one", 'prologue-projects'), $cat_name));
}
pp_delete_project($project_ID);
wp_redirect('admin.php?page=prologue-projects&message=2');
exit;
break;
case 'bulk-delete':
check_admin_referer('bulk-projects');
echo 1;
if (!current_user_can('manage_categories')) {
wp_die(__('You are not allowed to delete projects.', 'prologue-projects'));
}
foreach ((array) $_GET['delete'] as $project_ID) {
$project_name = get_catname($project_ID);
// Don't delete the default cats.
if ($project_ID == get_option('default_category')) {
wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one", 'prologue-projects'), $cat_name));
}
pp_delete_project($project_ID);
}
$sendback = wp_get_referer();
wp_redirect($sendback);
exit;
break;
case 'edit':
if (!current_user_can('manage_categories')) {
wp_die(__('You are not allowed to edit projects.', 'prologue-projects'));
}
$title = __('Edit Project', 'prologue-projects');
require_once 'admin-header.php';
$project_ID = (int) $_GET['project_ID'];
$project = pp_get_project_data($project_ID, 'all', 'editing');
?>
<div class="wrap nosubsub">
<?php
screen_icon();
?>
<h2><?php
echo wp_specialchars($title);
?>
</h2>
<?php
if (isset($_GET['message']) && ($msg = (int) $_GET['message'])) {
?>
<div id="message" class="updated fade"><p><?php
echo $messages[$msg];
//.........这里部分代码省略.........
示例14: import_cat_select_before_each
function import_cat_select_before_each($cat_ID, $level)
{
// callback to display sublist element
global $current_blog_ID, $blog, $cat, $postdata, $default_main_cat, $action, $tabindex;
echo '<li>';
if (get_allow_cross_posting() >= 1) {
// We allow cross posting, display checkbox:
echo '<input type="checkbox" name="post_extracats[]" class="checkbox" title="', T_('Select as an additionnal category'), '" value="', $cat_ID, '"';
echo ' />';
}
// Radio for main cat:
if ($current_blog_ID == $blog) {
if ($default_main_cat == 0 && $action == 'post') {
// Assign default cat for new post
$default_main_cat = $cat_ID;
}
echo ' <input type="radio" name="post_category" class="checkbox" title="', T_('Select as MAIN category'), '" value="', $cat_ID, '"';
if ($cat_ID == $postdata["Category"] || $cat_ID == $default_main_cat) {
echo ' checked="checked"';
}
echo ' />';
}
echo ' ' . htmlspecialchars(get_catname($cat_ID));
}
示例15: _e
<th scope="col"><?php _e('Description') ?></th>
<th scope="col"><?php _e('# Posts') ?></th>
<th colspan="2"><?php _e('Action') ?></th>
</tr>
<?php
cat_rows();
?>
</table>
</div>
<?php if ( $user_level > 3 ) : ?>
<div class="wrap">
<p><?php printf(__('<strong>Note:</strong><br />
Deleting a category does not delete posts from that category, it will just
set them back to the default category <strong>%s</strong>.'), get_catname(1)) ?>
</p>
</div>
<div class="wrap">
<h2><?php _e('Add New Category') ?></h2>
<form name="addcat" id="addcat" action="categories.php" method="post">
<p><?php _e('Name:') ?><br />
<input type="text" name="cat_name" value="" /></p>
<p><?php _e('Category parent:') ?><br />
<select name='cat' class='postform'>
<option value='0'><?php _e('None') ?></option>
<?php wp_dropdown_cats(0); ?>
</select></p>
<p><?php _e('Description: (optional)') ?> <br />