Plugin Directory

Changeset 1313007


Ignore:
Timestamp:
12/20/2015 06:31:46 PM (10 years ago)
Author:
rintynator
Message:

tagging version 1.1

Location:
ionic-user-push-notification/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • ionic-user-push-notification/trunk/assets/html/iup-admin-settings.html

    r1303715 r1313007  
    2020                </td>
    2121            </tr>
     22            <tr>
     23                <th scope="row"><b><?php echo __("Send push for new post", 'menu' ) ?></b></th>
     24                <td>
     25                    <input type="checkbox" name="sendNewPost" class="regular-checkbox" value="1" <?php if ((bool) $options['sendNewPost']) echo 'checked'; ?>> <?php echo __("Send push notifictation to all ionic user ids for new posts", 'menu' ) ?>
     26                    <p class="description"></p>
     27                </td>
     28            </tr>
     29            <tr>
     30                <th scope="row"><b><?php echo __("Send push for post update", 'menu' ) ?></b></th>
     31                <td>
     32                    <input type="checkbox" name="sendUpdatePost" class="regular-checkbox" value="1" <?php if ((bool) $options['sendUpdatePost']) echo 'checked'; ?>> <?php echo __("Send push notifictation to all ionic user ids for post updates", 'menu' ) ?>
     33                </td>
     34            </tr>
    2235        </table>
    2336        <p class="submit">
  • ionic-user-push-notification/trunk/includes/class-iup-admin.php

    r1303715 r1313007  
    103103        $storeData = false;
    104104
    105         $options = array('appId', 'privateApiKey');
     105        $options = array('appId', 'privateApiKey', 'sendUpdatePost', 'sendNewPost');
    106106
    107107        foreach ($options as $name) {
  • ionic-user-push-notification/trunk/includes/class-iup-send-push.php

    r1303715 r1313007  
    77
    88class Ionic_User_Send_Push {
     9
     10    /**
     11     * Send push notifications for new posts
     12     *
     13     * @param string $new_status
     14     * @param string $old_status
     15     * @param WP_Post $post
     16     */
     17    public function send_push_for_new_post($new_status, $old_status, WP_Post $post) {
     18        $options = self::load_options();
     19        $doSendPush = false;
     20
     21        if ('post' !== get_post_type($post)) {
     22            return;
     23        }
     24
     25        if (
     26            ($old_status === 'publish' && (bool) $options['sendUpdatePost'] === true)
     27            || ($new_status === 'publish' && (bool) $options['sendNewPost'] === true)
     28
     29        ) {
     30            $doSendPush = true;
     31        }
     32
     33        if ($doSendPush === false) {
     34            return;
     35        }
     36
     37        $title = get_the_title($post);
     38        $payload = array(
     39            'title' => $title,
     40            'url' => get_permalink($post),
     41            'id' => get_the_ID($post),
     42            'author' => get_the_author_meta('display_name', $post->post_author)
     43        );
     44
     45        $userIds = Ionic_User_UserId_Manager::get_all_userIds();
     46        $options = self::load_options();
     47
     48        self::send_push_notification($title, $userIds, $options, $payload);
     49    }
    950
    1051    /**
     
    3677     * @param array $userIds
    3778     * @param array $options
     79     * @param array $payload
    3880     * @return WP_Error
    3981     */
    40     public function send_push_notification($text, array $userIds, array $options) {
     82    public function send_push_notification($text, array $userIds, array $options, array $payload = array()) {
    4183        if (empty($text)) {
    4284            return new WP_Error( 'broke', __( "Missing text to send push notification!", "menu" ) );
     
    5496            'user_ids' => $userIds,
    5597            'notification' => array('alert' => $text),
     98            'ios' => array(
     99                'payload' => $payload
     100            ),
     101            'android' => array(
     102                'payload' => $payload
     103            )
    56104        );
    57105
  • ionic-user-push-notification/trunk/ionic-user-push.php

    r1303715 r1313007  
    44Plugin URI: https://github.com/rintynator/wp-ionic-user-push
    55Description: Send push notifications to ionic users
    6 Version: 1.0
     6Version: 1.1
    77Author: Thorsten Rintelen
    88Author URI: http://www.clever-code.de
     
    3737    }
    3838    add_action( 'admin_enqueue_scripts', 'load_custom_wp_admin_style' );
     39    add_action( 'transition_post_status', array( 'Ionic_User_Send_Push', 'send_push_for_new_post'), 2, 3);
    3940} else {
    4041    require_once IUP_PLUGIN_DIR_PATH . 'includes/class-iup-userId-manager.php';
  • ionic-user-push-notification/trunk/readme.md

    r1303715 r1313007  
    1111
    1212Send immediately or scheduled push notification to ionic user ids.
     13Also optional send push notification to all user ids for new posts.
    1314
    1415## Installation
     
    2324## Changelog
    2425
     26### 1.1.0
     27
     28* Send optional push notification to all user ids for a new post (Thnaks to Ayoub Arbouchi)
     29
    2530### 1.0.0
    2631
  • ionic-user-push-notification/trunk/readme.txt

    r1303715 r1313007  
    77Requires at least: 4.3
    88Tested up to: 4.3
    9 Stable tag: 1.0
    109
    1110== Description ==
    1211
    1312Send immediately or scheduled push notification to ionic user ids.
     13Also optional send push notification to all user ids for new posts.
    1414
    1515== Installation ==
     
    22224. Plan or send your push notifications!
    2323
    24 == Screenshots ==
    25 1. Basic settings
    26 2. Store scheduled push notifications
    27 3. Documentation
     24== Changelog ==
    2825
    29 == Changelog ==
     26= 1.1.0 =
     27
     28* Send optional push notification to all user ids for a new post (Thnaks to Ayoub Arbouchi)
    3029
    3130= 1.0.0 =
Note: See TracChangeset for help on using the changeset viewer.