XPressME Integration Kit

Trac

source: trunk/xpressme_integration_kit/include/add_xpress_process.php @ 454

Last change on this file since 454 was 454, checked in by toemon, 14 years ago

WordPressの一般設定の「ブログのアドレス (URL)」を変更できるようにした。
但し、アクセスが可能URLなURLでない場合は、インデックスページ呼び出し時に修正が行われる。
fixes #249

File size: 3.6 KB
Line 
1<?php
2// used wptouch plugin & iPhone access check (thx uemu)
3function is_iphone_with_wptouch(){
4        global $wptouch_plugin;
5        if (is_object($wptouch_plugin)) return $wptouch_plugin->applemobile;
6        return false;
7}
8
9function safe_site_url(){
10        global $xoops_config;
11       
12        if (is_xpress_index_page_call()){
13                $siteurl = get_option('siteurl');
14                $home = get_option('home');
15                $module_url = $xoops_config->module_url;
16                $guess_url = wp_guess_url();
17                $guess_url = preg_replace('/\/$/','',$guess_url);
18               
19                if($siteurl != $module_url) {
20                        if (!@fclose(@fopen($siteurl . '/xoops_version.php', "r"))){
21                                update_option('siteurl' , $module_url);
22                        }
23                }
24               
25                if($guess_url != $home) {
26                        if (!@fclose(@fopen($home . '/xoops_version.php', "r"))){
27                                update_option('home' , $guess_url);
28                        }
29                }
30        }
31}
32
33require_once( dirname( __FILE__ ).'/request_url.php');
34if (is_xpress_index_page_call()){
35        //When notifying by a private message, Notification_reserve_send();
36        //it is evaded that the data base becomes read-only as a result of the check on the referrer and the method.
37        $_SERVER['REQUEST_METHOD'] = 'POST';
38
39        require_once $xoops_config->xoops_mainfile_path; //It is necessary to execute it for the user attestation before wp-settings.php.
40        unset($offset);
41        require_once(ABSPATH.'wp-settings.php');
42       
43        safe_site_url();
44
45        if (!is_object($xoopsUser)){    // before login auth cookie clear
46                wp_logout();
47        }
48        wp();
49       
50        //for Event notification update on single post to which link is changed by permalink
51        if ( is_404() ) {
52                if (!empty($_POST['not_redirect'])) {
53                        include '../../mainfile.php';
54                        require_once XOOPS_ROOT_PATH.'/include/notification_update.php';
55                        exit();
56                }
57        }
58       
59        if (!function_exists('is_wordpress_style')){    // When the XPressME plug-in is invalid
60                require_once dirname( __FILE__ ).'/xpress_active_plugin.php' ;
61                xpress_pulugin_activation('xpressme/xpressme.php');
62                // reloaded
63                header('Location: ' . $xoops_config->module_url . '/');
64               
65                $err_str = "The activation of the XPressME plugin was executed.<br />\n";
66                $err_str .= "Because the XPressME plugin was invalid.<br />\n";
67                $err_str .= "Please do the rereading seeing on the page.\n";                   
68                die($err_str);
69        }
70       
71        Notification_reserve_send();
72        ob_start();     
73                if (version_compare($xoops_config->wp_version,'2.2', '<'))
74                        require_once dirname( __FILE__ ).'/old_template-loader.php' ;
75                else
76                        require_once( ABSPATH . WPINC . '/template-loader.php' );
77                $wp_output = ob_get_contents();
78        ob_end_clean();
79
80        //Rendering Select
81        if(
82                is_wordpress_style()            // When the display mode is WordPress style
83                || is_feed()                            // It judges it here because it does in is_index_page() through feed to which the permalink is set.
84                || is_iphone_with_wptouch()     // When iPhone access & used wptouch plugin (thx uemu)
85        ){
86                        echo $wp_output;
87        } else {
88                        require_once( dirname( __FILE__ ).'/xpress_render.php' );
89                        xpress_render($wp_output);
90        }
91
92        //When there is no block cache, and an optional block is different, cache is refreshed.
93        //When adding, and changing and deleting Post & Comment, block cache is refreshed by add_action at any time.
94        // This Function in xpressme plugin
95        require_once( dirname( __FILE__ ).'/xpress_block_render.php' );
96        xpress_unnecessary_block_cache_delete($xoops_config->module_name);
97        if (is_home()) xpress_block_cache_refresh($xoops_config->module_name);
98        exit();         // The return to wp-blog-header.php is stolen here
99}
100if (is_admin_post_call()) require_once $xoops_config->xoops_mainfile_path;              // for Notification_triggerEvent
101if (is_xpress_comments_post_call()) require_once $xoops_config->xoops_mainfile_path;    // for Notification_triggerEvent
102?>
Note: See TracBrowser for help on using the repository browser.