コード例 #1
0
    /**
     * Render the view.
     */
    public function render()
    {
        if (!$this->key) {
            return;
        }
        wp_enqueue_style('itelic-admin-license-detail');
        wp_enqueue_script('itelic-admin-license-detail');
        wp_localize_script('itelic-admin-license-detail', 'ITELIC', array('ajax' => admin_url('admin-ajax.php'), 'key' => $this->key->get_key(), 'disabling' => __("Deactivating", Plugin::SLUG), 'df' => it_exchange_php_date_format_to_jquery_datepicker_format($this->get_short_df()), 'update_nonce' => wp_create_nonce('itelic-update-key-' . $this->key->get_key()), 'statuses' => json_encode(Key::get_statuses())));
        $jdf = it_exchange_php_date_format_to_jquery_datepicker_format($this->get_short_df());
        $online = $this->key->is_online_product();
        $disable_activate = $this->key->get_status() != Key::ACTIVE;
        $disable_tip = __("Disabled or expired licenses cannot be activated.", Plugin::SLUG);
        $disable_title = $disable_activate ? "title=\"{$disable_tip}\"" : '';
        $disable_class = $disable_activate ? 'button-disabled' : '';
        $disabled_input = $disable_activate ? ' disabled' : '';
        ?>

		<div id="it-exchange-license-details">
			<div class="spacing-wrapper bottom-border header-block">

				<div class="status status-<?php 
        echo esc_attr($this->key->get_status());
        ?>
">
					<span data-value="<?php 
        echo esc_attr($this->key->get_status());
        ?>
" title="<?php 
        esc_attr_e("Click to edit", Plugin::SLUG);
        ?>
">
						<?php 
        echo $this->key->get_status(true);
        ?>
					</span>
				</div>

				<div class="name-block">
					<h2 class="customer-name"><?php 
        echo $this->key->get_customer()->wp_user->display_name;
        ?>
</h2>

					<h2 class="product-name"><?php 
        echo $this->key->get_product()->post_title;
        ?>
</h2>
				</div>
				<div class="key-block">
					<p>
						<label for="license-key" class="screen-reader-text"><?php 
        _e("License Key", Plugin::SLUG);
        ?>
</label>
						<input type="text" id="license-key" size="<?php 
        echo strlen($this->key->get_key());
        ?>
"
						       readonly value="<?php 
        echo esc_attr($this->key->get_key());
        ?>
">
					</p>
				</div>
			</div>

			<div class="spacing-wrapper bottom-border third-row misc-block">
				<div class="third expires">
					<h4><?php 
        _e("Expires", Plugin::SLUG);
        ?>
</h4>

					<h3 title="<?php 
        esc_attr_e("Click to edit", Plugin::SLUG);
        ?>
" data-df="<?php 
        echo $jdf;
        ?>
">
						<?php 
        if (null === ($d = $this->key->get_expires())) {
            ?>
							<?php 
            _e("Never", Plugin::SLUG);
            ?>
						<?php 
        } else {
            ?>
							<?php 
            echo \ITELIC\convert_gmt_to_local($d)->format($this->get_short_df());
            ?>
						<?php 
        }
        ?>
					</h3>
				</div>
				<div class="third transaction">
					<h4><?php 
        _e("Transaction", Plugin::SLUG);
        ?>
</h4>

					<h3>
						<a href="<?php 
        echo esc_url(get_edit_post_link($this->key->get_transaction()->ID));
        ?>
">
							<?php 
        echo it_exchange_get_transaction_order_number($this->key->get_transaction());
        ?>
						</a>
					</h3>
				</div>
				<div class="third max-activations">
					<h4><?php 
        _e("Max Activations", Plugin::SLUG);
        ?>
</h4>

					<h3 title="<?php 
        esc_attr_e("Click to edit", Plugin::SLUG);
        ?>
">
						<?php 
        echo $this->key->get_max() ? $this->key->get_max() : __('Unlimited', Plugin::SLUG);
        ?>
					</h3>
				</div>
			</div>

			<div class="spacing-wrapper activations<?php 
        echo count($this->renewals) ? ' bottom-border' : '';
        ?>
">
				<h3><?php 
        _e("Activations", Plugin::SLUG);
        ?>
</h3>

				<table id="activations-table" class="widefat">
					<thead>
					<tr>
						<th class="location-col"><?php 
        _e("Location", Plugin::SLUG);
        ?>
</th>
						<th class="status-col"><?php 
        _e("Status", Plugin::SLUG);
        ?>
</th>
						<th class="activation-col"><?php 
        _e("Activation", Plugin::SLUG);
        ?>
</th>
						<th class="deactivation-col"><?php 
        _e("Deactivation", Plugin::SLUG);
        ?>
</th>
						<th class="version-col"><?php 
        _e("Version", Plugin::SLUG);
        ?>
</th>
						<th class="delete-col">
							<span class="screen-reader-text"><?php 
        _e("Delete", Plugin::SLUG);
        ?>
</span></th>
					</tr>
					</thead>

					<tbody>
					<?php 
        foreach ($this->key->get_activations() as $activation) {
            ?>

						<?php 
            echo $this->get_activation_row_html($activation);
            ?>

					<?php 
        }
        ?>
					</tbody>
				</table>

				<h4><?php 
        _e("Remote Activate", Plugin::SLUG);
        ?>
</h4>

				<label for="remote-activate-location" class="screen-reader-text"><?php 
        _e("Install Location", Plugin::SLUG);
        ?>
</label>
				<input type="<?php 
        echo $online ? 'url' : 'text';
        ?>
" id="remote-activate-location"
				       placeholder="<?php 
        _e("Install Location", Plugin::SLUG);
        ?>
"<?php 
        echo $disabled_input;
        ?>
>
				<input type="submit" id="remote-activate-submit" class="it-exchange-button <?php 
        echo $disable_class;
        ?>
"
				       value="<?php 
        esc_attr_e("Activate", Plugin::SLUG);
        ?>
" data-tip="<?php 
        echo $disable_tip;
        ?>
"<?php 
        echo $disable_title;
        ?>
>
				<input type="hidden" id="remote-activate-key" value="<?php 
        echo esc_attr($this->key->get_key());
        ?>
">
				<?php 
        wp_nonce_field('itelic-remote-activate-key-' . $this->key->get_key());
        ?>
			</div>

			<?php 
        if (count($this->renewals)) {
            ?>

				<div class="spacing-wrapper renewals">

					<h3><?php 
            _e("Renewal History", Plugin::SLUG);
            ?>
</h3>

					<ul>
						<?php 
            foreach ($this->renewals as $renewal) {
                ?>

							<li>
								<?php 
                echo $renewal->get_renewal_date()->format(get_option('date_format'));
                ?>
								&nbsp;&mdash;&nbsp;

								<?php 
                if ($renewal->get_transaction()) {
                    ?>
									<a href="<?php 
                    echo get_edit_post_link($renewal->get_transaction()->ID);
                    ?>
">
										<?php 
                    echo it_exchange_get_transaction_order_number($renewal->get_transaction());
                    ?>
									</a>
								<?php 
                } else {
                    ?>
									<?php 
                    _e("Manual Renewal", Plugin::SLUG);
                    ?>
								<?php 
                }
                ?>
							</li>

						<?php 
            }
            ?>
					</ul>

				</div>

			<?php 
        }
        ?>

			<?php 
        /**
         * Fires at the end of the single license screen.
         *
         * @since 1.0
         *
         * @param Key $key
         */
        do_action('itelic_single_license_screen_end', $this->key);
        ?>

		</div>

		<?php 
        /**
         * Fires after the main single license screen.
         *
         * @since 1.0
         *
         * @param Key $key
         */
        do_action('itelic_single_license_screen_after', $this->key);
    }
