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

Installation when Timber is installed via Composer #9

Open
timknight opened this issue Oct 19, 2017 · 1 comment
Open

Installation when Timber is installed via Composer #9

timknight opened this issue Oct 19, 2017 · 1 comment

Comments

@timknight
Copy link

Are there special considerations that need to made with installing sugar when Timber is installed through Composer? Currently when installing it and trying to execute the dummy function I get an error:

Uncaught Error: Class 'Twig_Filter_Function' not found in /wp-content/plugins/sugar/timber-sugar.php

I'm loading Timber within the functions.php exactly as defined on https://timber.github.io/docs/getting-started/setup/#via-github-for-developers.

I've installed Sugar within a different instance where Timber is installed as a WordPress plugin instead and everything seems to function without any issue.

@timknight
Copy link
Author

I did rework the plugin to use the following, but this won't work when Timber is installed as a WordPress library, just when it's installed via Composer.

function __construct(){
  add_filter('get_twig', function( $twig ){
    $twig->addFilter(new Twig_Filter('dummy', array(__CLASS__, 'apply_dummy_filter')));
    $twig->addFunction(new Twig_Function('dummy', array(__CLASS__, 'apply_dummy')));

    $twig->addFilter(new Twig_Filter('twitterify', array(__CLASS__, 'twitterify')));
    return $twig;
  });
}

Maybe there's a way to get it to work with both, but either way for those in a similar situation that'll work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant