Plugin Directory

Changeset 2388400


Ignore:
Timestamp:
09/25/2020 03:50:58 PM (6 years ago)
Author:
pushnami
Message:

Adds settings option to capture category of last article read by a subscriber.

Location:
pushnami-web-push-notifications
Files:
14 added
4 edited

Legend:

Unmodified
Added
Removed
  • pushnami-web-push-notifications/trunk/includes/class-pushnami.php

    r2317588 r2388400  
    436436        $options->api_url = get_option('pushnami_api_url');
    437437        $options->prompt = !(get_option('pushnami_prompt') === '0');
    438         $options->update = !(get_option('pushnami_update') === '0');
     438        $options->update = !(get_option('pushnami_update') === '0') || get_option('track_category');
    439439        $options->optin = get_option('pushnami_advanced_optin');
    440440        $options->trigger = get_option('pushnami_prompt_trigger');
     
    487487        else $prompt_options = '';
    488488
     489        $update_options = array();
     490        // Get post categories
     491        $categories = get_the_category();
     492        if (!empty($categories)) {
     493            // In case of multiple post categories, use the first one
     494            $category = $categories[0]->name;
     495            array_push($update_options, '"last_category":"' . $category . '"');
     496        }
     497        if (sizeof($update_options)
     498            && get_option('track_category') === '1'
     499        ) {
     500            $update_options = '{' . join(',', $update_options) . '}';
     501        }
     502        else $update_options = '';
     503
    489504        $script_options  = '';
    490505
     
    499514        $script_options  .= 'Pushnami';
    500515        // if ($options->swPath) $script_options .= PHP_EOL . '            .setSWPath(\''.$options->swPath.'\')';
    501         if ($options->update) $script_options .= PHP_EOL . '            .update()';
     516        if ($options->update) $script_options .= PHP_EOL . '            .update(' . $update_options . ')';
    502517        if ($options->optin)  $script_options .= PHP_EOL . '            .showOverlay({force:true})';
    503518        if ($options->prompt) $script_options .= PHP_EOL . '            .prompt(' . $prompt_options . ')';
     
    538553            !get_option('pushnami_advanced_optin') &&
    539554            !get_option('pushnami_prompt_trigger') &&
    540             !get_option('pushnami_prompt_delay')
     555            !get_option('pushnami_prompt_delay') &&
     556            !get_option('track_category')
    541557        );
    542558    }
  • pushnami-web-push-notifications/trunk/pushnami.php

    r2344190 r2388400  
    77Plugin URI: https://wordpress.org/plugins/pushnami-web-push-notifications
    88Description: Capture & Monetize Your Audience. The leader for web push, mobile push notifications, and email. Trusted by more than 20K brands to send 10 billion messages per month.
    9 Version: 1.0.4
     9Version: 1.0.5
    1010Author: Pushnami
    1111Author URI: https://www.pushnami.com
  • pushnami-web-push-notifications/trunk/readme.txt

    r2363564 r2388400  
    5959== Changelog ==
    6060
     61= 1.0.5 =
     62* Adds settings option to capture category of last article read by a subscriber
     63
    6164= 1.0.4 =
    6265* Updates Pushnami free account sign-up links
  • pushnami-web-push-notifications/trunk/views/admin/pushnami-settings.php

    r2344194 r2388400  
    9191                } else {
    9292                    $('#prompt_update_error').css('display', 'none');
     93                    $('#submit_button').prop('disabled', false);
     94                }
     95            });
     96
     97            $('#track_category').click(function (event) {
     98                const promptChecked = event.target.checked;
     99                const updateChecked = $('#pushnami_update').prop("checked");
     100                if (!promptChecked && !updateChecked) {
     101                    $('#submit_button').prop('disabled', true);
     102                } else {
    93103                    $('#submit_button').prop('disabled', false);
    94104                }
     
    248258                }
    249259
     260                if(isset($_POST['track_category']) && !empty($_POST['track_category'])) {
     261                    update_option('track_category', '1');
     262                } else {
     263                    update_option('track_category', '0');
     264                }
     265
    250266                if(isset($_POST['pushnami_update']) && !empty($_POST['pushnami_update'])) {
    251267                    update_option('pushnami_update', '1');
     
    356372                        <?php
    357373                            $checked = !(get_option('pushnami_prompt') === '0');
     374                            checked($checked);
     375                        ?>
     376                    />
     377                </td>
     378            </tr>
     379            <tr valign="top" class="advanced_option">
     380                <th scope="row">Track Categories Read</th>
     381                <td>
     382                    <input
     383                        type="checkbox"
     384                        name="track_category"
     385                        id="track_category"
     386                        value="true"
     387                        <?php
     388                            $checked = !(get_option('track_category') === '0');
    358389                            checked($checked);
    359390                        ?>
Note: See TracChangeset for help on using the changeset viewer.