0

It's possible to use a wordpress plugin in other framework than wordpress like Codeigniter ? I want to use wordpress booking calendar ( https://wordpress.org/plugins/booking/ ) in a website built under the codeigniter framework. In backend of this site is built an admin panel using this theme: https://almsaeedstudio.com/preview

I want to load required wp files to use this plugin in my site, how I should to proceed ?

I know it's a vast question but if are someone who have any idea please or already made something like this please share your your knowledges. Thanks!

0
2

It is possible but probably not worth it. what you will need to do is bootstrap wordpress by including the wp-load.php file located at the root of the wordpress directory structure. The problem is that wordpress is still far from having a clean organized code which is globals free so while it is possible in theory, YMMV greatly depending on how clean is your code and what kind of GUI you will require.

I am not sure at all that I would embark on this kind of project just for one plugin, as in the end you will have two stacks to maintain and upgrade and retest after each upgrade.

1

That would be too time expensive to make it worth while. You might as well write the plugin using Codeigniter in the first place. The plugin itself, if written correctly, relies on the Wordpress core to implement its functionality. Codeigniter is architecturally different than Wordpress making this task a joy only for someone who likes hitting themselves in the thumb with a hammer repeatedly.

0

Found article for working with both codeigniter and wordpress, it may not directly answer the question but it may help. Article full quoted to ensure content availability.

https://www.cometchat.com/blog/how-to-integrate-codeigniter-with-wordpress/

August 12, 2015 CometChat Team It comes as little surprise that many website owners and administrators still prefer WordPress as their primary Content Management System (CMS), and you can’t blame them considering the comprehensive features that WordPress has to offer. However, when it comes to creating customized applications, WordPress is on the back burner as it is not a suitable tool due to many reasons. But, the ease of management and updates on the CMS are too hard to give up, which is why many website owners today prefer to use CodeIgniter for application building.

CodeIgniter is a lightweight PHP framework that can help in developing applications that can be integrated with WordPress, which I will explain shortly. While some users prefer developing the CodeIgniter and WordPress elements separately, we will go through an example where the primary navigation and footer are similar in both platforms, because it doesn’t make much sense to update the navigation and footer twice.

wp-ci.

As WordPress is our primary application here, we will use its functionality within CodeIgniter while keeping the CodeIgniter app in a sub-directory.

Here is a step by step guide to integrating CodeIgniter app with WordPress

  1. Add the WordPress Bootstrap File We’ll take a look at the case study of Phil Palmieri to help us understand how to integrate CodeIgniter with WordPress. The wp-load.php file will immediately precede the CodeIgniter bootstrap file in the index.php.

file: We took a cue from Phil Palmieri and referenced WordPress’s wp-load.php file immediately preceding the call to CodeIgniter bootstrap file in CI’s index.php file: * -------------------------------------------------------------------- * LOAD THE BOOTSTRAP FILE * -------------------------------------------------------------------- * * Here we go * */ //Load WordPress file. require_once('/Server/path/to/wp-load.php'); require_once BASEPATH.'core/CodeIgniter.php'; Easy right?

Now before we add WordPress functionality to the CodeIgniter CI’s file, we will perform a test to make sure everything is alright. As you can see from the same above, all the links and URLs within the CodeIgniter app will link back to the root directory of WordPress, which results in a 404 error.

Since both CodeIgniter and WordPress have “site_url” functionality, we’ll still get the error even when the WordPress bootstrap file is loaded before CodeIgniter bootstrap file. However, by installing a Runkit PHP extension, we can overwrite the global function, provided that we have both site_url functions for WordPress and CodeIgniter in separate directories.

2.Extend Codeigniter URL Helper We will now create a new namespaced function to ‘extend’ the URL helper of CodeIgniter. By using ci_site_url, we can resolve the site_url issue. The My_url_helper.php (helper) file should be in the application directory of CodeIgniter.

3.Change site_url to ci_site_url in CodeIgniter App. Quick search your applications, controllers, models, and directories and replace all site_url file references with ci_site_url.

4.Stop WordPress from Contorting Cookies! You might experience an issue where CodeIgniter will create cookies for every active database session when you log in. This can lead to WordPress bootstrap file rectifying the issue. This happens when WordPress loops via the $_COOKIE global and implements add_magic_quotes functionality to all elements, except the CodeIgniter cookie. Following is the code to resolve this issue.

Scroll to Line 520 and add this function: (Let’s say you’re using CI's default ci_session key)

/**
* 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);
    }
}

Comment out the following lines inside the wp_magic_quotes function and add a reference to the ci_ignore_magic_quotes function.

array_walk($_COOKIE, 'ci_ignore_magic_quotes');
//$_COOKIE = add_magic_quotes( $_COOKIE );

Additionally, you will have to set WordPress to not unset the

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

Once all the steps are complete, you can start using WordPress with your CodeIgniter application like it was always there!.

changes made in wp-includes/load.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.