OSDN Git Service

ブログカテゴリーメニューウィジェット更新。
authornaoki hirata <naoki@magic3.org>
Thu, 13 Jul 2017 03:29:42 +0000 (12:29 +0900)
committernaoki hirata <naoki@magic3.org>
Thu, 13 Jul 2017 03:29:42 +0000 (12:29 +0900)
include/manager/pageManager.php
include/sql/update_widgets.sql
include/wp/wp-includes/default-filters.php
include/wp/wp-includes/nav-menu-template.php
include/wp/wp-includes/theme.php
widgets/blog_category_menu/include/template/index.tmpl.html [new file with mode: 0644]
widgets/blog_category_menu/include/template/menu.tmpl.html [deleted file]

index 58fe1aa..241def7 100644 (file)
@@ -6265,22 +6265,50 @@ class PageManager extends Core
                return $url;
        }
        /**
-        * 指定のページ属性のページURLを生成
+        * 現在のアクセスポイントの指定のページ属性のページURLを生成
         *
         * @param string $contentType   コンテンツタイプ
-        * @param string $param         実行パラメータ
-        * @return string                       生成したURL
+        * @param string $param                 追加パラメータ
+        * @param bool $omitPageId              ページID省略形を使用するかどうか
+        * @return string                               生成したURL
         */
