Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a $path variable to charitable_template() #451

Closed
helgatheviking opened this issue Nov 9, 2017 · 1 comment

Comments

@helgatheviking
Copy link
Contributor

commented Nov 9, 2017

If the default path can be modified with a variable, then I can use charitable_template() instead of duplicating my own as charitable_recurring_template()

@ericnicolaas

This comment has been minimized.

Copy link
Contributor

commented Nov 9, 2017

What if we added a third parameter for the template class instead? So you could call a recurring template like this:

charitable_template( 'template.php', array(), 'Charitable_Recurring_Template' );

The basic approach in Charitable extensions so far has been to sub-class Charitable_Template in all extensions that need templates:


/**
 * Charitable_Anonymous_Template
 *
 * @since       1.0.0
 */
class Charitable_Anonymous_Template extends Charitable_Template {
    
    /**
     * Set theme template path. 
     *
     * @return  string
     * @access  public
     * @since   1.0.0
     */
    public function get_theme_template_path() {
        return trailingslashit( apply_filters( 'charitable_anonymous_theme_template_path', 'charitable/charitable-anonymous' ) );
    }

    /**
     * Return the base template path.
     *
     * @return  string
     * @access  public
     * @since   1.0.0
     */
    public function get_base_template_path() {
        return charitable_anonymous()->get_path( 'templates' );
    }
}

So this would just get you around needing a charitable_recurring_template() like that.

ericnicolaas added a commit that referenced this issue Nov 10, 2017
Merge pull request #453 from helgatheviking/feature/issue-451
Add $classname variable to charitable_template(). Closes #451.

@ericnicolaas ericnicolaas added this to the 1.5.2 milestone Nov 10, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.