class-settings-addon.php
6 years ago
class-settings-advanced.php
4 years ago
class-settings-display.php
4 years ago
class-settings-email.php
6 years ago
class-settings-gateways.php
4 years ago
class-settings-general.php
5 years ago
class-settings-license.php
6 years ago
class-settings-recurring.php
4 years ago
class-settings-license.php
279 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Give Settings Page/Tab |
| 4 | * |
| 5 | * @package Give |
| 6 | * @subpackage Classes/Give_Settings_License |
| 7 | * @copyright Copyright (c) 2016, GiveWP |
| 8 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 | * @since 1.8 |
| 10 | */ |
| 11 | |
| 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 13 | exit; // Exit if accessed directly. |
| 14 | } |
| 15 | |
| 16 | if ( ! class_exists( 'Give_Settings_License' ) ) : |
| 17 | |
| 18 | /** |
| 19 | * Give_Settings_License. |
| 20 | * |
| 21 | * @sine 1.8 |
| 22 | */ |
| 23 | class Give_Settings_License extends Give_Settings_Page { |
| 24 | protected $enable_save = false; |
| 25 | |
| 26 | /** |
| 27 | * Constructor. |
| 28 | */ |
| 29 | public function __construct() { |
| 30 | $this->id = 'licenses'; |
| 31 | $this->label = esc_html__( 'Licenses', 'give' ); |
| 32 | |
| 33 | parent::__construct(); |
| 34 | |
| 35 | // Do not use main form for this tab. |
| 36 | if ( give_get_current_setting_tab() === $this->id ) { |
| 37 | |
| 38 | // Remove default parent form. |
| 39 | add_action( 'give-settings_open_form', '__return_empty_string' ); |
| 40 | add_action( 'give-settings_close_form', '__return_empty_string' ); |
| 41 | |
| 42 | // Refresh licenses when visit license setting page. |
| 43 | give_refresh_licenses(); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Get settings array. |
| 49 | * |
| 50 | * @return array |
| 51 | * @since 1.8 |
| 52 | */ |
| 53 | public function get_settings() { |
| 54 | $settings = array(); |
| 55 | |
| 56 | /** |
| 57 | * Filter the licenses settings. |
| 58 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
| 59 | */ |
| 60 | $settings = apply_filters( 'give_settings_licenses', $settings ); |
| 61 | |
| 62 | /** |
| 63 | * Filter the settings. |
| 64 | * |
| 65 | * @param array $settings |
| 66 | * |
| 67 | * @since 1.8 |
| 68 | */ |
| 69 | $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
| 70 | |
| 71 | // Output. |
| 72 | return $settings; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Render license key field |
| 77 | * |
| 78 | * @since 2.5.0 |
| 79 | */ |
| 80 | public function output() { |
| 81 | ob_start(); |
| 82 | ?> |
| 83 | <div class="give-license-settings-wrap"> |
| 84 | |
| 85 | <div class="give-grid-row"> |
| 86 | |
| 87 | <div class="give-grid-col-6"> |
| 88 | <div id="give-license-activator-wrap" class="give-license-top-widget"> |
| 89 | <div id="give-license-activator-inner"> |
| 90 | |
| 91 | <h2 class="give-license-widget-heading"> |
| 92 | <span class="dashicons dashicons-plugins-checked"></span> |
| 93 | <?php _e( 'Activate an Add-on License', 'give' ); ?> |
| 94 | </h2> |
| 95 | |
| 96 | <p class="give-field-description"> |
| 97 | <?php |
| 98 | printf( |
| 99 | __( 'Enter your license key below to unlock your GiveWP add-ons. You can access your licenses anytime from the <a href="%1$s" target="_blank">My Account</a> section on the GiveWP website. ', 'give' ), |
| 100 | Give_License::get_account_url() |
| 101 | ); |
| 102 | ?> |
| 103 | </p> |
| 104 | |
| 105 | <form method="post" action="" class="give-license-activation-form"> |
| 106 | |
| 107 | <div class="give-license-notices"></div> |
| 108 | |
| 109 | <?php wp_nonce_field( 'give-license-activator-nonce', 'give_license_activator_nonce' ); ?> |
| 110 | |
| 111 | <label |
| 112 | for="give-license-activator" |
| 113 | class="screen-reader-text"> |
| 114 | <?php _e( 'Activate License', 'give' ); ?> |
| 115 | </label> |
| 116 | |
| 117 | <input |
| 118 | id="give-license-activator" |
| 119 | type="text" |
| 120 | name="give_license_key" |
| 121 | placeholder="<?php _e( 'Enter your license key', 'give' ); ?>" |
| 122 | /> |
| 123 | |
| 124 | <input |
| 125 | data-activate="<?php _e( 'Activate License', 'give' ); ?>" |
| 126 | data-activating="<?php _e( 'Verifying License...', 'give' ); ?>" |
| 127 | value="<?php _e( 'Activate License', 'give' ); ?>" |
| 128 | type="submit" |
| 129 | class="button button-primary" |
| 130 | /> |
| 131 | |
| 132 | </form> |
| 133 | |
| 134 | </div> |
| 135 | </div> |
| 136 | </div><!-- /.give-grid-col-6 --> |
| 137 | |
| 138 | <div class="give-grid-col-6"> |
| 139 | <div id="give-addon-uploader-wrap" class="give-license-top-widget" |
| 140 | ondragover="event.preventDefault()"> |
| 141 | <div id="give-addon-uploader-inner"> |
| 142 | <h2 class="give-license-widget-heading"> |
| 143 | <span class="dashicons dashicons-upload"></span> |
| 144 | <?php _e( 'Upload and Activate an Add-on', 'give' ); ?> |
| 145 | </h2> |
| 146 | |
| 147 | <?php if ( ! is_multisite() ) : ?> |
| 148 | |
| 149 | <p class="give-field-description"> |
| 150 | <?php |
| 151 | printf( |
| 152 | __( 'Drag an add-on zip file below to upload and activate it. Access your downloads by activating a license or via the <a href="%1$s" target="_blank">My Downloads</a> section on the GiveWP website. ', 'give' ), |
| 153 | Give_License::get_downloads_url() |
| 154 | ); |
| 155 | ?> |
| 156 | </p> |
| 157 | |
| 158 | <?php if ( 'direct' !== get_filesystem_method() ) : ?> |
| 159 | <div class="give-notice notice notice-error inline"> |
| 160 | <p> |
| 161 | <?php |
| 162 | echo sprintf( |
| 163 | __( 'Sorry, you can not upload plugin from here because we do not have direct access to file system. Please <a href="%1$s" target="_blank">click here</a> to upload GiveWP Add-on.', 'give' ), |
| 164 | admin_url( 'plugin-install.php?tab=upload' ) |
| 165 | ); |
| 166 | ?> |
| 167 | </p> |
| 168 | </div> |
| 169 | <?php else : ?> |
| 170 | <div class="give-upload-addon-form-wrap"> |
| 171 | <form |
| 172 | method="post" |
| 173 | enctype="multipart/form-data" |
| 174 | class="give-upload-addon-form" |
| 175 | action="/"> |
| 176 | |
| 177 | <div class="give-addon-upload-notices"></div> |
| 178 | |
| 179 | <div class="give-activate-addon-wrap"> |
| 180 | <p><span |
| 181 | class="dashicons dashicons-yes"></span> <?php _e( 'Add-on succesfully uploaded.', 'give' ); ?> |
| 182 | </p> |
| 183 | <button |
| 184 | class="give-activate-addon-btn button-primary" |
| 185 | data-activate="<?php _e( 'Activate Add-on', 'give' ); ?>" |
| 186 | data-activating="<?php _e( 'Activating Add-on...', 'give' ); ?>" |
| 187 | ><?php _e( 'Activate Add-on', 'give' ); ?></button> |
| 188 | </div> |
| 189 | |
| 190 | <?php wp_nonce_field( 'give-upload-addon', '_give_upload_addon' ); ?> |
| 191 | |
| 192 | <p class="give-upload-addon-instructions"> |
| 193 | <?php _e( 'Drag a plugin zip file here to upload', 'give' ); ?><br> |
| 194 | <span><?php _e( 'or', 'give' ); ?></span> |
| 195 | </p> |
| 196 | |
| 197 | <label for="give-upload-addon-file-select" class="button button-small"> |
| 198 | <?php _e( 'Select a File', 'give' ); ?> |
| 199 | </label> |
| 200 | |
| 201 | <input |
| 202 | id="give-upload-addon-file-select" |
| 203 | type="file" |
| 204 | name="addon" |
| 205 | value="<?php _e( 'Select File', 'give' ); ?>" |
| 206 | /> |
| 207 | |
| 208 | </form> |
| 209 | </div> |
| 210 | <?php endif; ?> |
| 211 | <?php |
| 212 | else : |
| 213 | printf( |
| 214 | __( 'Because of security reasons you can not upload add-ons from here. Please <a href="%1$s" target="_blank">visit network plugin install page</a> to install add-ons.' ), |
| 215 | network_admin_url( 'plugin-install.php' ) |
| 216 | ); |
| 217 | ?> |
| 218 | <?php endif; ?> |
| 219 | </div> |
| 220 | </div> |
| 221 | </div> |
| 222 | </div> |
| 223 | |
| 224 | <div class="give-grid-row<?php echo get_option( 'give_licenses', array() ) ? '' : ' give-hidden'; ?>"> |
| 225 | <div class="give-grid-col-12"> |
| 226 | |
| 227 | <div class="give-licenses-list-header give-clearfix"> |
| 228 | <h2><?php _e( 'Licenses and Add-ons', 'give' ); ?></h2> |
| 229 | |
| 230 | <?php |
| 231 | $refresh_status = Give_License::refresh_license_status(); |
| 232 | $is_allow_refresh = ( $refresh_status['compare'] === date( 'Ymd' ) && 5 > $refresh_status['count'] ) || ( $refresh_status['compare'] < date( 'Ymd' ) ); |
| 233 | $button_title = __( 'Refresh limit reached. Licenses can only be refreshed 5 times per day.', 'give' ); |
| 234 | $local_date = strtotime( get_date_from_gmt( date( 'Y-m-d H:i:s', $refresh_status['time'] ) ) ); |
| 235 | ?> |
| 236 | |
| 237 | <div id="give-refresh-button-wrap"> |
| 238 | <button id="give-button__refresh-licenses" |
| 239 | class="button-secondary" |
| 240 | data-activate="<?php _e( 'Refresh All Licenses', 'give' ); ?>" |
| 241 | data-activating="<?php _e( 'Refreshing All Licenses...', 'give' ); ?>" |
| 242 | data-nonce="<?php echo wp_create_nonce( 'give-refresh-all-licenses' ); ?>" |
| 243 | <?php echo $is_allow_refresh ? '' : 'disabled'; ?> |
| 244 | <?php echo $is_allow_refresh ? '' : sprintf( 'title="%1$s"', $button_title ); ?>> |
| 245 | <?php _e( 'Refresh All Licenses', 'give' ); ?> |
| 246 | </button> |
| 247 | <span id="give-last-refresh-notice"> |
| 248 | <?php |
| 249 | echo sprintf( |
| 250 | __( 'Last refreshed on %1$s at %2$s', 'give' ), |
| 251 | date( give_date_format(), $local_date ), |
| 252 | date( 'g:i a', $local_date ) |
| 253 | ); |
| 254 | ?> |
| 255 | </span> |
| 256 | </div> |
| 257 | |
| 258 | <hr> |
| 259 | <p class="give-field-description"><?php _e( 'The following list displays your add-ons and their corresponding activation and license statuses.', 'give' ); ?></p> |
| 260 | |
| 261 | </div> |
| 262 | |
| 263 | <section id="give-licenses-container"> |
| 264 | <?php echo Give_License::render_licenses_list(); ?> |
| 265 | </section> |
| 266 | |
| 267 | </div> |
| 268 | </div> |
| 269 | </div> |
| 270 | |
| 271 | <?php |
| 272 | echo ob_get_clean(); |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | endif; |
| 277 | |
| 278 | return new Give_Settings_License(); |
| 279 |