Skip to content

Commit

Permalink
Filters
Browse files Browse the repository at this point in the history
  • Loading branch information
qstudio committed Aug 24, 2020
1 parent 11bb085 commit 6a5c8b8
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 0 deletions.
6 changes: 6 additions & 0 deletions library/filter/_load.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ public static function load()
// escape ##
require_once self::get_plugin_path( 'library/filter/escape.php' );

// lowercase ##
require_once self::get_plugin_path( 'library/filter/lowercase.php' );

// uppercase ##
require_once self::get_plugin_path( 'library/filter/uppercase.php' );

// strip tags ##
require_once self::get_plugin_path( 'library/filter/strip.php' );

Expand Down
71 changes: 71 additions & 0 deletions library/filter/lowercase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

namespace q\willow\filter;

use q\qillow\core\helper as h;
use q\willow;
use q\willow\filter;

// load it up ##
\q\willow\filter\lowercase::run();

class lowercase extends willow\filter {

public static function run(){

// filter variable ##
\add_filter( 'q/willow/render/markup/variable', [ get_class(), 'variable' ], 10, 2 );

// filter tag ##
\add_filter( 'q/willow/render/markup/tag', [ get_class(), 'tag' ], 10, 2 );

}




// single variable
public static function variable( $value, $key ) {

// global first ##
if( isset( self::$filter[self::$args['context']][self::$args['task']]['variables'][$key]['l'] ) ){

// h::log( 'e:>Variable tag lowercaseping on: '.self::$args['context'].'->'.self::$args['task'].'->'.$key );

// h::log( 'd:>lowercaseping tags from value: '.$value );

$value = strtolower( $value );
// $value = htmlentities( $value, ENT_QUOTES, 'UTF-8' );

}

return $value;

}




// whole tag
public static function tag( $value, $key ) {

// h::log( self::$args );

// global first ##
if( isset( self::$filter[self::$args['context']][self::$args['task']]['global']['l'] ) ){

// h::log( 'e:>Global tag lowercaseping on: '.self::$args['context'].'->'.self::$args['task'].'->'.$key );

// h::log( 'd:>lowercaseping tags from value: '.$value );

$value = strtolower( $value );
// $value = htmlentities( $value, ENT_QUOTES, 'UTF-8' );

}

return $value;

}


}
71 changes: 71 additions & 0 deletions library/filter/uppercase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

namespace q\willow\filter;

use q\qillow\core\helper as h;
use q\willow;
use q\willow\filter;

// load it up ##
\q\willow\filter\uppercase::run();

class uppercase extends willow\filter {

public static function run(){

// filter variable ##
\add_filter( 'q/willow/render/markup/variable', [ get_class(), 'variable' ], 10, 2 );

// filter tag ##
\add_filter( 'q/willow/render/markup/tag', [ get_class(), 'tag' ], 10, 2 );

}




// single variable
public static function variable( $value, $key ) {

// global first ##
if( isset( self::$filter[self::$args['context']][self::$args['task']]['variables'][$key]['u'] ) ){

// h::log( 'e:>Variable tag uppercaseping on: '.self::$args['context'].'->'.self::$args['task'].'->'.$key );

// h::log( 'd:>uppercaseping tags from value: '.$value );

$value = strtoupper( $value );
// $value = htmlentities( $value, ENT_QUOTES, 'UTF-8' );

}

return $value;

}




// whole tag
public static function tag( $value, $key ) {

// h::log( self::$args );

// global first ##
if( isset( self::$filter[self::$args['context']][self::$args['task']]['global']['u'] ) ){

// h::log( 'e:>Global tag uppercaseping on: '.self::$args['context'].'->'.self::$args['task'].'->'.$key );

// h::log( 'd:>uppercaseping tags from value: '.$value );

$value = strtoupper( $value );
// $value = htmlentities( $value, ENT_QUOTES, 'UTF-8' );

}

return $value;

}


}

0 comments on commit 6a5c8b8

Please sign in to comment.