Hi Stefano,
thanks for the fast reply and your fantastic plugin.
It’s our standard newsletter plugin.
We are using it on each site our customer wants to send newsletter.
Good to hear, that you are working on it.
When do you think, this is possible?
In the meantime I have found a way to archieve this.
I hooked into the newsletter_init hook and then deregister and register and new handler for wp_ajax_tnpc_presets. In this function I got the instance of NewsletterEmails via its static function get_instance.
For testing I reduce the $PRESETS_LIST to array(“blank”) so only the blank preset is shown.
Actually I’m working to make custom blocks for preheader, header, footer and legal notice.
As I have saw in the code I could use the filter “newsletter_blocks_dir” to disable unwanted blocks.
Here’s my actual code:
function mjm_hook_wp_ajax_tnpc_presets(){
$content = '';
$newsletter_emails = NewsletterEmails::instance();
$newsletter_emails::$PRESETS_LIST = array('blank');
if(!empty($_REQUEST['id'])){
$preset = $newsletter_emails->get_preset($_REQUEST['id']);
foreach($preset->blocks as $item){
$newsletter_emails->render_block($item->block,true,(array) $item->options);
}
}
else{
$content = "<div class='clear tnpc-presets-title'>" . __('Choose a preset:', 'newsletter') . "</div>";
foreach ($newsletter_emails::$PRESETS_LIST as $id) {
$preset = $newsletter_emails->get_preset($id);
$content .= "<div class='tnpc-preset' onclick='tnpc_load_preset(\"$id\")'>";
$content .= "<img src='$preset->icon' title='$preset->name' />";
$content .= "<span class='tnpc-preset-label'>$preset->name</span>";
$content .= '</div>';
}
$content .= '<div class="clear"></div>';
echo $content;
}
wp_die();
}
function mjm_override_newsletter(){
$newsletter_emails = NewsletterEmails::instance(); remove_action('wp_ajax_tnpc_presets',array($newsletter_emails,'hook_wp_ajax_tnpc_presets'));
add_action('wp_ajax_tnpc_presets','mjm_hook_wp_ajax_tnpc_presets');
}
add_action('newsletter_init','mjm_override_newsletter');