You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I needed to modify the code of the services built into the plugin, and to have the ability to create my own services. So I added the following to my site's version of Shariff Wrapper, copied from the em_locate_template() function of the Events Manager plugin (which is distributed under the GPL). You can either use this or create your own version if that license doesn't allow you to include it in your plugin.
In shariff.php:
Change both instances of $path_service_file = dirname( __FILE__ ) . '/services/shariff-' . $service . '.php';
/**
* Works much like <a href="https://developer.wordpress.org/reference/functions/locate_template/" target="_blank">locate_template</a>, except it takes a string instead of an array of templates, we only need to load one.
* @param string $template_name
* @param boolean $load
* @uses locate_template()
* @return string
*/
function shariff3uu_locate_template( $template_name, $load=false, $the_args = array() ) {
//First we check if there are overriding tempates in the child or parent theme
$located = locate_template(array('plugins/shariff/'.$template_name));
if( !$located ){
$located = apply_filters('shariff3uu_locate_template_default', $located, $template_name, $load, $the_args);
if ( !$located && file_exists(dirname( __FILE__ ).'/'.$template_name) ) {
$located = dirname( __FILE__ ).'/'.$template_name;
}
}
$located = apply_filters('shariff3uu_locate_template', $located, $template_name, $load, $the_args);
if( $located && $load ){
if( is_array($the_args) ) extract($the_args);
include($located);
}
return $located;
}
Then in your theme folder you create a plugins/shariff/services folder. And create php files prefixed with shariff- that mirror the PHP structure of services included in the plugin.
The text was updated successfully, but these errors were encountered:
I needed to modify the code of the services built into the plugin, and to have the ability to create my own services. So I added the following to my site's version of Shariff Wrapper, copied from the
em_locate_template()
function of the Events Manager plugin (which is distributed under the GPL). You can either use this or create your own version if that license doesn't allow you to include it in your plugin.In
shariff.php
:Change both instances of
$path_service_file = dirname( __FILE__ ) . '/services/shariff-' . $service . '.php';
To
$path_service_file = shariff3uu_locate_template( 'services/shariff-' . $service . '.php', false );
Add this PHP function:
Then in your theme folder you create a
plugins/shariff/services
folder. And create php files prefixed withshariff-
that mirror the PHP structure of services included in the plugin.The text was updated successfully, but these errors were encountered: