Plugin Directory

Changeset 2474908


Ignore:
Timestamp:
02/15/2021 02:20:37 PM (5 years ago)
Author:
cip
Message:

1.1.0

Location:
wise-notifications/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • wise-notifications/trunk/readme.txt

    r2058070 r2474908  
    33Tags: push notifications, browser notifications, web notitications, iOS web notifications, web push notifications, push, safari, chrome, iOS, iPhone, user engagement
    44Requires at least: 4.0.1
    5 Tested up to: 5.1
     5Tested up to: 5.6.1
    66Requires PHP: 5.6
    7 Stable tag: 1.0.0
     7Stable tag: 1.1.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5353
    54541. 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.
     552. Upload and uncompress it in "/wp-content/plugins/" directory.
    56563. Activate the plugin through the "Plugins" menu in WordPress.
    57574. 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.
     585. 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.
    59596. Enjoy and profit!
    6060
     
    6363= 1.0.0 =
    6464* 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  
    9999            'setting_section_id'
    100100        );
     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        );
    101115    }
    102116
     
    120134        if (isset($input['subscribeLink'])) {
    121135            $new_input['subscribeLink'] = sanitize_text_field($input['subscribeLink']);
     136        }
     137
     138        if (isset($input['postTypes'])) {
     139            $new_input['postTypes'] = $input['postTypes'];
    122140        }
    123141
     
    156174        );
    157175    }
     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    }
    158190}
    159191
  • wise-notifications/trunk/wiseNotifications.php

    r2058070 r2474908  
    22/**
    33 * @package Wise Notifications - web push notifications for iOS
    4  * @version 1.0.0
     4 * @version 1.1.0
    55 */
    66/*
     
    88Description: Send updates using push notifications to your iOS website visitors.
    99Author: Ciprian Amariei, Diana Amitroaei
    10 Version: 1.0.0
     10Version: 1.1.0
    1111Author URI: https://wisenotifications.com
    1212*/
     
    4343if (is_admin()) {
    4444    include $wiseNotifications_pluginPath . 'settingsPage.php';
     45    include $wiseNotifications_pluginPath . 'metaBox.php';
    4546    wiseNotifications_log('check OneSignal exists', class_exists('OneSignal_Admin'));
    4647
     
    6667    {
    6768        wiseNotifications_log('wiseNotifications_postPublishedNotification started', ['new_status' => $new_status, 'old_status' => $old_status ]);
    68 
    6969        // Check if someone published a post for the first time.
    70         if (( $new_status == 'publish' ) /*&& ( $old_status != 'publish' )*/) {
     70        if ($new_status == 'publish') {
    7171            // TODO make sure the post is new and not updated (maybe check revisions?)
    7272            try {
     
    8181    {
    8282
     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
    8391        $title = $post->post_title;
    8492        $permalink = get_permalink($post->ID);
     
    8997            wiseNotifications_log('config data is missing', $pluginSettings, 'error');
    9098            // 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');
    91111            return;
    92112        }
     
    112132        // $url = 'https://skdlxfssth.execute-api.eu-central-1.amazonaws.com/dev/';
    113133        $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        }
    115139    }
    116140
     
    134158        wiseNotifications_log('notification sending received headers', $result);
    135159
    136         return $result;
     160        return 1|| $result['http_response']->get_response_object()->success;
    137161    }
    138162}
Note: See TracChangeset for help on using the changeset viewer.