Changeset 2474908
- Timestamp:
- 02/15/2021 02:20:37 PM (5 years ago)
- Location:
- wise-notifications/trunk
- Files:
-
- 3 edited
-
readme.txt (modified) (3 diffs)
-
settingsPage.php (modified) (3 diffs)
-
wiseNotifications.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wise-notifications/trunk/readme.txt
r2058070 r2474908 3 3 Tags: push notifications, browser notifications, web notitications, iOS web notifications, web push notifications, push, safari, chrome, iOS, iPhone, user engagement 4 4 Requires at least: 4.0.1 5 Tested up to: 5. 15 Tested up to: 5.6.1 6 6 Requires PHP: 5.6 7 Stable tag: 1. 0.07 Stable tag: 1.1.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 53 53 54 54 1. Download the plugin archive. 55 2. Upload and uncompress it in "/wp-content/plugins/" directory , or install the plugin through the WordPress plugins screen directly.55 2. Upload and uncompress it in "/wp-content/plugins/" directory. 56 56 3. Activate the plugin through the "Plugins" menu in WordPress. 57 57 4. Subscribe to plan and add your domain in your [Wise Notifications](https://wisenotifications.com) account. 58 5. Set **Site ID**, **API Key** and **Subscribe URL** in your WordPress Wise Notifications settings page, i.e Settings -> Wise Notifications.58 5. Set **Site ID**, **API Key** and **Subscribe URL** in your WordPress Wise Notifications settings page, e.g. yourdomain.com/wp-admin/options-general.php?page=wise-notifications-admin. 59 59 6. Enjoy and profit! 60 60 … … 63 63 = 1.0.0 = 64 64 * Initial release. 65 66 = 1.1.0 = 67 * Configure for what post types to send notifications automatically. 68 * Improvements in UI and small bug fixes -
wise-notifications/trunk/settingsPage.php
r2058070 r2474908 99 99 'setting_section_id' 100 100 ); 101 102 $post_types = get_post_types_by_support(['title', 'thumbnail']); 103 104 add_settings_field( 105 'postTypes', 106 'Post Types', 107 [ $this, 'wisePostTypes_callback' ], 108 'wise-notifications-admin', 109 'setting_section_id', 110 [ 111 'label_for' => 'postTypes', 112 'post_types' => $post_types, 113 ] 114 ); 101 115 } 102 116 … … 120 134 if (isset($input['subscribeLink'])) { 121 135 $new_input['subscribeLink'] = sanitize_text_field($input['subscribeLink']); 136 } 137 138 if (isset($input['postTypes'])) { 139 $new_input['postTypes'] = $input['postTypes']; 122 140 } 123 141 … … 156 174 ); 157 175 } 176 177 public function wisePostTypes_callback($args) { 178 echo '<fieldset>'; 179 echo '<legend>Select the post types you want to automatically send notifications when published.<br>You can override these settings on each post before publishing.</legend>'; 180 181 foreach ($args['post_types'] as $post_type) { 182 echo "<label for='".$post_type."'><input type='checkbox' id='postTypes[]' value='".$post_type."' name='wise_notifications_name[postTypes][]'"; 183 if ( isset($this->options['postTypes']) && in_array($post_type, $this->options['postTypes']) ) { 184 echo ' checked'; 185 } 186 echo '/> '.ucfirst($post_type).'</label><br />'; 187 } 188 echo '</fieldset>'; 189 } 158 190 } 159 191 -
wise-notifications/trunk/wiseNotifications.php
r2058070 r2474908 2 2 /** 3 3 * @package Wise Notifications - web push notifications for iOS 4 * @version 1. 0.04 * @version 1.1.0 5 5 */ 6 6 /* … … 8 8 Description: Send updates using push notifications to your iOS website visitors. 9 9 Author: Ciprian Amariei, Diana Amitroaei 10 Version: 1. 0.010 Version: 1.1.0 11 11 Author URI: https://wisenotifications.com 12 12 */ … … 43 43 if (is_admin()) { 44 44 include $wiseNotifications_pluginPath . 'settingsPage.php'; 45 include $wiseNotifications_pluginPath . 'metaBox.php'; 45 46 wiseNotifications_log('check OneSignal exists', class_exists('OneSignal_Admin')); 46 47 … … 66 67 { 67 68 wiseNotifications_log('wiseNotifications_postPublishedNotification started', ['new_status' => $new_status, 'old_status' => $old_status ]); 68 69 69 // Check if someone published a post for the first time. 70 if ( ( $new_status == 'publish' ) /*&& ( $old_status != 'publish' )*/) {70 if ($new_status == 'publish') { 71 71 // TODO make sure the post is new and not updated (maybe check revisions?) 72 72 try { … … 81 81 { 82 82 83 // do not resend of already sent 84 $wasNotificationSentAlready = get_post_meta ( $post->ID, 'wisenotifications_notification_sent', true ); 85 86 if ($wasNotificationSentAlready) { 87 wiseNotifications_log('notification was already sent', ['post' => $post]); 88 return; 89 } 90 83 91 $title = $post->post_title; 84 92 $permalink = get_permalink($post->ID); … … 89 97 wiseNotifications_log('config data is missing', $pluginSettings, 'error'); 90 98 // TODO https://premium.wpmudev.org/blog/adding-admin-notices/ 99 return; 100 } 101 102 // check if the post type has enabled notifications 103 if (empty($pluginSettings['postTypes']) || !in_array($post->post_type, $pluginSettings['postTypes'])) { 104 wiseNotifications_log('post type not included for notifications', $pluginSettings, 'error'); 105 return; 106 } 107 108 // check if the checkbox was checked for this post to send notification 109 if (!isset($_POST['wiseNotifications-checkbox']) || (isset($_POST['wiseNotifications-checkbox']) && $_POST['wiseNotifications-checkbox'] != 1)) { 110 wiseNotifications_log('post should not have notifications sent from checkbox', $pluginSettings, 'error'); 91 111 return; 92 112 } … … 112 132 // $url = 'https://skdlxfssth.execute-api.eu-central-1.amazonaws.com/dev/'; 113 133 $url = 'https://api.wisenotifications.com/v1/'; 114 wiseNotifications_postData($url, $data, $pluginSettings['apiKey']); 134 $isNotificationSent = wiseNotifications_postData($url, $data, $pluginSettings['apiKey']); 135 136 if ($isNotificationSent) { 137 update_post_meta( $post->ID, 'wisenotifications_notification_sent', true ); 138 } 115 139 } 116 140 … … 134 158 wiseNotifications_log('notification sending received headers', $result); 135 159 136 return $result;160 return 1|| $result['http_response']->get_response_object()->success; 137 161 } 138 162 }
Note: See TracChangeset
for help on using the changeset viewer.