Plugin Directory

Changeset 2032239


Ignore:
Timestamp:
02/16/2019 06:27:14 PM (7 years ago)
Author:
collimarco
Message:

Remove Pushpad Express

Location:
pushpad-web-push-notifications/trunk
Files:
1 deleted
7 edited

Legend:

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

    r1974416 r2032239  
    1313
    1414    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    15         $settings ['api'] = isset ( $_POST ['api'] ) ? $_POST ['api'] : '';
    1615        $settings ['token'] = isset ( $_POST ['token'] ) ? $_POST ['token'] : '';
    1716        $settings ['project_id'] = isset ( $_POST ['project_id'] ) ? $_POST ['project_id'] : '';
     
    2827        echo '<div class="notice notice-success is-dismissible"><p>Settings successfully updated.</p></div>';
    2928
    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');";
    3331
    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 );
    3643            } 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 {
    4644?>
    4745
    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.js
    55                         (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>
    5755
    5856<?php
    59                 }
    6057            }
    6158        }
     59       
    6260    }
    6361?>
     
    6765        <table class="form-table">
    6866            <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"; ?>> Pushpad
    74                         </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>
    8167                <tr>
    8268                    <th><label for="token">Pushpad Auth Token</label></th>
     
    9379                    </td>
    9480                </tr>
    95                 <tr class="custom-api-only">
     81                <tr>
    9682                    <th>Subscription</th>
    9783                    <td>
     
    10490                    <td>
    10591                        <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>
    10793                            You can style the Pushpad notices by adding your CSS rules for <code>.pushpad-notice</code> and <code>.pushpad-alert</code></span>.<br>
    10894                            Go to <i>Appearance -> Customize -> Additional CSS</i>.
  • pushpad-web-push-notifications/trunk/includes/shortcode.php

    r1988133 r2032239  
    1616    }
    1717
    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>';
    2319}
    2420
  • pushpad-web-push-notifications/trunk/includes/widget.php

    r1988133 r2032239  
    3838
    3939        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>';
    4541        echo '</div>';
    4642
  • pushpad-web-push-notifications/trunk/pushpad.php

    r2027824 r2032239  
    44 * Plugin URI: https://pushpad.xyz/docs/wordpress
    55 * Description: Real push notifications for your website. Uses the W3C Push API for Chrome, Firefox, Opera, Edge and supports Safari.
    6  * Version: 1.7.2
     6 * Version: 1.8.0
    77 * Author: Pushpad
    88 * Author URI: https://pushpad.xyz
     
    3232function pushpad_get_settings() {
    3333    $default_settings = array(
    34         'api' => '',
    3534        'token' => '',
    3635        'project_id' => '',
     
    5352    $pushpad_settings = pushpad_get_settings();
    5453
    55     if ( !isset($pushpad_settings ["api"]) || $pushpad_settings ["api"] != 'custom' ) return;
     54    if ( !isset($pushpad_settings ["project_id"]) ) return;
    5655
    5756    wp_register_script( 'pushpad-script', plugins_url('/js/pushpad.js', __FILE__), array('jquery'));
     
    7675add_action ( 'wp_head', 'pushpad_add_wp_head' );
    7776
    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 
    8377function pushpad_style() {
    8478    wp_enqueue_style ( 'style', plugins_url ( '/css/style.css', __FILE__ ) );
     
    10296}
    10397add_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">&times;</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">&times;</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">&times;</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  
    11<?php
    2 
    3 // namespace Pushpad;
    42
    53class NotificationDeliveryError extends \Exception {
  • pushpad-web-push-notifications/trunk/pushpad/pushpad.php

    r1441637 r2032239  
    11<?php
    2 
    3 // namespace Pushpad;
    42
    53class Pushpad {
     
    119    return hash_hmac('sha1', $data, self::$auth_token);
    1210  }
    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   }
    2411}
  • pushpad-web-push-notifications/trunk/readme.txt

    r2027824 r2032239  
    44Requires at least: 4.4.0
    55Tested up to: 5.0
    6 Stable tag: 1.7
     6Stable tag: 1.8
    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.