Changeset 2349284
- Timestamp:
- 07/30/2020 06:45:49 PM (6 years ago)
- Location:
- hey-notify
- Files:
-
- 33 added
- 36 edited
- 1 copied
-
assets/banner-1544x500-rtl.png (modified) (1 prop) (previous)
-
assets/banner-1544x500.png (modified) (1 prop) (previous)
-
assets/banner-772x250-rtl.png (modified) (1 prop) (previous)
-
assets/banner-772x250.png (modified) (1 prop) (previous)
-
assets/icon-128x128.png (modified) (1 prop) (previous)
-
assets/icon-256x256.png (modified) (1 prop) (previous)
-
assets/screenshot-1.png (added)
-
tags/1.1.0 (copied) (copied from hey-notify/trunk)
-
tags/1.1.0/.gitattributes (added)
-
tags/1.1.0/composer.json (added)
-
tags/1.1.0/composer.lock (added)
-
tags/1.1.0/hey-notify.php (modified) (3 diffs)
-
tags/1.1.0/includes/class-hook.php (modified) (1 diff)
-
tags/1.1.0/includes/class-service.php (modified) (2 diffs)
-
tags/1.1.0/includes/cpt.php (modified) (1 diff)
-
tags/1.1.0/includes/events/comment (added)
-
tags/1.1.0/includes/events/comment/class-comment-event.php (added)
-
tags/1.1.0/includes/events/comment/class-comment-hook.php (added)
-
tags/1.1.0/includes/events/comment/loader.php (added)
-
tags/1.1.0/includes/events/page/class-page-event.php (modified) (1 diff)
-
tags/1.1.0/includes/events/page/class-page-hook.php (modified) (5 diffs)
-
tags/1.1.0/includes/events/post/class-post-event.php (modified) (1 diff)
-
tags/1.1.0/includes/events/post/class-post-hook.php (modified) (6 diffs)
-
tags/1.1.0/includes/events/system (added)
-
tags/1.1.0/includes/events/system/class-system-event.php (added)
-
tags/1.1.0/includes/events/system/class-system-hook.php (added)
-
tags/1.1.0/includes/events/system/loader.php (added)
-
tags/1.1.0/includes/events/user (added)
-
tags/1.1.0/includes/events/user/class-user-event.php (added)
-
tags/1.1.0/includes/events/user/class-user-hook.php (added)
-
tags/1.1.0/includes/events/user/loader.php (added)
-
tags/1.1.0/includes/filters.php (modified) (2 diffs)
-
tags/1.1.0/includes/services/class-discord.php (modified) (5 diffs)
-
tags/1.1.0/includes/services/class-email.php (modified) (5 diffs)
-
tags/1.1.0/includes/services/class-slack.php (modified) (13 diffs)
-
tags/1.1.0/languages/hey-notify.pot (modified) (7 diffs)
-
tags/1.1.0/readme.md (added)
-
tags/1.1.0/readme.txt (modified) (3 diffs)
-
tags/1.1.0/uninstall.php (modified) (1 diff)
-
trunk/.gitattributes (added)
-
trunk/composer.json (added)
-
trunk/composer.lock (added)
-
trunk/hey-notify.php (modified) (3 diffs)
-
trunk/includes/class-hook.php (modified) (1 diff)
-
trunk/includes/class-service.php (modified) (2 diffs)
-
trunk/includes/cpt.php (modified) (1 diff)
-
trunk/includes/events/comment (added)
-
trunk/includes/events/comment/class-comment-event.php (added)
-
trunk/includes/events/comment/class-comment-hook.php (added)
-
trunk/includes/events/comment/loader.php (added)
-
trunk/includes/events/page/class-page-event.php (modified) (1 diff)
-
trunk/includes/events/page/class-page-hook.php (modified) (5 diffs)
-
trunk/includes/events/post/class-post-event.php (modified) (1 diff)
-
trunk/includes/events/post/class-post-hook.php (modified) (6 diffs)
-
trunk/includes/events/system (added)
-
trunk/includes/events/system/class-system-event.php (added)
-
trunk/includes/events/system/class-system-hook.php (added)
-
trunk/includes/events/system/loader.php (added)
-
trunk/includes/events/user (added)
-
trunk/includes/events/user/class-user-event.php (added)
-
trunk/includes/events/user/class-user-hook.php (added)
-
trunk/includes/events/user/loader.php (added)
-
trunk/includes/filters.php (modified) (2 diffs)
-
trunk/includes/services/class-discord.php (modified) (5 diffs)
-
trunk/includes/services/class-email.php (modified) (5 diffs)
-
trunk/includes/services/class-slack.php (modified) (13 diffs)
-
trunk/languages/hey-notify.pot (modified) (7 diffs)
-
trunk/readme.md (added)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/uninstall.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
hey-notify/assets/banner-1544x500-rtl.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
hey-notify/assets/banner-1544x500.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
hey-notify/assets/banner-772x250-rtl.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
hey-notify/assets/banner-772x250.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
hey-notify/assets/icon-128x128.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
hey-notify/assets/icon-256x256.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
hey-notify/tags/1.1.0/hey-notify.php
r2345565 r2349284 4 4 * Plugin URI: https://heynotifywp.com/ 5 5 * Description: Get notified when things happen in WordPress. 6 * Version: 1. 0.06 * Version: 1.1.0 7 7 * Author: FireTree Design, LLC <info@firetreedesign.com> 8 8 * Author URI: https://firetreedesign.com/ … … 19 19 } 20 20 21 define( 'HEY_NOTIFY_VERSION', '1. 0.0' );21 define( 'HEY_NOTIFY_VERSION', '1.1.0' ); 22 22 define( 'HEY_NOTIFY_PLUGIN_FILE', __FILE__ ); 23 23 define( 'HEY_NOTIFY_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); … … 36 36 require_once HEY_NOTIFY_PLUGIN_DIR . 'includes/events/post/loader.php'; 37 37 require_once HEY_NOTIFY_PLUGIN_DIR . 'includes/events/page/loader.php'; 38 require_once HEY_NOTIFY_PLUGIN_DIR . 'includes/events/comment/loader.php'; 39 require_once HEY_NOTIFY_PLUGIN_DIR . 'includes/events/user/loader.php'; 40 require_once HEY_NOTIFY_PLUGIN_DIR . 'includes/events/system/loader.php'; 38 41 39 42 // Services. -
hey-notify/tags/1.1.0/includes/class-hook.php
r2345565 r2349284 56 56 ); 57 57 58 $ new_data =wp_parse_args( $data, $defaults );58 $message = \wp_parse_args( $data, $defaults ); 59 59 60 do_action( 61 'hey_notify_send_message', 62 array( 63 'notification' => $this->notification, 64 'subject' => $new_data['subject'], 65 'title' => $new_data['title'], 66 'url' => $new_data['url'], 67 'image' => $new_data['image'], 68 'content' => $new_data['content'], 69 'fields' => $new_data['fields'], 70 'footer' => $new_data['footer'], 71 ) 60 $service = \carbon_get_post_meta( $this->notification->ID, 'hey_notify_service' ); 61 62 \do_action( 63 "hey_notify_send_message_{$service}", 64 $message, // Message. 65 'core', // Trigger. 66 $this->notification // Data. 72 67 ); 73 68 } -
hey-notify/tags/1.1.0/includes/class-service.php
r2345565 r2349284 19 19 20 20 /** 21 * Class constructor 21 * Class construct 22 * 23 * @return void 22 24 */ 23 25 public function __construct() { 24 26 add_filter( 'hey_notify_service_fields', array( $this, 'fields' ), 10 ); 25 27 add_filter( 'hey_notify_services_options', array( $this, 'services' ), 10 ); 26 add_action( 'hey_notify_send_message', array( $this, 'send' ), 10, 1 );27 28 } 28 29 … … 47 48 } 48 49 49 /**50 * Send the message51 *52 * @param array $message Message.53 * @return void54 */55 public function send( $message ) {56 // Do something.57 }58 59 50 } -
hey-notify/tags/1.1.0/includes/cpt.php
r2345565 r2349284 120 120 switch ( $column_name ) { 121 121 case 'service': 122 $services = \apply_filters( 'hey_notify_services_options', array() ); 123 $service = \carbon_get_post_meta( $post_id, 'hey_notify_service' ); 124 echo "<img src='" . esc_attr( $services[ $service ] ) . "' style='width: 100px; height: auto;' />"; 122 $services_array = \apply_filters( 'hey_notify_services_options', array() ); 123 $service = \carbon_get_post_meta( $post_id, 'hey_notify_service' ); 124 foreach ( $services_array as $services ) { 125 if ( $service === $services['value'] ) { 126 echo "<img src='" . esc_attr( $services['image'] ) . "' style='width: 100px; height: auto;' />"; 127 } 128 } 125 129 break; 126 130 case 'events': -
hey-notify/tags/1.1.0/includes/events/page/class-page-event.php
r2345565 r2349284 77 77 switch ( $event->{$event->type} ) { 78 78 case 'page_draft': 79 add_action( ' transition_post_status', array( $hook, 'page_draft' ), 10, 3);79 add_action( 'auto-draft_to_draft', array( $hook, 'page_draft' ), 10, 1 ); 80 80 break; 81 81 case 'page_published': 82 add_action( 'transition_post_status', array( $hook, 'page_published' ), 10, 3 ); 82 add_action( 'auto-draft_to_publish', array( $hook, 'page_published' ), 10, 1 ); 83 add_action( 'draft_to_publish', array( $hook, 'page_published' ), 10, 1 ); 84 add_action( 'future_to_publish', array( $hook, 'page_published' ), 10, 1 ); 85 add_action( 'pending_to_publish', array( $hook, 'page_published' ), 10, 1 ); 83 86 break; 84 87 case 'page_scheduled': 85 add_action( 'transition_post_status', array( $hook, 'page_scheduled' ), 10, 3 ); 88 add_action( 'auto-draft_to_future', array( $hook, 'page_scheduled' ), 10, 1 ); 89 add_action( 'draft_to_future', array( $hook, 'page_scheduled' ), 10, 1 ); 86 90 break; 87 91 case 'page_pending': 88 add_action( 'transition_post_status', array( $hook, 'page_pending' ), 10, 3 ); 92 add_action( 'auto-draft_to_pending', array( $hook, 'page_pending' ), 10, 1 ); 93 add_action( 'draft_to_pending', array( $hook, 'page_pending' ), 10, 1 ); 89 94 break; 90 95 case 'page_updated': 91 add_action( ' transition_post_status', array( $hook, 'page_updated' ), 10, 3);96 add_action( 'publish_to_publish', array( $hook, 'page_updated' ), 10, 1 ); 92 97 break; 93 98 case 'page_trashed': 94 add_action( 'tra nsition_post_status', array( $hook, 'page_trashed' ), 10, 3);99 add_action( 'trashed_post', array( $hook, 'page_trashed' ), 10, 1 ); 95 100 break; 96 101 } -
hey-notify/tags/1.1.0/includes/events/page/class-page-hook.php
r2345565 r2349284 21 21 * When a page enters a DRAFT state. 22 22 * 23 * @param string $new_status New status. 24 * @param string $old_status Old status. 25 * @param object $post Post object. 26 * @return void 27 */ 28 public function page_draft( $new_status, $old_status, $post ) { 29 30 if ( 'page' !== $post->post_type ) { 31 return; 32 } 33 34 if ( 'draft' === $old_status ) { 35 return; 36 } 37 38 if ( 'draft' !== $new_status ) { 39 return; 40 } 41 42 $this->prepare_data( \__( 'Hey, a new page was drafted!', 'hey-notify' ), $post ); 23 * @param object $post Post object. 24 * @return void 25 */ 26 public function page_draft( $post ) { 27 28 if ( empty( $post ) || ! is_object( $post ) ) { 29 return; 30 } 31 32 if ( 'page' !== $post->post_type ) { 33 return; 34 } 35 36 $current_user = \wp_get_current_user(); 37 38 if ( 0 === $current_user ) { 39 $subject = \sprintf( 40 /* translators: %s: Name of the site */ 41 \__( 'Hey, a new page was drafted on %s!', 'hey-notify' ), 42 \get_bloginfo( 'name' ) 43 ); 44 } else { 45 $subject = \sprintf( 46 /* translators: 1: Name of the user 2: Name of the site */ 47 \__( 'Hey, a new page was drafted by %1$s on %2$s!', 'hey-notify' ), 48 \esc_html( $current_user->display_name ), 49 \get_bloginfo( 'name' ) 50 ); 51 } 52 53 $this->prepare_data( $subject, $post ); 43 54 } 44 55 … … 46 57 * When a page enters the PUBLISH state. 47 58 * 48 * @param string $new_status New status. 49 * @param string $old_status Old status. 50 * @param object $post Post object. 51 * @return void 52 */ 53 public function page_published( $new_status, $old_status, $post ) { 54 55 if ( 'page' !== $post->post_type ) { 56 return; 57 } 58 59 $valid = false; 60 switch ( $old_status ) { 61 case 'new': 62 case 'draft': 63 case 'auto-draft': 64 case 'pending': 65 $valid = true; 66 break; 67 } 68 69 if ( false === $valid || 'publish' !== $new_status ) { 70 return; 71 } 72 73 $this->prepare_data( \__( 'Hey, a new page was published!', 'hey-notify' ), $post ); 59 * @param object $post Post object. 60 * @return void 61 */ 62 public function page_published( $post ) { 63 64 if ( empty( $post ) || ! is_object( $post ) ) { 65 return; 66 } 67 68 if ( 'page' !== $post->post_type ) { 69 return; 70 } 71 72 $current_user = \wp_get_current_user(); 73 74 if ( 0 === $current_user ) { 75 $subject = \sprintf( 76 /* translators: %s: Name of the site */ 77 \__( 'Hey, a new page was published on %s!', 'hey-notify' ), 78 \get_bloginfo( 'name' ) 79 ); 80 } else { 81 $subject = \sprintf( 82 /* translators: 1: Name of the user 2: Name of the site */ 83 \__( 'Hey, a new page was published by %1$s on %2$s!', 'hey-notify' ), 84 \esc_html( $current_user->display_name ), 85 \get_bloginfo( 'name' ) 86 ); 87 } 88 89 $this->prepare_data( $subject, $post ); 74 90 } 75 91 … … 77 93 * When a page enters the FUTURE state. 78 94 * 79 * @param string $new_status New status. 80 * @param string $old_status Old status. 81 * @param object $post Post object. 82 * @return void 83 */ 84 public function page_scheduled( $new_status, $old_status, $post ) { 85 86 if ( 'page' !== $post->post_type ) { 87 return; 88 } 89 90 $valid = false; 91 switch ( $old_status ) { 92 case 'new': 93 case 'draft': 94 case 'auto-draft': 95 $valid = true; 96 break; 97 } 98 99 if ( false === $valid || 'future' !== $new_status ) { 100 return; 101 } 102 103 $this->prepare_data( \__( 'Hey, a new page was scheduled!', 'hey-notify' ), $post ); 104 } 105 106 /** 107 * When a page enters the PENDING state 108 * 109 * @param string $new_status New status. 110 * @param string $old_status Old status. 111 * @param object $post Post object. 112 * @return void 113 */ 114 public function page_pending( $new_status, $old_status, $post ) { 115 116 if ( 'page' !== $post->post_type ) { 117 return; 118 } 119 120 $valid = false; 121 switch ( $old_status ) { 122 case 'new': 123 case 'draft': 124 case 'auto-draft': 125 case 'publish': 126 $valid = true; 127 break; 128 } 129 130 if ( false === $valid || 'pending' !== $new_status ) { 131 return; 132 } 133 134 $this->prepare_data( \__( 'Hey, a new page is pending!', 'hey-notify' ), $post ); 95 * @param object $post Post object. 96 * @return void 97 */ 98 public function page_scheduled( $post ) { 99 100 if ( empty( $post ) || ! is_object( $post ) ) { 101 return; 102 } 103 104 if ( 'page' !== $post->post_type ) { 105 return; 106 } 107 108 $current_user = \wp_get_current_user(); 109 110 if ( 0 === $current_user ) { 111 $subject = \sprintf( 112 /* translators: %s: Name of the site */ 113 \__( 'Hey, a new page was scheduled on %s!', 'hey-notify' ), 114 \get_bloginfo( 'name' ) 115 ); 116 } else { 117 $subject = \sprintf( 118 /* translators: 1: Name of the user 2: Name of the site */ 119 \__( 'Hey, a new page was scheduled by %1$s on %2$s!', 'hey-notify' ), 120 \esc_html( $current_user->display_name ), 121 \get_bloginfo( 'name' ) 122 ); 123 } 124 125 $this->prepare_data( $subject, $post ); 126 } 127 128 /** 129 * When a page enters the PENDING state. 130 * 131 * @param object $post Post object. 132 * @return void 133 */ 134 public function page_pending( $post ) { 135 136 $subject = \sprintf( 137 /* translators: %s: Name of the site */ 138 \__( 'Hey, a new page is pending on %s!', 'hey-notify' ), 139 \get_bloginfo( 'name' ) 140 ); 141 142 $this->prepare_data( $subject, $post ); 135 143 } 136 144 … … 138 146 * When a page is updated. 139 147 * 140 * @param string $new_status New status. 141 * @param string $old_status Old status. 142 * @param object $post Post object. 143 * @return void 144 */ 145 public function page_updated( $new_status, $old_status, $post ) { 146 147 if ( 'page' !== $post->post_type ) { 148 return; 149 } 150 151 if ( $old_status !== $new_status ) { 152 return; 153 } 154 155 $this->prepare_data( \__( 'Hey, a page was updated!', 'hey-notify' ), $post ); 148 * @param object $post Post object. 149 * @return void 150 */ 151 public function page_updated( $post ) { 152 153 if ( empty( $post ) || ! is_object( $post ) ) { 154 return; 155 } 156 157 if ( 'page' !== $post->post_type ) { 158 return; 159 } 160 161 if ( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST ) { 162 return; 163 } 164 165 $current_user = \wp_get_current_user(); 166 167 if ( 0 === $current_user ) { 168 $subject = \sprintf( 169 /* translators: %s: Name of the site */ 170 \__( 'Hey, a page was updated on %s!', 'hey-notify' ), 171 \get_bloginfo( 'name' ) 172 ); 173 } else { 174 $subject = \sprintf( 175 /* translators: 1: Name of the user 2: Name of the site */ 176 \__( 'Hey, a page was updated by %1$s on %2$s!', 'hey-notify' ), 177 \esc_html( $current_user->display_name ), 178 \get_bloginfo( 'name' ) 179 ); 180 } 181 182 $this->prepare_data( $subject, $post ); 156 183 } 157 184 … … 159 186 * When a page is trashed. 160 187 * 161 * @param string $new_status New status. 162 * @param string $old_status Old status. 163 * @param object $post Post object. 164 * @return void 165 */ 166 public function page_trashed( $new_status, $old_status, $post ) { 167 168 if ( 'page' !== $post->post_type ) { 169 return; 170 } 171 172 if ( 'trash' !== $new_status ) { 173 return; 174 } 175 176 $this->prepare_data( \__( 'Hey, a page was deleted!', 'hey-notify' ), $post ); 188 * @param int $id Post ID. 189 * @return void 190 */ 191 public function page_trashed( $id ) { 192 193 $post = get_post( $id ); 194 195 if ( is_wp_error( $post ) ) { 196 return; 197 } 198 199 if ( 'page' !== $post->post_type ) { 200 return; 201 } 202 203 $current_user = \wp_get_current_user(); 204 205 if ( 0 === $current_user ) { 206 $subject = \sprintf( 207 /* translators: %s: Name of the site */ 208 \__( 'Hey, a page was deleted on %s!', 'hey-notify' ), 209 \get_bloginfo( 'name' ) 210 ); 211 } else { 212 $subject = \sprintf( 213 /* translators: 1: Name of the user 2: Name of the site */ 214 \__( 'Hey, a page was deleted by %1$s on %2$s!', 'hey-notify' ), 215 \esc_html( $current_user->display_name ), 216 \get_bloginfo( 'name' ) 217 ); 218 } 219 220 $this->prepare_data( $subject, $post ); 177 221 } 178 222 -
hey-notify/tags/1.1.0/includes/events/post/class-post-event.php
r2345565 r2349284 78 78 switch ( $event->{$event->type} ) { 79 79 case 'post_draft': 80 add_action( ' transition_post_status', array( $hook, 'post_draft' ), 10, 3);80 add_action( 'auto-draft_to_draft', array( $hook, 'post_draft' ), 10, 1 ); 81 81 break; 82 82 case 'post_published': 83 add_action( 'transition_post_status', array( $hook, 'post_published' ), 10, 3 ); 83 add_action( 'auto-draft_to_publish', array( $hook, 'post_published' ), 10, 1 ); 84 add_action( 'draft_to_publish', array( $hook, 'post_published' ), 10, 1 ); 85 add_action( 'future_to_publish', array( $hook, 'post_published' ), 10, 1 ); 86 add_action( 'pending_to_publish', array( $hook, 'post_published' ), 10, 1 ); 84 87 break; 85 88 case 'post_scheduled': 86 add_action( 'transition_post_status', array( $hook, 'post_scheduled' ), 10, 3 ); 89 add_action( 'auto-draft_to_future', array( $hook, 'post_scheduled' ), 10, 1 ); 90 add_action( 'draft_to_future', array( $hook, 'post_scheduled' ), 10, 1 ); 87 91 break; 88 92 case 'post_pending': 89 add_action( 'transition_post_status', array( $hook, 'post_pending' ), 10, 3 ); 93 add_action( 'auto-draft_to_pending', array( $hook, 'post_pending' ), 10, 1 ); 94 add_action( 'draft_to_pending', array( $hook, 'post_pending' ), 10, 1 ); 90 95 break; 91 96 case 'post_updated': 92 add_action( ' transition_post_status', array( $hook, 'post_updated' ), 10, 3);97 add_action( 'publish_to_publish', array( $hook, 'post_updated' ), 10, 1 ); 93 98 break; 94 99 case 'post_trashed': 95 add_action( 'tra nsition_post_status', array( $hook, 'post_trashed' ), 10, 3);100 add_action( 'trashed_post', array( $hook, 'post_trashed' ), 10, 1 ); 96 101 break; 97 102 } -
hey-notify/tags/1.1.0/includes/events/post/class-post-hook.php
r2345565 r2349284 21 21 * When a post enters a DRAFT state. 22 22 * 23 * @param string $new_status New status. 24 * @param string $old_status Old status. 25 * @param object $post Post object. 26 * @return void 27 */ 28 public function post_draft( $new_status, $old_status, $post ) { 29 30 if ( 'post' !== $post->post_type ) { 31 return; 32 } 33 34 if ( 'draft' === $old_status ) { 35 return; 36 } 37 38 if ( 'draft' !== $new_status ) { 39 return; 40 } 41 42 $this->prepare_data( \__( 'Hey, a new post was drafted!', 'hey-notify' ), $post ); 23 * @param object $post Post object. 24 * @return void 25 */ 26 public function post_draft( $post ) { 27 28 if ( empty( $post ) || ! is_object( $post ) ) { 29 return; 30 } 31 32 if ( 'post' !== $post->post_type ) { 33 return; 34 } 35 36 $current_user = \wp_get_current_user(); 37 38 if ( 0 === $current_user ) { 39 $subject = \sprintf( 40 /* translators: %s: Name of the site */ 41 \__( 'Hey, a new post was drafted on %s!', 'hey-notify' ), 42 \get_bloginfo( 'name' ) 43 ); 44 } else { 45 $subject = \sprintf( 46 /* translators: 1: Name of the user 2: Name of the site */ 47 \__( 'Hey, a new post was drafted by %1$s on %2$s!', 'hey-notify' ), 48 \esc_html( $current_user->display_name ), 49 \get_bloginfo( 'name' ) 50 ); 51 } 52 53 $this->prepare_data( $subject, $post ); 43 54 } 44 55 … … 46 57 * When a post enters the PUBLISH state. 47 58 * 48 * @param string $new_status New status. 49 * @param string $old_status Old status. 50 * @param object $post Post object. 51 * @return void 52 */ 53 public function post_published( $new_status, $old_status, $post ) { 54 55 if ( 'post' !== $post->post_type ) { 56 return; 57 } 58 59 $valid = false; 60 switch ( $old_status ) { 61 case 'new': 62 case 'draft': 63 case 'auto-draft': 64 case 'pending': 65 $valid = true; 66 break; 67 } 68 69 if ( false === $valid || 'publish' !== $new_status ) { 70 return; 71 } 72 73 $this->prepare_data( \__( 'Hey, a new post was published!', 'hey-notify' ), $post ); 59 * @param object $post Post object. 60 * @return void 61 */ 62 public function post_published( $post ) { 63 64 if ( empty( $post ) || ! is_object( $post ) ) { 65 return; 66 } 67 68 if ( 'post' !== $post->post_type ) { 69 return; 70 } 71 72 $current_user = \wp_get_current_user(); 73 74 if ( 0 === $current_user ) { 75 $subject = \sprintf( 76 /* translators: %s: Name of the site */ 77 \__( 'Hey, a new post was published on %s!', 'hey-notify' ), 78 \get_bloginfo( 'name' ) 79 ); 80 } else { 81 $subject = \sprintf( 82 /* translators: 1: Name of the user 2: Name of the site */ 83 \__( 'Hey, a new post was published by %1$s on %2$s!', 'hey-notify' ), 84 \esc_html( $current_user->display_name ), 85 \get_bloginfo( 'name' ) 86 ); 87 } 88 89 $this->prepare_data( $subject, $post ); 74 90 } 75 91 … … 77 93 * When a post enters the FUTURE state. 78 94 * 79 * @param string $new_status New status. 80 * @param string $old_status Old status. 81 * @param object $post Post object. 82 * @return void 83 */ 84 public function post_scheduled( $new_status, $old_status, $post ) { 85 86 if ( 'post' !== $post->post_type ) { 87 return; 88 } 89 90 $valid = false; 91 switch ( $old_status ) { 92 case 'new': 93 case 'draft': 94 case 'auto-draft': 95 $valid = true; 96 break; 97 } 98 99 if ( false === $valid || 'future' !== $new_status ) { 100 return; 101 } 102 103 $this->prepare_data( \__( 'Hey, a new post was scheduled!', 'hey-notify' ), $post ); 95 * @param object $post Post object. 96 * @return void 97 */ 98 public function post_scheduled( $post ) { 99 100 if ( empty( $post ) || ! is_object( $post ) ) { 101 return; 102 } 103 104 if ( 'post' !== $post->post_type ) { 105 return; 106 } 107 108 $current_user = \wp_get_current_user(); 109 110 if ( 0 === $current_user ) { 111 $subject = \sprintf( 112 /* translators: %s: Name of the site */ 113 \__( 'Hey, a new post was scheduled on %s!', 'hey-notify' ), 114 \get_bloginfo( 'name' ) 115 ); 116 } else { 117 $subject = \sprintf( 118 /* translators: 1: Name of the user 2: Name of the site */ 119 \__( 'Hey, a new post was scheduled by %1$s on %2$s!', 'hey-notify' ), 120 \esc_html( $current_user->display_name ), 121 \get_bloginfo( 'name' ) 122 ); 123 } 124 125 $this->prepare_data( $subject, $post ); 104 126 } 105 127 … … 107 129 * When a post enters the PENDING state. 108 130 * 109 * @param string $new_status New status. 110 * @param string $old_status Old status. 111 * @param object $post Post object. 112 * @return void 113 */ 114 public function post_pending( $new_status, $old_status, $post ) { 115 116 if ( 'post' !== $post->post_type ) { 117 return; 118 } 119 120 $valid = false; 121 switch ( $old_status ) { 122 case 'new': 123 case 'draft': 124 case 'auto-draft': 125 case 'publish': 126 $valid = true; 127 break; 128 } 129 130 if ( false === $valid || 'pending' !== $new_status ) { 131 return; 132 } 133 134 $this->prepare_data( \__( 'Hey, a new post is pending!', 'hey-notify' ), $post ); 131 * @param object $post Post object. 132 * @return void 133 */ 134 public function post_pending( $post ) { 135 136 $subject = \sprintf( 137 /* translators: %s: Name of the site */ 138 \__( 'Hey, a new post is pending on %s!', 'hey-notify' ), 139 \get_bloginfo( 'name' ) 140 ); 141 142 $this->prepare_data( $subject, $post ); 135 143 } 136 144 … … 138 146 * When a post is updated. 139 147 * 140 * @param string $new_status New status. 141 * @param string $old_status Old status. 142 * @param object $post Post object. 143 * @return void 144 */ 145 public function post_updated( $new_status, $old_status, $post ) { 146 147 if ( 'post' !== $post->post_type ) { 148 return; 149 } 150 151 if ( $old_status !== $new_status ) { 152 return; 153 } 154 155 $this->prepare_data( \__( 'Hey, a post was updated!', 'hey-notify' ), $post ); 148 * @param object $post Post object. 149 * @return void 150 */ 151 public function post_updated( $post ) { 152 153 if ( empty( $post ) || ! is_object( $post ) ) { 154 return; 155 } 156 157 if ( 'post' !== $post->post_type ) { 158 return; 159 } 160 161 if ( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST ) { 162 return; 163 } 164 165 $current_user = \wp_get_current_user(); 166 167 if ( 0 === $current_user ) { 168 $subject = \sprintf( 169 /* translators: %s: Name of the site */ 170 \__( 'Hey, a post was updated on %s!', 'hey-notify' ), 171 \get_bloginfo( 'name' ) 172 ); 173 } else { 174 $subject = \sprintf( 175 /* translators: 1: Name of the user 2: Name of the site */ 176 \__( 'Hey, a post was updated by %1$s on %2$s!', 'hey-notify' ), 177 \esc_html( $current_user->display_name ), 178 \get_bloginfo( 'name' ) 179 ); 180 } 181 182 $this->prepare_data( $subject, $post ); 156 183 } 157 184 … … 159 186 * When a post is trashed. 160 187 * 161 * @param string $new_status New status. 162 * @param string $old_status Old status. 163 * @param object $post Post object. 164 * @return void 165 */ 166 public function post_trashed( $new_status, $old_status, $post ) { 167 168 if ( 'post' !== $post->post_type ) { 169 return; 170 } 171 172 if ( 'trash' !== $new_status ) { 173 return; 174 } 175 176 $this->prepare_data( \__( 'Hey, a post was deleted!', 'hey-notify' ), $post ); 188 * @param int $id Post ID. 189 * @return void 190 */ 191 public function post_trashed( $id ) { 192 193 $post = get_post( $id ); 194 195 if ( is_wp_error( $post ) ) { 196 return; 197 } 198 199 if ( 'post' !== $post->post_type ) { 200 return; 201 } 202 203 $current_user = \wp_get_current_user(); 204 205 if ( 0 === $current_user ) { 206 $subject = \sprintf( 207 /* translators: %s: Name of the site */ 208 \__( 'Hey, a post was deleted on %s!', 'hey-notify' ), 209 \get_bloginfo( 'name' ) 210 ); 211 } else { 212 $subject = \sprintf( 213 /* translators: 1: Name of the user 2: Name of the site */ 214 \__( 'Hey, a post was deleted by %1$s on %2$s!', 'hey-notify' ), 215 \esc_html( $current_user->display_name ), 216 \get_bloginfo( 'name' ) 217 ); 218 } 219 220 $this->prepare_data( $subject, $post ); 177 221 } 178 222 -
hey-notify/tags/1.1.0/includes/filters.php
r2345565 r2349284 30 30 $fields[] = ( 31 31 Field::make( 'radio_image', 'hey_notify_service', __( 'Select a service', 'hey-notify' ) ) 32 ->set_options( apply_filters( 'hey_notify_services_options', array()) )32 ->set_options( get_service_options() ) 33 33 ->set_default_value( \get_option( '_hey_notify_default_service' ) ) 34 34 ); … … 106 106 $fields[] = ( 107 107 Field::make( 'radio_image', 'hey_notify_default_service', __( 'Default service:', 'hey-notify' ) ) 108 ->set_options( apply_filters( 'hey_notify_services_options', array()) )108 ->set_options( get_service_options() ) 109 109 ); 110 110 return $fields; 111 111 } 112 113 /** 114 * Get the service options from the filter 115 * 116 * @return array 117 */ 118 function get_service_options() { 119 120 $services = apply_filters( 'hey_notify_services_options', array() ); 121 $options = array(); 122 123 foreach ( $services as $service ) { 124 if ( isset( $service['image'] ) ) { 125 $options[ $service['value'] ] = $service['image']; 126 } 127 } 128 129 return $options; 130 } -
hey-notify/tags/1.1.0/includes/services/class-discord.php
r2345565 r2349284 21 21 22 22 /** 23 * Class construct 24 * 25 * @return void 26 */ 27 public function __construct() { 28 parent::__construct(); 29 30 \add_action( 'hey_notify_send_message_discord', array( $this, 'send' ), 10, 3 ); 31 \add_action( 'hey_notify_discord_settings_core', array( $this, 'get_core_settings' ), 10, 1 ); 32 } 33 34 /** 35 * Get service settings 36 * 37 * @param object $data Data. 38 * @return boolean|array 39 */ 40 public function get_core_settings( $data ) { 41 42 if ( ! is_object( $data ) || ! isset( $data->ID ) ) { 43 return false; 44 } 45 46 return array( 47 'webhook_url' => \carbon_get_post_meta( $data->ID, 'hey_notify_discord_webhook' ), 48 'username' => \carbon_get_post_meta( $data->ID, 'hey_notify_discord_username' ), 49 'icon' => \carbon_get_post_meta( $data->ID, 'hey_notify_discord_avatar' ), 50 ); 51 52 } 53 54 /** 23 55 * Service options 24 56 * … … 27 59 */ 28 60 public function services( $services = array() ) { 29 if ( ! isset( $services['discord'] ) ) { 30 $services['discord'] = HEY_NOTIFY_PLUGIN_URL . '/images/services/discord.png'; 31 } 61 $services[] = array( 62 'value' => 'discord', 63 'label' => __( 'Discord', 'hey-notify' ), 64 'image' => HEY_NOTIFY_PLUGIN_URL . 'images/services/discord.png', 65 ); 32 66 33 67 return $services; … … 85 119 86 120 /** 87 * Sendthe message121 * Prepare the message 88 122 * 89 123 * @param array $message Message. 90 * @return void 91 */ 92 public function send( $message ) { 93 $service = \carbon_get_post_meta( $message['notification']->ID, 'hey_notify_service' ); 94 95 if ( 'discord' !== $service ) { 96 return; 97 } 98 99 $webhook_url = \carbon_get_post_meta( $message['notification']->ID, 'hey_notify_discord_webhook' ); 100 $username = \carbon_get_post_meta( $message['notification']->ID, 'hey_notify_discord_username' ); 101 $avatar = \carbon_get_post_meta( $message['notification']->ID, 'hey_notify_discord_avatar' ); 102 $body = array(); 103 $embed_item = array(); 124 * @param array $settings Settings. 125 * @return array 126 */ 127 private function prepare( $message, $settings ) { 128 129 $body = array(); 130 $embed_item = array(); 104 131 105 132 // Subject. … … 150 177 } 151 178 152 $body = array( 153 'embeds' => array( $embed_item ), 154 ); 155 156 if ( '' !== $username ) { 157 $body['username'] = $username; 158 } 159 160 if ( '' !== $avatar ) { 161 $avatar = \wp_get_attachment_image_url( $avatar, array( 250, 250 ) ); 162 if ( false !== $avatar ) { 163 $body['avatar_url'] = $avatar; 179 $body['embeds'] = array( $embed_item ); 180 181 if ( '' !== $settings['username'] ) { 182 $body['username'] = $settings['username']; 183 } 184 185 if ( '' !== $settings['avatar'] ) { 186 if ( filter_var( $settings['avatar'], FILTER_VALIDATE_URL ) ) { 187 $body['avatar_url'] = $settings['avatar']; 188 } else { 189 $avatar = \wp_get_attachment_image_url( $settings['avatar'], array( 250, 250 ) ); 190 if ( false !== $avatar ) { 191 $body['avatar_url'] = $avatar; 192 } 164 193 } 165 194 } 195 196 return $body; 197 198 } 199 200 /** 201 * Send the message 202 * 203 * @param array $message Message. 204 * @param string $trigger Trigger. 205 * @param mixed $data Data. 206 * @return void 207 */ 208 public function send( $message, $trigger, $data ) { 209 210 $settings = \apply_filters( "hey_notify_discord_settings_{$trigger}", $data ); 211 212 if ( ! is_array( $settings ) || ! isset( $settings['webhook_url'] ) ) { 213 return; 214 } 215 216 $body = $this->prepare( $message, $settings ); 166 217 167 218 $json = \wp_json_encode( $body ); 168 219 $response = \wp_remote_post( 169 $ webhook_url,220 $settings['webhook_url'], 170 221 array( 171 222 'headers' => array( … … 176 227 ); 177 228 178 do_action( 'hey_notify_message_sent', $json, $response ); 229 \do_action( 230 'hey_notify_message_sent', 231 array( 232 'service' => 'discord', 233 'json' => $json, 234 'response' => $response, 235 'trigger' => $trigger, 236 'message' => $message, 237 'data' => $data, 238 ) 239 ); 179 240 180 241 if ( ! \is_wp_error( $response ) ) { -
hey-notify/tags/1.1.0/includes/services/class-email.php
r2345565 r2349284 21 21 22 22 /** 23 * Class construct 24 * 25 * @return void 26 */ 27 public function __construct() { 28 parent::__construct(); 29 30 \add_action( 'hey_notify_send_message_email', array( $this, 'send' ), 10, 3 ); 31 \add_filter( 'hey_notify_email_settings_core', array( $this, 'get_core_settings' ), 10, 1 ); 32 } 33 34 /** 35 * Get service settings 36 * 37 * @param object $data Data. 38 * @return boolean|array 39 */ 40 public function get_core_settings( $data ) { 41 42 if ( ! is_object( $data ) || ! isset( $data->ID ) ) { 43 return false; 44 } 45 46 return array( 47 'email_addresses' => \carbon_get_post_meta( $data->ID, 'hey_notify_email_addresses' ), 48 ); 49 } 50 51 /** 23 52 * Service options 24 53 * … … 27 56 */ 28 57 public function services( $services = array() ) { 29 if ( ! isset( $services['email'] ) ) { 30 $services['email'] = HEY_NOTIFY_PLUGIN_URL . '/images/services/email.png'; 31 } 58 $services[] = array( 59 'value' => 'email', 60 'label' => __( 'Email', 'hey-notify' ), 61 'image' => HEY_NOTIFY_PLUGIN_URL . 'images/services/email.png', 62 ); 32 63 33 64 return $services; … … 70 101 71 102 /** 103 * Prepare the message 104 * 105 * @param array $message Message. 106 * @param array $settings Settings. 107 * @return string 108 */ 109 private function prepare( $message, $settings ) { 110 111 $body = ''; 112 113 // Title. 114 if ( isset( $message['title'] ) && '' !== $message['title'] ) { 115 $body .= "{$message['title']}\r\n"; 116 } 117 118 // URL. 119 if ( isset( $message['url'] ) && '' !== $message['url'] ) { 120 $body .= "{$message['url']}\r\n\r\n"; 121 } 122 123 // Content. 124 if ( isset( $message['content'] ) && '' !== $message['content'] ) { 125 $body .= "{$message['content']}\r\n\r\n"; 126 } 127 128 // Fields. 129 if ( isset( $message['fields'] ) && is_array( $message['fields'] ) ) { 130 foreach ( $message['fields'] as $field ) { 131 $body .= "{$field['name']}: {$field['value']}\r\n"; 132 } 133 } 134 135 // Footer. 136 if ( isset( $message['footer'] ) && '' !== $message['footer'] ) { 137 $body .= "{$message['footer']}"; 138 } 139 140 return $body; 141 } 142 143 /** 72 144 * Send the message 73 145 * 74 * @param array $message Message. 146 * @param array $message Message. 147 * @param string $trigger Trigger. 148 * @param mixed $data Data. 75 149 * @return void 76 150 */ 77 public function send( $message ) {78 79 $se rvice = \carbon_get_post_meta( $message['notification']->ID, 'hey_notify_service');80 81 if ( 'email' !== $service) {151 public function send( $message, $trigger, $data ) { 152 153 $settings = \apply_filters( "hey_notify_email_settings_{$trigger}", $data ); 154 155 if ( false === $settings ) { 82 156 return; 83 157 } 84 158 85 $email_addresses = \carbon_get_post_meta( $message['notification']->ID, 'hey_notify_email_addresses' ); 86 $to_email = array(); 87 if ( $email_addresses ) { 88 foreach ( $email_addresses as $email ) { 159 if ( ! is_array( $settings ) || ! isset( $settings['email_addresses'] ) ) { 160 return; 161 } 162 163 $to_email = array(); 164 if ( $settings['email_addresses'] ) { 165 foreach ( $settings['email_addresses'] as $email ) { 89 166 if ( '' !== trim( $email['email'] ) ) { 90 167 $to_email[] = $email['email']; … … 106 183 } 107 184 108 $body = ''; 109 110 // Title. 111 if ( isset( $message['title'] ) && '' !== $message['title'] ) { 112 $body .= "{$message['title']}\r\n"; 113 } 114 115 // URL. 116 if ( isset( $message['url'] ) && '' !== $message['url'] ) { 117 $body .= "{$message['url']}\r\n\r\n"; 118 } 119 120 // Content. 121 if ( isset( $message['content'] ) && '' !== $message['content'] ) { 122 $body .= "{$message['content']}\r\n\r\n"; 123 } 124 125 // Fields. 126 if ( isset( $message['fields'] ) && is_array( $message['fields'] ) ) { 127 foreach ( $message['fields'] as $field ) { 128 $body .= "{$field['name']}: {$field['value']}\r\n"; 129 } 130 } 131 132 // Footer. 133 if ( isset( $message['footer'] ) && '' !== $message['footer'] ) { 134 $body .= "{$message['footer']}"; 135 } 185 $body = $this->prepare( $message, $settings ); 136 186 137 187 $headers = array( … … 141 191 $result = wp_mail( $to_email, $subject, $body, $headers ); 142 192 143 do_action( 'hey_notify_message_sent', $body, $result ); 193 \do_action( 194 'hey_notify_message_sent', 195 array( 196 'service' => 'email', 197 'response' => $result, 198 'trigger' => $trigger, 199 'message' => $message, 200 'data' => $data, 201 ) 202 ); 144 203 } 145 204 } -
hey-notify/tags/1.1.0/includes/services/class-slack.php
r2345565 r2349284 21 21 22 22 /** 23 * Class construct 24 * 25 * @return void 26 */ 27 public function __construct() { 28 parent::__construct(); 29 30 \add_action( 'hey_notify_send_message_slack', array( $this, 'send' ), 10, 3 ); 31 \add_filter( 'hey_notify_slack_settings_core', array( $this, 'get_core_settings' ), 10, 1 ); 32 } 33 34 /** 35 * Get service settings 36 * 37 * @param object $data Data. 38 * @return boolean|array 39 */ 40 public function get_core_settings( $data ) { 41 42 if ( ! is_object( $data ) || ! isset( $data->ID ) ) { 43 return false; 44 } 45 46 return array( 47 'webhook_url' => \carbon_get_post_meta( $data->ID, 'hey_notify_slack_webhook' ), 48 'username' => \carbon_get_post_meta( $data->ID, 'hey_notify_slack_username' ), 49 'icon' => \carbon_get_post_meta( $data->ID, 'hey_notify_slack_icon' ), 50 'color' => \carbon_get_post_meta( $data->ID, 'hey_notify_slack_color' ), 51 ); 52 } 53 54 /** 23 55 * Add the service 24 56 * … … 27 59 */ 28 60 public function services( $services = array() ) { 29 if ( ! isset( $services['slack'] ) ) { 30 $services['slack'] = HEY_NOTIFY_PLUGIN_URL . '/images/services/slack.png'; 31 } 61 62 $services[] = array( 63 'value' => 'slack', 64 'label' => __( 'Slack', 'hey-notify' ), 65 'image' => HEY_NOTIFY_PLUGIN_URL . 'images/services/slack.png', 66 ); 32 67 33 68 return $services; … … 41 76 */ 42 77 public function fields( $fields = array() ) { 78 43 79 $fields[] = ( 44 80 Field::make( 'text', 'hey_notify_slack_webhook', __( 'Webhook URL', 'hey-notify' ) ) … … 83 119 Field::make( 'color', 'hey_notify_slack_color', __( 'Color', 'hey-notify' ) ) 84 120 ->set_help_text( __( 'Select a color to use for the message attachment.', 'hey-notify' ) ) 121 ->set_default_value( '#009bff' ) 85 122 ->set_conditional_logic( 86 123 array( … … 97 134 98 135 /** 99 * Prepare the message100 *101 * @param array $message Message.102 * @return array103 */104 private function prepare( $message ) {105 $clean_message = array(106 'notification' => $message['notification'],107 'subject' => $this->sanitize( $message['subject'] ),108 'title' => $this->sanitize( $message['title'] ),109 'url' => $message['url'],110 'image' => $message['image'],111 'content' => $this->sanitize( $message['content'] ),112 'footer' => $this->sanitize( $message['footer'] ),113 );114 115 $clean_fields = array();116 foreach ( $message['fields'] as $field ) {117 $clean_fields[] = array(118 'name' => $this->sanitize( $field['name'] ),119 'value' => $this->sanitize( $field['value'] ),120 'inline' => $field['inline'],121 );122 }123 124 $clean_message['fields'] = $clean_fields;125 126 return $clean_message;127 }128 129 /**130 136 * Sanitize a string for Slack 131 137 * … … 134 140 */ 135 141 private function sanitize( $string ) { 136 $string = str_replace( '&', '&', $string );137 $string = str_replace( '<', '<', $string );138 $string = str_replace( '>', '>', $string );142 $string = \str_replace( '&', '&', $string ); 143 $string = \str_replace( '<', '<', $string ); 144 $string = \str_replace( '>', '>', $string ); 139 145 return $string; 140 146 } 141 147 142 148 /** 143 * Sendthe message149 * Prepare the message 144 150 * 145 151 * @param array $message Message. 146 * @return void 147 */ 148 public function send( $message ) { 149 $service = \carbon_get_post_meta( $message['notification']->ID, 'hey_notify_service' ); 150 151 if ( 'slack' !== $service ) { 152 return; 153 } 154 155 $message = $this->prepare( $message ); 156 157 $webhook_url = \carbon_get_post_meta( $message['notification']->ID, 'hey_notify_slack_webhook' ); 158 $username = \carbon_get_post_meta( $message['notification']->ID, 'hey_notify_slack_username' ); 159 $icon = \carbon_get_post_meta( $message['notification']->ID, 'hey_notify_slack_icon' ); 160 $color = \carbon_get_post_meta( $message['notification']->ID, 'hey_notify_slack_color' ); 161 $blocks = array(); 152 * @param array $settings Settings. 153 * @return array 154 */ 155 private function prepare( $message, $settings ) { 156 157 $subject = $this->sanitize( $message['subject'] ); 158 $title = $this->sanitize( $message['title'] ); 159 $content = $this->sanitize( $message['content'] ); 160 $footer = $this->sanitize( $message['footer'] ); 161 $image = $message['image']; 162 $url = $message['url']; 163 164 $blocks = array(); 162 165 163 166 // Subject. 164 if ( isset( $ message['subject'] ) && '' !== $message['subject']) {165 $blocks[] = array( 166 'type' => 'section', 167 'text' => array( 168 'type' => 'mrkdwn', 169 'text' => $ message['subject'],167 if ( isset( $subject ) && '' !== $subject ) { 168 $blocks[] = array( 169 'type' => 'section', 170 'text' => array( 171 'type' => 'mrkdwn', 172 'text' => $subject, 170 173 ), 171 174 ); … … 173 176 174 177 // Title and URL. 175 if ( '' !== $ message['title'] && '' !== $message['url']) {176 $blocks[] = array( 177 'type' => 'section', 178 'text' => array( 179 'type' => 'mrkdwn', 180 'text' => "*<{$ message['url']}|{$message['title']}>*",181 ), 182 ); 183 } elseif ( '' !== $ message['title'] && '' === $message['url']) {184 $blocks[] = array( 185 'type' => 'section', 186 'text' => array( 187 'type' => 'mrkdwn', 188 'text' => "*{$ message['title']}*",189 ), 190 ); 191 } elseif ( '' === $ message['title'] && '' !== $message['url']) {192 $blocks[] = array( 193 'type' => 'section', 194 'text' => array( 195 'type' => 'mrkdwn', 196 'text' => "*<{$ message['url']}|{$message['url']}>*",178 if ( '' !== $title && '' !== $url ) { 179 $blocks[] = array( 180 'type' => 'section', 181 'text' => array( 182 'type' => 'mrkdwn', 183 'text' => "*<{$url}|{$title}>*", 184 ), 185 ); 186 } elseif ( '' !== $title && '' === $url ) { 187 $blocks[] = array( 188 'type' => 'section', 189 'text' => array( 190 'type' => 'mrkdwn', 191 'text' => "*{$title}*", 192 ), 193 ); 194 } elseif ( '' === $title && '' !== $url ) { 195 $blocks[] = array( 196 'type' => 'section', 197 'text' => array( 198 'type' => 'mrkdwn', 199 'text' => "*<{$url}|{$url}>*", 197 200 ), 198 201 ); … … 200 203 201 204 // Content. 202 if ( isset( $ message['content'] ) && '' !== $message['content']) {203 $blocks[] = array( 204 'type' => 'section', 205 'text' => array( 206 'type' => 'mrkdwn', 207 'text' => $ message['content'],205 if ( isset( $content ) && '' !== $content ) { 206 $blocks[] = array( 207 'type' => 'section', 208 'text' => array( 209 'type' => 'mrkdwn', 210 'text' => $content, 208 211 ), 209 212 ); … … 216 219 $fields[] = array( 217 220 'type' => 'mrkdwn', 218 'text' => "*{$ field['name']}*\n{$field['value']}",221 'text' => "*{$this->sanitize( $field['name'] )}*\n{$this->sanitize( $field['value'] )}", 219 222 ); 220 223 } … … 224 227 ); 225 228 226 if ( isset( $ message['image'] ) && '' !== $message['image']) {229 if ( isset( $image ) && '' !== $image ) { 227 230 $fields_array['accessory'] = array( 228 231 'type' => 'image', 229 'image_url' => $ message['image'],230 'alt_text' => isset( $ message['title'] ) ? $message['title']: __( 'Attached image', 'hey-notify' ),232 'image_url' => $image, 233 'alt_text' => isset( $title ) ? $title : __( 'Attached image', 'hey-notify' ), 231 234 ); 232 235 } … … 236 239 237 240 // Footer. 238 if ( isset( $ message['footer'] ) && '' !== $message['footer']) {239 $blocks[] = array( 240 'type' => 'section', 241 'text' => array( 242 'type' => 'mrkdwn', 243 'text' => $ message['footer'],241 if ( isset( $footer ) && '' !== $footer ) { 242 $blocks[] = array( 243 'type' => 'section', 244 'text' => array( 245 'type' => 'mrkdwn', 246 'text' => $footer, 244 247 ), 245 248 ); … … 249 252 250 253 $body['attachments'][] = array( 251 'color' => $ color,254 'color' => $settings['color'], 252 255 'blocks' => $blocks, 253 256 ); 254 257 255 if ( '' !== $username ) { 256 $body['username'] = $username; 257 } 258 259 if ( '' !== $icon ) { 260 $icon_url = \wp_get_attachment_image_url( $icon, array( 250, 250 ) ); 261 if ( false !== $icon_url ) { 262 $body['icon_url'] = $icon_url; 258 if ( '' !== $settings['username'] ) { 259 $body['username'] = $settings['username']; 260 } 261 262 if ( '' !== $settings['icon'] ) { 263 if ( filter_var( $settings['icon'], FILTER_VALIDATE_URL ) ) { 264 $body['icon_url'] = $settings['icon']; 265 } else { 266 $icon_url = \wp_get_attachment_image_url( $settings['icon'], array( 250, 250 ) ); 267 if ( false !== $icon_url ) { 268 $body['icon_url'] = $icon_url; 269 } 263 270 } 264 271 } 272 273 return $body; 274 } 275 276 /** 277 * Send the message 278 * 279 * @param array $message Message. 280 * @param string $trigger Trigger. 281 * @param mixed $data Data. 282 * @return void 283 */ 284 public function send( $message, $trigger, $data ) { 285 286 $settings = \apply_filters( "hey_notify_slack_settings_{$trigger}", $data ); 287 288 if ( ! is_array( $settings ) || ! isset( $settings['webhook_url'] ) ) { 289 return; 290 } 291 292 $body = $this->prepare( $message, $settings ); 265 293 266 294 $json = \wp_json_encode( $body ); 267 295 $response = \wp_remote_post( 268 $ webhook_url,296 $settings['webhook_url'], 269 297 array( 270 298 'headers' => array( … … 275 303 ); 276 304 277 do_action( 'hey_notify_message_sent', $json, $response ); 305 \do_action( 306 'hey_notify_message_sent', 307 array( 308 'service' => 'slack', 309 'json' => $json, 310 'response' => $response, 311 'trigger' => $trigger, 312 'message' => $message, 313 'data' => $data, 314 ) 315 ); 278 316 279 317 if ( ! \is_wp_error( $response ) ) { -
hey-notify/tags/1.1.0/languages/hey-notify.pot
r2345565 r2349284 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Hey Notify 1. 0.0\n"5 "Project-Id-Version: Hey Notify 1.1.0\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/hey-notify\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 2020-07- 21T19:21:51+00:00\n"12 "POT-Creation-Date: 2020-07-30T18:02:04+00:00\n" 13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 14 "X-Generator: WP-CLI 2.1.0\n" … … 17 17 #. Plugin Name of the plugin 18 18 #: includes/cpt.php:35 19 #: includes/services/class-email.php: 9919 #: includes/services/class-email.php:176 20 20 msgid "Hey Notify" 21 21 msgstr "" … … 98 98 msgstr "" 99 99 100 #: includes/events/comment/class-comment-event.php:30 101 msgid "Comments" 102 msgstr "" 103 104 #: includes/events/comment/class-comment-event.php:43 105 #: includes/events/page/class-page-event.php:43 106 #: includes/events/post/class-post-event.php:43 107 #: includes/events/system/class-system-event.php:43 108 #: includes/events/user/class-user-event.php:43 109 msgid "Action" 110 msgstr "" 111 112 #: includes/events/comment/class-comment-event.php:46 113 msgid "New Comment" 114 msgstr "" 115 116 #. translators: %s: Name of the site 117 #: includes/events/comment/class-comment-hook.php:41 118 msgid "Hey, a new comment has been posted on %s!" 119 msgstr "" 120 121 #: includes/events/comment/class-comment-hook.php:59 122 #: includes/events/page/class-page-hook.php:234 123 #: includes/events/post/class-post-hook.php:234 124 msgid "Author" 125 msgstr "" 126 127 #: includes/events/comment/class-comment-hook.php:64 128 #: includes/events/user/class-user-hook.php:120 129 #: includes/services/class-email.php:60 130 msgid "Email" 131 msgstr "" 132 133 #: includes/events/comment/class-comment-hook.php:69 134 #: includes/events/page/class-page-hook.php:239 135 #: includes/events/post/class-post-hook.php:239 136 msgid "Date" 137 msgstr "" 138 139 #: includes/events/comment/class-comment-hook.php:74 140 msgid "Status" 141 msgstr "" 142 143 #: includes/events/comment/class-comment-hook.php:106 144 msgid "Approved" 145 msgstr "" 146 147 #: includes/events/comment/class-comment-hook.php:108 148 msgid "Pending" 149 msgstr "" 150 151 #: includes/events/comment/class-comment-hook.php:110 152 msgid "Spam" 153 msgstr "" 154 100 155 #: includes/events/page/class-page-event.php:30 101 156 msgid "Pages" 102 157 msgstr "" 103 158 104 #: includes/events/page/class-page-event.php:43105 #: includes/events/post/class-post-event.php:43106 msgid "Action"107 msgstr ""108 109 159 #: includes/events/page/class-page-event.php:46 110 160 msgid "Page Draft" … … 131 181 msgstr "" 132 182 133 #: includes/events/page/class-page-hook.php:42 134 msgid "Hey, a new page was drafted!" 135 msgstr "" 136 137 #: includes/events/page/class-page-hook.php:73 138 msgid "Hey, a new page was published!" 139 msgstr "" 140 141 #: includes/events/page/class-page-hook.php:103 142 msgid "Hey, a new page was scheduled!" 143 msgstr "" 144 145 #: includes/events/page/class-page-hook.php:134 146 msgid "Hey, a new page is pending!" 147 msgstr "" 148 149 #: includes/events/page/class-page-hook.php:155 150 msgid "Hey, a page was updated!" 151 msgstr "" 152 183 #. translators: %s: Name of the site 184 #: includes/events/page/class-page-hook.php:41 185 msgid "Hey, a new page was drafted on %s!" 186 msgstr "" 187 188 #. translators: 1: Name of the user 2: Name of the site 189 #: includes/events/page/class-page-hook.php:47 190 msgid "Hey, a new page was drafted by %1$s on %2$s!" 191 msgstr "" 192 193 #. translators: %s: Name of the site 194 #: includes/events/page/class-page-hook.php:77 195 msgid "Hey, a new page was published on %s!" 196 msgstr "" 197 198 #. translators: 1: Name of the user 2: Name of the site 199 #: includes/events/page/class-page-hook.php:83 200 msgid "Hey, a new page was published by %1$s on %2$s!" 201 msgstr "" 202 203 #. translators: %s: Name of the site 204 #: includes/events/page/class-page-hook.php:113 205 msgid "Hey, a new page was scheduled on %s!" 206 msgstr "" 207 208 #. translators: 1: Name of the user 2: Name of the site 209 #: includes/events/page/class-page-hook.php:119 210 msgid "Hey, a new page was scheduled by %1$s on %2$s!" 211 msgstr "" 212 213 #. translators: %s: Name of the site 214 #: includes/events/page/class-page-hook.php:138 215 msgid "Hey, a new page is pending on %s!" 216 msgstr "" 217 218 #. translators: %s: Name of the site 219 #: includes/events/page/class-page-hook.php:170 220 msgid "Hey, a page was updated on %s!" 221 msgstr "" 222 223 #. translators: 1: Name of the user 2: Name of the site 153 224 #: includes/events/page/class-page-hook.php:176 154 msgid "Hey, a page was deleted!"155 msgstr "" 156 157 # : includes/events/page/class-page-hook.php:190158 #: includes/events/p ost/class-post-hook.php:190159 msgid " Author"160 msgstr "" 161 162 # : includes/events/page/class-page-hook.php:195163 #: includes/events/p ost/class-post-hook.php:195164 msgid " Date"225 msgid "Hey, a page was updated by %1$s on %2$s!" 226 msgstr "" 227 228 #. translators: %s: Name of the site 229 #: includes/events/page/class-page-hook.php:208 230 msgid "Hey, a page was deleted on %s!" 231 msgstr "" 232 233 #. translators: 1: Name of the user 2: Name of the site 234 #: includes/events/page/class-page-hook.php:214 235 msgid "Hey, a page was deleted by %1$s on %2$s!" 165 236 msgstr "" 166 237 … … 193 264 msgstr "" 194 265 195 #: includes/events/post/class-post-hook.php:42 196 msgid "Hey, a new post was drafted!" 197 msgstr "" 198 199 #: includes/events/post/class-post-hook.php:73 200 msgid "Hey, a new post was published!" 201 msgstr "" 202 203 #: includes/events/post/class-post-hook.php:103 204 msgid "Hey, a new post was scheduled!" 205 msgstr "" 206 207 #: includes/events/post/class-post-hook.php:134 208 msgid "Hey, a new post is pending!" 209 msgstr "" 210 211 #: includes/events/post/class-post-hook.php:155 212 msgid "Hey, a post was updated!" 213 msgstr "" 214 266 #. translators: %s: Name of the site 267 #: includes/events/post/class-post-hook.php:41 268 msgid "Hey, a new post was drafted on %s!" 269 msgstr "" 270 271 #. translators: 1: Name of the user 2: Name of the site 272 #: includes/events/post/class-post-hook.php:47 273 msgid "Hey, a new post was drafted by %1$s on %2$s!" 274 msgstr "" 275 276 #. translators: %s: Name of the site 277 #: includes/events/post/class-post-hook.php:77 278 msgid "Hey, a new post was published on %s!" 279 msgstr "" 280 281 #. translators: 1: Name of the user 2: Name of the site 282 #: includes/events/post/class-post-hook.php:83 283 msgid "Hey, a new post was published by %1$s on %2$s!" 284 msgstr "" 285 286 #. translators: %s: Name of the site 287 #: includes/events/post/class-post-hook.php:113 288 msgid "Hey, a new post was scheduled on %s!" 289 msgstr "" 290 291 #. translators: 1: Name of the user 2: Name of the site 292 #: includes/events/post/class-post-hook.php:119 293 msgid "Hey, a new post was scheduled by %1$s on %2$s!" 294 msgstr "" 295 296 #. translators: %s: Name of the site 297 #: includes/events/post/class-post-hook.php:138 298 msgid "Hey, a new post is pending on %s!" 299 msgstr "" 300 301 #. translators: %s: Name of the site 302 #: includes/events/post/class-post-hook.php:170 303 msgid "Hey, a post was updated on %s!" 304 msgstr "" 305 306 #. translators: 1: Name of the user 2: Name of the site 215 307 #: includes/events/post/class-post-hook.php:176 216 msgid "Hey, a post was deleted!" 217 msgstr "" 218 219 #: includes/events/post/class-post-hook.php:204 308 msgid "Hey, a post was updated by %1$s on %2$s!" 309 msgstr "" 310 311 #. translators: %s: Name of the site 312 #: includes/events/post/class-post-hook.php:208 313 msgid "Hey, a post was deleted on %s!" 314 msgstr "" 315 316 #. translators: 1: Name of the user 2: Name of the site 317 #: includes/events/post/class-post-hook.php:214 318 msgid "Hey, a post was deleted by %1$s on %2$s!" 319 msgstr "" 320 321 #: includes/events/post/class-post-hook.php:248 220 322 msgid "Categories" 221 323 msgstr "" 222 324 223 #: includes/events/post/class-post-hook.php:2 13325 #: includes/events/post/class-post-hook.php:257 224 326 msgid "Tags" 327 msgstr "" 328 329 #: includes/events/system/class-system-event.php:30 330 msgid "System" 331 msgstr "" 332 333 #: includes/events/system/class-system-event.php:46 334 msgid "WordPress Update Available" 335 msgstr "" 336 337 #: includes/events/system/class-system-event.php:47 338 msgid "Theme Update Available" 339 msgstr "" 340 341 #: includes/events/system/class-system-event.php:48 342 msgid "Plugin Update Available" 343 msgstr "" 344 345 #. translators: %s: Name of the site 346 #: includes/events/system/class-system-hook.php:67 347 msgid "Hey, a new version of WordPress is available on %s!" 348 msgstr "" 349 350 #: includes/events/system/class-system-hook.php:73 351 msgid "Current Version" 352 msgstr "" 353 354 #: includes/events/system/class-system-hook.php:78 355 msgid "New Version" 356 msgstr "" 357 358 #: includes/events/system/class-system-hook.php:86 359 msgid "View the update" 360 msgstr "" 361 362 #. translators: %s: Name of the site 363 #: includes/events/system/class-system-hook.php:153 364 msgid "Hey, new theme updates are available on %s!" 365 msgstr "" 366 367 #: includes/events/system/class-system-hook.php:159 368 msgid "View the theme updates" 369 msgstr "" 370 371 #. translators: %s: Name of the site 372 #: includes/events/system/class-system-hook.php:226 373 msgid "Hey, new plugin updates are available on %s!" 374 msgstr "" 375 376 #: includes/events/system/class-system-hook.php:232 377 msgid "View the plugin updates" 378 msgstr "" 379 380 #: includes/events/user/class-user-event.php:30 381 msgid "Users" 382 msgstr "" 383 384 #: includes/events/user/class-user-event.php:46 385 msgid "New User Registration" 386 msgstr "" 387 388 #: includes/events/user/class-user-event.php:47 389 msgid "Administrator Login" 390 msgstr "" 391 392 #: includes/events/user/class-user-event.php:48 393 msgid "Administrator Failed Login" 394 msgstr "" 395 396 #. translators: %s: Name of the site 397 #: includes/events/user/class-user-hook.php:36 398 msgid "Hey, a new user just registered on %s!" 399 msgstr "" 400 401 #. translators: %s: Name of the site 402 #: includes/events/user/class-user-hook.php:59 403 msgid "Hey, an administrator just logged in to %s!" 404 msgstr "" 405 406 #. translators: %s: Name of the site 407 #: includes/events/user/class-user-hook.php:92 408 msgid "Hey, an administrator just failed to log in to %s!" 409 msgstr "" 410 411 #: includes/events/user/class-user-hook.php:110 412 msgid "Display Name" 413 msgstr "" 414 415 #: includes/events/user/class-user-hook.php:115 416 msgid "Username" 417 msgstr "" 418 419 #: includes/events/user/class-user-hook.php:125 420 msgid "IP Address" 421 msgstr "" 422 423 #: includes/events/user/class-user-hook.php:138 424 msgid "View user's profile" 425 msgstr "" 426 427 #: includes/events/user/class-user-hook.php:161 428 msgid "Unknown" 225 429 msgstr "" 226 430 … … 273 477 msgstr "" 274 478 275 #: includes/services/class-discord.php:44 276 #: includes/services/class-slack.php:44 479 #: includes/services/class-discord.php:63 480 msgid "Discord" 481 msgstr "" 482 483 #: includes/services/class-discord.php:78 484 #: includes/services/class-slack.php:80 277 485 msgid "Webhook URL" 278 486 msgstr "" 279 487 280 #: includes/services/class-discord.php: 46488 #: includes/services/class-discord.php:80 281 489 msgid "The webhook that you created for your Discord channel." 282 490 msgstr "" 283 491 284 #: includes/services/class-discord.php: 46285 #: includes/services/class-slack.php: 46492 #: includes/services/class-discord.php:80 493 #: includes/services/class-slack.php:82 286 494 msgid "Learn More" 287 495 msgstr "" 288 496 289 #: includes/services/class-discord.php: 57497 #: includes/services/class-discord.php:91 290 498 msgid "Discord Avatar" 291 499 msgstr "" 292 500 293 #: includes/services/class-discord.php: 58501 #: includes/services/class-discord.php:92 294 502 msgid "Override the default avatar of the webhook. Not required." 295 503 msgstr "" 296 504 297 #: includes/services/class-discord.php: 70505 #: includes/services/class-discord.php:104 298 506 msgid "Discord Username" 299 507 msgstr "" 300 508 301 #: includes/services/class-discord.php: 71302 #: includes/services/class-slack.php: 71509 #: includes/services/class-discord.php:105 510 #: includes/services/class-slack.php:107 303 511 msgid "Override the default username of the webhook. Not required." 304 512 msgstr "" 305 513 306 #: includes/services/class-email.php: 44514 #: includes/services/class-email.php:75 307 515 msgid "Send notifications to" 308 516 msgstr "" 309 517 310 #: includes/services/class-email.php: 47311 #: includes/services/class-email.php: 53518 #: includes/services/class-email.php:78 519 #: includes/services/class-email.php:84 312 520 msgid "Email Address" 313 521 msgstr "" 314 522 315 #: includes/services/class-email.php: 52523 #: includes/services/class-email.php:83 316 524 msgid "Email Addresses" 317 525 msgstr "" 318 526 319 #: includes/services/class-email.php:1 05527 #: includes/services/class-email.php:182 320 528 msgid "Hey, here's your notification!" 321 529 msgstr "" 322 530 323 #: includes/services/class-slack.php:46 531 #: includes/services/class-slack.php:64 532 msgid "Slack" 533 msgstr "" 534 535 #: includes/services/class-slack.php:82 324 536 msgid "The webhook that you created for your Slack channel." 325 537 msgstr "" 326 538 327 #: includes/services/class-slack.php: 57539 #: includes/services/class-slack.php:93 328 540 msgid "Slack Icon" 329 541 msgstr "" 330 542 331 #: includes/services/class-slack.php: 58543 #: includes/services/class-slack.php:94 332 544 msgid "Override the default icon of the webhook. Not required." 333 545 msgstr "" 334 546 335 #: includes/services/class-slack.php: 70547 #: includes/services/class-slack.php:106 336 548 msgid "Slack Username" 337 549 msgstr "" 338 550 339 #: includes/services/class-slack.php: 83551 #: includes/services/class-slack.php:119 340 552 msgid "Color" 341 553 msgstr "" 342 554 343 #: includes/services/class-slack.php: 84555 #: includes/services/class-slack.php:120 344 556 msgid "Select a color to use for the message attachment." 345 557 msgstr "" 346 558 347 #: includes/services/class-slack.php:23 0559 #: includes/services/class-slack.php:233 348 560 msgid "Attached image" 349 561 msgstr "" -
hey-notify/tags/1.1.0/readme.txt
r2345565 r2349284 5 5 Tested up to: 5.4 6 6 Requires PHP: 5.3 7 Stable tag: 1. 0.07 Stable tag: 1.1.0 8 8 License: GPLv2 or later 9 9 License URI: http://ww.gnu.org/licenses/gpl-2.0.html … … 23 23 = Notifications for: = 24 24 25 * Posts 26 * Pages 27 * Comments (coming soon)28 * Users (coming soon)29 * System Events (coming soon)25 * Posts - Status transitions 26 * Pages - Status transitions 27 * Comments - New comments 28 * Users - New users, admin logins, failed admin logins 29 * System Events - WordPrewss, plugin, and theme updates 30 30 31 31 == Installation == … … 41 41 == Changelog == 42 42 43 = 1.1.0 = 44 * Added comment notifications. 45 * Added user notifications. 46 * Added system notifications. 47 43 48 = 1.0.0 = 44 49 * Initial release. -
hey-notify/tags/1.1.0/uninstall.php
r2345565 r2349284 13 13 } 14 14 15 $remove_data = \get_option( '_hey_notify_remove_data' ); 15 if ( \is_multisite() ) { 16 $sites = \get_sites( 17 array( 18 'number' => 99999, 19 'fields' => 'ids', 20 ) 21 ); 22 if ( $sites ) { 23 foreach ( $sites as $site ) { 24 \switch_to_blog( $site->blog_id ); 25 $remove_data = \get_option( '_hey_notify_remove_data' ); 26 if ( 'yes' === $remove_data ) { 27 delete_options(); 28 delete_posts(); 29 } 30 \restore_current_blog(); 31 } 32 } 33 } else { 34 $remove_data = \get_option( '_hey_notify_remove_data' ); 35 if ( 'yes' === $remove_data ) { 36 delete_options(); 37 delete_posts(); 38 } 39 } 16 40 17 if ( 'yes' === $remove_data ) { 41 /** 42 * Delete options 43 * 44 * @return void 45 */ 46 function delete_options() { 18 47 \delete_option( '_hey_notify_remove_data' ); 19 48 \delete_option( '_hey_notify_default_service' ); 49 \delete_option( 'hey_notify_wordpress_version' ); 50 \delete_option( 'hey_notify_theme_versions' ); 51 \delete_option( 'hey_notify_plugin_versions' ); 52 } 20 53 54 /** 55 * Delete posts 56 * 57 * @return void 58 */ 59 function delete_posts() { 21 60 $all_posts = \get_posts( 22 61 array( -
hey-notify/trunk/hey-notify.php
r2345565 r2349284 4 4 * Plugin URI: https://heynotifywp.com/ 5 5 * Description: Get notified when things happen in WordPress. 6 * Version: 1. 0.06 * Version: 1.1.0 7 7 * Author: FireTree Design, LLC <info@firetreedesign.com> 8 8 * Author URI: https://firetreedesign.com/ … … 19 19 } 20 20 21 define( 'HEY_NOTIFY_VERSION', '1. 0.0' );21 define( 'HEY_NOTIFY_VERSION', '1.1.0' ); 22 22 define( 'HEY_NOTIFY_PLUGIN_FILE', __FILE__ ); 23 23 define( 'HEY_NOTIFY_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); … … 36 36 require_once HEY_NOTIFY_PLUGIN_DIR . 'includes/events/post/loader.php'; 37 37 require_once HEY_NOTIFY_PLUGIN_DIR . 'includes/events/page/loader.php'; 38 require_once HEY_NOTIFY_PLUGIN_DIR . 'includes/events/comment/loader.php'; 39 require_once HEY_NOTIFY_PLUGIN_DIR . 'includes/events/user/loader.php'; 40 require_once HEY_NOTIFY_PLUGIN_DIR . 'includes/events/system/loader.php'; 38 41 39 42 // Services. -
hey-notify/trunk/includes/class-hook.php
r2345565 r2349284 56 56 ); 57 57 58 $ new_data =wp_parse_args( $data, $defaults );58 $message = \wp_parse_args( $data, $defaults ); 59 59 60 do_action( 61 'hey_notify_send_message', 62 array( 63 'notification' => $this->notification, 64 'subject' => $new_data['subject'], 65 'title' => $new_data['title'], 66 'url' => $new_data['url'], 67 'image' => $new_data['image'], 68 'content' => $new_data['content'], 69 'fields' => $new_data['fields'], 70 'footer' => $new_data['footer'], 71 ) 60 $service = \carbon_get_post_meta( $this->notification->ID, 'hey_notify_service' ); 61 62 \do_action( 63 "hey_notify_send_message_{$service}", 64 $message, // Message. 65 'core', // Trigger. 66 $this->notification // Data. 72 67 ); 73 68 } -
hey-notify/trunk/includes/class-service.php
r2345565 r2349284 19 19 20 20 /** 21 * Class constructor 21 * Class construct 22 * 23 * @return void 22 24 */ 23 25 public function __construct() { 24 26 add_filter( 'hey_notify_service_fields', array( $this, 'fields' ), 10 ); 25 27 add_filter( 'hey_notify_services_options', array( $this, 'services' ), 10 ); 26 add_action( 'hey_notify_send_message', array( $this, 'send' ), 10, 1 );27 28 } 28 29 … … 47 48 } 48 49 49 /**50 * Send the message51 *52 * @param array $message Message.53 * @return void54 */55 public function send( $message ) {56 // Do something.57 }58 59 50 } -
hey-notify/trunk/includes/cpt.php
r2345565 r2349284 120 120 switch ( $column_name ) { 121 121 case 'service': 122 $services = \apply_filters( 'hey_notify_services_options', array() ); 123 $service = \carbon_get_post_meta( $post_id, 'hey_notify_service' ); 124 echo "<img src='" . esc_attr( $services[ $service ] ) . "' style='width: 100px; height: auto;' />"; 122 $services_array = \apply_filters( 'hey_notify_services_options', array() ); 123 $service = \carbon_get_post_meta( $post_id, 'hey_notify_service' ); 124 foreach ( $services_array as $services ) { 125 if ( $service === $services['value'] ) { 126 echo "<img src='" . esc_attr( $services['image'] ) . "' style='width: 100px; height: auto;' />"; 127 } 128 } 125 129 break; 126 130 case 'events': -
hey-notify/trunk/includes/events/page/class-page-event.php
r2345565 r2349284 77 77 switch ( $event->{$event->type} ) { 78 78 case 'page_draft': 79 add_action( ' transition_post_status', array( $hook, 'page_draft' ), 10, 3);79 add_action( 'auto-draft_to_draft', array( $hook, 'page_draft' ), 10, 1 ); 80 80 break; 81 81 case 'page_published': 82 add_action( 'transition_post_status', array( $hook, 'page_published' ), 10, 3 ); 82 add_action( 'auto-draft_to_publish', array( $hook, 'page_published' ), 10, 1 ); 83 add_action( 'draft_to_publish', array( $hook, 'page_published' ), 10, 1 ); 84 add_action( 'future_to_publish', array( $hook, 'page_published' ), 10, 1 ); 85 add_action( 'pending_to_publish', array( $hook, 'page_published' ), 10, 1 ); 83 86 break; 84 87 case 'page_scheduled': 85 add_action( 'transition_post_status', array( $hook, 'page_scheduled' ), 10, 3 ); 88 add_action( 'auto-draft_to_future', array( $hook, 'page_scheduled' ), 10, 1 ); 89 add_action( 'draft_to_future', array( $hook, 'page_scheduled' ), 10, 1 ); 86 90 break; 87 91 case 'page_pending': 88 add_action( 'transition_post_status', array( $hook, 'page_pending' ), 10, 3 ); 92 add_action( 'auto-draft_to_pending', array( $hook, 'page_pending' ), 10, 1 ); 93 add_action( 'draft_to_pending', array( $hook, 'page_pending' ), 10, 1 ); 89 94 break; 90 95 case 'page_updated': 91 add_action( ' transition_post_status', array( $hook, 'page_updated' ), 10, 3);96 add_action( 'publish_to_publish', array( $hook, 'page_updated' ), 10, 1 ); 92 97 break; 93 98 case 'page_trashed': 94 add_action( 'tra nsition_post_status', array( $hook, 'page_trashed' ), 10, 3);99 add_action( 'trashed_post', array( $hook, 'page_trashed' ), 10, 1 ); 95 100 break; 96 101 } -
hey-notify/trunk/includes/events/page/class-page-hook.php
r2345565 r2349284 21 21 * When a page enters a DRAFT state. 22 22 * 23 * @param string $new_status New status. 24 * @param string $old_status Old status. 25 * @param object $post Post object. 26 * @return void 27 */ 28 public function page_draft( $new_status, $old_status, $post ) { 29 30 if ( 'page' !== $post->post_type ) { 31 return; 32 } 33 34 if ( 'draft' === $old_status ) { 35 return; 36 } 37 38 if ( 'draft' !== $new_status ) { 39 return; 40 } 41 42 $this->prepare_data( \__( 'Hey, a new page was drafted!', 'hey-notify' ), $post ); 23 * @param object $post Post object. 24 * @return void 25 */ 26 public function page_draft( $post ) { 27 28 if ( empty( $post ) || ! is_object( $post ) ) { 29 return; 30 } 31 32 if ( 'page' !== $post->post_type ) { 33 return; 34 } 35 36 $current_user = \wp_get_current_user(); 37 38 if ( 0 === $current_user ) { 39 $subject = \sprintf( 40 /* translators: %s: Name of the site */ 41 \__( 'Hey, a new page was drafted on %s!', 'hey-notify' ), 42 \get_bloginfo( 'name' ) 43 ); 44 } else { 45 $subject = \sprintf( 46 /* translators: 1: Name of the user 2: Name of the site */ 47 \__( 'Hey, a new page was drafted by %1$s on %2$s!', 'hey-notify' ), 48 \esc_html( $current_user->display_name ), 49 \get_bloginfo( 'name' ) 50 ); 51 } 52 53 $this->prepare_data( $subject, $post ); 43 54 } 44 55 … … 46 57 * When a page enters the PUBLISH state. 47 58 * 48 * @param string $new_status New status. 49 * @param string $old_status Old status. 50 * @param object $post Post object. 51 * @return void 52 */ 53 public function page_published( $new_status, $old_status, $post ) { 54 55 if ( 'page' !== $post->post_type ) { 56 return; 57 } 58 59 $valid = false; 60 switch ( $old_status ) { 61 case 'new': 62 case 'draft': 63 case 'auto-draft': 64 case 'pending': 65 $valid = true; 66 break; 67 } 68 69 if ( false === $valid || 'publish' !== $new_status ) { 70 return; 71 } 72 73 $this->prepare_data( \__( 'Hey, a new page was published!', 'hey-notify' ), $post ); 59 * @param object $post Post object. 60 * @return void 61 */ 62 public function page_published( $post ) { 63 64 if ( empty( $post ) || ! is_object( $post ) ) { 65 return; 66 } 67 68 if ( 'page' !== $post->post_type ) { 69 return; 70 } 71 72 $current_user = \wp_get_current_user(); 73 74 if ( 0 === $current_user ) { 75 $subject = \sprintf( 76 /* translators: %s: Name of the site */ 77 \__( 'Hey, a new page was published on %s!', 'hey-notify' ), 78 \get_bloginfo( 'name' ) 79 ); 80 } else { 81 $subject = \sprintf( 82 /* translators: 1: Name of the user 2: Name of the site */ 83 \__( 'Hey, a new page was published by %1$s on %2$s!', 'hey-notify' ), 84 \esc_html( $current_user->display_name ), 85 \get_bloginfo( 'name' ) 86 ); 87 } 88 89 $this->prepare_data( $subject, $post ); 74 90 } 75 91 … … 77 93 * When a page enters the FUTURE state. 78 94 * 79 * @param string $new_status New status. 80 * @param string $old_status Old status. 81 * @param object $post Post object. 82 * @return void 83 */ 84 public function page_scheduled( $new_status, $old_status, $post ) { 85 86 if ( 'page' !== $post->post_type ) { 87 return; 88 } 89 90 $valid = false; 91 switch ( $old_status ) { 92 case 'new': 93 case 'draft': 94 case 'auto-draft': 95 $valid = true; 96 break; 97 } 98 99 if ( false === $valid || 'future' !== $new_status ) { 100 return; 101 } 102 103 $this->prepare_data( \__( 'Hey, a new page was scheduled!', 'hey-notify' ), $post ); 104 } 105 106 /** 107 * When a page enters the PENDING state 108 * 109 * @param string $new_status New status. 110 * @param string $old_status Old status. 111 * @param object $post Post object. 112 * @return void 113 */ 114 public function page_pending( $new_status, $old_status, $post ) { 115 116 if ( 'page' !== $post->post_type ) { 117 return; 118 } 119 120 $valid = false; 121 switch ( $old_status ) { 122 case 'new': 123 case 'draft': 124 case 'auto-draft': 125 case 'publish': 126 $valid = true; 127 break; 128 } 129 130 if ( false === $valid || 'pending' !== $new_status ) { 131 return; 132 } 133 134 $this->prepare_data( \__( 'Hey, a new page is pending!', 'hey-notify' ), $post ); 95 * @param object $post Post object. 96 * @return void 97 */ 98 public function page_scheduled( $post ) { 99 100 if ( empty( $post ) || ! is_object( $post ) ) { 101 return; 102 } 103 104 if ( 'page' !== $post->post_type ) { 105 return; 106 } 107 108 $current_user = \wp_get_current_user(); 109 110 if ( 0 === $current_user ) { 111 $subject = \sprintf( 112 /* translators: %s: Name of the site */ 113 \__( 'Hey, a new page was scheduled on %s!', 'hey-notify' ), 114 \get_bloginfo( 'name' ) 115 ); 116 } else { 117 $subject = \sprintf( 118 /* translators: 1: Name of the user 2: Name of the site */ 119 \__( 'Hey, a new page was scheduled by %1$s on %2$s!', 'hey-notify' ), 120 \esc_html( $current_user->display_name ), 121 \get_bloginfo( 'name' ) 122 ); 123 } 124 125 $this->prepare_data( $subject, $post ); 126 } 127 128 /** 129 * When a page enters the PENDING state. 130 * 131 * @param object $post Post object. 132 * @return void 133 */ 134 public function page_pending( $post ) { 135 136 $subject = \sprintf( 137 /* translators: %s: Name of the site */ 138 \__( 'Hey, a new page is pending on %s!', 'hey-notify' ), 139 \get_bloginfo( 'name' ) 140 ); 141 142 $this->prepare_data( $subject, $post ); 135 143 } 136 144 … … 138 146 * When a page is updated. 139 147 * 140 * @param string $new_status New status. 141 * @param string $old_status Old status. 142 * @param object $post Post object. 143 * @return void 144 */ 145 public function page_updated( $new_status, $old_status, $post ) { 146 147 if ( 'page' !== $post->post_type ) { 148 return; 149 } 150 151 if ( $old_status !== $new_status ) { 152 return; 153 } 154 155 $this->prepare_data( \__( 'Hey, a page was updated!', 'hey-notify' ), $post ); 148 * @param object $post Post object. 149 * @return void 150 */ 151 public function page_updated( $post ) { 152 153 if ( empty( $post ) || ! is_object( $post ) ) { 154 return; 155 } 156 157 if ( 'page' !== $post->post_type ) { 158 return; 159 } 160 161 if ( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST ) { 162 return; 163 } 164 165 $current_user = \wp_get_current_user(); 166 167 if ( 0 === $current_user ) { 168 $subject = \sprintf( 169 /* translators: %s: Name of the site */ 170 \__( 'Hey, a page was updated on %s!', 'hey-notify' ), 171 \get_bloginfo( 'name' ) 172 ); 173 } else { 174 $subject = \sprintf( 175 /* translators: 1: Name of the user 2: Name of the site */ 176 \__( 'Hey, a page was updated by %1$s on %2$s!', 'hey-notify' ), 177 \esc_html( $current_user->display_name ), 178 \get_bloginfo( 'name' ) 179 ); 180 } 181 182 $this->prepare_data( $subject, $post ); 156 183 } 157 184 … … 159 186 * When a page is trashed. 160 187 * 161 * @param string $new_status New status. 162 * @param string $old_status Old status. 163 * @param object $post Post object. 164 * @return void 165 */ 166 public function page_trashed( $new_status, $old_status, $post ) { 167 168 if ( 'page' !== $post->post_type ) { 169 return; 170 } 171 172 if ( 'trash' !== $new_status ) { 173 return; 174 } 175 176 $this->prepare_data( \__( 'Hey, a page was deleted!', 'hey-notify' ), $post ); 188 * @param int $id Post ID. 189 * @return void 190 */ 191 public function page_trashed( $id ) { 192 193 $post = get_post( $id ); 194 195 if ( is_wp_error( $post ) ) { 196 return; 197 } 198 199 if ( 'page' !== $post->post_type ) { 200 return; 201 } 202 203 $current_user = \wp_get_current_user(); 204 205 if ( 0 === $current_user ) { 206 $subject = \sprintf( 207 /* translators: %s: Name of the site */ 208 \__( 'Hey, a page was deleted on %s!', 'hey-notify' ), 209 \get_bloginfo( 'name' ) 210 ); 211 } else { 212 $subject = \sprintf( 213 /* translators: 1: Name of the user 2: Name of the site */ 214 \__( 'Hey, a page was deleted by %1$s on %2$s!', 'hey-notify' ), 215 \esc_html( $current_user->display_name ), 216 \get_bloginfo( 'name' ) 217 ); 218 } 219 220 $this->prepare_data( $subject, $post ); 177 221 } 178 222 -
hey-notify/trunk/includes/events/post/class-post-event.php
r2345565 r2349284 78 78 switch ( $event->{$event->type} ) { 79 79 case 'post_draft': 80 add_action( ' transition_post_status', array( $hook, 'post_draft' ), 10, 3);80 add_action( 'auto-draft_to_draft', array( $hook, 'post_draft' ), 10, 1 ); 81 81 break; 82 82 case 'post_published': 83 add_action( 'transition_post_status', array( $hook, 'post_published' ), 10, 3 ); 83 add_action( 'auto-draft_to_publish', array( $hook, 'post_published' ), 10, 1 ); 84 add_action( 'draft_to_publish', array( $hook, 'post_published' ), 10, 1 ); 85 add_action( 'future_to_publish', array( $hook, 'post_published' ), 10, 1 ); 86 add_action( 'pending_to_publish', array( $hook, 'post_published' ), 10, 1 ); 84 87 break; 85 88 case 'post_scheduled': 86 add_action( 'transition_post_status', array( $hook, 'post_scheduled' ), 10, 3 ); 89 add_action( 'auto-draft_to_future', array( $hook, 'post_scheduled' ), 10, 1 ); 90 add_action( 'draft_to_future', array( $hook, 'post_scheduled' ), 10, 1 ); 87 91 break; 88 92 case 'post_pending': 89 add_action( 'transition_post_status', array( $hook, 'post_pending' ), 10, 3 ); 93 add_action( 'auto-draft_to_pending', array( $hook, 'post_pending' ), 10, 1 ); 94 add_action( 'draft_to_pending', array( $hook, 'post_pending' ), 10, 1 ); 90 95 break; 91 96 case 'post_updated': 92 add_action( ' transition_post_status', array( $hook, 'post_updated' ), 10, 3);97 add_action( 'publish_to_publish', array( $hook, 'post_updated' ), 10, 1 ); 93 98 break; 94 99 case 'post_trashed': 95 add_action( 'tra nsition_post_status', array( $hook, 'post_trashed' ), 10, 3);100 add_action( 'trashed_post', array( $hook, 'post_trashed' ), 10, 1 ); 96 101 break; 97 102 } -
hey-notify/trunk/includes/events/post/class-post-hook.php
r2345565 r2349284 21 21 * When a post enters a DRAFT state. 22 22 * 23 * @param string $new_status New status. 24 * @param string $old_status Old status. 25 * @param object $post Post object. 26 * @return void 27 */ 28 public function post_draft( $new_status, $old_status, $post ) { 29 30 if ( 'post' !== $post->post_type ) { 31 return; 32 } 33 34 if ( 'draft' === $old_status ) { 35 return; 36 } 37 38 if ( 'draft' !== $new_status ) { 39 return; 40 } 41 42 $this->prepare_data( \__( 'Hey, a new post was drafted!', 'hey-notify' ), $post ); 23 * @param object $post Post object. 24 * @return void 25 */ 26 public function post_draft( $post ) { 27 28 if ( empty( $post ) || ! is_object( $post ) ) { 29 return; 30 } 31 32 if ( 'post' !== $post->post_type ) { 33 return; 34 } 35 36 $current_user = \wp_get_current_user(); 37 38 if ( 0 === $current_user ) { 39 $subject = \sprintf( 40 /* translators: %s: Name of the site */ 41 \__( 'Hey, a new post was drafted on %s!', 'hey-notify' ), 42 \get_bloginfo( 'name' ) 43 ); 44 } else { 45 $subject = \sprintf( 46 /* translators: 1: Name of the user 2: Name of the site */ 47 \__( 'Hey, a new post was drafted by %1$s on %2$s!', 'hey-notify' ), 48 \esc_html( $current_user->display_name ), 49 \get_bloginfo( 'name' ) 50 ); 51 } 52 53 $this->prepare_data( $subject, $post ); 43 54 } 44 55 … … 46 57 * When a post enters the PUBLISH state. 47 58 * 48 * @param string $new_status New status. 49 * @param string $old_status Old status. 50 * @param object $post Post object. 51 * @return void 52 */ 53 public function post_published( $new_status, $old_status, $post ) { 54 55 if ( 'post' !== $post->post_type ) { 56 return; 57 } 58 59 $valid = false; 60 switch ( $old_status ) { 61 case 'new': 62 case 'draft': 63 case 'auto-draft': 64 case 'pending': 65 $valid = true; 66 break; 67 } 68 69 if ( false === $valid || 'publish' !== $new_status ) { 70 return; 71 } 72 73 $this->prepare_data( \__( 'Hey, a new post was published!', 'hey-notify' ), $post ); 59 * @param object $post Post object. 60 * @return void 61 */ 62 public function post_published( $post ) { 63 64 if ( empty( $post ) || ! is_object( $post ) ) { 65 return; 66 } 67 68 if ( 'post' !== $post->post_type ) { 69 return; 70 } 71 72 $current_user = \wp_get_current_user(); 73 74 if ( 0 === $current_user ) { 75 $subject = \sprintf( 76 /* translators: %s: Name of the site */ 77 \__( 'Hey, a new post was published on %s!', 'hey-notify' ), 78 \get_bloginfo( 'name' ) 79 ); 80 } else { 81 $subject = \sprintf( 82 /* translators: 1: Name of the user 2: Name of the site */ 83 \__( 'Hey, a new post was published by %1$s on %2$s!', 'hey-notify' ), 84 \esc_html( $current_user->display_name ), 85 \get_bloginfo( 'name' ) 86 ); 87 } 88 89 $this->prepare_data( $subject, $post ); 74 90 } 75 91 … … 77 93 * When a post enters the FUTURE state. 78 94 * 79 * @param string $new_status New status. 80 * @param string $old_status Old status. 81 * @param object $post Post object. 82 * @return void 83 */ 84 public function post_scheduled( $new_status, $old_status, $post ) { 85 86 if ( 'post' !== $post->post_type ) { 87 return; 88 } 89 90 $valid = false; 91 switch ( $old_status ) { 92 case 'new': 93 case 'draft': 94 case 'auto-draft': 95 $valid = true; 96 break; 97 } 98 99 if ( false === $valid || 'future' !== $new_status ) { 100 return; 101 } 102 103 $this->prepare_data( \__( 'Hey, a new post was scheduled!', 'hey-notify' ), $post ); 95 * @param object $post Post object. 96 * @return void 97 */ 98 public function post_scheduled( $post ) { 99 100 if ( empty( $post ) || ! is_object( $post ) ) { 101 return; 102 } 103 104 if ( 'post' !== $post->post_type ) { 105 return; 106 } 107 108 $current_user = \wp_get_current_user(); 109 110 if ( 0 === $current_user ) { 111 $subject = \sprintf( 112 /* translators: %s: Name of the site */ 113 \__( 'Hey, a new post was scheduled on %s!', 'hey-notify' ), 114 \get_bloginfo( 'name' ) 115 ); 116 } else { 117 $subject = \sprintf( 118 /* translators: 1: Name of the user 2: Name of the site */ 119 \__( 'Hey, a new post was scheduled by %1$s on %2$s!', 'hey-notify' ), 120 \esc_html( $current_user->display_name ), 121 \get_bloginfo( 'name' ) 122 ); 123 } 124 125 $this->prepare_data( $subject, $post ); 104 126 } 105 127 … … 107 129 * When a post enters the PENDING state. 108 130 * 109 * @param string $new_status New status. 110 * @param string $old_status Old status. 111 * @param object $post Post object. 112 * @return void 113 */ 114 public function post_pending( $new_status, $old_status, $post ) { 115 116 if ( 'post' !== $post->post_type ) { 117 return; 118 } 119 120 $valid = false; 121 switch ( $old_status ) { 122 case 'new': 123 case 'draft': 124 case 'auto-draft': 125 case 'publish': 126 $valid = true; 127 break; 128 } 129 130 if ( false === $valid || 'pending' !== $new_status ) { 131 return; 132 } 133 134 $this->prepare_data( \__( 'Hey, a new post is pending!', 'hey-notify' ), $post ); 131 * @param object $post Post object. 132 * @return void 133 */ 134 public function post_pending( $post ) { 135 136 $subject = \sprintf( 137 /* translators: %s: Name of the site */ 138 \__( 'Hey, a new post is pending on %s!', 'hey-notify' ), 139 \get_bloginfo( 'name' ) 140 ); 141 142 $this->prepare_data( $subject, $post ); 135 143 } 136 144 … … 138 146 * When a post is updated. 139 147 * 140 * @param string $new_status New status. 141 * @param string $old_status Old status. 142 * @param object $post Post object. 143 * @return void 144 */ 145 public function post_updated( $new_status, $old_status, $post ) { 146 147 if ( 'post' !== $post->post_type ) { 148 return; 149 } 150 151 if ( $old_status !== $new_status ) { 152 return; 153 } 154 155 $this->prepare_data( \__( 'Hey, a post was updated!', 'hey-notify' ), $post ); 148 * @param object $post Post object. 149 * @return void 150 */ 151 public function post_updated( $post ) { 152 153 if ( empty( $post ) || ! is_object( $post ) ) { 154 return; 155 } 156 157 if ( 'post' !== $post->post_type ) { 158 return; 159 } 160 161 if ( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST ) { 162 return; 163 } 164 165 $current_user = \wp_get_current_user(); 166 167 if ( 0 === $current_user ) { 168 $subject = \sprintf( 169 /* translators: %s: Name of the site */ 170 \__( 'Hey, a post was updated on %s!', 'hey-notify' ), 171 \get_bloginfo( 'name' ) 172 ); 173 } else { 174 $subject = \sprintf( 175 /* translators: 1: Name of the user 2: Name of the site */ 176 \__( 'Hey, a post was updated by %1$s on %2$s!', 'hey-notify' ), 177 \esc_html( $current_user->display_name ), 178 \get_bloginfo( 'name' ) 179 ); 180 } 181 182 $this->prepare_data( $subject, $post ); 156 183 } 157 184 … … 159 186 * When a post is trashed. 160 187 * 161 * @param string $new_status New status. 162 * @param string $old_status Old status. 163 * @param object $post Post object. 164 * @return void 165 */ 166 public function post_trashed( $new_status, $old_status, $post ) { 167 168 if ( 'post' !== $post->post_type ) { 169 return; 170 } 171 172 if ( 'trash' !== $new_status ) { 173 return; 174 } 175 176 $this->prepare_data( \__( 'Hey, a post was deleted!', 'hey-notify' ), $post ); 188 * @param int $id Post ID. 189 * @return void 190 */ 191 public function post_trashed( $id ) { 192 193 $post = get_post( $id ); 194 195 if ( is_wp_error( $post ) ) { 196 return; 197 } 198 199 if ( 'post' !== $post->post_type ) { 200 return; 201 } 202 203 $current_user = \wp_get_current_user(); 204 205 if ( 0 === $current_user ) { 206 $subject = \sprintf( 207 /* translators: %s: Name of the site */ 208 \__( 'Hey, a post was deleted on %s!', 'hey-notify' ), 209 \get_bloginfo( 'name' ) 210 ); 211 } else { 212 $subject = \sprintf( 213 /* translators: 1: Name of the user 2: Name of the site */ 214 \__( 'Hey, a post was deleted by %1$s on %2$s!', 'hey-notify' ), 215 \esc_html( $current_user->display_name ), 216 \get_bloginfo( 'name' ) 217 ); 218 } 219 220 $this->prepare_data( $subject, $post ); 177 221 } 178 222 -
hey-notify/trunk/includes/filters.php
r2345565 r2349284 30 30 $fields[] = ( 31 31 Field::make( 'radio_image', 'hey_notify_service', __( 'Select a service', 'hey-notify' ) ) 32 ->set_options( apply_filters( 'hey_notify_services_options', array()) )32 ->set_options( get_service_options() ) 33 33 ->set_default_value( \get_option( '_hey_notify_default_service' ) ) 34 34 ); … … 106 106 $fields[] = ( 107 107 Field::make( 'radio_image', 'hey_notify_default_service', __( 'Default service:', 'hey-notify' ) ) 108 ->set_options( apply_filters( 'hey_notify_services_options', array()) )108 ->set_options( get_service_options() ) 109 109 ); 110 110 return $fields; 111 111 } 112 113 /** 114 * Get the service options from the filter 115 * 116 * @return array 117 */ 118 function get_service_options() { 119 120 $services = apply_filters( 'hey_notify_services_options', array() ); 121 $options = array(); 122 123 foreach ( $services as $service ) { 124 if ( isset( $service['image'] ) ) { 125 $options[ $service['value'] ] = $service['image']; 126 } 127 } 128 129 return $options; 130 } -
hey-notify/trunk/includes/services/class-discord.php
r2345565 r2349284 21 21 22 22 /** 23 * Class construct 24 * 25 * @return void 26 */ 27 public function __construct() { 28 parent::__construct(); 29 30 \add_action( 'hey_notify_send_message_discord', array( $this, 'send' ), 10, 3 ); 31 \add_action( 'hey_notify_discord_settings_core', array( $this, 'get_core_settings' ), 10, 1 ); 32 } 33 34 /** 35 * Get service settings 36 * 37 * @param object $data Data. 38 * @return boolean|array 39 */ 40 public function get_core_settings( $data ) { 41 42 if ( ! is_object( $data ) || ! isset( $data->ID ) ) { 43 return false; 44 } 45 46 return array( 47 'webhook_url' => \carbon_get_post_meta( $data->ID, 'hey_notify_discord_webhook' ), 48 'username' => \carbon_get_post_meta( $data->ID, 'hey_notify_discord_username' ), 49 'icon' => \carbon_get_post_meta( $data->ID, 'hey_notify_discord_avatar' ), 50 ); 51 52 } 53 54 /** 23 55 * Service options 24 56 * … … 27 59 */ 28 60 public function services( $services = array() ) { 29 if ( ! isset( $services['discord'] ) ) { 30 $services['discord'] = HEY_NOTIFY_PLUGIN_URL . '/images/services/discord.png'; 31 } 61 $services[] = array( 62 'value' => 'discord', 63 'label' => __( 'Discord', 'hey-notify' ), 64 'image' => HEY_NOTIFY_PLUGIN_URL . 'images/services/discord.png', 65 ); 32 66 33 67 return $services; … … 85 119 86 120 /** 87 * Sendthe message121 * Prepare the message 88 122 * 89 123 * @param array $message Message. 90 * @return void 91 */ 92 public function send( $message ) { 93 $service = \carbon_get_post_meta( $message['notification']->ID, 'hey_notify_service' ); 94 95 if ( 'discord' !== $service ) { 96 return; 97 } 98 99 $webhook_url = \carbon_get_post_meta( $message['notification']->ID, 'hey_notify_discord_webhook' ); 100 $username = \carbon_get_post_meta( $message['notification']->ID, 'hey_notify_discord_username' ); 101 $avatar = \carbon_get_post_meta( $message['notification']->ID, 'hey_notify_discord_avatar' ); 102 $body = array(); 103 $embed_item = array(); 124 * @param array $settings Settings. 125 * @return array 126 */ 127 private function prepare( $message, $settings ) { 128 129 $body = array(); 130 $embed_item = array(); 104 131 105 132 // Subject. … … 150 177 } 151 178 152 $body = array( 153 'embeds' => array( $embed_item ), 154 ); 155 156 if ( '' !== $username ) { 157 $body['username'] = $username; 158 } 159 160 if ( '' !== $avatar ) { 161 $avatar = \wp_get_attachment_image_url( $avatar, array( 250, 250 ) ); 162 if ( false !== $avatar ) { 163 $body['avatar_url'] = $avatar; 179 $body['embeds'] = array( $embed_item ); 180 181 if ( '' !== $settings['username'] ) { 182 $body['username'] = $settings['username']; 183 } 184 185 if ( '' !== $settings['avatar'] ) { 186 if ( filter_var( $settings['avatar'], FILTER_VALIDATE_URL ) ) { 187 $body['avatar_url'] = $settings['avatar']; 188 } else { 189 $avatar = \wp_get_attachment_image_url( $settings['avatar'], array( 250, 250 ) ); 190 if ( false !== $avatar ) { 191 $body['avatar_url'] = $avatar; 192 } 164 193 } 165 194 } 195 196 return $body; 197 198 } 199 200 /** 201 * Send the message 202 * 203 * @param array $message Message. 204 * @param string $trigger Trigger. 205 * @param mixed $data Data. 206 * @return void 207 */ 208 public function send( $message, $trigger, $data ) { 209 210 $settings = \apply_filters( "hey_notify_discord_settings_{$trigger}", $data ); 211 212 if ( ! is_array( $settings ) || ! isset( $settings['webhook_url'] ) ) { 213 return; 214 } 215 216 $body = $this->prepare( $message, $settings ); 166 217 167 218 $json = \wp_json_encode( $body ); 168 219 $response = \wp_remote_post( 169 $ webhook_url,220 $settings['webhook_url'], 170 221 array( 171 222 'headers' => array( … … 176 227 ); 177 228 178 do_action( 'hey_notify_message_sent', $json, $response ); 229 \do_action( 230 'hey_notify_message_sent', 231 array( 232 'service' => 'discord', 233 'json' => $json, 234 'response' => $response, 235 'trigger' => $trigger, 236 'message' => $message, 237 'data' => $data, 238 ) 239 ); 179 240 180 241 if ( ! \is_wp_error( $response ) ) { -
hey-notify/trunk/includes/services/class-email.php
r2345565 r2349284 21 21 22 22 /** 23 * Class construct 24 * 25 * @return void 26 */ 27 public function __construct() { 28 parent::__construct(); 29 30 \add_action( 'hey_notify_send_message_email', array( $this, 'send' ), 10, 3 ); 31 \add_filter( 'hey_notify_email_settings_core', array( $this, 'get_core_settings' ), 10, 1 ); 32 } 33 34 /** 35 * Get service settings 36 * 37 * @param object $data Data. 38 * @return boolean|array 39 */ 40 public function get_core_settings( $data ) { 41 42 if ( ! is_object( $data ) || ! isset( $data->ID ) ) { 43 return false; 44 } 45 46 return array( 47 'email_addresses' => \carbon_get_post_meta( $data->ID, 'hey_notify_email_addresses' ), 48 ); 49 } 50 51 /** 23 52 * Service options 24 53 * … … 27 56 */ 28 57 public function services( $services = array() ) { 29 if ( ! isset( $services['email'] ) ) { 30 $services['email'] = HEY_NOTIFY_PLUGIN_URL . '/images/services/email.png'; 31 } 58 $services[] = array( 59 'value' => 'email', 60 'label' => __( 'Email', 'hey-notify' ), 61 'image' => HEY_NOTIFY_PLUGIN_URL . 'images/services/email.png', 62 ); 32 63 33 64 return $services; … … 70 101 71 102 /** 103 * Prepare the message 104 * 105 * @param array $message Message. 106 * @param array $settings Settings. 107 * @return string 108 */ 109 private function prepare( $message, $settings ) { 110 111 $body = ''; 112 113 // Title. 114 if ( isset( $message['title'] ) && '' !== $message['title'] ) { 115 $body .= "{$message['title']}\r\n"; 116 } 117 118 // URL. 119 if ( isset( $message['url'] ) && '' !== $message['url'] ) { 120 $body .= "{$message['url']}\r\n\r\n"; 121 } 122 123 // Content. 124 if ( isset( $message['content'] ) && '' !== $message['content'] ) { 125 $body .= "{$message['content']}\r\n\r\n"; 126 } 127 128 // Fields. 129 if ( isset( $message['fields'] ) && is_array( $message['fields'] ) ) { 130 foreach ( $message['fields'] as $field ) { 131 $body .= "{$field['name']}: {$field['value']}\r\n"; 132 } 133 } 134 135 // Footer. 136 if ( isset( $message['footer'] ) && '' !== $message['footer'] ) { 137 $body .= "{$message['footer']}"; 138 } 139 140 return $body; 141 } 142 143 /** 72 144 * Send the message 73 145 * 74 * @param array $message Message. 146 * @param array $message Message. 147 * @param string $trigger Trigger. 148 * @param mixed $data Data. 75 149 * @return void 76 150 */ 77 public function send( $message ) {78 79 $se rvice = \carbon_get_post_meta( $message['notification']->ID, 'hey_notify_service');80 81 if ( 'email' !== $service) {151 public function send( $message, $trigger, $data ) { 152 153 $settings = \apply_filters( "hey_notify_email_settings_{$trigger}", $data ); 154 155 if ( false === $settings ) { 82 156 return; 83 157 } 84 158 85 $email_addresses = \carbon_get_post_meta( $message['notification']->ID, 'hey_notify_email_addresses' ); 86 $to_email = array(); 87 if ( $email_addresses ) { 88 foreach ( $email_addresses as $email ) { 159 if ( ! is_array( $settings ) || ! isset( $settings['email_addresses'] ) ) { 160 return; 161 } 162 163 $to_email = array(); 164 if ( $settings['email_addresses'] ) { 165 foreach ( $settings['email_addresses'] as $email ) { 89 166 if ( '' !== trim( $email['email'] ) ) { 90 167 $to_email[] = $email['email']; … … 106 183 } 107 184 108 $body = ''; 109 110 // Title. 111 if ( isset( $message['title'] ) && '' !== $message['title'] ) { 112 $body .= "{$message['title']}\r\n"; 113 } 114 115 // URL. 116 if ( isset( $message['url'] ) && '' !== $message['url'] ) { 117 $body .= "{$message['url']}\r\n\r\n"; 118 } 119 120 // Content. 121 if ( isset( $message['content'] ) && '' !== $message['content'] ) { 122 $body .= "{$message['content']}\r\n\r\n"; 123 } 124 125 // Fields. 126 if ( isset( $message['fields'] ) && is_array( $message['fields'] ) ) { 127 foreach ( $message['fields'] as $field ) { 128 $body .= "{$field['name']}: {$field['value']}\r\n"; 129 } 130 } 131 132 // Footer. 133 if ( isset( $message['footer'] ) && '' !== $message['footer'] ) { 134 $body .= "{$message['footer']}"; 135 } 185 $body = $this->prepare( $message, $settings ); 136 186 137 187 $headers = array( … … 141 191 $result = wp_mail( $to_email, $subject, $body, $headers ); 142 192 143 do_action( 'hey_notify_message_sent', $body, $result ); 193 \do_action( 194 'hey_notify_message_sent', 195 array( 196 'service' => 'email', 197 'response' => $result, 198 'trigger' => $trigger, 199 'message' => $message, 200 'data' => $data, 201 ) 202 ); 144 203 } 145 204 } -
hey-notify/trunk/includes/services/class-slack.php
r2345565 r2349284 21 21 22 22 /** 23 * Class construct 24 * 25 * @return void 26 */ 27 public function __construct() { 28 parent::__construct(); 29 30 \add_action( 'hey_notify_send_message_slack', array( $this, 'send' ), 10, 3 ); 31 \add_filter( 'hey_notify_slack_settings_core', array( $this, 'get_core_settings' ), 10, 1 ); 32 } 33 34 /** 35 * Get service settings 36 * 37 * @param object $data Data. 38 * @return boolean|array 39 */ 40 public function get_core_settings( $data ) { 41 42 if ( ! is_object( $data ) || ! isset( $data->ID ) ) { 43 return false; 44 } 45 46 return array( 47 'webhook_url' => \carbon_get_post_meta( $data->ID, 'hey_notify_slack_webhook' ), 48 'username' => \carbon_get_post_meta( $data->ID, 'hey_notify_slack_username' ), 49 'icon' => \carbon_get_post_meta( $data->ID, 'hey_notify_slack_icon' ), 50 'color' => \carbon_get_post_meta( $data->ID, 'hey_notify_slack_color' ), 51 ); 52 } 53 54 /** 23 55 * Add the service 24 56 * … … 27 59 */ 28 60 public function services( $services = array() ) { 29 if ( ! isset( $services['slack'] ) ) { 30 $services['slack'] = HEY_NOTIFY_PLUGIN_URL . '/images/services/slack.png'; 31 } 61 62 $services[] = array( 63 'value' => 'slack', 64 'label' => __( 'Slack', 'hey-notify' ), 65 'image' => HEY_NOTIFY_PLUGIN_URL . 'images/services/slack.png', 66 ); 32 67 33 68 return $services; … … 41 76 */ 42 77 public function fields( $fields = array() ) { 78 43 79 $fields[] = ( 44 80 Field::make( 'text', 'hey_notify_slack_webhook', __( 'Webhook URL', 'hey-notify' ) ) … … 83 119 Field::make( 'color', 'hey_notify_slack_color', __( 'Color', 'hey-notify' ) ) 84 120 ->set_help_text( __( 'Select a color to use for the message attachment.', 'hey-notify' ) ) 121 ->set_default_value( '#009bff' ) 85 122 ->set_conditional_logic( 86 123 array( … … 97 134 98 135 /** 99 * Prepare the message100 *101 * @param array $message Message.102 * @return array103 */104 private function prepare( $message ) {105 $clean_message = array(106 'notification' => $message['notification'],107 'subject' => $this->sanitize( $message['subject'] ),108 'title' => $this->sanitize( $message['title'] ),109 'url' => $message['url'],110 'image' => $message['image'],111 'content' => $this->sanitize( $message['content'] ),112 'footer' => $this->sanitize( $message['footer'] ),113 );114 115 $clean_fields = array();116 foreach ( $message['fields'] as $field ) {117 $clean_fields[] = array(118 'name' => $this->sanitize( $field['name'] ),119 'value' => $this->sanitize( $field['value'] ),120 'inline' => $field['inline'],121 );122 }123 124 $clean_message['fields'] = $clean_fields;125 126 return $clean_message;127 }128 129 /**130 136 * Sanitize a string for Slack 131 137 * … … 134 140 */ 135 141 private function sanitize( $string ) { 136 $string = str_replace( '&', '&', $string );137 $string = str_replace( '<', '<', $string );138 $string = str_replace( '>', '>', $string );142 $string = \str_replace( '&', '&', $string ); 143 $string = \str_replace( '<', '<', $string ); 144 $string = \str_replace( '>', '>', $string ); 139 145 return $string; 140 146 } 141 147 142 148 /** 143 * Sendthe message149 * Prepare the message 144 150 * 145 151 * @param array $message Message. 146 * @return void 147 */ 148 public function send( $message ) { 149 $service = \carbon_get_post_meta( $message['notification']->ID, 'hey_notify_service' ); 150 151 if ( 'slack' !== $service ) { 152 return; 153 } 154 155 $message = $this->prepare( $message ); 156 157 $webhook_url = \carbon_get_post_meta( $message['notification']->ID, 'hey_notify_slack_webhook' ); 158 $username = \carbon_get_post_meta( $message['notification']->ID, 'hey_notify_slack_username' ); 159 $icon = \carbon_get_post_meta( $message['notification']->ID, 'hey_notify_slack_icon' ); 160 $color = \carbon_get_post_meta( $message['notification']->ID, 'hey_notify_slack_color' ); 161 $blocks = array(); 152 * @param array $settings Settings. 153 * @return array 154 */ 155 private function prepare( $message, $settings ) { 156 157 $subject = $this->sanitize( $message['subject'] ); 158 $title = $this->sanitize( $message['title'] ); 159 $content = $this->sanitize( $message['content'] ); 160 $footer = $this->sanitize( $message['footer'] ); 161 $image = $message['image']; 162 $url = $message['url']; 163 164 $blocks = array(); 162 165 163 166 // Subject. 164 if ( isset( $ message['subject'] ) && '' !== $message['subject']) {165 $blocks[] = array( 166 'type' => 'section', 167 'text' => array( 168 'type' => 'mrkdwn', 169 'text' => $ message['subject'],167 if ( isset( $subject ) && '' !== $subject ) { 168 $blocks[] = array( 169 'type' => 'section', 170 'text' => array( 171 'type' => 'mrkdwn', 172 'text' => $subject, 170 173 ), 171 174 ); … … 173 176 174 177 // Title and URL. 175 if ( '' !== $ message['title'] && '' !== $message['url']) {176 $blocks[] = array( 177 'type' => 'section', 178 'text' => array( 179 'type' => 'mrkdwn', 180 'text' => "*<{$ message['url']}|{$message['title']}>*",181 ), 182 ); 183 } elseif ( '' !== $ message['title'] && '' === $message['url']) {184 $blocks[] = array( 185 'type' => 'section', 186 'text' => array( 187 'type' => 'mrkdwn', 188 'text' => "*{$ message['title']}*",189 ), 190 ); 191 } elseif ( '' === $ message['title'] && '' !== $message['url']) {192 $blocks[] = array( 193 'type' => 'section', 194 'text' => array( 195 'type' => 'mrkdwn', 196 'text' => "*<{$ message['url']}|{$message['url']}>*",178 if ( '' !== $title && '' !== $url ) { 179 $blocks[] = array( 180 'type' => 'section', 181 'text' => array( 182 'type' => 'mrkdwn', 183 'text' => "*<{$url}|{$title}>*", 184 ), 185 ); 186 } elseif ( '' !== $title && '' === $url ) { 187 $blocks[] = array( 188 'type' => 'section', 189 'text' => array( 190 'type' => 'mrkdwn', 191 'text' => "*{$title}*", 192 ), 193 ); 194 } elseif ( '' === $title && '' !== $url ) { 195 $blocks[] = array( 196 'type' => 'section', 197 'text' => array( 198 'type' => 'mrkdwn', 199 'text' => "*<{$url}|{$url}>*", 197 200 ), 198 201 ); … … 200 203 201 204 // Content. 202 if ( isset( $ message['content'] ) && '' !== $message['content']) {203 $blocks[] = array( 204 'type' => 'section', 205 'text' => array( 206 'type' => 'mrkdwn', 207 'text' => $ message['content'],205 if ( isset( $content ) && '' !== $content ) { 206 $blocks[] = array( 207 'type' => 'section', 208 'text' => array( 209 'type' => 'mrkdwn', 210 'text' => $content, 208 211 ), 209 212 ); … … 216 219 $fields[] = array( 217 220 'type' => 'mrkdwn', 218 'text' => "*{$ field['name']}*\n{$field['value']}",221 'text' => "*{$this->sanitize( $field['name'] )}*\n{$this->sanitize( $field['value'] )}", 219 222 ); 220 223 } … … 224 227 ); 225 228 226 if ( isset( $ message['image'] ) && '' !== $message['image']) {229 if ( isset( $image ) && '' !== $image ) { 227 230 $fields_array['accessory'] = array( 228 231 'type' => 'image', 229 'image_url' => $ message['image'],230 'alt_text' => isset( $ message['title'] ) ? $message['title']: __( 'Attached image', 'hey-notify' ),232 'image_url' => $image, 233 'alt_text' => isset( $title ) ? $title : __( 'Attached image', 'hey-notify' ), 231 234 ); 232 235 } … … 236 239 237 240 // Footer. 238 if ( isset( $ message['footer'] ) && '' !== $message['footer']) {239 $blocks[] = array( 240 'type' => 'section', 241 'text' => array( 242 'type' => 'mrkdwn', 243 'text' => $ message['footer'],241 if ( isset( $footer ) && '' !== $footer ) { 242 $blocks[] = array( 243 'type' => 'section', 244 'text' => array( 245 'type' => 'mrkdwn', 246 'text' => $footer, 244 247 ), 245 248 ); … … 249 252 250 253 $body['attachments'][] = array( 251 'color' => $ color,254 'color' => $settings['color'], 252 255 'blocks' => $blocks, 253 256 ); 254 257 255 if ( '' !== $username ) { 256 $body['username'] = $username; 257 } 258 259 if ( '' !== $icon ) { 260 $icon_url = \wp_get_attachment_image_url( $icon, array( 250, 250 ) ); 261 if ( false !== $icon_url ) { 262 $body['icon_url'] = $icon_url; 258 if ( '' !== $settings['username'] ) { 259 $body['username'] = $settings['username']; 260 } 261 262 if ( '' !== $settings['icon'] ) { 263 if ( filter_var( $settings['icon'], FILTER_VALIDATE_URL ) ) { 264 $body['icon_url'] = $settings['icon']; 265 } else { 266 $icon_url = \wp_get_attachment_image_url( $settings['icon'], array( 250, 250 ) ); 267 if ( false !== $icon_url ) { 268 $body['icon_url'] = $icon_url; 269 } 263 270 } 264 271 } 272 273 return $body; 274 } 275 276 /** 277 * Send the message 278 * 279 * @param array $message Message. 280 * @param string $trigger Trigger. 281 * @param mixed $data Data. 282 * @return void 283 */ 284 public function send( $message, $trigger, $data ) { 285 286 $settings = \apply_filters( "hey_notify_slack_settings_{$trigger}", $data ); 287 288 if ( ! is_array( $settings ) || ! isset( $settings['webhook_url'] ) ) { 289 return; 290 } 291 292 $body = $this->prepare( $message, $settings ); 265 293 266 294 $json = \wp_json_encode( $body ); 267 295 $response = \wp_remote_post( 268 $ webhook_url,296 $settings['webhook_url'], 269 297 array( 270 298 'headers' => array( … … 275 303 ); 276 304 277 do_action( 'hey_notify_message_sent', $json, $response ); 305 \do_action( 306 'hey_notify_message_sent', 307 array( 308 'service' => 'slack', 309 'json' => $json, 310 'response' => $response, 311 'trigger' => $trigger, 312 'message' => $message, 313 'data' => $data, 314 ) 315 ); 278 316 279 317 if ( ! \is_wp_error( $response ) ) { -
hey-notify/trunk/languages/hey-notify.pot
r2345565 r2349284 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Hey Notify 1. 0.0\n"5 "Project-Id-Version: Hey Notify 1.1.0\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/hey-notify\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 2020-07- 21T19:21:51+00:00\n"12 "POT-Creation-Date: 2020-07-30T18:02:04+00:00\n" 13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 14 "X-Generator: WP-CLI 2.1.0\n" … … 17 17 #. Plugin Name of the plugin 18 18 #: includes/cpt.php:35 19 #: includes/services/class-email.php: 9919 #: includes/services/class-email.php:176 20 20 msgid "Hey Notify" 21 21 msgstr "" … … 98 98 msgstr "" 99 99 100 #: includes/events/comment/class-comment-event.php:30 101 msgid "Comments" 102 msgstr "" 103 104 #: includes/events/comment/class-comment-event.php:43 105 #: includes/events/page/class-page-event.php:43 106 #: includes/events/post/class-post-event.php:43 107 #: includes/events/system/class-system-event.php:43 108 #: includes/events/user/class-user-event.php:43 109 msgid "Action" 110 msgstr "" 111 112 #: includes/events/comment/class-comment-event.php:46 113 msgid "New Comment" 114 msgstr "" 115 116 #. translators: %s: Name of the site 117 #: includes/events/comment/class-comment-hook.php:41 118 msgid "Hey, a new comment has been posted on %s!" 119 msgstr "" 120 121 #: includes/events/comment/class-comment-hook.php:59 122 #: includes/events/page/class-page-hook.php:234 123 #: includes/events/post/class-post-hook.php:234 124 msgid "Author" 125 msgstr "" 126 127 #: includes/events/comment/class-comment-hook.php:64 128 #: includes/events/user/class-user-hook.php:120 129 #: includes/services/class-email.php:60 130 msgid "Email" 131 msgstr "" 132 133 #: includes/events/comment/class-comment-hook.php:69 134 #: includes/events/page/class-page-hook.php:239 135 #: includes/events/post/class-post-hook.php:239 136 msgid "Date" 137 msgstr "" 138 139 #: includes/events/comment/class-comment-hook.php:74 140 msgid "Status" 141 msgstr "" 142 143 #: includes/events/comment/class-comment-hook.php:106 144 msgid "Approved" 145 msgstr "" 146 147 #: includes/events/comment/class-comment-hook.php:108 148 msgid "Pending" 149 msgstr "" 150 151 #: includes/events/comment/class-comment-hook.php:110 152 msgid "Spam" 153 msgstr "" 154 100 155 #: includes/events/page/class-page-event.php:30 101 156 msgid "Pages" 102 157 msgstr "" 103 158 104 #: includes/events/page/class-page-event.php:43105 #: includes/events/post/class-post-event.php:43106 msgid "Action"107 msgstr ""108 109 159 #: includes/events/page/class-page-event.php:46 110 160 msgid "Page Draft" … … 131 181 msgstr "" 132 182 133 #: includes/events/page/class-page-hook.php:42 134 msgid "Hey, a new page was drafted!" 135 msgstr "" 136 137 #: includes/events/page/class-page-hook.php:73 138 msgid "Hey, a new page was published!" 139 msgstr "" 140 141 #: includes/events/page/class-page-hook.php:103 142 msgid "Hey, a new page was scheduled!" 143 msgstr "" 144 145 #: includes/events/page/class-page-hook.php:134 146 msgid "Hey, a new page is pending!" 147 msgstr "" 148 149 #: includes/events/page/class-page-hook.php:155 150 msgid "Hey, a page was updated!" 151 msgstr "" 152 183 #. translators: %s: Name of the site 184 #: includes/events/page/class-page-hook.php:41 185 msgid "Hey, a new page was drafted on %s!" 186 msgstr "" 187 188 #. translators: 1: Name of the user 2: Name of the site 189 #: includes/events/page/class-page-hook.php:47 190 msgid "Hey, a new page was drafted by %1$s on %2$s!" 191 msgstr "" 192 193 #. translators: %s: Name of the site 194 #: includes/events/page/class-page-hook.php:77 195 msgid "Hey, a new page was published on %s!" 196 msgstr "" 197 198 #. translators: 1: Name of the user 2: Name of the site 199 #: includes/events/page/class-page-hook.php:83 200 msgid "Hey, a new page was published by %1$s on %2$s!" 201 msgstr "" 202 203 #. translators: %s: Name of the site 204 #: includes/events/page/class-page-hook.php:113 205 msgid "Hey, a new page was scheduled on %s!" 206 msgstr "" 207 208 #. translators: 1: Name of the user 2: Name of the site 209 #: includes/events/page/class-page-hook.php:119 210 msgid "Hey, a new page was scheduled by %1$s on %2$s!" 211 msgstr "" 212 213 #. translators: %s: Name of the site 214 #: includes/events/page/class-page-hook.php:138 215 msgid "Hey, a new page is pending on %s!" 216 msgstr "" 217 218 #. translators: %s: Name of the site 219 #: includes/events/page/class-page-hook.php:170 220 msgid "Hey, a page was updated on %s!" 221 msgstr "" 222 223 #. translators: 1: Name of the user 2: Name of the site 153 224 #: includes/events/page/class-page-hook.php:176 154 msgid "Hey, a page was deleted!"155 msgstr "" 156 157 # : includes/events/page/class-page-hook.php:190158 #: includes/events/p ost/class-post-hook.php:190159 msgid " Author"160 msgstr "" 161 162 # : includes/events/page/class-page-hook.php:195163 #: includes/events/p ost/class-post-hook.php:195164 msgid " Date"225 msgid "Hey, a page was updated by %1$s on %2$s!" 226 msgstr "" 227 228 #. translators: %s: Name of the site 229 #: includes/events/page/class-page-hook.php:208 230 msgid "Hey, a page was deleted on %s!" 231 msgstr "" 232 233 #. translators: 1: Name of the user 2: Name of the site 234 #: includes/events/page/class-page-hook.php:214 235 msgid "Hey, a page was deleted by %1$s on %2$s!" 165 236 msgstr "" 166 237 … … 193 264 msgstr "" 194 265 195 #: includes/events/post/class-post-hook.php:42 196 msgid "Hey, a new post was drafted!" 197 msgstr "" 198 199 #: includes/events/post/class-post-hook.php:73 200 msgid "Hey, a new post was published!" 201 msgstr "" 202 203 #: includes/events/post/class-post-hook.php:103 204 msgid "Hey, a new post was scheduled!" 205 msgstr "" 206 207 #: includes/events/post/class-post-hook.php:134 208 msgid "Hey, a new post is pending!" 209 msgstr "" 210 211 #: includes/events/post/class-post-hook.php:155 212 msgid "Hey, a post was updated!" 213 msgstr "" 214 266 #. translators: %s: Name of the site 267 #: includes/events/post/class-post-hook.php:41 268 msgid "Hey, a new post was drafted on %s!" 269 msgstr "" 270 271 #. translators: 1: Name of the user 2: Name of the site 272 #: includes/events/post/class-post-hook.php:47 273 msgid "Hey, a new post was drafted by %1$s on %2$s!" 274 msgstr "" 275 276 #. translators: %s: Name of the site 277 #: includes/events/post/class-post-hook.php:77 278 msgid "Hey, a new post was published on %s!" 279 msgstr "" 280 281 #. translators: 1: Name of the user 2: Name of the site 282 #: includes/events/post/class-post-hook.php:83 283 msgid "Hey, a new post was published by %1$s on %2$s!" 284 msgstr "" 285 286 #. translators: %s: Name of the site 287 #: includes/events/post/class-post-hook.php:113 288 msgid "Hey, a new post was scheduled on %s!" 289 msgstr "" 290 291 #. translators: 1: Name of the user 2: Name of the site 292 #: includes/events/post/class-post-hook.php:119 293 msgid "Hey, a new post was scheduled by %1$s on %2$s!" 294 msgstr "" 295 296 #. translators: %s: Name of the site 297 #: includes/events/post/class-post-hook.php:138 298 msgid "Hey, a new post is pending on %s!" 299 msgstr "" 300 301 #. translators: %s: Name of the site 302 #: includes/events/post/class-post-hook.php:170 303 msgid "Hey, a post was updated on %s!" 304 msgstr "" 305 306 #. translators: 1: Name of the user 2: Name of the site 215 307 #: includes/events/post/class-post-hook.php:176 216 msgid "Hey, a post was deleted!" 217 msgstr "" 218 219 #: includes/events/post/class-post-hook.php:204 308 msgid "Hey, a post was updated by %1$s on %2$s!" 309 msgstr "" 310 311 #. translators: %s: Name of the site 312 #: includes/events/post/class-post-hook.php:208 313 msgid "Hey, a post was deleted on %s!" 314 msgstr "" 315 316 #. translators: 1: Name of the user 2: Name of the site 317 #: includes/events/post/class-post-hook.php:214 318 msgid "Hey, a post was deleted by %1$s on %2$s!" 319 msgstr "" 320 321 #: includes/events/post/class-post-hook.php:248 220 322 msgid "Categories" 221 323 msgstr "" 222 324 223 #: includes/events/post/class-post-hook.php:2 13325 #: includes/events/post/class-post-hook.php:257 224 326 msgid "Tags" 327 msgstr "" 328 329 #: includes/events/system/class-system-event.php:30 330 msgid "System" 331 msgstr "" 332 333 #: includes/events/system/class-system-event.php:46 334 msgid "WordPress Update Available" 335 msgstr "" 336 337 #: includes/events/system/class-system-event.php:47 338 msgid "Theme Update Available" 339 msgstr "" 340 341 #: includes/events/system/class-system-event.php:48 342 msgid "Plugin Update Available" 343 msgstr "" 344 345 #. translators: %s: Name of the site 346 #: includes/events/system/class-system-hook.php:67 347 msgid "Hey, a new version of WordPress is available on %s!" 348 msgstr "" 349 350 #: includes/events/system/class-system-hook.php:73 351 msgid "Current Version" 352 msgstr "" 353 354 #: includes/events/system/class-system-hook.php:78 355 msgid "New Version" 356 msgstr "" 357 358 #: includes/events/system/class-system-hook.php:86 359 msgid "View the update" 360 msgstr "" 361 362 #. translators: %s: Name of the site 363 #: includes/events/system/class-system-hook.php:153 364 msgid "Hey, new theme updates are available on %s!" 365 msgstr "" 366 367 #: includes/events/system/class-system-hook.php:159 368 msgid "View the theme updates" 369 msgstr "" 370 371 #. translators: %s: Name of the site 372 #: includes/events/system/class-system-hook.php:226 373 msgid "Hey, new plugin updates are available on %s!" 374 msgstr "" 375 376 #: includes/events/system/class-system-hook.php:232 377 msgid "View the plugin updates" 378 msgstr "" 379 380 #: includes/events/user/class-user-event.php:30 381 msgid "Users" 382 msgstr "" 383 384 #: includes/events/user/class-user-event.php:46 385 msgid "New User Registration" 386 msgstr "" 387 388 #: includes/events/user/class-user-event.php:47 389 msgid "Administrator Login" 390 msgstr "" 391 392 #: includes/events/user/class-user-event.php:48 393 msgid "Administrator Failed Login" 394 msgstr "" 395 396 #. translators: %s: Name of the site 397 #: includes/events/user/class-user-hook.php:36 398 msgid "Hey, a new user just registered on %s!" 399 msgstr "" 400 401 #. translators: %s: Name of the site 402 #: includes/events/user/class-user-hook.php:59 403 msgid "Hey, an administrator just logged in to %s!" 404 msgstr "" 405 406 #. translators: %s: Name of the site 407 #: includes/events/user/class-user-hook.php:92 408 msgid "Hey, an administrator just failed to log in to %s!" 409 msgstr "" 410 411 #: includes/events/user/class-user-hook.php:110 412 msgid "Display Name" 413 msgstr "" 414 415 #: includes/events/user/class-user-hook.php:115 416 msgid "Username" 417 msgstr "" 418 419 #: includes/events/user/class-user-hook.php:125 420 msgid "IP Address" 421 msgstr "" 422 423 #: includes/events/user/class-user-hook.php:138 424 msgid "View user's profile" 425 msgstr "" 426 427 #: includes/events/user/class-user-hook.php:161 428 msgid "Unknown" 225 429 msgstr "" 226 430 … … 273 477 msgstr "" 274 478 275 #: includes/services/class-discord.php:44 276 #: includes/services/class-slack.php:44 479 #: includes/services/class-discord.php:63 480 msgid "Discord" 481 msgstr "" 482 483 #: includes/services/class-discord.php:78 484 #: includes/services/class-slack.php:80 277 485 msgid "Webhook URL" 278 486 msgstr "" 279 487 280 #: includes/services/class-discord.php: 46488 #: includes/services/class-discord.php:80 281 489 msgid "The webhook that you created for your Discord channel." 282 490 msgstr "" 283 491 284 #: includes/services/class-discord.php: 46285 #: includes/services/class-slack.php: 46492 #: includes/services/class-discord.php:80 493 #: includes/services/class-slack.php:82 286 494 msgid "Learn More" 287 495 msgstr "" 288 496 289 #: includes/services/class-discord.php: 57497 #: includes/services/class-discord.php:91 290 498 msgid "Discord Avatar" 291 499 msgstr "" 292 500 293 #: includes/services/class-discord.php: 58501 #: includes/services/class-discord.php:92 294 502 msgid "Override the default avatar of the webhook. Not required." 295 503 msgstr "" 296 504 297 #: includes/services/class-discord.php: 70505 #: includes/services/class-discord.php:104 298 506 msgid "Discord Username" 299 507 msgstr "" 300 508 301 #: includes/services/class-discord.php: 71302 #: includes/services/class-slack.php: 71509 #: includes/services/class-discord.php:105 510 #: includes/services/class-slack.php:107 303 511 msgid "Override the default username of the webhook. Not required." 304 512 msgstr "" 305 513 306 #: includes/services/class-email.php: 44514 #: includes/services/class-email.php:75 307 515 msgid "Send notifications to" 308 516 msgstr "" 309 517 310 #: includes/services/class-email.php: 47311 #: includes/services/class-email.php: 53518 #: includes/services/class-email.php:78 519 #: includes/services/class-email.php:84 312 520 msgid "Email Address" 313 521 msgstr "" 314 522 315 #: includes/services/class-email.php: 52523 #: includes/services/class-email.php:83 316 524 msgid "Email Addresses" 317 525 msgstr "" 318 526 319 #: includes/services/class-email.php:1 05527 #: includes/services/class-email.php:182 320 528 msgid "Hey, here's your notification!" 321 529 msgstr "" 322 530 323 #: includes/services/class-slack.php:46 531 #: includes/services/class-slack.php:64 532 msgid "Slack" 533 msgstr "" 534 535 #: includes/services/class-slack.php:82 324 536 msgid "The webhook that you created for your Slack channel." 325 537 msgstr "" 326 538 327 #: includes/services/class-slack.php: 57539 #: includes/services/class-slack.php:93 328 540 msgid "Slack Icon" 329 541 msgstr "" 330 542 331 #: includes/services/class-slack.php: 58543 #: includes/services/class-slack.php:94 332 544 msgid "Override the default icon of the webhook. Not required." 333 545 msgstr "" 334 546 335 #: includes/services/class-slack.php: 70547 #: includes/services/class-slack.php:106 336 548 msgid "Slack Username" 337 549 msgstr "" 338 550 339 #: includes/services/class-slack.php: 83551 #: includes/services/class-slack.php:119 340 552 msgid "Color" 341 553 msgstr "" 342 554 343 #: includes/services/class-slack.php: 84555 #: includes/services/class-slack.php:120 344 556 msgid "Select a color to use for the message attachment." 345 557 msgstr "" 346 558 347 #: includes/services/class-slack.php:23 0559 #: includes/services/class-slack.php:233 348 560 msgid "Attached image" 349 561 msgstr "" -
hey-notify/trunk/readme.txt
r2345565 r2349284 5 5 Tested up to: 5.4 6 6 Requires PHP: 5.3 7 Stable tag: 1. 0.07 Stable tag: 1.1.0 8 8 License: GPLv2 or later 9 9 License URI: http://ww.gnu.org/licenses/gpl-2.0.html … … 23 23 = Notifications for: = 24 24 25 * Posts 26 * Pages 27 * Comments (coming soon)28 * Users (coming soon)29 * System Events (coming soon)25 * Posts - Status transitions 26 * Pages - Status transitions 27 * Comments - New comments 28 * Users - New users, admin logins, failed admin logins 29 * System Events - WordPrewss, plugin, and theme updates 30 30 31 31 == Installation == … … 41 41 == Changelog == 42 42 43 = 1.1.0 = 44 * Added comment notifications. 45 * Added user notifications. 46 * Added system notifications. 47 43 48 = 1.0.0 = 44 49 * Initial release. -
hey-notify/trunk/uninstall.php
r2345565 r2349284 13 13 } 14 14 15 $remove_data = \get_option( '_hey_notify_remove_data' ); 15 if ( \is_multisite() ) { 16 $sites = \get_sites( 17 array( 18 'number' => 99999, 19 'fields' => 'ids', 20 ) 21 ); 22 if ( $sites ) { 23 foreach ( $sites as $site ) { 24 \switch_to_blog( $site->blog_id ); 25 $remove_data = \get_option( '_hey_notify_remove_data' ); 26 if ( 'yes' === $remove_data ) { 27 delete_options(); 28 delete_posts(); 29 } 30 \restore_current_blog(); 31 } 32 } 33 } else { 34 $remove_data = \get_option( '_hey_notify_remove_data' ); 35 if ( 'yes' === $remove_data ) { 36 delete_options(); 37 delete_posts(); 38 } 39 } 16 40 17 if ( 'yes' === $remove_data ) { 41 /** 42 * Delete options 43 * 44 * @return void 45 */ 46 function delete_options() { 18 47 \delete_option( '_hey_notify_remove_data' ); 19 48 \delete_option( '_hey_notify_default_service' ); 49 \delete_option( 'hey_notify_wordpress_version' ); 50 \delete_option( 'hey_notify_theme_versions' ); 51 \delete_option( 'hey_notify_plugin_versions' ); 52 } 20 53 54 /** 55 * Delete posts 56 * 57 * @return void 58 */ 59 function delete_posts() { 21 60 $all_posts = \get_posts( 22 61 array(
Note: See TracChangeset
for help on using the changeset viewer.