コード例 #2
0
    /**
     * This echos the feature metabox.
     *
     * @since 1.0
     *
     * @param \WP_Post $post
     */
    function print_metabox($post)
    {
        add_action('admin_footer', array($this, 'changelog_popup'));
        wp_enqueue_style('itelic-add-edit-product');
        wp_enqueue_script('itelic-add-edit-product');
        wp_localize_script('itelic-add-edit-product', 'ITELIC', array('ajax' => admin_url('admin-ajax.php'), 'product' => isset($post->ID) ? $post->ID : 0, 'df' => it_exchange_php_date_format_to_jquery_datepicker_format(get_option('date_format'))));
        $settings = it_exchange_get_option('addon_itelic');
        $downloads = it_exchange_get_product_feature(isset($post->ID) ? $post->ID : 0, 'downloads');
        if (!is_array($downloads)) {
            $downloads = array();
        }
        $data = it_exchange_get_product_feature(isset($post->ID) ? $post->ID : 0, $this->slug);
        $hidden = $data['enabled'] ? '' : ' hide-if-js';
        $hidden_variants = $data['enabled_variant_activations'] ? '' : ' hide-if-js';
        $hidden_simple = $hidden_variants ? '' : ' hide-if-js';
        $version_read = empty($data['version']) ? '' : 'readonly';
        ?>

		<p><?php 
        echo $this->description;
        ?>
</p>

		<p>
			<input type="checkbox" id="itelic-enable" name="itelic[enabled]" <?php 
        checked(true, $data['enabled']);
        ?>
>
			<label for="itelic-enable"><?php 
        _e("Enable Licensing for this product", Plugin::SLUG);
        ?>
</label>
		</p>

		<div class="itelic-settings<?php 
        echo esc_attr($hidden);
        ?>
">

			<?php 
        if ($settings['sell-online-software']) {
            ?>
				<p>
					<input type="checkbox" id="itelic-online-software" name="itelic[online-software]" <?php 
            checked(true, $data['online-software']);
            ?>
>
					<label for="itelic-online-software"><?php 
            _e("Enable online software tools for this product", Plugin::SLUG);
            ?>
</label>
					<span class="tip" title="
					<?php 
            _e("Online software tools allows for your customers to remotely activate and deactivate their license keys.", Plugin::SLUG);
            ?>
					<?php 
            _e("Remote activation and remote deactivation needs to be enabled in the add-on settings for this to take effect.", Plugin::SLUG);
            ?>
					">
						i
					</span>
				</p>
			<?php 
        }
        ?>

			<label for="itelic-update-file"><?php 
        _e("Update File", Plugin::SLUG);
        ?>
</label>

			<?php 
        if (empty($downloads)) {
            ?>
				<div class="notice notice-warning below-h2">
					<p><?php 
            _e("You need to upload a new file to the Product Files section and save the product before configuring the Update File.", Plugin::SLUG);
            ?>
</p>
				</div>
			<?php 
        } else {
            ?>
				<select id="itelic-update-file" name="itelic[update-file]">
					<?php 
            foreach ($downloads as $download) {
                ?>
						<option value="<?php 
                echo esc_attr($download['id']);
                ?>
" <?php 
                selected($data['update-file'], $download['id']);
                ?>
>
							<?php 
                echo $download['name'];
                ?>
						</option>
					<?php 
            }
            ?>
				</select>
			<?php 
        }
        ?>

			<p class="description">
				<?php 
        _e("Select a file to be used for automatic updates.", Plugin::SLUG);
        ?>
				<?php 
        _e("You shouldn't need to update this after the initial release.", Plugin::SLUG);
        ?>
			</p>

			<label for="itelic-version">

				<?php 
        if ($version_read) {
            ?>
					<?php 
            _e("Current Version", Plugin::SLUG);
            ?>
				<?php 
        } else {
            ?>
					<?php 
            _e("Initial Version", Plugin::SLUG);
            ?>
				<?php 
        }
        ?>
			</label>
			<input type="text" id="itelic-version" name="itelic[version]" <?php 
        echo $version_read;
        ?>
 value="<?php 
        echo esc_attr($data['version']);
        ?>
">

			<p class="description">
				<?php 
        if (!$version_read) {
            ?>
					<?php 
            _e("Set the initial version of this product.", Plugin::SLUG);
            ?>
&nbsp;
				<?php 
        } else {
            ?>
					<?php 
            printf(__('Create a new release from the <a href="%s">releases</a> tab.', Plugin::SLUG), add_query_arg('view', 'add-new', Dispatch::get_tab_link('releases')));
            ?>
				<?php 
        }
        ?>
			</p>

			<label for="itelic-changelog"><?php 
        _e("Changelog", Plugin::SLUG);
        ?>
</label>
			<button id="view-changelog" class="button"><?php 
        _e("View Changelog", Plugin::SLUG);
        ?>
</button>
			<p class="description"><?php 
        _e("View the compiled changelog from the last 10 releases.", Plugin::SLUG);
        ?>
</p>

			<label for="itelic-key-type"><?php 
        _e("Key Type", Plugin::SLUG);
        ?>
</label>
			<select id="itelic-key-type" name="itelic[key-type]">

				<option value=""><?php 
        _e("Select a Key Type", Plugin::SLUG);
        ?>
</option>

				<?php 
        foreach (itelic_get_key_types() as $slug => $type) {
            ?>
					<option value="<?php 
            echo esc_attr($slug);
            ?>
" <?php 
            selected($data['key-type'], $slug);
            ?>
>
						<?php 
            echo itelic_get_key_type_name($slug);
            ?>
					</option>
				<?php 
        }
        ?>
			</select>

			<p class="description"><?php 
        _e("How should license keys be generated for this product.", Plugin::SLUG);
        ?>
</p>

			<div id="itelic-key-type-settings">
				<?php 
        if (!empty($data['key-type'])) {
            ?>
					<?php 
            $this->get_key_type_settings($data['key-type'], isset($post->ID) ? $post->ID : 0);
            ?>
				<?php 
        }
        ?>
			</div>

			<?php 
        $controller = $this->get_variants_controller($post->ID);
        ?>

			<?php 
        if ($controller) {
            ?>
				<p>
					<input type="checkbox" id="itelic-enable-variant-activations" name="itelic[enabled_variant_activations]"
						<?php 
            checked(true, $data['enabled_variant_activations']);
            ?>
>
					<label for="itelic-enable-variant-activations"><?php 
            _e("Enable Variant Activation limits", Plugin::SLUG);
            ?>
</label>
				</p>
			<?php 
        }
        ?>

			<div class="itelic-activation-limit<?php 
        echo esc_attr($hidden_simple);
        ?>
">
				<label for="itelic-limit"><?php 
        _e("Activation Limit", Plugin::SLUG);
        ?>
</label>
				<input type="number" name="itelic[limit]" id="itelic-limit" min="0" value="<?php 
        echo esc_attr($data['limit']);
        ?>
">
			</div>

			<div class="notice-container <?php 
        echo $data['enabled_variant_activations'] ? '' : 'hide-if-js';
        ?>
">

				<?php 
        if ($controller && !$controller->all_variant_combos_for_product) {
            ?>
					<div class="notice notice-warning below-h2">
						<p><?php 
            _e("You need to create Product Variants and save the product before setting variant activation limits.", Plugin::SLUG);
            ?>
</p>
					</div>
				<?php 
        }
        ?>
			</div>

			<?php 
        if ($controller && $controller->all_variant_combos_for_product) {
            ?>
				<?php 
            $hashes = $data['activation_variant'];
            ?>

				<div class="itelic-variants-activation-limit-table<?php 
            echo esc_attr($hidden_variants);
            ?>
">

					<div class="itelic-activation-limit-variant-header-row">
						<div class="itelic-activation-limit-variant-header-cell"><?php 
            _e("Variant", Plugin::SLUG);
            ?>
</div>
						<div class="itelic-activation-limit-variant-header-cell itelic-activation-limit-variant-input-cell"><?php 
            _e("Limit", Plugin::SLUG);
            ?>
</div>
					</div>

					<?php 
            foreach ($controller->all_variant_combos_for_product as $combo) {
                ?>
						<?php 
                $hash = $this->combo_to_hash($combo);
                ?>
						<div class="itelic-activation-limit-variant-row">

							<div class="itelic-activation-limit-variant-cell"><?php 
                echo $controller->generate_title_from_combos($combo);
                ?>
</div>

							<div class="itelic-activation-limit-variant-cell itelic-activation-limit-variant-input-cell">
								<input class="itelic-activation-limit-variant-input" name="itelic[activation_variant][<?php 
                echo esc_attr($hash);
                ?>
]"
								       type="number" min="0" value="<?php 
                echo isset($hashes[$hash]) ? $hashes[$hash] : '';
                ?>
">
							</div>
						</div>
					<?php 
            }
            ?>
				</div>

			<?php 
        }
        ?>

			<p class="description"><?php 
        _e("How many times can this license be activated. Leave blank for unlimited.", Plugin::SLUG);
        ?>
