Changeset 2032239
- Timestamp:
- 02/16/2019 06:27:14 PM (7 years ago)
- Location:
- pushpad-web-push-notifications/trunk
- Files:
-
- 1 deleted
- 7 edited
-
admin/pushpad-settings.php (modified) (5 diffs)
-
includes/shortcode.php (modified) (1 diff)
-
includes/widget.php (modified) (1 diff)
-
js/pushpad-admin.js (deleted)
-
pushpad.php (modified) (5 diffs)
-
pushpad/notification.php (modified) (1 diff)
-
pushpad/pushpad.php (modified) (2 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
pushpad-web-push-notifications/trunk/admin/pushpad-settings.php
r1974416 r2032239 13 13 14 14 if ($_SERVER['REQUEST_METHOD'] === 'POST') { 15 $settings ['api'] = isset ( $_POST ['api'] ) ? $_POST ['api'] : '';16 15 $settings ['token'] = isset ( $_POST ['token'] ) ? $_POST ['token'] : ''; 17 16 $settings ['project_id'] = isset ( $_POST ['project_id'] ) ? $_POST ['project_id'] : ''; … … 28 27 echo '<div class="notice notice-success is-dismissible"><p>Settings successfully updated.</p></div>'; 29 28 30 if ($settings ['api'] == 'custom') { 31 // service-worker.js 32 $importScripts = "importScripts('https://pushpad.xyz/service-worker.js');"; 29 // service-worker.js 30 $importScripts = "importScripts('https://pushpad.xyz/service-worker.js');"; 33 31 34 if (file_exists ( ABSPATH . 'service-worker.js' )) { 35 $serviceWorkerContents = file_get_contents ( ABSPATH . 'service-worker.js' ); 32 if (file_exists ( ABSPATH . 'service-worker.js' )) { 33 $serviceWorkerContents = file_get_contents ( ABSPATH . 'service-worker.js' ); 34 } else { 35 $serviceWorkerContents = ''; 36 } 37 38 $newServiceWorkerContents = $importScripts . "\n\n" . $serviceWorkerContents; 39 40 if ( strpos( $serviceWorkerContents, $importScripts ) === false ) { 41 if ( is_writable ( ABSPATH . 'service-worker.js' ) || !file_exists ( ABSPATH . 'service-worker.js' ) && is_writable ( ABSPATH ) ) { 42 file_put_contents( ABSPATH . 'service-worker.js', $newServiceWorkerContents ); 36 43 } else { 37 $serviceWorkerContents = '';38 }39 40 $newServiceWorkerContents = $importScripts . "\n\n" . $serviceWorkerContents;41 42 if ( strpos( $serviceWorkerContents, $importScripts ) === false ) {43 if ( is_writable ( ABSPATH . 'service-worker.js' ) || !file_exists ( ABSPATH . 'service-worker.js' ) && is_writable ( ABSPATH ) ) {44 file_put_contents( ABSPATH . 'service-worker.js', $newServiceWorkerContents );45 } else {46 44 ?> 47 45 48 <p>49 The file service-worker.js in the root directory of Wordpress is not writable.50 Please change its permissions and try again. Otherwise replace its contents manually:51 </p>52 <pre class="pushpad"><code><?= esc_html ( $newServiceWorkerContents ) ?></code></pre>53 <p>54 Also make sure that the file is accessible at https://example.com/service-worker.js55 (for example https://example.com/wordpress/service-worker.js is invalid).56 </p>46 <p> 47 The file service-worker.js in the root directory of Wordpress is not writable. 48 Please change its permissions and try again. Otherwise replace its contents manually: 49 </p> 50 <pre class="pushpad"><code><?= esc_html ( $newServiceWorkerContents ) ?></code></pre> 51 <p> 52 Also make sure that the file is accessible at https://example.com/service-worker.js 53 (for example https://example.com/wordpress/service-worker.js is invalid). 54 </p> 57 55 58 56 <?php 59 }60 57 } 61 58 } 59 62 60 } 63 61 ?> … … 67 65 <table class="form-table"> 68 66 <tbody> 69 <tr>70 <th>Which product are you using?</th>71 <td>72 <label>73 <input type="radio" name="api" value="custom" <?php if ($settings['api'] == "custom" ) echo "checked"; ?>> Pushpad74 </label>75 <br>76 <label>77 <input type="radio" name="api" value="simple" <?php if ($settings['api'] == "simple" ) echo "checked"; ?>> Express (deprecated)78 </label>79 </td>80 </tr>81 67 <tr> 82 68 <th><label for="token">Pushpad Auth Token</label></th> … … 93 79 </td> 94 80 </tr> 95 <tr class="custom-api-only">81 <tr> 96 82 <th>Subscription</th> 97 83 <td> … … 104 90 <td> 105 91 <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"> and <code>.pushpad-button.subscribed</code></span>.<br>92 You can style the Pushpad button by adding your CSS rules for <code>.pushpad-button</code> and <code>.pushpad-button.subscribed</code>.<br> 107 93 You can style the Pushpad notices by adding your CSS rules for <code>.pushpad-notice</code> and <code>.pushpad-alert</code></span>.<br> 108 94 Go to <i>Appearance -> Customize -> Additional CSS</i>. -
pushpad-web-push-notifications/trunk/includes/shortcode.php
r1988133 r2032239 16 16 } 17 17 18 if ($pushpad_settings ['api'] == 'simple') { 19 return '<a class="pushpad-button" href="https://pushpad.xyz/projects/' . esc_html ( $pushpad_settings ['project_id'] ) . '/subscription/edit?ui=false">' . esc_html ( $atts ['subscribe'] ) . '</a>'; 20 } else { 21 return '<button class="pushpad-button" data-subscribe-text="' . esc_html ( $atts ['subscribe'] ) . '" data-unsubscribe-text="' . esc_html ( $atts ['unsubscribe'] ) . '">' . esc_html ( $atts ['subscribe'] ) . '</button>'; 22 } 18 return '<button class="pushpad-button" data-subscribe-text="' . esc_html ( $atts ['subscribe'] ) . '" data-unsubscribe-text="' . esc_html ( $atts ['unsubscribe'] ) . '">' . esc_html ( $atts ['subscribe'] ) . '</button>'; 23 19 } 24 20 -
pushpad-web-push-notifications/trunk/includes/widget.php
r1988133 r2032239 38 38 39 39 echo '<div class="pushpad-button-wrapper">'; 40 if ($pushpad_settings ['api'] == 'simple') { 41 echo '<a class="pushpad-button" href="https://pushpad.xyz/projects/' . esc_html ( $pushpad_settings ['project_id'] ) . '/subscription/edit?ui=false">' . esc_html ( $instance ['widget-subscribe-button-text'] ) . '</a>'; 42 } else { 43 echo '<button class="pushpad-button" data-subscribe-text="' . esc_html ( $instance ['widget-subscribe-button-text'] ) . '" data-unsubscribe-text="' . esc_html ( $instance ['widget-unsubscribe-button-text'] ) . '">' . esc_html ( $instance ['widget-subscribe-button-text'] ) . '</button>'; 44 } 40 echo '<button class="pushpad-button" data-subscribe-text="' . esc_html ( $instance ['widget-subscribe-button-text'] ) . '" data-unsubscribe-text="' . esc_html ( $instance ['widget-unsubscribe-button-text'] ) . '">' . esc_html ( $instance ['widget-subscribe-button-text'] ) . '</button>'; 45 41 echo '</div>'; 46 42 -
pushpad-web-push-notifications/trunk/pushpad.php
r2027824 r2032239 4 4 * Plugin URI: https://pushpad.xyz/docs/wordpress 5 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.26 * Version: 1.8.0 7 7 * Author: Pushpad 8 8 * Author URI: https://pushpad.xyz … … 32 32 function pushpad_get_settings() { 33 33 $default_settings = array( 34 'api' => '',35 34 'token' => '', 36 35 'project_id' => '', … … 53 52 $pushpad_settings = pushpad_get_settings(); 54 53 55 if ( !isset($pushpad_settings [" api"]) || $pushpad_settings ["api"] != 'custom') return;54 if ( !isset($pushpad_settings ["project_id"]) ) return; 56 55 57 56 wp_register_script( 'pushpad-script', plugins_url('/js/pushpad.js', __FILE__), array('jquery')); … … 76 75 add_action ( 'wp_head', 'pushpad_add_wp_head' ); 77 76 78 function pushpad_script() {79 wp_enqueue_script ( 'pushpad-admin-script', plugins_url ( '/js/pushpad-admin.js', __FILE__ ) );80 }81 add_action ( 'admin_enqueue_scripts', 'pushpad_script' );82 83 77 function pushpad_style() { 84 78 wp_enqueue_style ( 'style', plugins_url ( '/css/style.css', __FILE__ ) ); … … 102 96 } 103 97 add_action( 'admin_notices', 'pushpad_notices' ); 104 105 function pushpad_express_notices() {106 if ( isset( $_GET['pushpad_status'] ) ) {107 $pushpad_settings = pushpad_get_settings();108 switch ( $_GET['pushpad_status'] ) {109 case 'subscribed':110 echo '<div class="pushpad-notice">' . esc_html( $pushpad_settings ['subscribed_notice'] ) . ' <a href="#" onclick="javascript:this.parentNode.style.display=\'none\';" class="close">×</a></div>';111 break;112 case 'not_subscribed':113 echo '<div class="pushpad-alert">' . esc_html( $pushpad_settings ['not_subscribed_notice'] ) . ' <a href="#" onclick="javascript:this.parentNode.style.display=\'none\';" class="close">×</a></div>';114 break;115 case 'unsupported':116 echo '<div class="pushpad-alert">' . esc_html( $pushpad_settings ['unsupported_notice'] ) . ' <a href="#" onclick="javascript:this.parentNode.style.display=\'none\';" class="close">×</a></div>';117 break;118 }119 }120 }121 add_action( 'wp_footer', 'pushpad_express_notices' ); -
pushpad-web-push-notifications/trunk/pushpad/notification.php
r2027821 r2032239 1 1 <?php 2 3 // namespace Pushpad;4 2 5 3 class NotificationDeliveryError extends \Exception { -
pushpad-web-push-notifications/trunk/pushpad/pushpad.php
r1441637 r2032239 1 1 <?php 2 3 // namespace Pushpad;4 2 5 3 class Pushpad { … … 11 9 return hash_hmac('sha1', $data, self::$auth_token); 12 10 } 13 14 public static function path($options = array()) {15 $project_id = isset($options['project_id']) ? $options['project_id'] : self::$project_id;16 if (!isset($project_id)) throw new \Exception('You must set Pushpad\Pushpad::$project_id');17 return "https://pushpad.xyz/projects/$project_id/subscription/edit";18 }19 20 public static function path_for($uid, $options = array()) {21 $uid_signature = self::signature_for($uid);22 return self::path($options) . "?uid=$uid&uid_signature=$uid_signature";23 }24 11 } -
pushpad-web-push-notifications/trunk/readme.txt
r2027824 r2032239 4 4 Requires at least: 4.4.0 5 5 Tested up to: 5.0 6 Stable tag: 1. 76 Stable tag: 1.8 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.