本文整理汇总了PHP中_cat_row函数的典型用法代码示例。如果您正苦于以下问题:PHP _cat_row函数的具体用法?PHP _cat_row怎么用?PHP _cat_row使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_cat_row函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cat_rows
function cat_rows( $parent = 0, $level = 0, $categories = 0 ) {
if ( !$categories ) {
$args = array('hide_empty' => 0);
if ( !empty($_GET['s']) )
$args['search'] = $_GET['s'];
$categories = get_categories( $args );
}
$children = _get_term_hierarchy('category');
if ( $categories ) {
ob_start();
foreach ( $categories as $category ) {
if ( $category->parent == $parent) {
echo "\t" . _cat_row( $category, $level );
if ( isset($children[$category->term_id]) )
cat_rows( $category->term_id, $level +1, $categories );
}
}
$output = ob_get_contents();
ob_end_clean();
$output = apply_filters('cat_rows', $output);
echo $output;
} else {
return false;
}
}
示例2: _cat_rows
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $categories
* @param unknown_type $count
* @param unknown_type $parent
* @param unknown_type $level
* @param unknown_type $page
* @param unknown_type $per_page
* @return unknown
*/
function _cat_rows( $categories, &$count, $parent = 0, $level = 0, $page = 1, $per_page = 20 ) {
if ( empty($categories) ) {
$args = array('hide_empty' => 0);
if ( !empty($_GET['s']) )
$args['search'] = $_GET['s'];
$categories = get_categories( $args );
}
if ( !$categories )
return false;
$children = _get_term_hierarchy('category');
$start = ($page - 1) * $per_page;
$end = $start + $per_page;
$i = -1;
ob_start();
foreach ( $categories as $category ) {
if ( $count >= $end )
break;
$i++;
if ( $category->parent != $parent )
continue;
// If the page starts in a subtree, print the parents.
if ( $count == $start && $category->parent > 0 ) {
$my_parents = array();
while ( $my_parent) {
$my_parent = get_category($my_parent);
$my_parents[] = $my_parent;
if ( !$my_parent->parent )
break;
$my_parent = $my_parent->parent;
}
$num_parents = count($my_parents);
while( $my_parent = array_pop($my_parents) ) {
echo "\t" . _cat_row( $my_parent, $level - $num_parents );
$num_parents--;
}
}
if ( $count >= $start )
echo "\t" . _cat_row( $category, $level );
unset($categories[$i]); // Prune the working set
$count++;
if ( isset($children[$category->term_id]) )
_cat_rows( $categories, $count, $category->term_id, $level + 1, $page, $per_page );
}
$output = ob_get_contents();
ob_end_clean();
echo $output;
}
示例3: _cat_rows
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $categories
* @param unknown_type $count
* @param unknown_type $parent
* @param unknown_type $level
* @param unknown_type $page
* @param unknown_type $per_page
* @return unknown
*/
function _cat_rows($parent = 0, $level = 0, $categories, &$children, $page = 1, $per_page = 20, &$count)
{
$start = ($page - 1) * $per_page;
$end = $start + $per_page;
ob_start();
foreach ($categories as $key => $category) {
if ($count >= $end) {
break;
}
if ($category->parent != $parent && empty($_GET['s'])) {
continue;
}
// If the page starts in a subtree, print the parents.
if ($count == $start && $category->parent > 0) {
$my_parents = array();
$p = $category->parent;
while ($p) {
$my_parent = get_category($p);
$my_parents[] = $my_parent;
if ($my_parent->parent == 0) {
break;
}
$p = $my_parent->parent;
}
$num_parents = count($my_parents);
while ($my_parent = array_pop($my_parents)) {
echo "\t" . _cat_row($my_parent, $level - $num_parents);
$num_parents--;
}
}
if ($count >= $start) {
echo "\t" . _cat_row($category, $level);
}
unset($categories[$key]);
$count++;
if (isset($children[$category->term_id])) {
_cat_rows($category->term_id, $level + 1, $categories, $children, $page, $per_page, $count);
}
}
$output = ob_get_contents();
ob_end_clean();
echo $output;
}
示例4: cat_rows
function cat_rows( $parent = 0, $level = 0, $categories = 0 ) {
if (!$categories )
$categories = get_categories( 'hide_empty=0' );
$children = _get_category_hierarchy();
if ( $categories ) {
ob_start();
foreach ( $categories as $category ) {
if ( $category->category_parent == $parent) {
echo "\t" . _cat_row( $category, $level );
if ( isset($children[$category->cat_ID]) )
cat_rows( $category->cat_ID, $level +1, $categories );
}
}
$output = ob_get_contents();
ob_end_clean();
$output = apply_filters('cat_rows', $output);
echo $output;
} else {
return false;
}
}
示例5: die
die(-1);
}
switch ($_POST['tax_type']) {
case 'cat':
$data = array();
$data['cat_ID'] = $id;
$data['cat_name'] = $_POST['name'];
$data['category_nicename'] = $_POST['slug'];
if (isset($_POST['parent']) && (int) $_POST['parent'] > 0) {
$data['category_parent'] = $_POST['parent'];
}
$cat = get_category($id, ARRAY_A);
$data['category_description'] = $cat['category_description'];
$updated = wp_update_category($data);
if ($updated && !is_wp_error($updated)) {
echo _cat_row($updated, 0);
} else {
die(__('Category not updated.'));
}
break;
case 'link-cat':
$updated = wp_update_term($id, 'link_category', $_POST);
if ($updated && !is_wp_error($updated)) {
echo link_cat_row($updated['term_id']);
} else {
die(__('Category not updated.'));
}
break;
case 'tag':
$taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
$tag = get_term($id, $taxonomy);
示例6: get_category
if ( !$cat = get_category( $cat ) )
die('0');
$level = 0;
$cat_full_name = $cat->cat_name;
$_cat = $cat;
while ( $_cat->category_parent ) {
$_cat = get_category( $_cat->category_parent );
$cat_full_name = $_cat->cat_name . ' — ' . $cat_full_name;
$level++;
}
$cat_full_name = attribute_escape($cat_full_name);
$x = new WP_Ajax_Response( array(
'what' => 'cat',
'id' => $cat->cat_ID,
'data' => _cat_row( $cat, $level, $cat_full_name ),
'supplemental' => array('name' => $cat_full_name, 'show-link' => sprintf(__( 'Category <a href="#%s">%s</a> added' ), "cat-$cat->cat_ID", $cat_full_name))
) );
$x->send();
break;
case 'add-comment' :
if ( !current_user_can( 'edit_post', $id ) )
die('-1');
$search = isset($_POST['s']) ? $_POST['s'] : false;
$start = isset($_POST['page']) ? intval($_POST['page']) * 25 : 25;
list($comments, $total) = _wp_get_comment_list( $search, $start, 1 );
if ( !$comments )
die('1');
$x = new WP_Ajax_Response();
示例7: WP_Ajax_Response
$x = new WP_Ajax_Response(array('what' => 'cat', 'id' => $cat));
$x->send();
}
if (!$cat || !($cat = get_category($cat))) {
die('0');
}
$level = 0;
$cat_full_name = $cat->name;
$_cat = $cat;
while ($_cat->parent) {
$_cat = get_category($_cat->parent);
$cat_full_name = $_cat->name . ' — ' . $cat_full_name;
$level++;
}
$cat_full_name = attribute_escape($cat_full_name);
$x = new WP_Ajax_Response(array('what' => 'cat', 'id' => $cat->term_id, 'data' => _cat_row($cat, $level, $cat_full_name), 'supplemental' => array('name' => $cat_full_name, 'show-link' => sprintf(__('Category <a href="#%s">%s</a> added'), "cat-{$cat->term_id}", $cat_full_name))));
$x->send();
break;
case 'add-link-cat':
// From Blogroll -> Categories
check_ajax_referer('add-link-category');
if (!current_user_can('manage_categories')) {
die('-1');
}
if ('' === trim($_POST['name'])) {
$x = new WP_Ajax_Response(array('what' => 'link-cat', 'id' => new WP_Error('name', __('You did not enter a category name.'))));
$x->send();
}
$r = wp_insert_term($_POST['name'], 'link_category', $_POST);
if (is_wp_error($r)) {
$x = new WP_AJAX_Response(array('what' => 'link-cat', 'id' => $r));