• 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 the template 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?

    • This topic was modified 3 years, 2 months ago by Joseph D'Souza. Reason: Tidy up code mistake
    • This topic was modified 3 years, 2 months ago by Joseph D'Souza. Reason: further tidy up code mistake
Viewing 1 replies (of 1 total)
  • Plugin Author Blobfolio

    (@blobfolio)

    Hey @dsouzaj86,

    Sorry about that. COVID and cancer have derailed that original timeline. Haha.

    The main holdup is the plugin needs new build scripts. The current process is just a hacky stopgap, not contributor-friendly.

    If you want to shoot me an email ([email protected]), I can zip up and send you the sources. It should give you a decent jumping-off point if you wanted to fork the project.

Viewing 1 replies (of 1 total)
  • The topic ‘Default template args filter’ is closed to new replies.