From 17cff6136debd923a6260f9e43792c6935f69708 Mon Sep 17 00:00:00 2001 From: Ryan Domingue Date: Tue, 29 Jul 2014 22:54:52 -0700 Subject: [PATCH 1/4] Sets up the post submit box to display the follower message --- modules/notifications/notifications.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/notifications/notifications.php b/modules/notifications/notifications.php index 228cc9f87..1bd77f82e 100644 --- a/modules/notifications/notifications.php +++ b/modules/notifications/notifications.php @@ -78,6 +78,7 @@ function init() { add_action( 'ef_post_insert_editorial_comment', array( $this, 'notification_comment') ); add_action( 'delete_user', array($this, 'delete_user_action') ); add_action( 'ef_send_scheduled_email', array( $this, 'send_single_email' ), 10, 4 ); + add_action( 'post_submitbox_misc_actions', array($this, 'submitbox_followers_message') ); add_action( 'admin_init', array( $this, 'register_settings' ) ); @@ -410,6 +411,20 @@ public function handle_user_post_subscription() { $this->print_ajax_response( 'success', (object)$this->get_follow_action_parts( $post ) ); } + /** + * Set up the submit box for displaying the number of users/user groups following a page/post + */ + function submitbox_followers_message() { + ?> +
+
Followers: + + + Edit followers + +
+ Date: Tue, 29 Jul 2014 22:56:16 -0700 Subject: [PATCH 2/4] Display the follower count message in the post submit box --- modules/notifications/lib/notifications.js | 48 +++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/modules/notifications/lib/notifications.js b/modules/notifications/lib/notifications.js index aee16be59..fd1f140fa 100644 --- a/modules/notifications/lib/notifications.js +++ b/modules/notifications/lib/notifications.js @@ -6,6 +6,9 @@ jQuery(document).ready(function($) { post_id: $('#post_ID').val(), }; + // Display the user/group follower count in the post submit box + ef_displayFollowerCountInSubmitBox(); + $('.ef-post_following_list li input:checkbox, .ef-following_usergroups li input:checkbox').click(function() { var user_group_ids = []; var parent_this = $(this); @@ -28,6 +31,8 @@ jQuery(document).ready(function($) { url : (ajaxurl) ? ajaxurl : wpListL10n.url, data : params, success : function(x) { + // Update the user/group follower count in the post submit box + ef_displayFollowerCountInSubmitBox(); var backgroundColor = parent_this.css( 'background-color' ); $(parent_this.parent().parent()) .animate( { 'backgroundColor':'#CCEEBB' }, 200 ) @@ -38,4 +43,45 @@ jQuery(document).ready(function($) { } }); }); -}); \ No newline at end of file +}); + +/** + * Count the users and user groups who will be notified of a status change + * Display the message in the submit box + */ +var ef_displayFollowerCountInSubmitBox = function() { + var checkedFollowers, checkedUserGroups, countDisplay, message = '', followerMessage = '', userGroupMessage = '',conjunction = ''; + + // Get checked checkboxes + checkedFollowers = jQuery('.ef-post_following_list li input:checkbox:checked'); + checkedUserGroups = jQuery('#ef-following_usergroups li input:checkbox:checked'); + // checkedFollowers includes user groups + userCount = checkedFollowers.length - checkedUserGroups.length; + userGroupCount = checkedUserGroups.length; + + // The within which the message will be displayed + countDisplay = jQuery('#post-follower-count-display'); + + // Create the individual messages + if (userCount > 0) { + followerMessage = userCount + ((userCount === 1) ? ' user' : ' users'); + } + if (userGroupCount > 0) { + userGroupMessage = userGroupCount + ((userGroupCount === 1) ? ' user group' : ' user groups'); + } + + if (userCount > 0 && userGroupCount > 0) { + // Both will be displayed, so we need a conjunction + conjunction = ' & '; + message = (followerMessage + conjunction + userGroupMessage); + } else if (userCount > 0 || userGroupCount > 0) { + // Only one will be displayed, the other is an empty string + message = (followerMessage + userGroupMessage); + } else { + // Default message + message = 'none'; + } + + // Print the message + countDisplay.html(message); +}; From 80cc3bfe728d7a00ad49593a1d412dd5f0fcbf51 Mon Sep 17 00:00:00 2001 From: Ryan Domingue Date: Tue, 29 Jul 2014 22:56:46 -0700 Subject: [PATCH 3/4] Styles the follower submit box message --- modules/notifications/lib/notifications.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/notifications/lib/notifications.css b/modules/notifications/lib/notifications.css index 85e70084d..c6e3a512a 100644 --- a/modules/notifications/lib/notifications.css +++ b/modules/notifications/lib/notifications.css @@ -91,4 +91,8 @@ #ef-usergroup-users h4 { margin-top: 0; +} + +.misc-pub-follower-count span { + font-weight: bold; } \ No newline at end of file From 5090d5a1efd640ff54b0d55551441dc28e89e5cd Mon Sep 17 00:00:00 2001 From: Ryan Domingue Date: Fri, 29 Aug 2014 12:06:40 -0700 Subject: [PATCH 4/4] Set up strings for localization --- modules/notifications/notifications.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/notifications/notifications.php b/modules/notifications/notifications.php index 1bd77f82e..7bf00c8d2 100644 --- a/modules/notifications/notifications.php +++ b/modules/notifications/notifications.php @@ -417,10 +417,10 @@ public function handle_user_post_subscription() { function submitbox_followers_message() { ?>
-