</p>
		</div>
		<?php 
    }
コード例 #3
0
    /**
     * Render the page.
     *
     * @since 1.0
     */
    public function render()
    {
        $df = it_exchange_php_date_format_to_jquery_datepicker_format(get_option('date_format'));
        $options = it_exchange_get_option('settings_general');
        $position = $options['currency-symbol-position'];
        $decimals = $options['currency-decimals-separator'];
        $thousands = $options['currency-thousands-separator'];
        $symbol = it_exchange_get_currency_symbol($options['default-currency']);
        $form = \ITUtility::merge_defaults($_POST, array('product' => '', 'customer' => '', 'username' => '', 'email' => '', 'first' => '', 'last' => '', 'activations' => '', 'expiration' => '', 'license' => '', 'paid' => '', 'customer-type' => 'existing'));
        ?>

		<form method="POST" action="<?php 
        echo esc_attr(add_query_arg('view', 'add-new', Dispatch::get_tab_link('licenses')));
        ?>
">
			<div class="main-editor">

				<?php 
        do_action('itelic_add_new_license_screen_before_steps');
        ?>

				<ol>
					<?php 
        do_action('itelic_add_new_license_screen_begin_steps');
        ?>

					<li>
						<label for="product"><?php 
        _e("Select a Product", Plugin::SLUG);
        ?>
</label>

						<div class="product-container">
							<select id="product" name="product">
								<?php 
        foreach ($this->products as $product) {
            ?>
									<option value="<?php 
            echo $product->ID;
            ?>
" <?php 
            selected($form['product'], $product->ID);
            ?>
>
										<?php 
            echo $product->post_title;
            ?>
									</option>
								<?php 
        }
        ?>
							</select>
						</div>
					</li>

					<li>
						<fieldset id="customer-type">
							<label><?php 
        _e("Select a Customer", Plugin::SLUG);
        ?>
</label>

							<div class="new-customer-container">
								<p>
									<input type="radio" id="new-customer" name="customer-type" value="new" <?php 
        checked($form['customer-type'], 'new');
        ?>
>
									<label for="new-customer"><?php 
        _e("New Customer", Plugin::SLUG);
        ?>
</label>
								</p>
							</div>

							<div class="existing-customer-container">
								<p>
									<input type="radio" id="existing-customer" name="customer-type" value="existing" <?php 
        checked($form['customer-type'], 'existing');
        ?>
>
									<label for="existing-customer"><?php 
        _e("Existing Customer", Plugin::SLUG);
        ?>
</label>
								</p>
							</div>
						</fieldset>

						<fieldset class="new-customer-form <?php 
        echo $form['customer-type'] == 'new' ? '' : 'hide-if-js';
        ?>
">
							<p>
								<label for="username"><?php 
        _e("Username", Plugin::SLUG);
        ?>
</label>
								<input type="text" id="username" name="username" value="<?php 
        echo $form['username'];
        ?>
">
							</p>

							<p>
								<label for="email"><?php 
        _e("Email", Plugin::SLUG);
        ?>
</label>
								<input type="email" id="email" name="email" value="<?php 
        echo $form['email'];
        ?>
">
							</p>

							<p>
								<label for="first"><?php 
        _e("First Name", Plugin::SLUG);
        ?>
</label>
								<input type="text" id="first" name="first" value="<?php 
        echo $form['first'];
        ?>
">
							</p>

							<p>
								<label for="last"><?php 
        _e("Last Name", Plugin::SLUG);
        ?>
</label>
								<input type="text" id="last" name="last" value="<?php 
        echo $form['last'];
        ?>
">
							</p>
						</fieldset>

						<fieldset class="existing-customer-form <?php 
        echo $form['customer-type'] == 'existing' ? '' : 'hide-if-js';
        ?>
">
							<p>
								<label for="customer" class="screen-reader-text"><?php 
        _e('Customer', Plugin::SLUG);
        ?>
</label>
								<select id="customer" name="customer">
									<?php 
        foreach (get_users() as $user) {
            ?>
										<option value="<?php 
            echo $user->ID;
            ?>
" <?php 
            selected($form['customer'], $user->ID);
            ?>
>
											<?php 
            echo $user->user_login;
            ?>
										</option>
									<?php 
        }
        ?>
								</select>
							</p>
						</fieldset>
					</li>
					<li>
						<div class="activations-container">
							<label for="activations"><?php 
        _e("Activation Limit", Plugin::SLUG);
        ?>
</label>
							<input type="number" id="activations" name="activations" min="0" value="<?php 
        echo $form['activations'];
        ?>
">

							<p class="description"><?php 
        _e("Leave blank for unlimited activations.");
        ?>
</p>
						</div>
					</li>
					<li>
						<div class="expiration-container">

							<label for="expiration"><?php 
        _e("Expiration Date", Plugin::SLUG);
        ?>
</label>
							<input type="date" id="expiration" name="expiration" value="<?php 
        echo $form['expiration'];
        ?>
" data-format="<?php 
        echo esc_attr($df);
        ?>
">

						</div>
					</li>

					<li>
						<div class="key-container">
							<label for="license"><?php 
        _e('License Key', Plugin::SLUG);
        ?>
</label>

							<p>
								<a href="javascript:" id="trigger-manual-key" class="<?php 
        echo empty($form['license']) ? '' : 'hide-if-js';
        ?>
">
									<?php 
        _e("Set the license key manually.", Plugin::SLUG);
        ?>
								</a>

								<a href="javascript:" id="trigger-automatic-key" class="<?php 
        echo empty($form['license']) ? 'hide-if-js' : '';
        ?>
">
									<?php 
        _e("Let Exchange automatically generate a license key for you.", Plugin::SLUG);
        ?>
								</a>
							</p>

							<input type="text" name="license" id="license" value="<?php 
        echo $form['license'];
        ?>
" class="<?php 
        echo empty($form['license']) ? 'hide-if-js' : '';
        ?>
">

						</div>
					</li>

					<li>
						<div class="paid-container">

							<label for="paid"><?php 
        _e("Amount Paid", Plugin::SLUG);
        ?>
</label>
							<input type="text" name="paid" id="paid" value="<?php 
        echo $form['paid'];
        ?>
"
							       data-symbol="<?php 
        echo $symbol;
        ?>
" data-symbol-position="<?php 
        echo $position;
        ?>
"
							       data-thousands-separator="<?php 
        echo $thousands;
        ?>
"
							       data-decimals-separator="<?php 
        echo $decimals;
        ?>
">

						</div>
					</li>

					<?php 
        do_action('itelic_add_new_license_screen_end_steps');
        ?>
				</ol>

				<?php 
        do_action('itelic_add_new_license_screen_after_steps');
        ?>

				<p class="buttons">
					<?php 
        submit_button(__("Create", Plugin::SLUG), 'primary', 'itelic-add-new-key', false);
        ?>
				</p>
			</div>

			<?php 
        wp_nonce_field('itelic-add-new-key');
        ?>

		</form>

		<?php 
    }