Plugin Directory

Changeset 1688743


Ignore:
Timestamp:
07/01/2017 01:52:49 PM (9 years ago)
Author:
collimarco
Message:

Show custom notices to the user for Pushpad Pro

Location:
pushpad-web-push-notifications/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pushpad-web-push-notifications/trunk/admin/pushpad-settings.php

    r1688741 r1688743  
    104104                    <td>
    105105                        <p class="description">
    106                             You can style the Pushpad button by adding your CSS rules for <code>.pushpad-button</code><span class="custom-api-only"> or <code>.pushpad-button.subscribed</code></span>.<br>
     106                            You can style the Pushpad button by adding your CSS rules for <code>.pushpad-button</code><span class="custom-api-only"> and <code>.pushpad-button.subscribed</code></span>.<br>
     107                            You can style the Pushpad notices by adding your CSS rules for <code>.pushpad-notice</code> and <code>.pushpad-alert</code></span>.<br>
    107108                            Go to <i>Appearance -> Customize -> Additional CSS</i>.
    108109                        </p>
    109110                    </td>
    110111                </tr>
    111                 <tr class="simple-api-only">
     112                <tr>
    112113                    <th><label for="token">Custom text</label></th>
    113114                    <td>
  • pushpad-web-push-notifications/trunk/pushpad.php

    r1688742 r1688743  
    44 * Plugin URI: https://pushpad.xyz/docs/wordpress
    55 * Description: Real push notifications for your website. Uses the W3C Push API for Chrome and Firefox and supports Safari.
    6  * Version: 1.5.0
     6 * Version: 1.6.0
    77 * Author: Pushpad
    88 * Author URI: https://pushpad.xyz
     
    5151
    5252function pushpad_add_wp_head() {
    53     $pushpad_settings = get_option ( 'pushpad_settings', array () );
     53    $pushpad_settings = pushpad_get_settings();
    5454    if ( !isset($pushpad_settings ["api"]) || $pushpad_settings ["api"] != 'custom' ) return;
    5555?>
     
    6161    echo "pushpad('init', '" . esc_js ( $pushpad_settings ["project_id"] ) . "');";
    6262?>
     63
     64    function pushpadShowMessage(notice_or_alert, text) {
     65        jQuery('body').append('<div class="pushpad-' + notice_or_alert + '">' + text + ' <a href="#" onclick="javascript:this.parentNode.style.display=\'none\';" class="close">&times;</a></div>');
     66    }
    6367
    6468    jQuery(function () {
     
    9195                    if (isSubscribed) {
    9296                        updateButton(true);
     97                        pushpadShowMessage('notice', '<?php echo esc_js( esc_html( $pushpad_settings ["subscribed_notice"] ) ); ?>');
    9398                    } else {
    9499                        updateButton(false);
    95                         alert('You have blocked notifications for this website. Please change your browser preferences and try again.');
     100                        pushpadShowMessage('alert', '<?php echo esc_js( esc_html( $pushpad_settings ["not_subscribed_notice"] ) ); ?>');
    96101                    }
    97102                });
     
    101106        pushpad('unsupported', function() {
    102107            jQuery('.pushpad-button').on('click', function() {
    103                 alert('Sorry, your browser does not support web push notifications.');
     108                pushpadShowMessage('alert', '<?php echo esc_js( esc_html( $pushpad_settings ["unsupported_notice"] ) ); ?>');
    104109            });
    105110        });
  • pushpad-web-push-notifications/trunk/readme.txt

    r1688742 r1688743  
    44Requires at least: 4.4.0
    55Tested up to: 4.8.0
    6 Stable tag: 1.5
     6Stable tag: 1.6
    77
    88Real push notifications for your website. Uses the W3C Push API for Chrome and Firefox and supports Safari.
Note: See TracChangeset for help on using the changeset viewer.