Plugin Directory

Changeset 1225048


Ignore:
Timestamp:
08/19/2015 12:32:00 PM (11 years ago)
Author:
pushwoosh
Message:

2.3.16

Location:
push-notifications/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • push-notifications/trunk/css/pushwoosh.css

    r874622 r1225048  
    1919}
    2020
    21 #pushwoosh_safari_title {
    22     width: 90%;
     21#pushwoosh_safari_title, #pushwoosh_filter {
     22    width: 100%;
    2323    float: left;
    2424    margin: 0 5px 0 0;
    25 }
    26 
    27 #pushwoosh_length_over {
    28     margin: 3px 0 0 0;
    29     color: #b1b6c3;
    3025}
    3126
  • push-notifications/trunk/html/pushwoosh.html

    r1139183 r1225048  
    22<b>Chrome/Safari Title:</b>
    33    <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" />
    65    <br/>
    76<b>Message:</b>
     
    98<textarea id="pushwoosh_message_content" name="pushwoosh_message_content" placeholder="%s">%s</textarea>
    109    <br/>
     10<input id="pushwoosh_filter" maxlength="255" name="pushwoosh_filter" type='text' placeholder="%s" value="%s" />
     11    <br />
    1112<input type="checkbox" name="pushwoosh_send_push" id="pushwoosh_checkbox_send_push" value="1" %s />
    1213<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     false
    23 );
  • push-notifications/trunk/lib/pushwoosh.php

    r942866 r1225048  
    4141            throw new PushwooshBadRequestException('Bad response format');
    4242           
    43         }       
     43        }
    4444        if ($response['status_code'] != 200 || $response['status_message'] != 'OK') {
    4545            throw new PushwooshBadRequestException(sprintf('Pushwoosh responded with error: %s with code: %s', $response['status_message'], $response['status_code']) );
    4646        }
    47         return $response;       
     47        return $response;
    4848    }
    4949
    50     public function createMessage($applicationCode, $options = array()) {
     50    public function createMessage($applicationCode, $messageContent, $options = array()) {
    5151        $body = array(
    5252            'application' => $applicationCode,
    5353            'auth' => $this->settings['auth'],
    54             'notifications' => array(
    55             )           
     54            'notifications' => array(),
    5655        );
    5756        $messageDefault = array(
    5857            'send_date' => 'now',
    5958            'content' => array(
    60                 'en' => '',
    61             )
     59                'en' => $messageContent,
     60            ),
    6261        );
    6362        if (!is_array($options) || !isset($options[0])) {
     
    6766            $body['notifications'][] = $message + $messageDefault;
    6867        }
    69         return $this->request('createMessage', $body);     
     68        return $this->request('createMessage', $body);
    7069    }
     70
    7171    public function compileDevicesFilter($applicationCode, $tags = array()) {
    7272        $conditions = array('A("' . $applicationCode . '")');
     
    100100    }
    101101
    102     public function createTargetedMessage($applicationCode, $message = array(), $options = array()) {
     102    public function createTargetedMessage($applicationCode, $messageContent, $options = array()) {
    103103        $body = array(
    104104            'auth' => $this->settings['auth'],
    105105            'send_date' => 'now',
    106106            'content' => array(
    107                 'en' => ''
     107                'en' => $messageContent,
    108108                )
    109109            );
    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());
    113112        return $this->request('createTargetedMessage', $body);
    114113    }
  • push-notifications/trunk/pushwoosh.php

    r1222733 r1225048  
    33    /**
    44     * @package Pushwoosh
    5      * @version 2.3.15
     5     * @version 2.3.16
    66     */
    77
     
    1212    * Author: Pushwoosh, Inc
    1313    * Author URI: https://www.pushwoosh.com/
    14     * Version: 2.3.15
     14    * Version: 2.3.16
    1515    *
    1616    * Copyright 2014 Arello Mobile (email: support@arello-mobile.com)
     
    103103        $checkbox_checked = 'checked="checked"';
    104104        $message_content = '';
     105        $pushwoosh_filter = '';
     106        $pushwoosh_filter_placeholder = 'Filter name';
    105107        $safari_title = '';
    106108
     
    110112            $message_content = get_post_meta($post->ID, 'pushwoosh_message_content', true);
    111113            $safari_title = get_post_meta($post->ID, 'safari_title', true);
     114            $pushwoosh_filter = get_post_meta($post->ID, 'pushwoosh_filter', true);
    112115        }
    113116        $plugin_content = file_get_contents(plugin_dir_path(__FILE__) . '/html/pushwoosh.html');
     
    117120            __($textArea_placeholder, 'pushwoosh'),
    118121            $message_content,
     122            $pushwoosh_filter_placeholder,
     123            $pushwoosh_filter,
    119124            $checkbox_checked,
    120125            __($checkbox_label, 'pushwoosh')
     
    128133        $api_token = get_option('pushwoosh_api_token', array('text_string' => null));
    129134        $safari_action = get_option('pushwoosh_safari_action', array('text_string' => null));
     135
    130136        $options['safari_action'] = $safari_action['text_string'];
    131137        if ($options['safari_title'] == '') {
     
    146152
    147153        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);
    150155            $status = 'Success';
    151156        } catch (Exception $e) {
     
    164169        }
    165170
     171        $options = array();
    166172        if (!empty($_POST)) {
    167173            if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
     
    184190            }
    185191            $options['chrome_title'] = $options['safari_title'];
    186 
     192            $options['filter'] = $_POST['pushwoosh_filter'];
     193            // update post meta data
    187194            update_post_meta($ID, 'pushwoosh_message_content', $message_content);
    188195            update_post_meta($ID, 'safari_title', $options['safari_title']);
    189         }
     196            update_post_meta($ID, 'pushwoosh_filter', $options['filter']);
     197        }
     198
     199        return $options;
    190200    }
    191201
     
    199209        }
    200210
    201         if ($post->post_type == 'page') {
    202             return;
    203         }
     211        if ($post->post_type == 'page') {
     212            return;
     213        }
    204214
    205215        $message_content = null;
     
    213223
    214224        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);
    238227        } else {
    239228            $message_content = get_post_meta($post_id, 'pushwoosh_message_content', true);
    240229            $options['safari_title'] = get_post_meta($post_id, 'safari_title', true);
     230            $options['filter'] = get_post_meta($post_id, 'pushwoosh_filter', true);
    241231        }
    242232        $options['safari_title'] = stripslashes($options['safari_title']);
  • push-notifications/trunk/readme.txt

    r1222733 r1225048  
    44Tags: pushwoosh, push notifications, push
    55Requires at least: 3.0.1
    6 Tested up to: 4.2
     6Tested up to: 4.3
    77Stable tag: 2.4
    88License: GPLv2 or later
     
    7070* Fix push on restore page from revision
    7171
     72= 2.3.16 =
     73* Add filter for push segmentation
     74
    7275== Installation ==
    73761. Download the Pushwoosh plugin.
  • push-notifications/trunk/settings.php

    r1158592 r1225048  
    7575
    7676    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);
    7878    }
    7979
Note: See TracChangeset for help on using the changeset viewer.