$cat
以上
$cat
以上
再インストールした時に起こる問題のようだ。クッキーを削除したら動作するようになった。
WordPress MUで、表示中以外のブログを含めたサイト全体の新着ブログを表示するプラグインです。デフォルトのWordPress MUではできませんが、このプラグインを使えば可能になります。
みなさまのお問い合わせやバグの指摘などから「正しい動作の実現」や「機能の追加」ができ、大変ありがたい限りです。是非とも、遠慮なくコメント欄でお問い合わせください。
例えば以下のような記述をテンプレート内にすると、サイト内の新規ブログを新しい順に5個(デフォルト)表示します。x個表示したい場合は、have_posts()の引数をhave_posts(x)と記述すれば、任意の回数だけ表示します。
通常のWordPressタグと同じようなコントロールができます。但し、query_posts関数は使用できません。
<div class="section"> <?php while(JopGlobalBlogIndex::have_posts()): ?> <?php JopGlobalBlogIndex::the_post(); ?> <div class="item"> <h3><a href="<?php print(JopGlobalBlogIndex::the_permalink()); ?>" title="<?php print(JopGlobalBlogIndex::the_title()); ?>"><?php print(JopGlobalBlogIndex::the_title()); ?></a>(<?php print(JopGlobalBlogIndex::the_author()); ?>)<?php print(JopGlobalBlogIndex::the_time('Y/m/d H:i:s')); ?></h3> <p class="item_category">Category: <?php print(JopGlobalBlogIndex::the_category()); ?></p> <?php print(JopGlobalBlogIndex::the_content()); ?> <p class="readmore"><a href="<?php print(JopGlobalBlogIndex::the_permalink()); ?>" title="<?php print(JopGlobalBlogIndex::the_title()); ?>">Read More</a></p> </div> <?php endwhile; ?> </div>
<?php while(JopGlobalBlogIndex::have_posts([int $limit = 5[, array $option = array('allowedId' => array(), 'restrictedId' => array())]])): ?> <?php JopGlobalBlogIndex::the_post(); ?>
から
<?php endwhile; ?>
の部分が記事の個数だけループされる部分です。$option[‘allowedId’]には表示したいブログのIDを配列で指定でき、$option[‘restrictedId’]には表示したくないブログのIDを指定できます。但し、$option[‘allowedId’]か$option[‘restrictedId’]の一方しか使用できず、両方指定してある場合は前者が有効となります。
「/wp-content/mu-plugins/jopGlobalBlogArchive.php」
<?php /* Plugin Name: jopGlobalBlogArchive Plugin URI: http://blog.justoneplanet.info/wp-content/uploads/wordpressmu/jopGlobalBlogArchive/ Description: Prepare the list of some newer posts and categories from WPMU. Author: Mitsuaki Ishimoto Version: 0.1.8 Author URI: http://blog.justoneplanet.info/ */ /* Copyright 2009 Mitsuaki Ishimoto (email : justoneplanet.info) This program is free software; fundamentally, you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. But the Author(:Mitsuaki Ishimoto) can deny for someone evil or immoral to use this plugin. it means someone evil or immoral is the people and organizations to hold a candle to the devil, to harm someone, not to observe various laws, not to contribute society and so on. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ //======================================================= //actions add_action('publish_post', 'jopSavePostForArchive'); add_action('publish_page', 'jopSavePostForArchive'); add_action('delete_post', 'jopDeletePostForArchive'); add_action('delete_category', 'jopDeleteCategoryForArchive'); //======================================================= //class class JopGlobalBlogIndex { /* * $global_prefix * (string) : prefix of database not including blog id */ private static $global_prefix; /* * $post * (object) : data of a post at current loop */ private static $post; /* * $posts * (array) : data of posts from the global post's table of database */ private static $posts; /* * $counter * (int) : counter for counting of loop */ private static $counter = 0; /** * __construct * An instantiation is prohibited. */ private function __construct(){ throw new Exception('An instantiation is prohibited.'); } /** * getOptionsByBlogId * get user's option defined by blog id and key * @return (string) maybe_unserialize($_wp_alloptions[$blog_id][$key]) : option's value * @param (string) $key : the key you need * @param (string) maybe_unserialize($_wp_alloptions[$blog_id][$key]) : option's value */ private static function getOptionsByBlogId($key, $id){ global $wpdb; $suppress = $wpdb->suppress_errors(); $alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM " . self::$global_prefix . $id . "_options FORCE INDEX(PRIMARY) ORDER BY option_id ASC" ); $wpdb->suppress_errors($suppress); foreach((array)$alloptions_db as $o){ $_wp_alloptions[$blog_id][$o->option_name] = $o->option_value; } wp_cache_set('alloptions', $_wp_alloptions[$blog_id], 'options'); return maybe_unserialize($_wp_alloptions[$blog_id][$key]); } /** * get_page_uri * @return */ private static function get_page_uri(){ global $wpdb; $uri = self::$post->post_name; if(self::$post->post_parent == self::$post->ID){ return $uri; } $id = self::$post->post_parent; while($id != 0){ $sql = "SELECT `ID`,`post_name`,`post_parent` FROM " . self::$global_prefix . self::$post->blog_id . "_posts WHERE `ID` = '{$id}'"; $result = $wpdb->get_results($sql, OBJECT); $result = $result[0]; $id = $result->post_parent; $uri = $result->post_name . "/" . $uri; } return $uri; } /** * _get_page_link * @return (string) * @param boolean $id[optional] * @param boolean $leavename[optional] */ private static function _get_page_link($id = false, $leavename = false){ global $wp_rewrite; $pagestruct = $wp_rewrite->get_page_permastruct(); if($pagestruct != ''){ $link = self::get_page_uri($id); $link = ($leavename)? $pagestruct : str_replace('%pagename%', $link, $pagestruct); $link = trailingslashit(self::getOptionsByBlogId('home', self::$post->blog_id)) . "$link"; $link = user_trailingslashit($link, 'page'); } else{ $link = trailingslashit(self::getOptionsByBlogId('home', self::$post->blog_id)) . "?page_id={$post->post_id}"; } return apply_filters('_get_page_link', $link, $id); } /** * get_page_link * @return (string) page_link */ private static function get_page_link($id = false, $leavename = false){ if('page' == self::getOptionsByBlogId('show_on_front', self::$post->blog_id) && self::$post->post_id == self::getOptionsByBlogId('page_on_front', self::$post->blog_id)){ $link = self::getOptionsByBlogId('home', self::$post->blog_id); } else{ $link = self::_get_page_link($id, $leavename); } return apply_filters('page_link', $link, $id); } /** * get_permalink * get the permalink from current post * @return the permalink * @param (int) $id[optional] * @param (bool?) $leavename[optional] */ private static function get_permalink($id = 0, $leavename = false) { if(empty(self::$post->ID)){ return false; } if(self::$post->post_type == 'page'){ return self::get_page_link(self::$post->ID, $leavename); } elseif(self::$post->post_type == 'attachment'){ return get_attachment_link(self::$post->ID); } $permalink = get_option('permalink_structure'); if('' != $permalink && !in_array(self::$post->post_status, array('draft', 'pending'))){ $unixtime = strtotime(self::$post->post_date); $category = ''; if(strpos($permalink, '%category%') !== false){ $cats = get_the_category(self::$post->ID); if($cats){ usort($cats, '_usort_terms_by_ID'); // order by ID $category = $cats[0]->slug; if($parent = $cats[0]->parent){ $category = get_category_parents($parent, false, '/', true) . $category; } } // show default category in permalinks, without // having to assign it explicitly if(empty($category)) { $default_category = get_category(get_option('default_category')); $category = is_wp_error($default_category) ? '' : $default_category->slug; } } $author = ''; if(strpos($permalink, '%author%') !== false){ $authordata = get_userdata(self::$post->post_author); $author = $authordata->user_nicename; } $date = explode(" ", date('Y m d H i s', $unixtime)); $blog_path = explode('/', self::$post->path); $blog_path = $blog_path[count($blog_path) - 2]; $rewritecode = array( 'blog', '%year%', '%monthnum%', '%day%', '%hour%', '%minute%', '%second%', $leavename? '' : '%postname%', '%post_id%', '%category%', '%author%', $leavename? '' : '%pagename%', ); $rewritereplace = array( (self::$post->blog_id == 1)? 'blog' : $blog_path, $date[0], $date[1], $date[2], $date[3], $date[4], $date[5], self::$post->post_name, self::$post->ID, $category, $author, self::$post->post_name, ); $permalink = get_option('home') . str_replace($rewritecode, $rewritereplace, $permalink); $permalink = user_trailingslashit($permalink, 'single'); return apply_filters('post_link', $permalink, self::$post, $leavename); } else{ // if they're not using the fancy permalink option $permalink = get_option('home') . '/?p=' . self::$post->ID; return apply_filters('post_link', $permalink, self::$post, $leavename); } } /** * savePost * save post into the table '(prefix_)jop_global_posts' on installing and updating * @return (null) * @param (object) $result * @param (int) $blogid */ public static function savePost($result, $blogid){ global $wpdb; $id = $result['ID']; $sql = "INSERT INTO " . self::getGlobalPrefix() . "jop_global_posts( `blog_id`, `post_id`, `identifier`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_category`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count` ) VALUES('" . $blogid . "', '" . $result['ID'] . "', '" . $blogid . "/" . $result['ID'] . "', '" . $wpdb->_real_escape($result['post_author']) . "', '" . $result['post_date'] . "', '" . $result['post_date_gmt'] . "', '" . $wpdb->_real_escape($result['post_content']) . "', '" . $wpdb->_real_escape($result['post_title']) . "', '" . $result['post_category'] . "', '" . $wpdb->_real_escape($result['post_excerpt']) . "', '" . $wpdb->_real_escape($result['post_status']) . "', '" . $wpdb->_real_escape($result['comment_status']) . "', '" . $wpdb->_real_escape($result['ping_status']) . "', '" . $wpdb->_real_escape($result['post_password']) . "', '" . $wpdb->_real_escape($result['post_name']) . "', '" . $wpdb->_real_escape($result['to_ping']) . "', '" . $wpdb->_real_escape($result['pinged']) . "', '" . $result['post_modified'] . "', '" . $result['post_modified_gmt'] . "', '" . $wpdb->_real_escape($result['post_content_filtered']) . "', '" . $result['post_parent'] . "', '" . $wpdb->_real_escape($result['guid']) . "', '" . $result['menu_order'] . "', '" . $wpdb->_real_escape($result['post_type']) . "', '" . $wpdb->_real_escape($result['post_mime_type']) . "', '" . $result['comment_count'] . "' ) ON DUPLICATE KEY UPDATE " . "`post_author` = '" . $wpdb->_real_escape($result['post_author']) . "'," . "`post_date` = '" . $result['post_date'] . "'," . "`post_date_gmt` = '" . $result['post_date_gmt'] . "'," . "`post_content` = '" . $wpdb->_real_escape($result['post_content']) . "'," . "`post_title` = '" . $wpdb->_real_escape($result['post_title']) . "'," . "`post_category` = '" . $result['post_category'] . "'," . "`post_excerpt` = '" . $wpdb->_real_escape($result['post_excerpt']) . "'," . "`post_status` = '" . $wpdb->_real_escape($result['post_status']) . "'," . "`comment_status` = '" . $wpdb->_real_escape($result['comment_status']) . "'," . "`ping_status` = '" . $wpdb->_real_escape($result['ping_status']) . "'," . "`post_password` = '" . $wpdb->_real_escape($result['post_password']) . "'," . "`post_name` = '" . $wpdb->_real_escape($result['post_name']) . "'," . "`to_ping` = '" . $wpdb->_real_escape($result['to_ping']) . "'," . "`pinged` = '" . $wpdb->_real_escape($result['pinged']) . "'," . "`post_modified` = '" . $result['post_modified'] . "'," . "`post_modified_gmt` = '" . $result['post_modified_gmt'] . "'," . "`post_content_filtered` = '" . $wpdb->_real_escape($result['post_content_filtered']) . "'," . "`post_parent` = '" . $result['post_parent'] . "'," . "`guid` = '" . $wpdb->_real_escape($result['guid']) . "'," . "`menu_order` = '" . $result['menu_order'] . "'," . "`post_type` = '" . $wpdb->_real_escape($result['post_type']) . "'," . "`post_mime_type` = '" . $wpdb->_real_escape($result['post_mime_type']) . "'," . "`comment_count` = '" . $result['comment_count'] . "'"; $wpdb->query($sql); /* * pick up the term id for save */ $sql = "SELECT " . self::getGlobalPrefix() . $blogid . "_term_relationships.object_id, " . self::getGlobalPrefix() . $blogid . "_term_taxonomy.term_id FROM " . self::getGlobalPrefix() . $blogid . "_term_relationships LEFT JOIN " . self::getGlobalPrefix() . $blogid . "_term_taxonomy ON " . self::getGlobalPrefix() . $blogid . "_term_relationships.term_taxonomy_id = " . self::getGlobalPrefix() . $blogid . "_term_taxonomy.term_taxonomy_id WHERE " . self::getGlobalPrefix() . $blogid . "_term_relationships.`object_id` = '{$result['ID']}'"; $result = $wpdb->get_results($sql, ARRAY_A); /* * Once deleting for update */ $sql = "DELETE FROM " . self::getGlobalPrefix() . "jop_global_term_relationships WHERE `object_id` = '{$id}' AND `blog_id` = '{$blogid}'"; $wpdb->query($sql); /* * insert */ $values = array(); foreach($result as $key => $value){ $values[] = "'{$value['object_id']}', '{$blogid}', '{$value['term_id']}', '{$blogid}/{$value['object_id']}/{$value['term_id']}'"; } $values = '(' . implode('),(', $values) . ')'; $sql = "INSERT INTO " . self::getGlobalPrefix() . "jop_global_term_relationships( `object_id`, `blog_id`, `cat_ID`, `identifier` ) VALUES $values"; $wpdb->query($sql); } /** * install * 1st query makes the table that keep the posts written by all users. * 2nd query makes the table that keep the terms written by all users. * @return (null) */ private static function install(){ global $wpdb; $table_name = self::$global_prefix . "jop_global_term_relationships"; if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name){ $sql = "CREATE TABLE IF NOT EXISTS `$table_name` ( `object_id` bigint(20) NOT NULL DEFAULT '0', `blog_id` int(11) NOT NULL DEFAULT '0', `cat_ID` bigint(20) NOT NULL DEFAULT '0', `identifier` varchar(255) NOT NULL DEFAULT '0/0', UNIQUE KEY `identifier` (`identifier`), KEY `cat_ID` (`cat_ID`), KEY `blog_id` (`blog_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8"; $wpdb->get_results($sql); } $table_name = self::$global_prefix . "jop_global_posts"; if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name){ $sql = "CREATE TABLE IF NOT EXISTS `$table_name` ( `ID` bigint(20) NOT NULL AUTO_INCREMENT, `blog_id` int(11) NOT NULL DEFAULT '0', `post_id` int(11) NOT NULL DEFAULT '0', `identifier` varchar(255) NOT NULL, `post_author` bigint(20) NOT NULL DEFAULT '0', `post_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `post_date_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `post_content` longtext NOT NULL, `post_title` text NOT NULL, `post_category` int(4) NOT NULL DEFAULT '0', `post_excerpt` text NOT NULL, `post_status` varchar(20) NOT NULL DEFAULT 'publish', `comment_status` varchar(20) NOT NULL DEFAULT 'open', `ping_status` varchar(20) NOT NULL DEFAULT 'open', `post_password` varchar(20) NOT NULL, `post_name` varchar(200) NOT NULL, `to_ping` text NOT NULL, `pinged` text NOT NULL, `post_modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `post_modified_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `post_content_filtered` text NOT NULL, `post_parent` bigint(20) NOT NULL DEFAULT '0', `guid` varchar(255) NOT NULL, `menu_order` int(11) NOT NULL DEFAULT '0', `post_type` varchar(20) NOT NULL DEFAULT 'post', `post_mime_type` varchar(100) NOT NULL, `comment_count` bigint(20) NOT NULL DEFAULT '0', PRIMARY KEY (`ID`), UNIQUE KEY `identifier` (`identifier`), KEY `blog_id` (`blog_id`), KEY `post_id` (`post_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8"; $wpdb->get_results($sql); /* * save the posts have been published. */ $tables = $wpdb->get_results("SHOW TABLES LIKE '" . self::$global_prefix . "_\_posts'", ARRAY_N); foreach($tables as $table){ $results = $wpdb->get_results("SELECT * FROM {$table[0]} WHERE `post_status` = 'publish'", ARRAY_A); $blogid = str_replace(array(self::$global_prefix, '_posts'), '', $table[0]); foreach($results as $result){ self::savePost($result, $blogid); } } } } /** * init * @return null */ public static function init(){ global $wpdb; self::$global_prefix = preg_replace("/[0-9]+_/", '', $wpdb->prefix); self::install(); } /** * getGlobalPrefix * method for access to prefix * @return (string) self::$global_prefix : table prefix */ public static function getGlobalPrefix(){ return self::$global_prefix; } /** * have_posts * set the list of newer posts written by all users if self::$posts is not set * judge if the self::$posts of current index exist or not * @return (bool) * @param (int) $limit : define the number of rows. * @param (array) $option : define the option. */ public static function have_posts($limit = 5, $option = array()){ global $wpdb; if(!isset(self::$posts)){ $col = array( 'ID', 'blog_id', 'post_id', 'post_date', 'post_content', 'post_name', 'post_author', 'post_title', 'post_category', 'post_status', 'post_type', 'post_parent', 'guid' ); foreach($col as $key => $value){ $col[$key] = self::$global_prefix . "jop_global_posts." . $value; } $col = implode(',', $col); $sqlForAllowedBlog = ''; if(is_array($option['allowedId'])){ for($i = 0; $i < count($option['allowedId']); $i++){ if(is_int($option['allowedId'][$i]) && $option['allowedId'][$i] > 0){ $sqlForAllowedBlog .= " OR " . self::$global_prefix . "jop_global_posts.`blog_id` = '{$option['allowedId'][$i]}'"; } } $sqlForAllowedBlog = substr($sqlForAllowedBlog, 4); } elseif(is_array($option['restrictedId'])){ for($i = 0; $i < count($option['restrictedId']); $i++){ if(is_int($option['restrictedId'][$i]) && $option['restrictedId'][$i] > 0){ $sqlForAllowedBlog .= " AND " . self::$global_prefix . "jop_global_posts.`blog_id` != '{$option['restrictedId'][$i]}'"; } } $sqlForAllowedBlog = substr($sqlForAllowedBlog, 5); } if($sqlForAllowedBlog !== ''){ $sqlForAllowedBlog = " AND ($sqlForAllowedBlog) "; } $sql = "SELECT {$col}," . self::$global_prefix . "blogs.path FROM " . self::$global_prefix . "jop_global_posts LEFT JOIN " . self::$global_prefix . "blogs ON " . self::$global_prefix . "jop_global_posts.blog_id = " . self::$global_prefix . "blogs.blog_id WHERE " . self::$global_prefix . "jop_global_posts.`post_status` = 'publish' AND " . self::$global_prefix . "jop_global_posts.`post_password` = '' $sqlForAllowedBlog ORDER BY `post_date` DESC LIMIT 0,$limit"; $result = $wpdb->get_results($sql, OBJECT); self::$posts = $result; } if(isset(self::$posts[self::$counter])){ return true; } else{ self::$counter = 0; self::$posts = null;//for multiple loop(in the case of different situation) return false; } } /** * the_post * get the post in a loop and set the counter for the next loop. * @return (array) self::$post */ public static function the_post(){ self::$post = self::$posts[self::$counter]; self::$counter++; return self::$post; } /** * the_title * get the title from the current loop. * @return (string) self::$post->post_title */ public static function the_title(){ return apply_filters('the_title', self::$post->post_title); } /** * the_ID * get the title from the current loop. * @return (string) self::$post->ID */ public static function the_ID(){ return self::$post->ID; } /** * the_permalink * get the title from the current loop. * @return (string) self::$post->guid */ public static function the_permalink(){ return apply_filters('the_permalink', self::get_permalink()); } /** * the_time * get the title from the current loop. * @return (string) self::$post->post_date */ public static function the_time($d = ''){ return apply_filters('the_time', self::get_the_time( $d ), $d); } /** * get_the_time * @return (String) date */ private function get_the_time($d = ''){ if('' == $d){ $the_time = get_post_time(get_option('time_format'), false, self::$post, true); } else{ $the_time = get_post_time($d, false, self::$post, true); } return apply_filters('get_the_time', $the_time, $d, self::$post); } /** * the_author * get the title from the current loop. * @return (string) self::$post->post_author */ public static function the_author(){ global $wpdb; $id = self::$post->post_author; $sql = "SELECT `user_nicename` FROM `" . self::$global_prefix . "users` WHERE `ID` = '$id'"; $result = $wpdb->get_results($sql, ARRAY_N); return $result[0][0]; } /** * the_content * get the body from the current loop. * @return (string) self::$post->post_content */ public static function the_content($stripteaser = false){ $content = self::$post->post_content; if($stripteaser){ list($content) = preg_split('/<!--more(.*?)?-->/', $content); } $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); return $content; } /** * the_summary * get the summary form the current loop. * @return (string) self::$post->post_content * @param (int) $limit */ public static function the_summary($limit = 50){ if(!is_int($limit)){ $limit = 50; } $content = self::$post->post_content; $funcs = get_defined_functions(); if(in_array('mb_substr', $funcs['internal'])){ $content = mb_substr(strip_tags($content), 0, $limit); } else{ $content = substr(strip_tags($content), 0, $limit); } $content = str_replace(']]>', ']]>', $content); return $content; } /** * the_category * get the title from the current loop. * @return (string) self::$post->post_category */ public static function the_category(){ global $wpdb; $blog_id = self::$post->blog_id; $post_id = self::$post->post_id; $sql = "SELECT `" . self::$global_prefix . "sitecategories`.`cat_name` FROM `" . self::$global_prefix . "jop_global_term_relationships` LEFT JOIN `" . self::$global_prefix . "sitecategories` ON `" . self::$global_prefix . "jop_global_term_relationships`.`cat_ID` = `" . self::$global_prefix . "sitecategories`.`cat_ID` WHERE `" . self::$global_prefix . "jop_global_term_relationships`.`object_id` = '$post_id' AND `" . self::$global_prefix . "jop_global_term_relationships`.`blog_id` = '$blog_id'"; $tmpAry = array(); $result = $wpdb->get_results($sql, ARRAY_A); foreach($result as $key => $value){ $tmpAry[] = $value['cat_name']; } sort($tmpAry); return implode(', ', $tmpAry); } /*prepare*/ public static function the_tags(){ return self::$post->post_title; } public static function the_title_attribute(){ return self::$post->post_title; } /*categories*/ /** * wp_list_categories * get the title from the current loop. * @return (string) self::$post->post_category */ public static function wp_list_categories($args = ''){ $defaults = array( 'show_option_all' => '', 'orderby' => 'name', 'order' => 'ASC', 'show_last_update' => 0, 'style' => 'list', 'show_count' => 0, 'hide_empty' => 1, 'use_desc_for_title' => 1, 'child_of' => 0, 'feed' => '', 'feed_type' => '', 'feed_image' => '', 'exclude' => '', 'current_category' => 0, 'hierarchical' => true, 'title_li' => __('Categories'), 'echo' => 1, 'depth' => 0 ); $r = wp_parse_args($args, $defaults); if(!isset($r['pad_counts']) && $r['show_count'] && $r['hierarchical']){ $r['pad_counts'] = true; } if(isset($r['show_date'])){ $r['include_last_update_time'] = $r['show_date']; } extract($r); $categories = get_categories($r); $output = ''; if($title_li && 'list' == $style){ $output = '<li class="categories">' . $r['title_li'] . '<ul>'; } if(empty($categories)){ if('list' == $style){ $output .= '<li>' . __("No categories") . '</li>'; } else{ $output .= __("No categories"); } } else{ global $wp_query; if(!empty($show_option_all)){ if('list' == $style){ $output .= '<li><a href="' . get_bloginfo('url') . '">' . $show_option_all . '</a></li>'; } else{ $output .= '<a href="' . get_bloginfo('url') . '">' . $show_option_all . '</a>'; } } if(empty($r['current_category']) && is_category()){ $r['current_category'] = $wp_query->get_queried_object_id(); } if($hierarchical){ $depth = $r['depth']; } else{ $depth = -1; // Flat. } $output .= walk_category_tree($categories, $depth, $r); } if($title_li && 'list' == $style){ $output .= '</ul></li>'; } $output = apply_filters('wp_list_categories', $output); if($echo){ echo $output; } else{ return $output; } } } JopGlobalBlogIndex::init(); //======================================================= //functions /** * jopDeleteCategoryForArchive * @return (null) * @param (int) $id */ function jopDeleteCategoryForArchive($id){ global $wpdb; $sql = "DELETE FROM " . JopGlobalBlogIndex::getGlobalPrefix() . "jop_global_term_relationships WHERE `blog_id` = '{$wpdb->blogid}' AND `cat_ID` = '{$id}'"; $wpdb->query($sql); } /** * jopSavePostForArchive * @return (null) * @param (int) $id */ function jopSavePostForArchive($id){ global $wpdb; $sql = "SELECT * FROM " . JopGlobalBlogIndex::getGlobalPrefix() . $wpdb->blogid . "_posts WHERE `ID` = '$id'"; $result = $wpdb->get_results($sql, ARRAY_A); $result = $result[0]; JopGlobalBlogIndex::savePost($result, $wpdb->blogid); } /** * jopDeletePostForArchive * @return (null) * @param (int) $id */ function jopDeletePostForArchive($id){ global $wpdb; $sql = "DELETE FROM " . JopGlobalBlogIndex::getGlobalPrefix() . "jop_global_posts WHERE `identifier` = '" . $wpdb->blogid . '/' . $id . "'"; $wpdb->query($sql); //var_dump($sql); //throw new Exception(); } ?>
GNU General Public Licenseです。但し、法律に従わない組織や個人などの邪悪な(者の)使用は認めません。
・・・できるんですが、パーマリンクの設定を行うとバグが発生するようです。具体的には・・・
デフォルト以外のラジオボタンを選択すると
対処方法としてはパーマリンク設定を変更しない!?「数字ベース」を選択するとブログの表示は出来るようだが、設定画面でエラーがでる。
設定>パーマリンクの設定をクリックすると
言語のアクティベートを解除して、もう一度アクティベートをすると不具合が解消される。ただしパーマリンク設定の変更は現状出来ない。
こちらから行えます
いわゆる管理者。無制限状態。なんでも出来る
編集者。ダッシュボード、投稿、管理(アップロード使用可)、ブログロール、プロフィールが操作可能
投稿者。ダッシュボード、投稿、管理(アップロード使用可)、プロフィールが操作可能
寄稿者。ダッシュボード、投稿、管理(アップロード使用不可)、プロフィールが操作可能
購読者。ダッシュボードとプロフィールが操作可能
自己責任において行ってください
下記、対象ファイルのソースコード
デフォルトの場合はwp-content/themes/EasyAll/のファイルに手を加えます。
<ul> <?php /* Widgetized sidebar, if you have the plugin installed. */ if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?> <li id="calendar"><h2><?php _e('Calendar'); ?></h2> <?php get_calendar(); ?> </li> <li id="search"> <form method="get" id="searchform" action="<?php bloginfo('url'); ?>"> <div> <input type="text" name="s" id="s" size="15" /> <input type="submit" value="<?php _e('Search'); ?>" /> </div> </form> </li> <?php get_links_list(); ?> <li><h2><?php _e('Archives'); ?></h2> <ul> <?php wp_get_archives('type=monthly&show_post_count=true'); ?> </ul> </li> <li><h2><?php _e('Categories'); ?></h2> <ul> <?php list_cats(0, '', 'name', 'asc', '', 1, 0, 1, 1, 1, 1, 0,'','','','','') ?> </ul> </li> <li id="meta"><h2><?php _e('Meta'); ?></h2> <ul> <?php wp_register(); ?> <li><?php wp_loginout(); ?></li> <li><a href="<?php bloginfo('rss2_url'); ?>" title="<?php _e('Syndicate this site using RSS'); ?>"><?php _e('<abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li> <li><a href="<?php bloginfo('comments_rss2_url'); ?>" title="<?php _e('The latest comments to all posts in RSS'); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li> <li><a href="http://validator.w3.org/check/referer" title="<?php _e('This page validates as XHTML 1.0 Transitional'); ?>"><?php _e('Valid <abbr title="eXtensible HyperText Markup Language">XHTML</abbr>'); ?></a></li> <li><a href="http://gmpg.org/xfn/"><abbr title="XHTML Friends Network">XFN</abbr></a></li> <li><?php echo sprintf(__('<a href="http://wordpress.org/" title="%s">WordPress</a>'), __("Powered by WordPress, state-of-the-art semantic personal publishing platform.")); ?></li> <?php wp_meta(); ?> </ul> </li> <?php endif; ?> </ul> </div> <!-- end sidebar -->
<li id="calendar"><h2><?php _e('Calendar'); ?></h2> <?php get_calendar(); ?> </li>
を削除しましょう。
<li>
から
</li>
を削除すればイイ。ここは<li>タグで各パーツが区切られているわけですな。例えば、
<div id="techno" class="mb1em"> <a href="http://www.technorati.jp/faves?sub=addfavbtn&add=http://blog.justoneplanet.info/"><img src="http://static.technorati.jp/pix/fave/btn-fave2.png" alt="" /></a> </div>
を<ul>タグの前に挿入すればテクノラティのお気に入りボタンが挿入できるわけです。
左のようにGoogle Adsenceを挿入したりできるわけです。
<php?から?>まではPHPスクリプトが書いてある部分なので多少HTMLとは話が違ってきます。慎重な方、心臓が弱い方は手を加えない方が宜しいですな。
まぁ気長に頑張りましょう。
まずはダウンロード
http://sourceforge.jp/projects/wordpress/files/
ダウンロードしたら圧縮してあるので解凍しましょう。
ファイル名は「wordpress-me221.zip」
解凍後、 FTPクライアントでアップロードします。
さて僕の場合はwordpressフォルダをアップしたので、FFFTPで言うとFFFTPで言うと右側のwordpressフォルダで右クリック。属性変更を選択し707もしくは777を入力します。
そしたらhttp://www.example.com/wordpress/ をブラウザで入力します。WordPressをインストールしたディレクトリですね。
普通の人はこれでサクサクインストールできるらしい
その場合はディレクトリのパーミッションを705もしくは755に戻し、直にファイルを編集します。wp-admin/install.php、wp-admin/upgrade.php を削除します
.htaccessなど設置して http://www.example.com/wordpress/を直接たたけない方。というか僕。 wp-config.phpを直接テキストエディタで開き編集しましょう。
define('DB_NAME', '●●●●●●●●●'); // The name of the database define('DB_USER', '●●●●●●●●●'); // Your MySQL username define('DB_PASSWORD', '*******'); // ...and password define('DB_HOST', 'mysql??.db.sakura.ne.jp'); // 99% chance you won't need
とデーターベースの設定をしましょう。
他に文字コードなども設定できますが特に僕は必要なかったので。
そしたらブラウザで・・・/wp-admin/install.phpと入力→データーベースにテーブルが作成されます。
画面にadminとパスワードが表示されます。
絶対にパスワードは忘れないで下さいね。
別のphpファイル用のphp.iniがまずかったらしく
WordPress用のディレクトリには被らないようにして
何とか正しく表示されるようになりました♪