Skip to content

Commit

Permalink
[BUGFIX] Replace deprecated Twig_Function_Function with Twig_SimpleFu…
Browse files Browse the repository at this point in the history
…nction
  • Loading branch information
Christian committed Jan 11, 2017
1 parent 781e9c0 commit bcd6d50
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
vendor/*
composer.lock
composer.lock
.idea/
5 changes: 2 additions & 3 deletions classes/class-engine-twig.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@ protected function initialize() {
'language_attributes' => 'language_attributes',
'body_class' => 'body_class',
'sidebar' => array( $this, 'sidebar' ),
'svg' => array( $this, 'svg' ),
'woocommerce' => array( $this, 'woo' )
);

foreach( $default_functions as $shortcut => $function ) {
$this->environment->addFunction( $shortcut, new \Twig_Function_Function( $function ) );
$this->environment->addFunction( new \Twig_SimpleFunction( $shortcut, $function ) );
}

$this->environment->addFunction( 'svg', new \Twig_Function_Function( array( $this, 'svg' ) ) );

# Add filters
$filters = array(
'html' => 'esc_html',
Expand Down
18 changes: 9 additions & 9 deletions classes/class-l10n.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ protected function __construct() {
* @param Twig_Environment $env The environment to modify.
*/
public function setup_environment( $environment ) {
$environment->addFunction( '__', new \Twig_Function_Function( array( $this, '__' ) ) );
$environment->addFunction( '_e', new \Twig_Function_Function( array( $this, '_e' ) ) );
$environment->addFunction( 'esc_attr_e', new \Twig_Function_Function( array( $this, 'esc_attr_e' ) ) );
$environment->addFunction( 'esc_html_e', new \Twig_Function_Function( array( $this, 'esc_html_e' ) ) );
$environment->addFunction( new \Twig_SimpleFunction( '__', array( $this, '__' ) ) );
$environment->addFunction( new \Twig_SimpleFunction( '_e', array( $this, '_e' ) ) );
$environment->addFunction( new \Twig_SimpleFunction( 'esc_attr_e', array( $this, 'esc_attr_e' ) ) );
$environment->addFunction( new \Twig_SimpleFunction( 'esc_html_e', ( $this, 'esc_html_e' ) ) );

$environment->addFunction( '_x', new \Twig_Function_Function( array( $this, '_x' ) ) );
$environment->addFunction( '_ex', new \Twig_Function_Function( array( $this, '_ex' ) ) );
$environment->addFunction( 'esc_attr_x', new \Twig_Function_Function( array( $this, 'esc_attr_x' ) ) );
$environment->addFunction( 'esc_html_x', new \Twig_Function_Function( array( $this, 'esc_html_x' ) ) );
$environment->addFunction( new \Twig_SimpleFunction( '_x', array( $this, '_x' ) ) );
$environment->addFunction( new \Twig_SimpleFunction( '_ex', array( $this, '_ex' ) ) );
$environment->addFunction( new \Twig_SimpleFunction( 'esc_attr_x', array( $this, 'esc_attr_x' ) ) );
$environment->addFunction( new \Twig_SimpleFunction( 'esc_html_x', array( $this, 'esc_html_x' ) ) );

$environment->addFunction( '_n', new \Twig_Function_Function( array( $this, '_n' ) ) );
$environment->addFunction( new \Twig_SimpleFunction( '_n', array( $this, '_n' ) ) );
}

public function __( $text, $domain = '' ) {
Expand Down

0 comments on commit bcd6d50

Please sign in to comment.