Changeset 1988133
- Timestamp:
- 12/07/2018 05:00:24 PM (7 years ago)
- Location:
- pushpad-web-push-notifications/trunk
- Files:
-
- 1 added
- 5 edited
-
admin/pushpad-admin.php (modified) (1 diff)
-
includes/shortcode.php (modified) (1 diff)
-
includes/widget.php (modified) (1 diff)
-
js/pushpad.js (added)
-
pushpad.php (modified) (3 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
pushpad-web-push-notifications/trunk/admin/pushpad-admin.php
r1974416 r1988133 17 17 <p>Go to <i>Appearance -> Widgets</i> and add the <i>Pushpad Button</i>.</p> 18 18 <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> 20 20 <h3>Browser prompt</h3> 21 21 <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 3 3 $atts = shortcode_atts ( array ( 4 4 'subscribe' => 'Subscribe', 5 'unsubscribe' => ' Unsubscribe'5 'unsubscribe' => 'Subscribed' 6 6 ), $atts, 'pushpad-button' ); 7 7 -
pushpad-web-push-notifications/trunk/includes/widget.php
r1688739 r1988133 55 55 $description = isset ( $instance ['widget-description'] ) ? $instance ['widget-description'] : "We'll send you a notification when we publish something new."; 56 56 $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'; 58 58 ?> 59 59 -
pushpad-web-push-notifications/trunk/pushpad.php
r1974416 r1988133 3 3 * Plugin Name: Pushpad - Web Push Notifications 4 4 * Plugin URI: https://pushpad.xyz/docs/wordpress 5 * Description: Real push notifications for your website. Uses the W3C Push API for Chrome and Firefoxand supports Safari.6 * Version: 1. 6.15 * 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 7 7 * Author: Pushpad 8 8 * Author URI: https://pushpad.xyz … … 52 52 function pushpad_add_wp_head() { 53 53 $pushpad_settings = pushpad_get_settings(); 54 54 55 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' ); 55 59 ?> 56 60 … … 58 62 (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'); 59 63 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">×</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 }; 112 71 </script> 113 72 114 73 <?php 115 74 } 75 116 76 add_action ( 'wp_head', 'pushpad_add_wp_head' ); 117 77 118 78 function 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__ ) ); 120 80 } 121 81 add_action ( 'admin_enqueue_scripts', 'pushpad_script' ); -
pushpad-web-push-notifications/trunk/readme.txt
r1974416 r1988133 3 3 Tags: push notifications, web push notifications, web push, push api, push, notifications 4 4 Requires at least: 4.4.0 5 Tested up to: 4.9.26 Stable tag: 1. 65 Tested up to: 5.0.0 6 Stable tag: 1.7 7 7 8 8 Real 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.