Plugin Directory

Changeset 2430948


Ignore:
Timestamp:
12/03/2020 02:30:58 PM (5 years ago)
Author:
Lugat
Message:

added filter attribute to fields

Location:
jinx-block-renderer/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • jinx-block-renderer/trunk/index.php

    r2405204 r2430948  
    55   * Plugin URI: https://wordpress.org/plugins/jinx-block-renderer/
    66   * Description: Manipulate Gutenberg Blocks
    7    * Version: 0.1.3
     7   * Version: 0.2.0
    88   * Author: SquareFlower Websolutions (Lukas Rydygel) <hallo@squareflower.de>
    99   * Author URI: https://squareflower.de
  • jinx-block-renderer/trunk/readme.txt

    r2405205 r2430948  
    33Tags: blocks, gutenberg, manipulate, template
    44Requires at least: 5.0
    5 Tested up to: 5.5.1
     5Tested up to: 5.5.3
    66Requires PHP: 7.1
    77Stable tag: trunk
     
    5353          'attr' => 'src',
    5454          //'attr' => null // default - returns the results value
     55          //'filter' => 'my_filter_function' // filters each matched field
    5556        ],
    5657      ],
  • jinx-block-renderer/trunk/src/Field.php

    r2358333 r2430948  
    1212    public $attr;
    1313    public $item;
     14    public $filter;
    1415   
    1516    public function init()
     
    6667    protected function getData($elment)
    6768    {
    68       return isset($this->attr) ? $elment->getAttribute($this->attr) : $elment->nodeValue;
     69     
     70      $data = isset($this->attr) ? $elment->getAttribute($this->attr) : $elment->nodeValue;
     71     
     72      return is_callable($this->filter) ? call_user_func($this->filter, $data) : $data;
     73     
    6974    }
    7075   
Note: See TracChangeset for help on using the changeset viewer.