-       function createContentPageUrl($contentType, $param = '')
+       function createContentPageUrl($contentType, $param = '', $omitPageId = true)
        {
                global $gEnvManager;
+               static $urlArray = array();
                
-               $pageSubId = $this->getPageSubIdByContentType($contentType, $gEnvManager->getCurrentPageId());
-               if (empty($pageSubId)) $pageSubId = $gEnvManager->getDefaultPageSubId();
+               // 複数回呼ばれるのでコンテンツタイプごとにページまでのURLは保存しておく
+               $baseUrl = $urlArray[$contentType];
+               if (!isset($baseUrl)){
+                       // コンテンツタイプからページサブIDを取得
+                       $pageSubId = $this->getPageSubIdByContentType($contentType, $gEnvManager->getCurrentPageId());          // DBから取得
                
-               $url = $gEnvManager->createPageUrl();
-               $url .= '?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $pageSubId;
-               if (!empty($param)) $url .= '&' . $param;
+                       if (empty($pageSubId)){ // ページサブIDが取得できない場合はデフォルトのページサブIDを取得
+                               $pageSubId = $gEnvManager->getDefaultPageSubId();
+                       } else if ($pageSubId == $gEnvManager->getDefaultPageSubId()){          // デフォルトページの場合
+                               if ($omitPageId) $pageSubId = '';       // ページID省略形を使用する場合はページサブIDを省略
+                       }
+                       
+                       // 現在のアクセスポイントのURLを取得
+                       $baseUrl = $gEnvManager->createPageUrl();
+                       
+                       // ページサブIDを付加
+                       if (!empty($pageSubId)) $baseUrl .= '?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $pageSubId;
+                       
+                       // URLを保存
+                       $urlArray[$contentType] = $baseUrl;
+               }
+               
+               // 追加パラメータ
+               $url = $baseUrl;
+               if (!empty($param)){
+                       if (strEndsWith($url, '.php') || strEndsWith($url, '/')){
+                               $url .= '?';
+                       } else {
+                               $url .= '&';
+                       }
+                       $url .= $param;
+               }
                return $url;
        }
        /**
index 7cf0faa..42f89d0 100644 (file)
@@ -106,7 +106,7 @@ INSERT INTO _widgets
 DELETE FROM _widgets WHERE wd_id = 'blog_new_box';\r
 INSERT INTO _widgets\r
 (wd_id,          wd_name,         wd_category_id, wd_template_type, wd_version, wd_author,      wd_copyright, wd_license, wd_official_level, wd_description,             wd_has_admin, wd_enable_operation, wd_use_instance_def, wd_initialized, wd_cache_type, wd_view_control_type, wd_has_rss, wd_release_dt, wd_install_dt, wd_create_dt) VALUES\r
-('blog_new_box', 'ブログ-最新', 'blog',        'wordpress', '2.2.0',    'Naoki Hirata', 'Magic3.org', 'GPL',      10,                'ブログの最新記事一覧を表示。', true,        false,               false,true,               1, -1, true, '2015-02-23', now(),    now());\r
+('blog_new_box', 'ブログ-最新', 'blog',        'wordpress', '3.0.0',    'Naoki Hirata', 'Magic3.org', 'GPL',      10,                'ブログの最新記事一覧を表示。', true,        false,               false,true,               1, -1, true, '2017-07-12', now(),    now());\r
 DELETE FROM _widgets WHERE wd_id = 'blog_update_box';\r
 INSERT INTO _widgets\r
 (wd_id,          wd_name,            wd_category_id, wd_version, wd_author,      wd_copyright, wd_license, wd_official_level, wd_description,             wd_has_admin, wd_enable_operation, wd_use_instance_def, wd_initialized, wd_cache_type, wd_view_control_type, wd_has_rss, wd_release_dt, wd_install_dt, wd_create_dt) VALUES\r
@@ -117,8 +117,8 @@ INSERT INTO _widgets
 ('blog_calendar_box', 'ブログ-カレンダー', 'blog',         '1.2.0',    'Naoki Hirata', 'Magic3.org', 'GPL', 10, 'カレンダーからブログ記事にアクセスするためのボックス。',        false,           false,       true,         true,        false,         false,               false,true,               '2015-10-02', now(),    now());\r
 DELETE FROM _widgets WHERE wd_id = 'blog_category_menu';\r
 INSERT INTO _widgets\r
-(wd_id,                wd_name,                     wd_category_id, wd_version, wd_author,      wd_copyright, wd_license, wd_official_level, wd_description, wd_read_scripts, wd_read_css, wd_available, wd_editable, wd_has_admin, wd_enable_operation, wd_use_instance_def, wd_initialized, wd_release_dt, wd_install_dt, wd_create_dt) VALUES\r
-('blog_category_menu', 'ブログ-カテゴリーメニュー', 'blog',         '1.1.0',    'Naoki Hirata', 'Magic3.org', 'GPL',      10,                'ブログカテゴリメニュー',          false,           false,       true,         true,        false,         false,               false,true,           '2015-10-02',now(), now());\r
+(wd_id,                wd_name,                     wd_category_id, wd_template_type, wd_version, wd_author,      wd_copyright, wd_license, wd_official_level, wd_description, wd_read_scripts, wd_read_css, wd_available, wd_editable, wd_has_admin, wd_enable_operation, wd_use_instance_def, wd_initialized, wd_release_dt, wd_install_dt, wd_create_dt) VALUES\r
+('blog_category_menu', 'ブログ-カテゴリーメニュー', 'blog', 'wordpress',        '2.0.0',    'Naoki Hirata', 'Magic3.org', 'GPL',      10,                'ブログカテゴリメニュー',          false,           false,       true,         true,        false,         false,               false,true,           '2017-07-12',now(), now());\r
 DELETE FROM _widgets WHERE wd_id = 'blog_archive_menu';\r
 INSERT INTO _widgets\r
 (wd_id,               wd_name,                     wd_category_id, wd_version, wd_author,      wd_copyright, wd_license, wd_official_level, wd_description, wd_has_admin, wd_enable_operation, wd_use_instance_def, wd_initialized, wd_release_dt, wd_install_dt, wd_create_dt) VALUES\r
index f217c33..56b5b66 100644 (file)
@@ -214,9 +214,9 @@ add_filter( 'option_category_base',     '_wp_filter_taxonomy_base'            );
 //add_filter( 'pings_open',               '_close_comments_for_old_post', 10, 2 );
 add_filter( 'editable_slug',            'urldecode'                           );
 add_filter( 'editable_slug',            'esc_textarea'                        );
-add_filter( 'nav_menu_meta_box_object', '_wp_nav_menu_meta_box_object'        );
-add_filter( 'pingback_ping_source_uri', 'pingback_ping_source_uri'            );
-add_filter( 'xmlrpc_pingback_error',    'xmlrpc_pingback_error'               );
+//add_filter( 'nav_menu_meta_box_object', '_wp_nav_menu_meta_box_object'        );
+//add_filter( 'pingback_ping_source_uri', 'pingback_ping_source_uri'            );
+//add_filter( 'xmlrpc_pingback_error',    'xmlrpc_pingback_error'               );
 add_filter( 'title_save_pre',           'trim'                                );
 
 add_action( 'transition_comment_status', '_clear_modified_cache_on_transition_comment_status', 10, 2 );
@@ -451,7 +451,7 @@ add_action( 'wp_playlist_scripts', 'wp_playlist_scripts' );
 add_action( 'customize_controls_enqueue_scripts', 'wp_plupload_default_settings' );
 
 // Nav menu
-add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 );
+//add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 );
 
 // Widgets
 //add_action( 'init', 'wp_widgets_init', 1 );
index 93c2848..079bdc7 100644 (file)
@@ -135,14 +135,18 @@ function wp_nav_menu( $args = array() ) {
                // こちらが実行される
                        return call_user_func( $args->fallback_cb, (array) $args );
        }
+       
+       return null;
+       
        // ########## ここ以降は未使用 ##########
-       if ( ! $menu || is_wp_error( $menu ) )
+/*     if ( ! $menu || is_wp_error( $menu ) )
                return false;
 
        $nav_menu = $items = '';
 
        $show_container = false;
        if ( $args->container ) {
+       */
                /**
                 * Filters the list of HTML tags that are valid for use as menu containers.
                 *
@@ -151,7 +155,7 @@ function wp_nav_menu( $args = array() ) {
                 * @param array $tags The acceptable HTML tags for use as menu containers.
                 *                    Default is array containing 'div' and 'nav'.
                 */
