Default template args filter
-
Would be nice if it was possible to have a filter for the
template::OPTIONS
property. It’s a constant right now, but if it became a local property of thetemplate
class, then within the constructor it would be possible to add a filter to override the default values. An example use case would be if you wanted to enable linkify across all emails by default, you could do it once on the filter, rather than defining at template level for every instance.It might look like this
public function __construct($slug=null) { global $wpdb; // Reset. $this->template = static::TEMPLATE; // Pluck a template. if (false === ($slug = static::ab($slug))) { return false; } // And get the content. $dbResult = $wpdb->get_results(" SELECT <code>post_content</code> AS <code>raw</code>, <code>post_name</code> AS <code>slug</code>, <code>post_title</code> AS <code>title</code> FROM <code>{$wpdb->prefix}posts</code> WHERE <code>post_type</code>='wh-template' AND <code>post_status</code>='publish' AND <code>post_name</code>='" . \esc_sql($slug) . "' "); if (! isset($dbResult[0])) { return false; } $Row = common\data::array_pop_top($dbResult); $this->template = common\data::parse_args($Row, static::TEMPLATE); $this->defaults = \apply_filters('wh_default_options', self::OPTIONS, $this->template['slug']); // <-- HERE return true; }
Also, just over a year ago you said that the plugin source would be available “in about a year”, so that it would be possible to contribute to the plugin. Any word on this, please?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Default template args filter’ is closed to new replies.