Changeset 1826247
- Timestamp:
- 02/21/2018 02:19:57 PM (8 years ago)
- Location:
- pending-submission-notifications
- Files:
-
- 3 edited
-
assets/banner-772x250.jpg (modified) (previous)
-
trunk/pending-submission-notifications.php (modified) (1 diff)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pending-submission-notifications/trunk/pending-submission-notifications.php
r1560796 r1826247 1 1 <?php 2 2 /** 3 * Plugin Name: Pending Submission Notification 4 * Plugin URI: http://lifeofadesigner.com 5 * Description: Send email notifications to the admin whenever a new article is submitted for review by a contributor 6 * Author: Razvan Horeanga 7 * Text Domain: pending-submission-notifications 8 * Version: 1.2 9 * Author URI: http://lifeofadesigner.com 10 3 11 * @package Pending_Submission_Notification 4 * @version 1.1 5 */ 6 /* 7 Plugin Name: Pending Submission Notification 8 Plugin URI: http://lifeofadesigner.com 9 Description: Send email notifications to the admin whenever a new article is submitted for review by a contributor 10 Author: Razvan Horeanga 11 Version: 1.1 12 Author URI: http://lifeofadesigner.com 13 */ 12 * @version 1.2 13 **/ 14 14 15 16 17 if ( is_admin() ){ 18 add_action( 'admin_menu', 'pending_submission_notification_menu' ); 15 // Exit if file is called directly. 16 if ( ! defined( 'ABSPATH' ) ) { 17 exit; 19 18 } 20 19 21 function pending_submission_notification_menu() { 22 add_options_page( 'Pending Submission Notifications Options', 'Pending Submission Notifications', 'manage_options', 'pending-submissions-notifications-settings', 'pending_submission_notification_options' ); 23 add_action( 'admin_init', 'register_pending_submission_notifications_settings' ); 24 } 20 require_once plugin_dir_path( __FILE__ ) . 'admin/admin.php'; 25 21 22 add_action( 'transition_post_status', 'pending_submission_notifications_send_email', 10, 3 ); 26 23 24 /** 25 * Send out email depending on who updates the status of the post. 26 * 27 * @param string $new_status New post status. 28 * @param string $old_status Old post status. 29 * @param WP_Post $post Post object. 30 */ 31 function pending_submission_notifications_send_email( $new_status, $old_status, $post ) { 27 32 28 function register_pending_submission_notifications_settings() { 29 //register our settings 30 register_setting( 'pending-submission-notification-group', 'pending_submission_notification_admin_email' ); 31 } 32 33 34 function pending_submission_notification_options() { 35 36 ?> 37 <div class="wrap"> 38 <h2>Pending Submission Notifications</h2> 39 <p>Who should receive an email notification for new submissions?</p> 40 <form method="post" action="options.php"> 41 <?php settings_fields( 'pending-submission-notification-group' ); ?> 42 <?php do_settings_sections( 'pending-submission-notification-group' ); ?> 43 <table class="form-table"> 44 <tr valign="top"> 45 <th scope="row">Email Address:</th> 46 <td><input type="text" name="pending_submission_notification_admin_email" class="regular-text" value="<?php echo get_option('pending_submission_notification_admin_email'); ?>" /></td> 47 </tr> 48 </table> 49 <?php submit_button(); ?> 50 </form> 51 </div> 52 <?php 53 } 54 55 add_action('transition_post_status','pending_submission_send_email', 10, 3 ); 56 function pending_submission_send_email( $new_status, $old_status, $post ) { 57 58 // Notifiy Admin that Contributor has writen a post 59 if ($new_status == 'pending' && user_can($post->post_author, 'edit_posts') && !user_can($post->post_author, 'publish_posts')) { 60 $pending_submission_email = get_option('pending_submission_notification_admin_email'); 61 $admins = (empty($pending_submission_email)) ? get_option('admin_email') : $pending_submission_email; 62 $url = get_permalink($post->ID); 63 $edit_link = get_edit_post_link($post->ID, ''); 64 $preview_link = get_permalink($post->ID) . '&preview=true'; 65 $username = get_userdata($post->post_author); 66 $username_last_edit = get_the_modified_author($post->ID); 67 $post_modified = $post->post_modified; 68 $subject = 'New submission pending review: "' . $post->post_title . '"'; 69 $message = 'A new submission is pending review.'; 70 $message .= "\r\n\r\n"; 71 $message .= "Author: $username->user_login\r\n"; 72 $message .= "Title: $post->post_title\r\n"; 73 $message .= "Last Edited By: $username_last_edit\r\n"; 74 $message .= "Last Edited Date: $post->post_modified"; 75 $message .= "\r\n\r\n"; 76 $message .= "Edit the submission: $edit_link\r\n"; 77 $message .= "Preview it: $preview_link"; 78 $result = wp_mail($admins, $subject, $message); 79 } 80 81 // Notifiy Contributor that Admin has published their post 82 83 else if ($old_status == 'pending' && $new_status == 'publish' && user_can($post->post_author, 'edit_posts') && !user_can($post->post_author, 'publish_posts')) { 84 $username = get_userdata($post->post_author); 85 $url = get_permalink($post->ID); 86 $subject = "Your submission is now live:" . " " . $post->post_title; 87 $message = '"' . $post->post_title . '"' . " was just published!. \r\n"; 88 $message .= $url; 89 $result = wp_mail($username->user_email, $subject, $message); 33 // Notify Admin that Contributor has written a post. 34 if ( 'pending' === $new_status && user_can( $post->post_author, 'edit_posts' ) && ! user_can( $post->post_author, 'publish_posts' ) ) { 35 $pending_submission_email = get_option( 'pending_submission_notification_admin_email' ); 36 $admins = ( empty( $pending_submission_email ) ) ? get_option( 'admin_email' ) : $pending_submission_email; 37 $edit_link = get_edit_post_link( $post->ID, '' ); 38 $preview_link = get_permalink( $post->ID ) . '&preview=true'; 39 $username = get_userdata( $post->post_author ); 40 $username_last_edit = get_the_modified_author(); 41 $subject = __( 'New submission pending review', 'pending-submission-notifications' ) . ': "' . $post->post_title . '"'; 42 $message = __( 'A new submission is pending review.', 'pending-submission-notifications' ); 43 $message .= "\r\n\r\n"; 44 $message .= __( 'Author', 'pending-submission-notifications' ) . ': ' . $username->user_login . "\r\n"; 45 $message .= __( 'Title', 'pending-submission-notifications' ) . ': ' . $post->post_title . "\r\n"; 46 $message .= __( 'Last edited by', 'pending-submission-notifications' ) . ': ' . $username_last_edit . "\r\n"; 47 $message .= __( 'Last edit date', 'pending-submission-notifications' ) . ': ' . $post->post_modified; 48 $message .= "\r\n\r\n"; 49 $message .= __( 'Edit the submission', 'pending-submission-notifications' ) . ': ' . $edit_link . "\r\n"; 50 $message .= __( 'Preview the submission', 'pending-submission-notifications' ) . ': ' . $preview_link; 51 $result = wp_mail( $admins, $subject, $message ); 52 } // Notify Contributor that Admin has published their post. 53 elseif ( 'pending' === $old_status && 'publish' === $new_status && user_can( $post->post_author, 'edit_posts' ) && ! user_can( $post->post_author, 'publish_posts' ) ) { 54 $username = get_userdata( $post->post_author ); 55 $url = get_permalink( $post->ID ); 56 $subject = __( 'Your submission is now live! ', 'pending-submission-notifications' ); 57 $message = '"' . $post->post_title . '" ' . __( 'was just published ', 'pending-submission-notifications' ) . "! \r\n\r\n"; 58 $message .= $url; 59 $result = wp_mail( $username->user_email, $subject, $message ); 90 60 } 91 61 } 92 93 ?> -
pending-submission-notifications/trunk/readme.txt
r1560790 r1826247 4 4 Tags: notifications, pending submissions, submit for review, email notification, pending notification 5 5 Requires at least: 3.8 6 Tested up to: 4. 77 Stable tag: 1. 16 Tested up to: 4.9.4 7 Stable tag: 1.2 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 23 23 24 24 25 1. Upload `pending-submission-notifications.php`to the `/wp-content/plugins/` directory25 1. Upload the `pending-submission-notifications` folder to to the `/wp-content/plugins/` directory 26 26 2. Activate the plugin through the 'Plugins' menu in WordPress 27 3. This is optional - change the emai address that should receive notifications under Settings>Pending Submission Notifications27 3. This is optional - change the email address that should receive notifications under Settings>Pending Submission Notifications. 28 28 29 29 == Screenshots == … … 33 33 == Changelog == 34 34 35 = 1.2 = 36 *Added support for internationalization. 37 35 38 = 1.1 = 36 39 *Added information about last user to edit the post and the timestamp of last edit.
Note: See TracChangeset
for help on using the changeset viewer.