-               $allowed_tags = apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav' ) );
+/*             $allowed_tags = apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav' ) );
                if ( is_string( $args->container ) && in_array( $args->container, $allowed_tags ) ) {
                        $show_container = true;
                        $class = $args->container_class ? ' class="' . esc_attr( $args->container_class ) . '"' : ' class="menu-'. $menu->slug .'-container"';
@@ -161,7 +165,7 @@ function wp_nav_menu( $args = array() ) {
        }
 
        // Set up the $menu_item variables
-       _wp_menu_item_classes_by_context( $menu_items );
+//     _wp_menu_item_classes_by_context( $menu_items );
 
        $sorted_menu_items = $menu_items_with_children = array();
        foreach ( (array) $menu_items as $menu_item ) {
@@ -179,7 +183,7 @@ function wp_nav_menu( $args = array() ) {
        }
 
        unset( $menu_items, $menu_item );
-
+*/
        /**
         * Filters the sorted list of menu item objects before generating the menu's HTML.
         *
@@ -188,9 +192,9 @@ function wp_nav_menu( $args = array() ) {
         * @param array    $sorted_menu_items The menu items, sorted by each menu item's menu order.
         * @param stdClass $args              An object containing wp_nav_menu() arguments.
         */
-       $sorted_menu_items = apply_filters( 'wp_nav_menu_objects', $sorted_menu_items, $args );
+/*     $sorted_menu_items = apply_filters( 'wp_nav_menu_objects', $sorted_menu_items, $args );
 
-       $items .= walk_nav_menu_tree( $sorted_menu_items, $args->depth, $args );
+//     $items .= walk_nav_menu_tree( $sorted_menu_items, $args->depth, $args );
        unset($sorted_menu_items);
 
        // Attributes
@@ -208,7 +212,7 @@ function wp_nav_menu( $args = array() ) {
        $menu_id_slugs[] = $wrap_id;
 
        $wrap_class = $args->menu_class ? $args->menu_class : '';
-
+*/
        /**
         * Filters the HTML list content for navigation menus.
         *
@@ -219,7 +223,7 @@ function wp_nav_menu( $args = array() ) {
         * @param string   $items The HTML list content for the menu items.
         * @param stdClass $args  An object containing wp_nav_menu() arguments.
         */
-       $items = apply_filters( 'wp_nav_menu_items', $items, $args );
+//     $items = apply_filters( 'wp_nav_menu_items', $items, $args );
        /**
         * Filters the HTML list content for a specific navigation menu.
         *
@@ -230,7 +234,7 @@ function wp_nav_menu( $args = array() ) {
         * @param string   $items The HTML list content for the menu items.
         * @param stdClass $args  An object containing wp_nav_menu() arguments.
         */
-       $items = apply_filters( "wp_nav_menu_{$menu->slug}_items", $items, $args );
+/*     $items = apply_filters( "wp_nav_menu_{$menu->slug}_items", $items, $args );
 
        // Don't print any markup if there are no items at this point.
        if ( empty( $items ) )
@@ -241,7 +245,7 @@ function wp_nav_menu( $args = array() ) {
 
        if ( $show_container )
                $nav_menu .= '</' . $args->container . '>';
-
+*/
        /**
         * Filters the HTML content for navigation menus.
         *
@@ -252,12 +256,13 @@ function wp_nav_menu( $args = array() ) {
         * @param string   $nav_menu The HTML content for the navigation menu.
         * @param stdClass $args     An object containing wp_nav_menu() arguments.
         */
-       $nav_menu = apply_filters( 'wp_nav_menu', $nav_menu, $args );
+/*     $nav_menu = apply_filters( 'wp_nav_menu', $nav_menu, $args );
 
        if ( $args->echo )
                echo $nav_menu;
        else
                return $nav_menu;
+               */
 }
 
 /**
@@ -271,6 +276,7 @@ function wp_nav_menu( $args = array() ) {
  *
  * @param array $menu_items The current menu item objects to which to add the class property information.
  */
