Plugin Directory

Changeset 2152158


Ignore:
Timestamp:
09/06/2019 07:25:49 AM (7 years ago)
Author:
labs64
Message:

Preparing for 0.9.8 release

Location:
pluginpass-pro-plugintheme-licensing/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • pluginpass-pro-plugintheme-licensing/trunk/README.txt

    r2150569 r2152158  
    88Tested up to: 5.2.2
    99Requires PHP: 5.6
    10 Stable tag: 0.9.7
     10Stable tag: 0.9.8
    1111License: GPLv2 or later
    1212License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    136136* Update: User consent before validation #13
    137137
    138 = 0.9.7 =
     138= 0.9.8 =
    139139* Fix: Adjust User-Agent to reflect plugin name and version #14
    140140* Update: plugin documentation
  • pluginpass-pro-plugintheme-licensing/trunk/constants.php

    r2150569 r2152158  
    88define( __NAMESPACE__ . '\NS', __NAMESPACE__ . '\\' );
    99
    10 define( NS . 'PLUGIN_VERSION', '0.9.7' );
     10define( NS . 'PLUGIN_VERSION', '0.9.8' );
    1111
    1212define( NS . 'PLUGIN_NAME', 'pluginpass' );
  • pluginpass-pro-plugintheme-licensing/trunk/examples/class-pluginpass-demo-settings.php

    r2150569 r2152158  
    1818 * @subpackage Pluginpass_Demo_Plugin/admin
    1919 */
    20 class Pluginpass_Demo_Settings
    21 {
    22     private $plugin_name;
    23 
    24     private $version;
    25 
    26     public function __construct($plugin_name, $version)
    27     {
    28         $this->plugin_name = $plugin_name;
    29         $this->version = $version;
    30     }
    31 
    32     /**
    33      */
    34     public function pluginpass_demo_options_menu()
    35     {
    36         //Add the menu to the Plugins set of menu items
    37         add_options_page(
    38             'PluginPass Demo',                  // The title to be displayed in the browser window for this page.
    39             'PluginPass Demo',                  // The text to be displayed for this menu item
    40             'manage_options',                   // Which type of users can see this menu item
    41             'pluginpass_demo_options',          // The unique ID - that is, the slug - for this menu item
    42             array( $this, 'render_settings_page_content')               // The name of the function to call when rendering this menu's page
    43         );
    44     }
    45 
    46     /**
    47      */
    48     public function pluginpass_demo_options_page()
    49     {
    50         add_settings_section(
    51             'general_settings_section',                     // ID used to identify this section and with which to register options
    52             __('Plugin Options', 'pluginpass-demo-plugin'),             // Title to be displayed on the administration page
    53             array( $this, 'general_options_callback'),      // Callback used to render the description of the section
    54             'pluginpass_demo_display_options'                       // Page on which to add this section of options
    55         );
    56     }
    57 
    58     /**
    59      * Renders a simple page to display for the theme menu defined above.
    60      */
    61     public function render_settings_page_content()
    62     {
    63         ?>
    64         <!-- Create a header in the default WordPress 'wrap' container -->
    65         <div class="wrap">
    66 
    67             <h2><?php _e('PluginPass Demo Options', 'pluginpass-demo-plugin'); ?></h2>
     20class Pluginpass_Demo_Settings {
     21    private $plugin_name;
     22
     23    private $version;
     24
     25    public function __construct( $plugin_name, $version ) {
     26        $this->plugin_name = $plugin_name;
     27        $this->version     = $version;
     28    }
     29
     30    /**
     31     */
     32    public function pluginpass_demo_options_menu() {
     33        //Add the menu to the Plugins set of menu items
     34        add_options_page(
     35            'PluginPass Demo',                    // The title to be displayed in the browser window for this page.
     36            'PluginPass Demo',                    // The text to be displayed for this menu item
     37            'manage_options',                    // Which type of users can see this menu item
     38            'pluginpass_demo_options',            // The unique ID - that is, the slug - for this menu item
     39            [
     40                $this,
     41                'render_settings_page_content'
     42            ]
     43        );
     44    }
     45
     46    /**
     47     */
     48    public function pluginpass_demo_options_page() {
     49        add_settings_section(
     50            'general_settings_section',                        // ID used to identify this section and with which to register options
     51            __( 'Plugin Options', 'pluginpass-demo-plugin' ),                // Title to be displayed on the administration page
     52            [ $this, 'general_options_callback' ],        // Callback used to render the description of the section
     53            'pluginpass_demo_display_options'                        // Page on which to add this section of options
     54        );
     55    }
     56
     57    /**
     58     * Renders a simple page to display for the theme menu defined above.
     59     */
     60    public function render_settings_page_content() {
     61        ?>
     62        <!-- Create a header in the default WordPress 'wrap' container -->
     63        <div class="wrap">
     64
     65            <h2><?php _e( 'PluginPass Demo Options', 'pluginpass-demo-plugin' ); ?></h2>
    6866            <?php settings_errors(); ?>
    6967
    70                 <?php
    71         do_settings_sections('pluginpass_demo_display_options'); ?>
    72 
    73         </div><!-- /.wrap -->
    74     <?php
    75     }
    76 
    77     /**
    78      */
    79     public function general_options_callback()
    80     {
    81         if (!is_plugin_active('pluginpass/pluginpass.php') and current_user_can('activate_plugins')) {
    82             // Stop activation redirect and show error
    83             wp_die('This plugin/theme requires PluginPass plugin to be installed and active!');
    84         }
    85 
    86         $api_key = '588a16b3-d8b8-4a37-8965-b217eb93dc70';
    87         $product_number = 'P6N6UW7U4';
    88         $product_module_number = 'MN5VYRR54';
    89 
    90         $plugin_folder = 'pluginpass-demo/pluginpass-demo.php';
    91 
    92         $quard = new \PluginPass\Inc\Common\PluginPass_Guard( $api_key, $product_number, $plugin_folder );
    93         $quard->set_consent();
    94 
    95         if ($quard->validate($product_module_number)) {
    96             echo "<div class=\"notice notice-success\"><p>Valid license(-s) for $product_module_number found.</p></div>";
    97         } else {
    98             $go_to_shop = $quard->get_shop_url();
    99             echo "<div class=\"notice notice-error\"><p>No valid license(-s) for $product_module_number found!</p><p>Acquire licenses here: $go_to_shop</p></div>";
    100         }
    101 
    102         echo '<p>RAW Validation Result:</p><pre>';
    103         print_r($quard->validation_result());
    104         echo  '</pre>';
    105     }
    106 
     68            <?php
     69            do_settings_sections( 'pluginpass_demo_display_options' ); ?>
     70
     71        </div><!-- /.wrap -->
     72        <?php
     73    }
     74
     75
     76    public function install_and_activate_pluginpass_as_dependency() {
     77    $pluginpass_slug   = 'pluginpass-pro-plugintheme-licensing';
     78        $pluginpass_folder = "$pluginpass_slug/pluginpass.php";
     79
     80        // Require PluginPass plugin
     81        if ( is_admin() && current_user_can( 'activate_plugins' ) && ! is_plugin_active( $pluginpass_folder ) ) {
     82            // plugin installed but not activated
     83            if ( array_key_exists( $pluginpass_folder, get_plugins() ) ) {
     84                $pluginpass_activate_url = wp_nonce_url(
     85                    self_admin_url( 'plugins.php?action=activate&plugin=' . $pluginpass_folder ),
     86                    'activate-plugin_' . $pluginpass_folder
     87                );
     88
     89                $message = sprintf(
     90                    'This plugin/theme requires PluginPass plugin to be installed and active.<br><br> <a class="button button-primary" href="%s">%s</a>',
     91                    $pluginpass_activate_url,
     92                    'Activate PluginPass now &raquo;'
     93                );
     94
     95            } else {
     96                $pluginpass_install_url = wp_nonce_url(
     97                    self_admin_url( 'update.php?action=install-plugin&plugin=' . $pluginpass_slug ),
     98                    'install-plugin_' . $pluginpass_slug
     99                );
     100
     101                $message = sprintf(
     102                    'This plugin/theme requires PluginPass plugin to be installed and active.<br><br> <a class="button button-primary" href="%s">%s</a>',
     103                    $pluginpass_install_url,
     104                    'Install PluginPass now &raquo;'
     105                );
     106            }
     107
     108            $this->show_notice( $message, 'error', false );
     109
     110            exit;
     111        }
     112    }
     113
     114    public function show_demonstration_form( $api_key, $product_number, $product_module_number, $plugin_folder, $has_consent ) {
     115        $plugins = get_plugins();
     116        ?>
     117        <form method='get' action=''>
     118            <input type='hidden' name='page' value='pluginpass_demo_options'>
     119            <table class='form-table'>
     120                <tbody>
     121                <tr>
     122                    <th>
     123                        <label for='api_key'>API Key:</label>
     124                    </th>
     125                    <td>
     126                        <input id='api_key' type='text' name='api_key' value='<?php print $api_key ?>'
     127                               class='regular-text' required>
     128                        <p class='description'>
     129                            PluginPass uses the NetLicensing services to validate plugins/themes. You need to create an <a
     130                                    target='_blank' href='https://ui.netlicensing.io/#/settings'>API Key</a>;
     131                            recommended API Key role is "Licensee" role.
     132                        </p>
     133                    </td>
     134                </tr>
     135                <tr>
     136                    <th>
     137                        <label for='product_number'>Product Number:</label>
     138                    </th>
     139                    <td>
     140                        <input id='product_number' type='text' name='product_number'
     141                               value='<?php print $product_number ?>'
     142                               class='regular-text' required>
     143                        <p class='description'>
     144                            Provide NetLicensing "Product Number". Detailed configuration details can be found <a
     145                                    target='_blank' href='https://github.com/Labs64/PluginPass/wiki/Set-up-NetLicensing'>here</a>.
     146                        </p>
     147                    </td>
     148                </tr>
     149                <tr>
     150                    <th>
     151                        <label for='product_module_number'>Module Number:</label>
     152                    </th>
     153                    <td>
     154                        <input id='product_module_number' type='text' name='product_module_number'
     155                               value='<?php print $product_module_number ?>' class='regular-text' required>
     156                        <p class='description'>
     157                          Provide NetLicensing "Module Number" to be verified. Detailed configuration details can be found <a
     158                                  target='_blank' href='https://github.com/Labs64/PluginPass/wiki/Set-up-NetLicensing'>here</a>.
     159                        </p>
     160                    </td>
     161                </tr>
     162                <tr>
     163                    <th><label for='plugin_folder'>Plugin:</label></th>
     164                    <td>
     165                        <select id="plugin_folder" name="plugin_folder">
     166                            <?php foreach ( $plugins as $key => $plugin ): ?>
     167                                <option <?php if ( $key === $plugin_folder ): ?> selected <?php endif; ?>
     168                                        value="<?php print $key; ?>">
     169                                    <?php print $plugin['Name']; ?>
     170                                </option>
     171                            <?php endforeach; ?>
     172                        </select>
     173                        <p class='description'>
     174                          Choose Plugin to be validated.
     175                        </p>
     176                    </td>
     177                </tr>
     178                <?php if ( ! $has_consent ): ?>
     179                    <tr>
     180                        <th>
     181                            <label for='product_module_number'>User Consent:</label>
     182                        </th>
     183                        <td>
     184                            <fieldset>
     185                                <legend class='screen-reader-text'>
     186                                    <span>User Consent</span>
     187                                </legend>
     188                                <label for='users_can_register'>
     189                                    <input name='has_consent' type='checkbox' value='1'>
     190                                    I agree to have my personal data <a
     191                                            target='_blank' href='https://www.labs64.com/legal/privacy-policy'>processed as follows</a>.
     192                                </label>
     193                            </fieldset>
     194                        </td>
     195                    </tr>
     196                <?php endif; ?>
     197                </tbody>
     198            </table>
     199            <p class='submit'>
     200                <input type='submit' name='submit' class='button button-primary' value='Validate'>
     201            </p>
     202        </form>
     203        <?php
     204    }
     205
     206    protected function show_notice( $message, $type = 'success', $dismiss = true ) {
     207        $is_dismissible = $dismiss ? 'is-dismissible' : '';
     208
     209        echo "<div class=\"notice notice-$type $is_dismissible\">
     210                <p>$message</p>
     211             </div>";
     212    }
     213
     214
     215    public function general_options_callback() {
     216
     217        // check if pluginpass is installed and active
     218        $this->install_and_activate_pluginpass_as_dependency();
     219
     220        $api_key = ! empty( $_GET['api_key'] )
     221            ? $_GET['api_key']
     222            : get_option( 'pluginpass_api_key', '' );
     223
     224        $product_number = ! empty( $_GET['product_number'] )
     225            ? $_GET['product_number']
     226            : get_option( 'pluginpass_product_number', '' );
     227
     228        $product_module_number = ! empty( $_GET['product_module_number'] )
     229            ? $_GET['product_module_number']
     230            : get_option( 'pluginpass_product_module_number', '' );
     231
     232        $plugin_folder = ! empty( $_GET['plugin_folder'] )
     233            ? $_GET['plugin_folder']
     234            : get_option( 'pluginpass_plugin_folder', '' );
     235
     236        $has_consent = ! empty( $_GET['has_consent'] )
     237            ? $_GET['has_consent']
     238            : false;
     239
     240        if ( ! empty( $_GET['submit'] ) ) {
     241            add_option( 'pluginpass_api_key', $api_key );
     242            add_option( 'pluginpass_product_number', $product_number );
     243            add_option( 'pluginpass_product_module_number', $product_module_number );
     244            add_option( 'pluginpass_plugin_folder', $plugin_folder );
     245
     246            try {
     247                $guard = new \PluginPass\Inc\Common\PluginPass_Guard( $api_key, $product_number, $plugin_folder );
     248
     249                if ( $guard->has_consent() ) {
     250                    $has_consent = true;
     251                }
     252
     253                if ( $has_consent ) {
     254                    $guard->set_consent();
     255                }
     256
     257                if ( $guard->validate( $product_module_number ) ) {
     258                    $this->show_notice( "Module $product_module_number is valid", 'success' );
     259                } else {
     260                    $shop_url = $guard->get_shop_url();
     261                    $this->show_notice( "Module $product_module_number is not invalid. Renew or acquire license <a target='_blank' href='$shop_url'>click</a>.", 'warning' );
     262                }
     263
     264                $result = print_r( $guard->validation_result(), true );
     265
     266                $this->show_notice( "Validation result: $result", 'success' );
     267            } catch ( \PluginPass\Inc\Exceptions\Consent_Missing_Exception $consent_missing_exception ) {
     268                $this->show_notice( 'User consent must be available to process personal data!', 'error' );
     269            } catch ( Exception $exception ) {
     270                $this->show_notice( $exception->getMessage(), 'error' );
     271            }
     272        }
     273
     274        $this->show_demonstration_form( $api_key, $product_number, $product_module_number, $plugin_folder, $has_consent );
     275    }
    107276}
  • pluginpass-pro-plugintheme-licensing/trunk/inc/common/class-pluginpass-guard.php

    r2150569 r2152158  
    5757     * @throws \Exception
    5858     */
    59     public function set_consent() {
    60         if ( empty( $this->plugin->consented_at ) ) {
    61             $this->update_plugin( [ 'consented_at' => date( DATE_ATOM ) ], [ 'ID' => $this->plugin->ID ] );
     59    public function set_consent( ) {
     60        if (empty( $this->plugin->consented_at ) ) {
     61            $this->plugin = $this->update_plugin( [ 'consented_at' => date( DATE_ATOM ) ], [ 'ID' => $this->plugin->ID ] );
    6262        }
    6363
  • pluginpass-pro-plugintheme-licensing/trunk/pluginpass.php

    r2150569 r2152158  
    1616 * Plugin URI:        https://github.com/Labs64/PluginPass
    1717 * Description:       WordPress Plugin/Theme Licensing powered by Labs64 NetLicensing
    18  * Version:           0.9.7
     18 * Version:           0.9.8
    1919 * Author:            Labs64
    2020 * Author URI:        https://netlicensing.io
Note: See TracChangeset for help on using the changeset viewer.