Changeset 1225048
- Timestamp:
- 08/19/2015 12:32:00 PM (11 years ago)
- Location:
- push-notifications/trunk
- Files:
-
- 7 edited
-
css/pushwoosh.css (modified) (1 diff)
-
html/pushwoosh.html (modified) (2 diffs)
-
js/pushwoosh.js (modified) (1 diff)
-
lib/pushwoosh.php (modified) (3 diffs)
-
pushwoosh.php (modified) (11 diffs)
-
readme.txt (modified) (2 diffs)
-
settings.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
push-notifications/trunk/css/pushwoosh.css
r874622 r1225048 19 19 } 20 20 21 #pushwoosh_safari_title {22 width: 90%;21 #pushwoosh_safari_title, #pushwoosh_filter { 22 width: 100%; 23 23 float: left; 24 24 margin: 0 5px 0 0; 25 }26 27 #pushwoosh_length_over {28 margin: 3px 0 0 0;29 color: #b1b6c3;30 25 } 31 26 -
push-notifications/trunk/html/pushwoosh.html
r1139183 r1225048 2 2 <b>Chrome/Safari Title:</b> 3 3 <br/> 4 <input id="pushwoosh_safari_title" maxlength="25" onshow="showLengthOver()" onkeyup="showLengthOver()" name="safari_title" value='%s' type="text" placeholder="%s" /> 5 <div id="pushwoosh_length_over"></div> 4 <input id="pushwoosh_safari_title" maxlength="32" name="safari_title" value='%s' type="text" placeholder="%s" /> 6 5 <br/> 7 6 <b>Message:</b> … … 9 8 <textarea id="pushwoosh_message_content" name="pushwoosh_message_content" placeholder="%s">%s</textarea> 10 9 <br/> 10 <input id="pushwoosh_filter" maxlength="255" name="pushwoosh_filter" type='text' placeholder="%s" value="%s" /> 11 <br /> 11 12 <input type="checkbox" name="pushwoosh_send_push" id="pushwoosh_checkbox_send_push" value="1" %s /> 12 13 <label for="pushwoosh_checkbox_send_push">%s</label> -
push-notifications/trunk/js/pushwoosh.js
r1158592 r1225048 1 function showLengthOver() {2 var max_length = 25;3 var critical_color = 'red';4 var default_color = '#b1b6c3';5 var safari_title = document.getElementById('pushwoosh_safari_title');6 if (safari_title != undefined) {7 var title_length = safari_title.value.length;8 var result = max_length - title_length;9 if (result < 6) {10 document.getElementById('pushwoosh_length_over').style.color = critical_color;11 } else {12 document.getElementById('pushwoosh_length_over').style.color = default_color;13 }14 document.getElementById('pushwoosh_length_over').innerHTML = result;15 }16 }17 18 document.addEventListener('DOMContentLoaded',19 function () {20 showLengthOver();21 },22 false23 ); -
push-notifications/trunk/lib/pushwoosh.php
r942866 r1225048 41 41 throw new PushwooshBadRequestException('Bad response format'); 42 42 43 } 43 } 44 44 if ($response['status_code'] != 200 || $response['status_message'] != 'OK') { 45 45 throw new PushwooshBadRequestException(sprintf('Pushwoosh responded with error: %s with code: %s', $response['status_message'], $response['status_code']) ); 46 46 } 47 return $response; 47 return $response; 48 48 } 49 49 50 public function createMessage($applicationCode, $ options = array()) {50 public function createMessage($applicationCode, $messageContent, $options = array()) { 51 51 $body = array( 52 52 'application' => $applicationCode, 53 53 'auth' => $this->settings['auth'], 54 'notifications' => array( 55 ) 54 'notifications' => array(), 56 55 ); 57 56 $messageDefault = array( 58 57 'send_date' => 'now', 59 58 'content' => array( 60 'en' => '',61 ) 59 'en' => $messageContent, 60 ), 62 61 ); 63 62 if (!is_array($options) || !isset($options[0])) { … … 67 66 $body['notifications'][] = $message + $messageDefault; 68 67 } 69 return $this->request('createMessage', $body); 68 return $this->request('createMessage', $body); 70 69 } 70 71 71 public function compileDevicesFilter($applicationCode, $tags = array()) { 72 72 $conditions = array('A("' . $applicationCode . '")'); … … 100 100 } 101 101 102 public function createTargetedMessage($applicationCode, $message = array(), $options = array()) {102 public function createTargetedMessage($applicationCode, $messageContent, $options = array()) { 103 103 $body = array( 104 104 'auth' => $this->settings['auth'], 105 105 'send_date' => 'now', 106 106 'content' => array( 107 'en' => ''107 'en' => $messageContent, 108 108 ) 109 109 ); 110 $body = array_merge($body, $options); 111 $body = array_merge($body, $message); 112 $body['devices_filter'] = $this->compileDevicesFilter($applicationCode, array()); 110 $body = array_merge($body, $options); 111 $body['devices_filter'] = $this->compileDevicesFilter($applicationCode, array()); 113 112 return $this->request('createTargetedMessage', $body); 114 113 } -
push-notifications/trunk/pushwoosh.php
r1222733 r1225048 3 3 /** 4 4 * @package Pushwoosh 5 * @version 2.3.1 55 * @version 2.3.16 6 6 */ 7 7 … … 12 12 * Author: Pushwoosh, Inc 13 13 * Author URI: https://www.pushwoosh.com/ 14 * Version: 2.3.1 514 * Version: 2.3.16 15 15 * 16 16 * Copyright 2014 Arello Mobile (email: support@arello-mobile.com) … … 103 103 $checkbox_checked = 'checked="checked"'; 104 104 $message_content = ''; 105 $pushwoosh_filter = ''; 106 $pushwoosh_filter_placeholder = 'Filter name'; 105 107 $safari_title = ''; 106 108 … … 110 112 $message_content = get_post_meta($post->ID, 'pushwoosh_message_content', true); 111 113 $safari_title = get_post_meta($post->ID, 'safari_title', true); 114 $pushwoosh_filter = get_post_meta($post->ID, 'pushwoosh_filter', true); 112 115 } 113 116 $plugin_content = file_get_contents(plugin_dir_path(__FILE__) . '/html/pushwoosh.html'); … … 117 120 __($textArea_placeholder, 'pushwoosh'), 118 121 $message_content, 122 $pushwoosh_filter_placeholder, 123 $pushwoosh_filter, 119 124 $checkbox_checked, 120 125 __($checkbox_label, 'pushwoosh') … … 128 133 $api_token = get_option('pushwoosh_api_token', array('text_string' => null)); 129 134 $safari_action = get_option('pushwoosh_safari_action', array('text_string' => null)); 135 130 136 $options['safari_action'] = $safari_action['text_string']; 131 137 if ($options['safari_title'] == '') { … … 146 152 147 153 try { 148 $pushwoosh->createTargetedMessage($application_code['text_string'], 149 array('send_date' => 'now', 'content' => $message_content), $options); 154 $pushwoosh->createMessage($application_code['text_string'], $message_content, $options); 150 155 $status = 'Success'; 151 156 } catch (Exception $e) { … … 164 169 } 165 170 171 $options = array(); 166 172 if (!empty($_POST)) { 167 173 if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { … … 184 190 } 185 191 $options['chrome_title'] = $options['safari_title']; 186 192 $options['filter'] = $_POST['pushwoosh_filter']; 193 // update post meta data 187 194 update_post_meta($ID, 'pushwoosh_message_content', $message_content); 188 195 update_post_meta($ID, 'safari_title', $options['safari_title']); 189 } 196 update_post_meta($ID, 'pushwoosh_filter', $options['filter']); 197 } 198 199 return $options; 190 200 } 191 201 … … 199 209 } 200 210 201 if ($post->post_type == 'page') {202 return;203 }211 if ($post->post_type == 'page') { 212 return; 213 } 204 214 205 215 $message_content = null; … … 213 223 214 224 if (!empty($_POST)) { 215 if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { 216 return; 217 } 218 219 if (!isset($_POST['pushwoosh_post_nonce'])) { 220 return; 221 } 222 if (!wp_verify_nonce($_POST['pushwoosh_post_nonce'], plugin_basename( __FILE__ ))) { 223 return; 224 } 225 if (empty($_POST['pushwoosh_send_push'])) { 226 return; 227 } 228 if (array_key_exists('safari_title', $_POST)) { 229 $options['safari_title'] = $_POST['safari_title']; 230 } else { 231 $options['safari_title'] = ''; 232 } 233 if (array_key_exists('pushwoosh_message_content', $_POST)) { 234 $message_content = $_POST['pushwoosh_message_content']; 235 } 236 update_post_meta($post_id, 'pushwoosh_message_content', $message_content); 237 update_post_meta($post_id, 'safari_title', $options['safari_title']); 225 $postOptions = pushwoosh_save_post($post_id); 226 $options = array_merge($options, $postOptions); 238 227 } else { 239 228 $message_content = get_post_meta($post_id, 'pushwoosh_message_content', true); 240 229 $options['safari_title'] = get_post_meta($post_id, 'safari_title', true); 230 $options['filter'] = get_post_meta($post_id, 'pushwoosh_filter', true); 241 231 } 242 232 $options['safari_title'] = stripslashes($options['safari_title']); -
push-notifications/trunk/readme.txt
r1222733 r1225048 4 4 Tags: pushwoosh, push notifications, push 5 5 Requires at least: 3.0.1 6 Tested up to: 4. 26 Tested up to: 4.3 7 7 Stable tag: 2.4 8 8 License: GPLv2 or later … … 70 70 * Fix push on restore page from revision 71 71 72 = 2.3.16 = 73 * Add filter for push segmentation 74 72 75 == Installation == 73 76 1. Download the Pushwoosh plugin. -
push-notifications/trunk/settings.php
r1158592 r1225048 75 75 76 76 public function input_submit($value) { 77 echo sprintf('<input type="submit" name="Submit" value="%s" />', $value);77 echo sprintf('<input type="submit" name="Submit" class="button button-primary" value="%s" />', $value); 78 78 } 79 79
Note: See TracChangeset
for help on using the changeset viewer.