I'm new to Wordpress and working on my first theme. The theme will be heavily combined with one plugin. I'm wondering how I could change some of the plugin settings in the theme function.php without touching the plugin itself.
I have tried looking it up on the internet but haven't found any concrete answers for my issue.
What I'm using:
Wordpress 4.2, Justimmo api plugin
The Problem:
I'm trying to figure out how I could in my theme function.php
redirect/replace the plugin template files with the ones that are in my theme.
Currently in the plugin folder are template files and how they will render on the website. I would write my own template file, making sure it looks like my theme and replace it with the plugin template file.
If I were to edit the template files directly in the plugin folder, whenever there might be a update, they would be overwritten. I don't feel that is right.
After looking around the internet, I feel I could achieve it with add_filter
, but not fully sure how to.
The Plugin
On Github: https://github.com/justimmo/wordpress-plugin/blob/master/justimmo.php
In the original plugin has a lines (row 240 for indexPage()
and row 328 for getIndexUrl()
):
class JiApiWpPlugin
{
function indexPage()
{
include(JI_API_WP_PLUGIN_DIR . '/templates/index.php');
}
function getIndexUrl()
{
return $this->getUrlPrefix().'ji_plugin=search';
}
}
It dictates where one of the template files can be found, and also gives a permalink to the plugin.
What I want
I would like to add a filter to take the template file from my theme instead, and to rewrite the path to the template file.
If there is an easy way for adding a hook, that overwrites it, great.
Also I have found that I could do some template replacements with add_filter
.
Have tried:
add_filter( 'template_include', 'gulz_justimmo_page_template' );
function gulz_justimmo_page_template( $page_template )
{
if ( is_page( 'ji_plugin' ) ) {
$page_template = dirname( __FILE__ ) . '/justimmotemp/justimmo-index.php';
}
return $page_template;
}
But I'm not fully sure how to check if the plugin permalinks page is activated.
I feel it should be a simple thing for users overwrite or redirect plugin template files with the ones that are in their theme, but I can't figure it out.
I would be grateful for all help and advice.