代码点火器中的Wordpress [英] Wordpress in Code Igniter

查看:107
本文介绍了代码点火器中的Wordpress的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好,我已经搜索过,没有什么完全覆盖这个..

Ok.. I've searched and nothing quite covers this..

我已经遵循本指南: http://philpalmieri.com/2009/06/codeigniter-and-wordpress-play-well-together/ < a>

I have followed this guide: http://philpalmieri.com/2009/06/codeigniter-and-wordpress-play-well-together/

这基本上说,安装wordpress,让它工作,然后替换index.php文件与代码Igniters,然后在文件的底部我们启动代码Igniter,需要wordpress的wp-load文件。

Which basically says, to install wordpress, get it working, then replace the index.php file with Code Igniters, and then at the bottom of the file right before we initiate Code Igniter, require the wp-load file of word press.

工作正常。

,我的$ _SESSION不工作。我设置代码igniter使用数据库会话,并且它记录会话值,但它仍然不工作。我不能登录到我的代码Igniter系统管理面板,我不能做任何东西,需要会话,因为会话不工作。 LOL。

However now, my $_SESSION doesn't work. I have set code igniter to use Database sessions, and its logging the session values, but It still doesn't work. I cant log into my Code Igniter systems admin panel, I cant do much of anything that requires sessions because Sessions dont work. LOL.

任何想法家伙?我不知道如何解决这个问题。

Any ideas guys? I have no clue how to fix this.

推荐答案

我做了下面的工作,我有一个代码Igniter应用程序在Wordpress目录中的一个单独的目录) - 我显然不是喜欢的是,我不得不修改一个核心文件在Wordpress。

I did the following to get this to work (I have a Code Igniter application in a separate directory within a Wordpress directory) -- what I obviously don't like about it is that I had to modify a core file within Wordpress.

首先,我将代码Igniter cookie名称添加到wp-includes / load.php中的$ no_unset数组。在我的例子中,它是ci_session:

First, I added my Code Igniter cookie name to the $no_unset array in wp-includes/load.php In my case it was ci_session:

    $no_unset = array( 'GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix','ci_session' );

其次,我发现Wordpress的add_magic_quotes函数正在处理$ _COOKIE全局。这使得CodeIgniter在每个页面加载或重定向时重新创建cookie,从而破坏任何连续性。所以,我在wp-includes.load.php(在第545行附近)注释了这一行。

Second, I figured out that Wordpress's add_magic_quotes function was mangling the $_COOKIE global. This was causing CodeIgniter to re-create the cookie on each page load or redirect and thereby breaking any continuity. So, I commented this line out in wp-includes.load.php (around line 545)

//$_COOKIE = add_magic_quotes( $_COOKIE );

接下来,为了保持这个功能对所有其他Wordpress相关的cookie,我创建了一个array_walk函数循环在$ _COOKIE全局和应用add_magic_quotes到所有的cookies除了我的在wp-includes / load.php函数

Next, to keep this function in tact for all other Wordpress related cookies, I created an array_walk function to loop over the $_COOKIE global and apply add_magic_quotes to all cookies except for mine within the wp-includes/load.php function

/**
* Applies Magic Quotes to the $_COOKIE global but ignores Codeigniter's Cookie
* @param  string $value Value passed by array_walk function
* @param  string $key   Key passed by array_walk function
*/
function ci_ignore_magic_quotes($value,$key)
{
    if($key != "ci_session")
    {
        stripslashes_deep($value);
    }
}

//Put this line in place of the commented out line above...
array_walk($_COOKIE, 'ci_ignore_magic_quotes');

在我这样做后,我不再有多个cookie存储在我的ci_sessions表,会话成功保留。

After I did this, I was no longer having multiple cookies stored in my ci_sessions table and sessions were successfully retained.

我希望这有助于!

这篇关于代码点火器中的Wordpress的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