XPressME Integration Kit

Trac

Changeset 560


Ignore:
Timestamp:
Mar 19, 2010, 3:29:26 PM (14 years ago)
Author:
toemon
Message:

WPテーマで<body>タグ内のclassを参照している場合の対応 Fixes#319

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xpressme_integration_kit/include/xpress_render.php

    r432 r560  
    9292function get_body($contents) 
    9393{ 
    94         $xpess_config = new XPressME_Class(); 
     94        global $xpess_config; 
     95        if (!is_object($xpess_config)) $xpess_config = new XPressME_Class(); 
    9596        $pattern = "<body[^>]*?>(.*)<\/body>"; 
    9697        $body = ''; 
     
    9899                $body = $body_matches[1]; 
    99100        } 
     101         
     102        $pattern = '<body\s*([^>]*)>'; 
     103        $body_class = 'class="xpress"'; 
     104        if(preg_match("/".$pattern."/s",  $contents, $body_matches)){ 
     105                $body_tag_option = $body_matches[1]; 
     106 
     107                $pattern = 'class\s*=\s*[\'|"]([^\'|^"]*)[\'|"]';                
     108                if(preg_match("/".$pattern."/",  $body_tag_option, $class_matches)){ 
     109                        $class_value = $class_matches[1]; 
     110                        $reprace = 'xpress '. $class_value; 
     111                        $body_class = preg_replace("/".$class_value."/",  $reprace, $body_tag_option); 
     112                } else { 
     113                        $body_class = 'class="xpress" ' . $body_tag_option; 
     114                } 
     115        } 
     116 
    100117        if (!$xpess_config->is_theme_sidebar_disp){ 
    101118                $side_panel = get_sidebar_rander(); 
    102119                        $body = str_replace($side_panel,'',$body); 
    103120        } 
     121        $body = "\n<div " . $body_class . "> <!-- Substitution of wordpress <body > -->\n" . $body . "\n</div> <!-- Substitution of wordpress </body > -->\n"; 
    104122        return $body; 
    105123} 
Note: See TracChangeset for help on using the changeset viewer.