How to run codeigniter(HMVC) inside wordpress folder - wordpress

Anybody have install codeigniter(HMVC) within wordpress.
I am trying to install codeigniter(HMVC) inside wordpress folder.
my codeigniter is work on Virtual host can it possible to run codeigniter within wordpress setup with codeigniter is work on virtual host.
Any suggestion.

It is very easy. Here is step by step process.
First see the structure.
You can see it is inside wordpress directory. Next Add this in index.php of codeigniter
require_once('../wp-load.php');
And finally to avoid conflict between Wordpress and Codeigntier's site_url function add this file in codeigniter/application/core as MY_url_helper.php
if (!defined('BASEPATH')) exit('No direct script access allowed');
if (!function_exists('ci_site_url')) {
function ci_site_url($uri = '')
{
$CI =& get_instance();
return $CI->config->site_url($uri);
}
}
if (!function_exists('ci_base_url')) {
function ci_base_url($uri = '')
{
$CI =& get_instance();
return $CI->config->base_url($uri);
}
}
Now when you use site_url() it will refer to wordpress site_url() and
ci_site_url() it will refer to codeigniter's site_url.
And now when you need to access codeigniter try this.
`http://localhost/wordpress/codeigniter/index.php/mycontroller/mymethod`
Hope it is easy to set up and helps.

Codeignetor can run OK in every directory if server allows to install on that directory.
If its not working please confirm the security settings from server.

Related

How can I integrate wordpress into magento 2 project in valet plus?

I am using Valet+ for my Magento projects.
Currently I’m trying to add WP integration for M2 project. I put wordpress copy into pub/wp/ directory and want to go through the installation process, but I’m receiving 404 error when I’m trying to access url like https://magento2.test/wp/
Could anyone advice for it?
Thank you!
You can use custom valet driver for it.
Copy Magento2ValetDriver.php into magento root directory and rename it to LocalValetDriver.php
Also, change the class name to LocalValetDriver in it.
In the function frontControllerPath, add the following code at the top.
if ($uri === '/wp') {
$_SERVER['DOCUMENT_ROOT'] = $sitePath . '/pub/wp';
return $sitePath . '/pub/wp/index.php';
}

HTTPS Issue With Mixed Content - ARForms Plugin

I have a site wordpress in HTTPS, but also i have an Mixed Content because of ARForms Plugin. PHP 5.6
fonts.googleapis.com and some images in this plugin unsecure, and that files i cant find in database anf template files, please help me by PHP.
Thank you.
This is what i found in configuration and this functional not work:
$arfsiteurl = home_url();
if (is_ssl() and ( !preg_match('/^https:\/\/.*\..*$/', $arfsiteurl) or ! preg_match('/^https:\/\/.*\..*$/', WP_PLUGIN_URL))) {
$arfsiteurl = str_replace('http://', 'https://', $arfsiteurl);
define('ARFURL', str_replace('http://', 'https://', WP_PLUGIN_URL . '/arforms'));
} else {
define('ARFURL', WP_PLUGIN_URL . '/arforms');
}
You should try to download these scripts locally and enqueue them with your HTTPS secure server.
As for the plugin scripts, you could also try to install this plugin and click the flush rewrite rules for it to automatically add code into your .htaccess file.

Unable to access analytics.txt once uploaded, returns 404

I've been asked to add an analytics.txt file to a wordpress website so I've created the file and uploaded it to the server document root but when I go to it via the url www.examples.com/analytics.txt all I get is a 404 error.
I've checked the file permissions and I've cleared the wordpress cache but neither have helped.
Any ideas?
The folder structure is as follows:
wp-admin
wp-content
wp-includes
analytics.txt <-- added this file, but cannot seem to access it via a web browser
index.php
etc...
This is NOT the solution but it is a work-around while I carry on trying to figure out why wordpress won't allow me to access my file.
So if you're desperate and HAVE to get it sorted right now, here is what you could do, but I warn you, it's ugly! Open your index.php file and you should see something like this:
<?php
define('WP_USE_THEMES', true);
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
?>
Make a backup copy first and then add the wrapping if statement:
<?php
if ($_SERVER[REQUEST_URI] == '/analytics.txt') {
die('Put the text that you were instructed to put into your analytics.txt file in here');
} else {
define('WP_USE_THEMES', true);
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
}
?>
Like I said, this is a dirty solution but when needs must and the client is getting impatient, this could help in the mean time.
Hoping that someone will have a better solution though!
I was able to get this to work with the following for the Sage theme:
Upload the analytics.txt through the theme administration panel
Copy the url of the upload and remove the hostname. For me it looked like this: app/uploads/2018/09/analytics.txt
Open the functions.php file and add the following:
function analytics_txt_rewrite(){
add_rewrite_rule('^analytics\.txt$','<route to your analytics.txt file>','top');
}
add_action('init','analytics_txt_rewrite');
Flush and regenerate the rewrite rules database: From WordPress Administration Screens, Select Settings -> Permalinks and just click Save Changes without any changes.

Wordpress plugin, do not prepend host in wp_register_script

I am pretty new to WP and have a little question about the wp_register_script function,.
I have a dev environment where the url is test.example.com .. right know when i make a plugin and use wordpress wp_register_script to insert the .js and .css files wordpress prepend the host in front of the url ..
Is there a good way to handle this?? without creating a test DB and change the "siteurl" ?
I found a workaround for my issue ..
I could set WP_SITEURL in the we-config.php file (not the best solution)
if(isset($_SERVER['HTTP_HOST']) && $_SERVER['HTTP_HOST'] == "test.example.com") {
define('WP_SITEURL','http://test.example.com'); // use this if we are testing on test.skala.fm (not localhost)
define('ENVIRONMENT', 'local'); // using localdb
//define('ENVIRONMENT', 'production'); // use this if we are testing on test.example.com (not localhost)
} else {
define('ENVIRONMENT', 'production');
}

Wordpress - Get root directory?

How can I get the root directory of my site? I want to use it as the src for <img>.
For example If I install the wordpress on www.mysite.com/blog/, the root is /blog.
But If I install it to www.mysite.com/test/blog, the root is /test/blog.
I tried to use the snippet from this question, but it returns the whole path as seen in FTP. So instead of returning just /blog, it returns /home/public_html/blog which won't work if used as src in image tag.
Any solution? Thanks.
You may use site_url() (eventually with echo) to get absolute path with server name and directory. Also, have a look at wordpress documentation about similar functions & what they provide.
You may have better luck over at the Wordpress Stack Exchange site :)
And this suggestion to use ABSPATH didn't help on that thread? https://stackoverflow.com/a/2356467/413254
site_url() return the path with http, in some cases, it is not allowed if the server turns off url inclusion. You can use the function below to get the root path of wordpress installation folder:
function get_wp_installation()
{
$full_path = getcwd();
$ar = explode("wp-", $full_path);
return $ar[0];
}

Resources