Support » Plugin: Email Subscribers & Newsletters - Simple and Effective newsletter system » Add action to insert custom CSS into optin and unsubscribe message

  • Resolved gchtr

    (@gchtr)


    Hi there

    When a user clicks on a link in the email to subscribe, a link is opened that displays a message (triggered from jobs/es-option.php and jobs/es-unsubscribe.php).

    Could you add a an action (named es_message_head or the like) into <head> so that developers can insert their own CSS to style this message?

    Example for jobs/es-optin.php:

    
    <html>
        <head>
            <title><?php echo $blogname; ?></title>
            <meta http-equiv="refresh" content="10; url=<?php echo $home_url; ?>" charset="<?php echo esc_attr( get_option( 'blog_charset' ) ); ?>" />
    
            <?php echo do_action( 'es_message_head' ); ?>
        </head>
    

    That would be really cool!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Icegram

    (@icegram)

    Hi @gchtr,

    Sure. We’ll add support for same in upcoming releases.

    Awesome, thank you!

    Plugin Author Icegram

    (@icegram)

    Hi @gchtr,

    We have added an action in the latest release. So, kindly update Email Subscribers to v3.2.5 and then have a check and let us know if it works for you.

    It works great! Thank you very much!

    I figured that actually the echo before do_action( 'es_message_head' ); is not required. My bad, normally actions don’t get echoed out, because they don’t return anything. So <?php do_action( 'es_message_head' ); ?> would be enough. Luckily, this doesn’t have any bad effect. Just in case you want to slip that into your next release ;).

    If anyone happens to stumble over and wants to know how to apply the new es_message_head action:

    
    add_action( 'es_message_head', 'print_es_message_styles' );
    
    // Enqueue theme styles and print them
    function print_es_message_styles() {
        wp_enqueue_style( 'styles', get_template_directory_uri() . '/build/styles.min.css' );
        wp_print_styles( 'styles' );
    }
    

    And then in your CSS you could do something like this

    
    // Additional styles for email subscription confirmation messages displayed
    // when a subscriber clicks on a link in an email.
    .es_successfully_subscribed,
    .es_successfully_unsubscribed {
        max-width: 1000px;
        margin: 0 auto;
        padding-top: 40px;
        text-align: center;
    }
    

    You could also directly print your custom styles in the function. But if you have custom webfonts etc., it’s probably more convenient to work with the solution above.

    
    // Enqueue theme styles and print them
    function print_es_message_styles() {
        echo '<style type="text/css">
            .es_successfully_subscribed,
            .es_successfully_unsubscribed {
                max-width: 1000px;
                margin: 0 auto;
                text-align: center;
            }
        </style>';
    }
    
    • This reply was modified 3 years, 2 months ago by gchtr.
    • This reply was modified 3 years, 2 months ago by gchtr. Reason: Fix code sections
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add action to insert custom CSS into optin and unsubscribe message’ is closed to new replies.