WordPress.org

Support

Support » Plugins and Hacks » [Plugin: ALO EasyMail Newsletter] Enabling PHP code on Newsletter themes

[Plugin: ALO EasyMail Newsletter] Enabling PHP code on Newsletter themes

  • eqhes

    @davidcs66

    Hi,

    First of all, thank you Alessandro Massasso for such great plugin ;).

    I’m using ALO EasyMail Newsletter 2.2.1. I need using custom fields to extend this plugin and I resolved it editing this 2 lines on alo-easymail_functions.php. With this hack you will be able to use PHP on your themes and, of course, you will be able to use custom fields.

    Replace this:
    >>>
    $html = file_get_contents( $theme_path );
    >>>

    By these others:
    >>>
    ob_start();
    require( $theme_path );
    $html = ob_get_clean();
    >>>

    And this other one:
    >>>
    $themes = glob( $dir. “*.{htm,html}”, GLOB_BRACE );
    >>>

    By the next:
    >>>
    $themes = glob( $dir. “*.{htm,html,php}”, GLOB_BRACE );
    >>>

    In the theme file you are going to need the folder URL of the theme, and we know that it’s not the same if we are sending an email than if we are reading the newsletter online. Here is how I get it (put this code on the top of your theme main file):
    >>>
    <?php
    $newsletter_data_folder = “”;
    if( empty( $theme ) ){ //$theme cames from alo-easymail_functions.php
    $newsletter_data_folder = get_bloginfo(“template_url”).”/alo-easymail-themes/your_newsletter_name”;
    }else{
    $newsletter_data_folder = str_replace( “.php”, “”, $theme );
    }
    ?>
    >>>

    All done! 🙂

    http://wordpress.org/extend/plugins/alo-easymail/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author eventualo

    @eventualo

    Hi eqhes! Thanks a lot for your code! I’ll add it in next release.
    Well done!

    eqhes

    @davidcs66

    Great! Thank you ;).

    I love this plugin!
    In version 2.3 is now possible to use PHP and I’m trying to use Custom Fields in my template.
    I try to get custom field in the loop and it works fine in my single-newsletter.php template, I use the same code in my template file, but when I send the mail the content is blank.
    What am I doing wrong?
    Thank you!

    Plugin Author eventualo

    @eventualo

    I forgot to document it… but in php template file you can use 2 available objects: $newsletter, $recipient.
    The newsletter (post) ID is: $newsletter->ID.
    So you can call a newsletter/post meta:
    get_post_meta($newsletter->ID, 'meta_name', true);

    Thank you, eventualo!

    It also worked for me coding my custom fields as placeholders in alo-easymail_custom-hooks.php:
    in custom_easymail_placeholders I define my [CUSTOM-FIELD-AS-PLACEHOLDER] and I get the custom fields values in custom_easymail_placeholders_get_latest in which I replace the placeholders with the values.

    However calling directly the get_post_meta($newsletter->ID, 'meta_name', in the newsletter template file I think is the smartest solution.

    Thank a lot!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: ALO EasyMail Newsletter] Enabling PHP code on Newsletter themes’ is closed to new replies.