Plugin Directory

Changeset 1988133


Ignore:
Timestamp:
12/07/2018 05:00:24 PM (7 years ago)
Author:
collimarco
Message:

Improvements and fixes for Wordpress 5.0

Location:
pushpad-web-push-notifications/trunk
Files:
1 added
5 edited

Legend:

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

    r1974416 r1988133  
    1717  <p>Go to <i>Appearance -> Widgets</i> and add the <i>Pushpad Button</i>.</p>
    1818  <h3>Shortcode</h3>
    19   <p>Inside any page or post you can use <code>[pushpad-button]</code> or <code>[pushpad-button subscribe="Subscribe" unsubscribe="Unsubscribe"]</code>.</p>
     19  <p>Inside any page or post you can use <code>[pushpad-button]</code> or <code>[pushpad-button subscribe="Subscribe" unsubscribe="Subscribed"]</code>.</p>
    2020  <h3>Browser prompt</h3>
    2121  <p>You can ask your visitors to subscribe to push notifications on page load by enabling an option in <i>Pushpad -> Settings</i>.</p>
  • pushpad-web-push-notifications/trunk/includes/shortcode.php

    r1688739 r1988133  
    33    $atts = shortcode_atts ( array (
    44            'subscribe' => 'Subscribe',
    5             'unsubscribe' => 'Unsubscribe'
     5            'unsubscribe' => 'Subscribed'
    66    ), $atts, 'pushpad-button' );
    77   
  • pushpad-web-push-notifications/trunk/includes/widget.php

    r1688739 r1988133  
    5555        $description = isset ( $instance ['widget-description'] ) ? $instance ['widget-description'] : "We'll send you a notification when we publish something new.";
    5656        $button_text = isset ( $instance ['widget-subscribe-button-text'] ) ? $instance ['widget-subscribe-button-text'] : 'Subscribe';
    57         $unsubscribe_button_text = isset ( $instance ['widget-unsubscribe-button-text'] ) ? $instance ['widget-unsubscribe-button-text'] : 'Unsubscribe';
     57        $unsubscribe_button_text = isset ( $instance ['widget-unsubscribe-button-text'] ) ? $instance ['widget-unsubscribe-button-text'] : 'Subscribed';
    5858?>
    5959
  • pushpad-web-push-notifications/trunk/pushpad.php

    r1974416 r1988133  
    33 * Plugin Name: Pushpad - Web Push Notifications
    44 * Plugin URI: https://pushpad.xyz/docs/wordpress
    5  * Description: Real push notifications for your website. Uses the W3C Push API for Chrome and Firefox and supports Safari.
    6  * Version: 1.6.1
     5 * Description: Real push notifications for your website. Uses the W3C Push API for Chrome, Firefox, Opera, Edge and supports Safari.
     6 * Version: 1.7.0
    77 * Author: Pushpad
    88 * Author URI: https://pushpad.xyz
     
    5252function pushpad_add_wp_head() {
    5353    $pushpad_settings = pushpad_get_settings();
     54
    5455    if ( !isset($pushpad_settings ["api"]) || $pushpad_settings ["api"] != 'custom' ) return;
     56
     57    wp_register_script( 'pushpad-script', plugins_url('/js/pushpad.js', __FILE__), array('jquery'));
     58    wp_enqueue_script( 'pushpad-script' );
    5559?>
    5660
     
    5862    (function(p,u,s,h,x){p.pushpad=p.pushpad||function(){(p.pushpad.q=p.pushpad.q||[]).push(arguments)};h=u.getElementsByTagName('head')[0];x=u.createElement('script');x.async=1;x.src=s;h.appendChild(x);})(window,document,'https://pushpad.xyz/pushpad.js');
    5963
    60 <?php
    61     echo "pushpad('init', '" . esc_js ( $pushpad_settings ["project_id"] ) . "');";
    62 ?>
    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     }
    67 
    68     jQuery(function () {
    69         var updateButton = function (isSubscribed) {
    70             jQuery('button.pushpad-button').each(function () {
    71                 var btn = jQuery(this);
    72                 if (isSubscribed) {
    73                     btn.html(btn.data('unsubscribe-text'));
    74                     btn.removeClass('unsubscribed').addClass('subscribed');
    75                 } else {
    76                     btn.html(btn.data('subscribe-text'));
    77                     btn.removeClass('subscribed').addClass('unsubscribed');
    78                 }
    79             });
    80         };
    81         pushpad('status', updateButton);
    82 
    83         <?php
    84         if ( $pushpad_settings ["subscribe_on_load"] ) {
    85             echo "pushpad('subscribe', function () { updateButton(true); });";
    86         }
    87         ?>
    88 
    89         jQuery(".pushpad-button").on("click", function(e) {
    90             e.preventDefault();
    91             if (jQuery(this).hasClass('subscribed')) {
    92                 pushpad('unsubscribe', function () { updateButton(false); });
    93             } else {
    94                 pushpad('subscribe', function (isSubscribed) {
    95                     if (isSubscribed) {
    96                         updateButton(true);
    97                         pushpadShowMessage('notice', '<?php echo esc_js( esc_html( $pushpad_settings ["subscribed_notice"] ) ); ?>');
    98                     } else {
    99                         updateButton(false);
    100                         pushpadShowMessage('alert', '<?php echo esc_js( esc_html( $pushpad_settings ["not_subscribed_notice"] ) ); ?>');
    101                     }
    102                 });
    103             }
    104         });
    105 
    106         pushpad('unsupported', function() {
    107             jQuery('.pushpad-button').on('click', function() {
    108                 pushpadShowMessage('alert', '<?php echo esc_js( esc_html( $pushpad_settings ["unsupported_notice"] ) ); ?>');
    109             });
    110         });
    111     });
     64    var pushpadSettings = {
     65        projectId: <?php echo "'" . esc_js ( $pushpad_settings ["project_id"] ) . "'" ?>,
     66        subscribeOnLoad: <?php echo ($pushpad_settings ["subscribe_on_load"] ? 'true' : 'false') ?>,
     67        subscribedNotice: <?php echo "'" . esc_js( esc_html( $pushpad_settings ["subscribed_notice"] ) ) . "'" ?>,
     68        notSubscribedNotice: <?php echo "'" . esc_js( esc_html( $pushpad_settings ["not_subscribed_notice"] ) ) . "'" ?>,
     69        unsupportedNotice: <?php echo "'" . esc_js( esc_html( $pushpad_settings ["unsupported_notice"] ) ) . "'" ?>
     70    };
    11271</script>
    11372
    11473<?php
    11574}
     75
    11676add_action ( 'wp_head', 'pushpad_add_wp_head' );
    11777
    11878function pushpad_script() {
    119     wp_enqueue_script ( 'pushpad-script', plugins_url ( '/js/pushpad-admin.js', __FILE__ ) );
     79    wp_enqueue_script ( 'pushpad-admin-script', plugins_url ( '/js/pushpad-admin.js', __FILE__ ) );
    12080}
    12181add_action ( 'admin_enqueue_scripts', 'pushpad_script' );
  • pushpad-web-push-notifications/trunk/readme.txt

    r1974416 r1988133  
    33Tags: push notifications, web push notifications, web push, push api, push, notifications
    44Requires at least: 4.4.0
    5 Tested up to: 4.9.2
    6 Stable tag: 1.6
     5Tested up to: 5.0.0
     6Stable tag: 1.7
    77
    88Real push notifications for your website. Uses the W3C Push API for Chrome, Firefox, Opera, Edge and supports Safari.
Note: See TracChangeset for help on using the changeset viewer.