Last active
December 29, 2015 12:49
-
-
Save vmassuchetto/7673204 to your computer and use it in GitHub Desktop.
Revisions
-
vmassuchetto revised this gist
Nov 27, 2013 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -32,9 +32,9 @@ function post_mail_content( $content ) { return $html; } add_action( 'new_to_pending', 'post_mail' ); add_action( 'draft_to_pending', 'post_mail' ); add_action( 'pending_to_pending', 'post_mail' ); /** * Sends a message to site admins when posts are published or pending * for approval. -
vmassuchetto revised this gist
Nov 27, 2013 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,9 +19,9 @@ function post_mail_content( $content ) { <td bgcolor="#FFFFFF" class="container"> <div class="content"> <table> <tbody><tr><td> <?php echo $content; ?> </td></tr></tbody> </table> </div> </td> @@ -83,6 +83,6 @@ function post_mail( $post ) { </table> <?php $content = ob_get_clean(); $content = post_mail_content( $content ); wp_mail( $to, $subject, $content, $headers ); } -
vmassuchetto revised this gist
Nov 27, 2013 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,10 +19,10 @@ function post_mail_content( $content ) { <td bgcolor="#FFFFFF" class="container"> <div class="content"> <table> <tbody><tr>< <?php echo $content; ?> </td></tr></ </table> </div> </td> <td></td> -
vmassuchetto revised this gist
Nov 27, 2013 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,9 +27,7 @@ function post_mail_content( $content ) { </td> <td></td> </tr></tbody> </table></body></html><?php $html = ob_get_clean(); return $html; } -
vmassuchetto revised this gist
Nov 27, 2013 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,7 +27,9 @@ function post_mail_content( $content ) { </td> <td></td> </tr></tbody> </table> </body> </html><?php $html = ob_get_clean(); return $html; } -
vmassuchetto created this gist
Nov 27, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,88 @@ <?php /** * Wraps a message $content in a responsive e-mail template. * * Reference: http://zurb.com/playground/projects/responsive-email-templates/basic.html */ function post_mail_content( $content ) { ob_start(); ?><html xmlns="http://www.w3.org/1999/xhtml"><head> <meta content="width=device-width" name="viewport"> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> <title><?php echo get_bloginfo( 'name' ) . ' -- ' . __( 'New post' ); ?></title> <link href="<?php echo get_stylesheet_directory_uri(); ?>/css/email.css" type="text/css" rel="stylesheet"> </head> <body bgcolor="#FFFFFF"> <table class="body-wrap"> <tbody><tr> <td></td> <td bgcolor="#FFFFFF" class="container"> <div class="content"> <table> <tbody><tr><td> <?php echo $content; ?> </td></tr></tbody> </table> </div> </td> <td></td> </tr></tbody> </table><?php $html = ob_get_clean(); return $html; } add_action( 'new_to_pending', 'grupo_post_mail' ); add_action( 'draft_to_pending', 'grupo_post_mail' ); add_action( 'pending_to_pending', 'grupo_post_mail' ); /** * Sends a message to site admins when posts are published or pending * for approval. * * If it's in debug mode it will just create the e-mail as a file in * the temporary directory from the operational system (e.g. `/tmp`). */ function post_mail( $post ) { if ( !in_array( $post->post_type, array( 'post', 'lugar' ) ) ) return false; global $wpdb; $to = array(); $users = get_users( array( 'role' => 'administrator' ) ); $author = get_user_by( 'ID', $post->post_author ); foreach( $users as $user ) { $to[] = $user->display_name . '<' . $user->user_email . '>'; } $subject = '[' . get_bloginfo( 'name' ) . '] ' . __( 'New post' ) . ' - ' . trim( $post->post_title ); $headers = array( "From: {$author->display_name} <{$author->user_email}>", "Bcc: " . implode( ',', $to ) ); ob_start(); ?> <p><?php sprintf( __( 'A new %s was created:' ), '<i>' . $post->post_type . '</i>' ); ?>:</p> <h3><?php echo edit_post_link( $post->post_title, '', '', $post->ID ); ?></h3> <p class="callout"> <?php _e( 'Categories' ); ?>: <?php get_the_category( $post->ID ); ?><br/> <?php _e( 'Tags' ); ?>: <?php get_the_tags( $post->ID ); ?> </p> <table width="100%" class="social"> <tbody><tr><td> <table align="left" class="column"><tbody><tr><td> <h5 class=""><?php _e( 'Author' ); ?>:</h5> <p> <a href="<?php echo admin_url( 'user-edit.php' ); ?>?user_id=<?php echo $user->ID; ?>"><?php echo $user->display_name; ?></a> (<?php echo $user->user_login; ?>)<br/> <a href="mailto:<?php echo $user->user_email; ?>"><?php echo $user->user_email; ?></a> </p> </td></tr></tbody></table> </td></tr></tbody> </table> <?php $content = ob_get_clean(); $content = post_mail_content( $content ); wp_mail( $to, $subject, $content, $headers ); }