Plugin Directory

Changeset 2973600


Ignore:
Timestamp:
10/01/2023 10:41:07 PM (2 years ago)
Author:
vistawp
Message:

Update to version 1.2.1 from GitHub

Location:
vistawp
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • vistawp/tags/1.2.1/includes/options/license-manager.php

    r2961844 r2973600  
    1818   * set this to NULL and use the below two constants to set up choices.
    1919   * Otherwise, if this is set to an int or string, that will be used
    20    * as the pricing tier ID/product ID on vistawp
     20   * as the pricing tier ID/product ID when calling the EDD API on vistawp.com
     21   *
    2122   * @var string|int
    2223   */
    23   private const TIER = 20333;
    24 
    25   /**
    26    * Maps names of pricing tiers to their item ID on vistawp.com
    27    * Names are used to populate the settings page dropdown
    28    * If this array needs updating, there's a corresponding array named $tiers in the auto-updater code
    29    * at the bottom of vista.php which will also need updating. The two arrays should be identical.
     24  private const TIER = 23071;
     25
     26  /**
     27   * Maps names of pricing tiers to their item ID in EDD on vistawp.com
     28   * Names are used to populate the settings page dropdown,
     29   * IDs are used to validate the license key with the API.
    3030   * @var array<string>
    3131   */
    3232  private const TIER_ID = array(
    33     "Starter" => "20333",
    34     "Premium" => "20336",
    35     "Premium Pro" => "20338",
    36     "Enterprise" => "20340",
     33    "VistaWP Monthly Subscription" => "23071",
     34    "Vista Yearly Subscription" => "20670",
    3735  );
    3836
    3937  /**
    4038   * Maps string tier names to int levels
    41    * Other classes in this plugin use these levels to determine whether certain features
    42    * are accessible to the user
     39   * Other classes in this plugin may use these levels
     40   * to determine whether certain features are accessible to the user,
     41   * although tiered features currently are not implemented.
    4342   * @var array<int>
    4443   */
    4544  private const TIER_LEVEL = array(
    46     "Starter" => 1,
    47     "Premium" => 2,
    48     "Premium Pro" => 3,
    49     "Enterprise" => 4,
     45    "VistaWP Monthly Subscription" => 1,
     46    "Vista Yearly Subscription" => 1,
    5047  );
    5148
     
    9895    $this->valid = (bool) (\get_option('vista_license_valid', NULL) ?? false);
    9996
    100     V\Main::get_instance()->register_style('vsta_admin', \vista_plugin_url("/css/admin.css"));
     97    V\Main::get_instance()->register_style(
     98      'vsta_admin',
     99      \vista_plugin_url("/css/admin.css")
     100    );
    101101
    102102    if (\is_admin()) {
     
    134134      $this->key = \sanitize_key($_POST['vsta-license-key']);
    135135      if (is_null(self::TIER)) {
    136         $this->tier = \sanitize_text_field( $_POST['vsta-tier']);
     136        $this->tier = \sanitize_text_field($_POST['vsta-tier']);
    137137      }
    138138     
    139139      // Validate with API. This outputs the result html to the page
    140140      $this->api_verify();
    141       // Only update if the license key passed validation, or if the user cleared it to get demo data
     141      // Only update if the license key passed validation,
     142      // or if the user cleared it to get demo data
    142143      if ($this->valid || !$this->key) {
    143144        \update_option('vista_license_key', $this->key);
     
    159160   * Validates the key with the API
    160161   * and outputs HTML to the page indicating the result.
    161    * Sets $this->valid to indicate the result as well
     162   * Sets $this->valid (and the corresponding WP setting)
     163   * to indicate the result as well, but does not update the key
     164   * or tier class vars or WP options
    162165   */
    163166  protected function api_verify() {
    164     $api = new \VSTA\API\License_API($this->key, self::TIER ?? self::TIER_ID[$this->tier]);
     167    // Here we retrive the tier ID from the mapping,
     168    // if a single tier is not hardcoded
     169    $api = new \VSTA\API\License_API(
     170      $this->key,
     171      self::TIER ?? self::TIER_ID[$this->tier]
     172    );
    165173    $result = $api->activate();
    166174
     175    // API returns null for success; update options accordingly
    167176    if (is_null($result)) {
    168177      \update_option("vista_license_valid", true);
    169178      $this->valid = true;
    170179    } else {
    171       ?><div class="notice notice-error">Error: <?php echo esc_html($result) ?></div><?php
     180      ?>
     181      <div class="notice notice-error">
     182        Error: <?php echo esc_html($result)
     183      ?></div><?php
    172184
    173185      \update_option("vista_license_valid", false);
     
    184196    $licenseKey = $this->get_key();
    185197    $licenseStatus = $licenseKey ? 'Active' : 'Disabled';
    186 
    187198    ?>
    188199
     
    209220      >
    210221
     222      <?php
     223      // If the tier is hardcoded, don't show the dropdown. Otherwise,
     224      // this displays a dropdown to select the user's pricing tier
     225      if (is_null(self::TIER)):
     226      ?>
     227      <br>
     228      <label class="vista-license-label" for="vsta-tier">Subscription Tier</label>
     229      <select name="vsta-tier" id="vsta-tier" required>
     230        <?php
     231        foreach (self::TIER_ID as $name => $unused) {
     232          if ($name == $this->tier) {
     233            echo "<option selected>" . esc_html($name) . "</option>";
     234          } else {
     235            echo  "<option>" . esc_html($name) . "</option>" ;
     236          }
     237        }
     238         ?>
     239      </select>
     240      <?php endif; ?>
     241
    211242      <input type="submit" class="vsta-btn-go" name="submit" value="Activate">
    212243      <button class="vsta-btn-danger" id="vsta-deactivate-btn" name="deactivate" value="1">Clear</button>
     
    256287
    257288  /**
    258    * Gets the level of the pricing tier of this subscription, from 0 (no license) to 4 (enterprise)
    259    * Mappings from tiers to levels are found in TIER_LEVEL
     289   * Gets the level of the pricing tier of this subscription.
     290   * Mappings from tiers to levels are found in TIER_LEVEL.
     291   * Currently unused.
    260292   * @return int Pricing tier level
    261293   */
     
    263295    if (!$this->valid)
    264296      return 0;
    265     return self::TIER ?? (is_null($this->tier) ? 0 : self::TIER_LEVEL[$this->tier]);
     297    return self::TIER ??
     298      (is_null($this->tier) ? 0 : self::TIER_LEVEL[$this->tier]);
    266299  }
    267300}
  • vistawp/tags/1.2.1/readme.txt

    r2964274 r2973600  
    55Requires at least: 4.7 
    66Tested up to: 6.3 
    7 Stable tag: 1.2.0 
     7Stable tag: 1.2.1 
    88Requires PHP: 7.0 
    99License: GPLv2 or later 
  • vistawp/tags/1.2.1/vista.php

    r2964274 r2973600  
    33* Plugin Name: VistaWP
    44* Description: Retrieves and displays real estate listings
    5 * Version: 1.2.0
     5* Version: 1.2.1
    66* Author: VistaWP
    77* Author URI: https://vistawp.com/
  • vistawp/trunk/includes/options/license-manager.php

    r2961844 r2973600  
    1818   * set this to NULL and use the below two constants to set up choices.
    1919   * Otherwise, if this is set to an int or string, that will be used
    20    * as the pricing tier ID/product ID on vistawp
     20   * as the pricing tier ID/product ID when calling the EDD API on vistawp.com
     21   *
    2122   * @var string|int
    2223   */
    23   private const TIER = 20333;
    24 
    25   /**
    26    * Maps names of pricing tiers to their item ID on vistawp.com
    27    * Names are used to populate the settings page dropdown
    28    * If this array needs updating, there's a corresponding array named $tiers in the auto-updater code
    29    * at the bottom of vista.php which will also need updating. The two arrays should be identical.
     24  private const TIER = 23071;
     25
     26  /**
     27   * Maps names of pricing tiers to their item ID in EDD on vistawp.com
     28   * Names are used to populate the settings page dropdown,
     29   * IDs are used to validate the license key with the API.
    3030   * @var array<string>
    3131   */
    3232  private const TIER_ID = array(
    33     "Starter" => "20333",
    34     "Premium" => "20336",
    35     "Premium Pro" => "20338",
    36     "Enterprise" => "20340",
     33    "VistaWP Monthly Subscription" => "23071",
     34    "Vista Yearly Subscription" => "20670",
    3735  );
    3836
    3937  /**
    4038   * Maps string tier names to int levels
    41    * Other classes in this plugin use these levels to determine whether certain features
    42    * are accessible to the user
     39   * Other classes in this plugin may use these levels
     40   * to determine whether certain features are accessible to the user,
     41   * although tiered features currently are not implemented.
    4342   * @var array<int>
    4443   */
    4544  private const TIER_LEVEL = array(
    46     "Starter" => 1,
    47     "Premium" => 2,
    48     "Premium Pro" => 3,
    49     "Enterprise" => 4,
     45    "VistaWP Monthly Subscription" => 1,
     46    "Vista Yearly Subscription" => 1,
    5047  );
    5148
     
    9895    $this->valid = (bool) (\get_option('vista_license_valid', NULL) ?? false);
    9996
    100     V\Main::get_instance()->register_style('vsta_admin', \vista_plugin_url("/css/admin.css"));
     97    V\Main::get_instance()->register_style(
     98      'vsta_admin',
     99      \vista_plugin_url("/css/admin.css")
     100    );
    101101
    102102    if (\is_admin()) {
     
    134134      $this->key = \sanitize_key($_POST['vsta-license-key']);
    135135      if (is_null(self::TIER)) {
    136         $this->tier = \sanitize_text_field( $_POST['vsta-tier']);
     136        $this->tier = \sanitize_text_field($_POST['vsta-tier']);
    137137      }
    138138     
    139139      // Validate with API. This outputs the result html to the page
    140140      $this->api_verify();
    141       // Only update if the license key passed validation, or if the user cleared it to get demo data
     141      // Only update if the license key passed validation,
     142      // or if the user cleared it to get demo data
    142143      if ($this->valid || !$this->key) {
    143144        \update_option('vista_license_key', $this->key);
     
    159160   * Validates the key with the API
    160161   * and outputs HTML to the page indicating the result.
    161    * Sets $this->valid to indicate the result as well
     162   * Sets $this->valid (and the corresponding WP setting)
     163   * to indicate the result as well, but does not update the key
     164   * or tier class vars or WP options
    162165   */
    163166  protected function api_verify() {
    164     $api = new \VSTA\API\License_API($this->key, self::TIER ?? self::TIER_ID[$this->tier]);
     167    // Here we retrive the tier ID from the mapping,
     168    // if a single tier is not hardcoded
     169    $api = new \VSTA\API\License_API(
     170      $this->key,
     171      self::TIER ?? self::TIER_ID[$this->tier]
     172    );
    165173    $result = $api->activate();
    166174
     175    // API returns null for success; update options accordingly
    167176    if (is_null($result)) {
    168177      \update_option("vista_license_valid", true);
    169178      $this->valid = true;
    170179    } else {
    171       ?><div class="notice notice-error">Error: <?php echo esc_html($result) ?></div><?php
     180      ?>
     181      <div class="notice notice-error">
     182        Error: <?php echo esc_html($result)
     183      ?></div><?php
    172184
    173185      \update_option("vista_license_valid", false);
     
    184196    $licenseKey = $this->get_key();
    185197    $licenseStatus = $licenseKey ? 'Active' : 'Disabled';
    186 
    187198    ?>
    188199
     
    209220      >
    210221
     222      <?php
     223      // If the tier is hardcoded, don't show the dropdown. Otherwise,
     224      // this displays a dropdown to select the user's pricing tier
     225      if (is_null(self::TIER)):
     226      ?>
     227      <br>
     228      <label class="vista-license-label" for="vsta-tier">Subscription Tier</label>
     229      <select name="vsta-tier" id="vsta-tier" required>
     230        <?php
     231        foreach (self::TIER_ID as $name => $unused) {
     232          if ($name == $this->tier) {
     233            echo "<option selected>" . esc_html($name) . "</option>";
     234          } else {
     235            echo  "<option>" . esc_html($name) . "</option>" ;
     236          }
     237        }
     238         ?>
     239      </select>
     240      <?php endif; ?>
     241
    211242      <input type="submit" class="vsta-btn-go" name="submit" value="Activate">
    212243      <button class="vsta-btn-danger" id="vsta-deactivate-btn" name="deactivate" value="1">Clear</button>
     
    256287
    257288  /**
    258    * Gets the level of the pricing tier of this subscription, from 0 (no license) to 4 (enterprise)
    259    * Mappings from tiers to levels are found in TIER_LEVEL
     289   * Gets the level of the pricing tier of this subscription.
     290   * Mappings from tiers to levels are found in TIER_LEVEL.
     291   * Currently unused.
    260292   * @return int Pricing tier level
    261293   */
     
    263295    if (!$this->valid)
    264296      return 0;
    265     return self::TIER ?? (is_null($this->tier) ? 0 : self::TIER_LEVEL[$this->tier]);
     297    return self::TIER ??
     298      (is_null($this->tier) ? 0 : self::TIER_LEVEL[$this->tier]);
    266299  }
    267300}
  • vistawp/trunk/readme.txt

    r2964274 r2973600  
    55Requires at least: 4.7 
    66Tested up to: 6.3 
    7 Stable tag: 1.2.0 
     7Stable tag: 1.2.1 
    88Requires PHP: 7.0 
    99License: GPLv2 or later 
  • vistawp/trunk/vista.php

    r2964274 r2973600  
    33* Plugin Name: VistaWP
    44* Description: Retrieves and displays real estate listings
    5 * Version: 1.2.0
     5* Version: 1.2.1
    66* Author: VistaWP
    77* Author URI: https://vistawp.com/
Note: See TracChangeset for help on using the changeset viewer.