Skip to content

Instantly share code, notes, and snippets.

@anthonybudd
Last active May 26, 2017 15:03
Show Gist options
  • Select an option

  • Save anthonybudd/5ea5f3901c2d18d9668e8946c857259e to your computer and use it in GitHub Desktop.

Select an option

Save anthonybudd/5ea5f3901c2d18d9668e8946c857259e to your computer and use it in GitHub Desktop.
<?php
Abstract Class WP_Model implements JsonSerializable{
...
public function isFilterProperty($attribute){
return (
(
isset($this->filter) &&
in_array($attribute, $this->filter) &&
method_exists($this, ('_filter'. ucfirst($attribute)))
) || (
count(array_filter(array_keys($this->filter), 'is_string')) > 0 &&
isset($this->filter) &&
in_array($attribute, array_keys($this->filter)) &&
isset($this->filter[$attribute]) &&
function_exists($this->filter[$attribute])
)
);
}
public function getFilterProperty($attribute){
if( count(array_filter(array_keys($this->filter), 'is_string')) > 0 &&
isset($this->filter[$attribute]) &&
function_exists($this->filter[$attribute])) {
return ($this->filter[$attribute]($this->get($attribute)));
}
return call_user_func_array([$this, ('_filter'. ucfirst($attribute))], [$this->get($attribute)]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment