OSDN Git Service

WordPressテンプレート機能更新。
authornaoki hirata <naoki@magic3.org>
Tue, 10 Oct 2017 22:42:06 +0000 (07:42 +0900)
committernaoki hirata <naoki@magic3.org>
Tue, 10 Oct 2017 22:42:06 +0000 (07:42 +0900)
include/container/baseFrameContainer.php
include/manager/pageManager.php
include/wp/contentApi.php
include/wp/wp-includes/post-template.php

index 4e77aa5..c0d52f0 100644 (file)
@@ -947,6 +947,13 @@ class BaseFrameContainer extends Core
                                                        return;                         // ここで終了
                                                }
                                        }
+                               } else {
+                                       // 検索キーワードが設定されている場合は画面タイトルを設定
+                                       $value = $request->trimValueOf(M3_REQUEST_PARAM_KEYWORD);
+                                       if (!empty($value)){
+                                               // 検索画面のタイトルを設定
+                                               $GLOBALS['gContentApi']->setPostTitle('検索');
+                                       }
                                }
                                
                                // コンテンツタイプが設定されていないページ(お問合わせページ等)に場合は、固定ページ用のテンプレートを使用
index 5019085..6c60cbc 100644 (file)
@@ -6655,6 +6655,15 @@ class PageManager extends Core
                return $this->pageInfo[$pageId . self::PAGE_ID_SEPARATOR . $pageSubId];
        }
        /**
+        * 現在のページのページ情報を取得
+        *
+        * @return array                        ページ情報レコード
+        */     
+       function getCurrentPageInfo()
+       {
+               return $this->currentPageInfo;
+       }
+       /**
         * 現在のページ情報からテンプレートIDを取得
         *
         * @param string $subTemplateId         テンプレートIDが取得できるときはサブページIDが返る
index d8c9157..09d534f 100644 (file)
@@ -40,6 +40,7 @@ class ContentApi extends BaseApi
        private $relativePosts;                 // 現在のコンテンツに関連したWP_Postオブジェクト
        private $showThumb;                             // コンテンツ表示制御(サムネールを表示するかどうか)
        private $isTemplatePart;                // get_template_part()内での処理かどうか(コンポーネント出力判断用)
+       private $postTitle;                             // コンテンツタイプが設定されていない場合の画面タイトル
        
        const CF_DEFAULT_CONTENT_TYPE = 'default_content_type';         // デフォルトコンテンツタイプ取得用
        const DEFAULT_CONTENT_TYPE = 'blog';            // デフォルトコンテンツタイプのデフォルト値
@@ -1071,5 +1072,24 @@ class ContentApi extends BaseApi
                        return false;
                }
        }
+       /**
+        * コンテンツタイプが設定されていない場合の画面タイトルを設定
+        *
+        * @param string $title                 タイトル
+        * @return                                              なし
+        */
+       public function setPostTitle($title)
+       {
+               $this->postTitle = $title;
+       }
+       /**
+        * コンテンツタイプが設定されていない場合の画面タイトルを取得
+        *
+        * @return string                       タイトル
+        */
+       public function getPostTitle()
+       {
+               return $this->postTitle;
+       }
 }
 ?>
index 7592b7a..49aaf03 100644 (file)
@@ -146,6 +146,12 @@ function get_the_title( $post = 0 ) {
                        $title = sprintf( $private_title_format, $title );
                }
        }
+       // ##### コンテンツからタイトルを取得できない場合は画面のタイトルを取得 #####
+       // ##### この関数が呼ばれる時点ではまだウィジェットは実行されていないので$gPageManager->getHeadSubTitle()でタイトルは取得できない #####
+       if (empty($title)){
+               global $gContentApi;
+               $title = $gContentApi->getPostTitle();
+       }
 
        // ##### タイトルが取得できない場合はメニューから取得 #####
        if (empty($title)){