function update_category_cache($cat_id) { $f_id = 1; require_once 'codegen_functions.php'; for ($f_id = 1; $f_id < 6; $f_id++) { generate_category_cache($cat_id, $lang, $f_id); } $query = "SELECT category_id FROM categories WHERE parent_category_id='{$cat_id}' "; $result = mysql_query($query) or die(mysql_error() . $query); while ($row = mysql_fetch_array($result)) { update_category_cache($row['category_id']); } }
$wp_rewrite->flush_rules(); update_option('db_upgraded', false); /** * Runs on the next page load after successful upgrade * * @since 2.8 */ do_action('after_db_upgrade'); } elseif (get_option('db_version') != $wp_db_version) { wp_redirect(admin_url('upgrade.php?_wp_http_referer=' . urlencode(stripslashes($_SERVER['REQUEST_URI'])))); exit; } require_once ABSPATH . 'wp-admin/includes/admin.php'; auth_redirect(); nocache_headers(); update_category_cache(); set_screen_options(); $posts_per_page = get_option('posts_per_page'); $date_format = get_option('date_format'); $time_format = get_option('time_format'); wp_reset_vars(array('profile', 'redirect', 'redirect_url', 'a', 'popuptitle', 'popupurl', 'text', 'trackback', 'pingback')); wp_admin_css_color('classic', __('Blue'), admin_url("css/colors-classic.css"), array('#073447', '#21759B', '#EAF3FA', '#BBD8E7')); wp_admin_css_color('fresh', __('Gray'), admin_url("css/colors-fresh.css"), array('#464646', '#6D6D6D', '#F1F1F1', '#DFDFDF')); wp_enqueue_script('common'); wp_enqueue_script('jquery-color'); $editing = false; if (isset($_GET['page'])) { $plugin_page = stripslashes($_GET['page']); $plugin_page = plugin_basename($plugin_page); } require ABSPATH . 'wp-admin/menu.php';
function get_category_children($id, $before = '/', $after = '') { global $cache_categories; if (!isset($cache_categories)) { update_category_cache(); } $c_cache = $cache_categories; // Can't do recursive foreach on a global, have to make a copy $chain = ''; foreach ($c_cache as $category) { if ($category->category_parent == $id) { $chain .= $before . $category->cat_ID . $after; $chain .= get_category_children($category->cat_ID, $before, $after); } } return $chain; }
function update_post_category_cache($post_ids) { global $wpdb, $category_cache, $cache_categories; if (empty($post_ids)) return; if (is_array($post_ids)) $post_ids = implode(',', $post_ids); $dogs = $wpdb->get_results("SELECT DISTINCT post_id, cat_ID FROM $wpdb->categories, $wpdb->post2cat WHERE category_id = cat_ID AND post_id IN ($post_ids)"); if (! isset($cache_categories)) update_category_cache(); if ( !empty($dogs) ) { foreach ($dogs as $catt) { $category_cache[$catt->post_id][$catt->cat_ID] = &$cache_categories[$catt->cat_ID]; } } }
function update_post_category_cache($post_ids) { global $wpdb, $category_cache, $cache_categories; if (empty($post_ids)) { return; } if (is_array($post_ids)) { //implode 返回一个字符串,其内容为由 glue 分割开的数组的值 $post_ids = implode(',', $post_ids); } $dogs = $wpdb->get_results("SELECT DISTINCT\r\n\tpost_id, cat_ID FROM {$wpdb->categories}, {$wpdb->post2cat}\r\n\tWHERE category_id = cat_ID AND post_id IN ({$post_ids})"); if (!isset($cache_categories)) { update_category_cache(); } if (!empty($dogs)) { foreach ($dogs as $catt) { $category_cache[$catt->post_id][$catt->cat_ID] =& $cache_categories[$catt->cat_ID]; } } }
$obj_count = -$obj_count; echo "<br><font color='red'><b>Error:</b></font> Cannot delete this category: It looks like you have " . $obj_count . " record(s) in this category! <a href='" . $_SERVER['PHP_SELF'] . "?action=del&category_id=" . $_REQUEST['category_id'] . "&confirm=yes'>Click Here to delete anyway.</a></br>"; } if ($_REQUEST['save'] != '' && CACHE_ENABLED == 'YES') { $CACHE_ENABLED = 'NO'; include '../include/codegen_functions.php'; update_category_cache(0); $CACHE_ENABLED = 'YES'; } } if ($_REQUEST['action'] == 'process') { format_cat_translation_table(0); if ($_REQUEST['save'] != '' && CACHE_ENABLED == 'YES') { $CACHE_ENABLED = 'NO'; include '../include/codegen_functions.php'; update_category_cache(0); $CACHE_ENABLED = 'YES'; } } echo "<div align='left'><h3><a href=" . htmlentities($_SERVER['PHP_SELF']) . ">Root Category</a> -> " . getPath($_REQUEST['cat'], $_SERVER['PHP_SELF'], $_SESSION[form_id]) . " "; if ($_REQUEST['cat'] != 0) { $MODE = "ADMIN"; ?> <a onClick="return confirmLink(this, 'Delete this category, are you sure? (This will also delete all sub-categories in this category)') " href="<?php echo htmlentities($_SERVER['PHP_SELF']); ?> ?action=del&category_id=<?php echo $_REQUEST['cat']; ?> "><IMG src='delete.gif' width='16' height='16' border='0' alt='Delete'></a> <a href="<?php