+/*
 function _wp_menu_item_classes_by_context( &$menu_items ) {
        global $wp_query, $wp_rewrite;
 
@@ -498,7 +504,7 @@ function _wp_menu_item_classes_by_context( &$menu_items ) {
                $menu_items[$key]->classes = array_unique( $classes );
        }
 }
-
+*/
 /**
  * Retrieve the HTML list content for nav menu items.
  *
@@ -510,12 +516,12 @@ function _wp_menu_item_classes_by_context( &$menu_items ) {
  * @param stdClass $r     An object containing wp_nav_menu() arguments.
  * @return string The HTML list content for the menu items.
  */
-function walk_nav_menu_tree( $items, $depth, $r ) {
+/*function walk_nav_menu_tree( $items, $depth, $r ) {
        $walker = ( empty($r->walker) ) ? new Walker_Nav_Menu : $r->walker;
        $args = array( $items, $depth, $r );
 
        return call_user_func_array( array( $walker, 'walk' ), $args );
-}
+}*/
 
 /**
  * Prevents a menu item ID from being used more than once.
@@ -528,11 +534,11 @@ function walk_nav_menu_tree( $items, $depth, $r ) {
  * @param object $item
  * @return string
  */
-function _nav_menu_item_id_use_once( $id, $item ) {
+/*function _nav_menu_item_id_use_once( $id, $item ) {
        static $_used_ids = array();
        if ( in_array( $item->ID, $_used_ids ) ) {
                return '';
        }
        $_used_ids[] = $item->ID;
        return $id;
-}
+}*/
index bb5631d..80be907 100644 (file)
@@ -121,11 +121,11 @@ function wp_get_theme( $stylesheet = null, $theme_root = null ) {
  * @param bool $clear_update_cache Whether to clear the Theme updates cache
  */
 function wp_clean_themes_cache( $clear_update_cache = true ) {
-       if ( $clear_update_cache )
+/*     if ( $clear_update_cache )
                delete_site_transient( 'update_themes' );
        search_theme_directories( true );
        foreach ( wp_get_themes( array( 'errors' => null ) ) as $theme )
-               $theme->cache_delete();
+               $theme->cache_delete();*/
 }
 
 /**
@@ -806,7 +806,7 @@ function validate_current_theme() {
         *
         * @param bool $validate Whether to validate the current theme. Default true.
         */
-       if ( wp_installing() || ! apply_filters( 'validate_current_theme', true ) )
+/*     if ( wp_installing() || ! apply_filters( 'validate_current_theme', true ) )
                return true;
 
        if ( ! file_exists( get_template_directory() . '/index.php' ) ) {
@@ -825,7 +825,7 @@ function validate_current_theme() {
                switch_theme( WP_DEFAULT_THEME );
                return false;
        }
-
+*/
        /**
         * If we're in an invalid state but WP_DEFAULT_THEME doesn't exist,
         * switch to the latest core default theme that's installed.
@@ -835,13 +835,15 @@ function validate_current_theme() {
         * checks against WP_DEFAULT_THEME above, also.) We also can't do anything
         * if it turns out there is no default theme installed. (That's `false`.)
         */
-       $default = WP_Theme::get_core_default_theme();
+/*     $default = WP_Theme::get_core_default_theme();
        if ( false === $default || get_stylesheet() == $default->get_stylesheet() ) {
                return true;
        }
 
        switch_theme( $default->get_stylesheet() );
        return false;
+       */
+       return true;
 }
 
 /**
diff --git a/widgets/blog_category_menu/include/template/index.tmpl.html b/widgets/blog_category_menu/include/template/index.tmpl.html
new file mode 100644 (file)
index 0000000..01a5687
--- /dev/null
@@ -0,0 +1,17 @@
+/**
+ * 表示データ作成用テンプレート(patTemplate)
+ *
+ * LICENSE: This source file is licensed under the terms of the GNU General Public License.
+ *
+ * @package    Magic3 Framework
+ * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
+ * @copyright  Copyright 2006-2017 Magic3 Project.
+ * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
+ * @version    SVN: $Id$
+ * @link       http://www.magic3.org
+ */
+<patTemplate:tmpl name="_widget">
+<ul>
+  <patTemplate:tmpl name="itemlist"><li {CLASS}><a href="{LINK_URL}"><span>{NAME}</span></a></li></patTemplate:tmpl>
+</ul>
+</patTemplate:tmpl>
diff --git a/widgets/blog_category_menu/include/template/menu.tmpl.html b/widgets/blog_category_menu/include/template/menu.tmpl.html
deleted file mode 100644 (file)
index 1174fe8..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<patTemplate:tmpl name="_widget">
-<ul>
-  <patTemplate:tmpl name="itemlist"><li><a href="{LINK_URL}"><span>{NAME}</span></a></li></patTemplate:tmpl>
-</ul>
-</patTemplate:tmpl>