/** * Render the screen options to choose whether to display release help tooltips. * * @since 1.0 * * @param string $settings * @param \WP_Screen $screen * * @return string */ public function render_release_tooltip($settings, \WP_Screen $screen) { if (!Tab_Dispatch::is_current_view('releases') || !Release_Dispatch::is_current_view('add-new')) { return $settings; } add_filter('screen_options_show_submit', '__return_true'); $show = get_option('itelic_show_release_type_help', 'show'); ob_start(); ?> <fieldset class="release-help-screen-option"> <legend><?php _e("Licensing", Plugin::SLUG); ?> </legend> <input type="checkbox" step="1" min="1" max="999" name="itelic_release_type_help" id="itelic_release_type_help" <?php checked($show, 'show'); ?> value="1"> <label for="itelic_release_type_help"><?php _e("Show Release Type Help", Plugin::SLUG); ?> </label> <?php wp_nonce_field('itelic-release-type-help', 'itelic_nonce'); ?> </fieldset> <?php $settings .= ob_get_clean(); return $settings; }
/** * Setup the Log List Table for rendering. * * @since 1.0 */ public function setup_table() { if (!Dispatch::is_current_view('logs')) { return; } add_thickbox(); $this->table = new Log_Table(array('single' => __("API Log", Plugin::SLUG), 'plural' => __('API Logs', Plugin::SLUG)), array('message' => __("Message", Plugin::SLUG), 'level' => __("Level", Plugin::SLUG), 'time' => __("Time", Plugin::SLUG), 'ip' => __("IP", Plugin::SLUG), 'user' => __("User", Plugin::SLUG), 'group' => __("Group", Plugin::SLUG), 'levelFilterLabel' => __("Filter by Level", Plugin::SLUG), 'allLevels' => __("All Levels", Plugin::SLUG), 'filter' => __("Filter", Plugin::SLUG)), new Table('itelic-api-logs'), '\\ITELIC\\API\\Log'); }
/** * Check if the current view is for a certain tab. * * @since 1.0 * * @param string $view * * @return bool */ public static function is_current_view($view) { if (!Tab_Dispatch::is_current_view('licenses')) { return false; } if (!isset(self::$views[$view])) { return false; } return $view == self::get_current_view(); }
/** * Render the view for this controller. * * @return void */ public function render() { $report = Dispatch::get_report($_GET['report']); if (is_null($report)) { wp_redirect(Tab_Dispatch::get_tab_link('reports')); exit; } $this->enqueue(); $view = new SingleV($report); $view->begin(); $view->title(); if (!$report) { $view->notice(__("Invalid report.", Plugin::SLUG), View::NOTICE_ERROR); } $view->tabs('reports'); $view->render(); $view->end(); }
/** * Render a report type preview. * * @since 1.0 * * @param Report $report */ protected function render_report(Report $report) { $link = add_query_arg(array('view' => 'single', 'report' => $report->get_slug()), Dispatch::get_tab_link('reports')); $desc = $report->get_description(); if (strlen($desc) > 100) { $desc = substr($desc, 0, 97); $desc .= '…'; } ?> <div class="report report-<?php echo $report->get_slug(); ?> "> <h3><?php echo $report->get_title(); ?> </h3> <p><?php echo $desc; ?> </p> <a href="<?php echo $link; ?> "><?php _e("View", Plugin::SLUG); ?> </a> </div> <?php }
$html .= '</p>'; $html .= '<h4>' . __('Minor', Plugin::SLUG) . '</h4>'; $html .= '<p>'; $html .= get_minor_release_help_text(); $html .= '</p>'; $html .= '<h4>' . __('Security', Plugin::SLUG) . '</h4>'; $html .= '<p>'; $html .= get_security_release_help_text(); $html .= '</p>'; $html .= '<h4>' . __('Pre-release', Plugin::SLUG) . '</h4>'; $html .= '<p>'; $html .= get_pre_release_help_text(); $html .= '</p>'; return $html; }, function () { return Dispatch::is_current_view('releases') && \ITELIC\Admin\Releases\Dispatch::is_current_view('add-new'); }); $help->add(__("Overview", Plugin::SLUG), function () { $html = ''; $html .= '<p>'; $html .= __("Renewal reminders are sent to your customers whenever their license keys are approaching their expiration date. You can create as many renewal reminders as needed. However, as the number of reminders is increase there is a performance impact. It is recommended to have no more than ten reminders.", Plugin::SLUG); $html .= '</p>'; return $html; }, function () { return get_current_screen()->post_type == CPT::TYPE; }); $help->add(__("Creating Reminders", Plugin::SLUG), function () { $html = ''; $html .= '<p>'; $html .= __("Creating a renewal reminder is similar to creating a WordPress post. The title is used as the subject line, and the post content is used as the message body. The message can be customized using the <em>Insert Template Tag</em> button. Use the <em>Scheduling</em> metabox to control when the reminder is sent out.", Plugin::SLUG); $html .= '</p>';
/** * Get the admin edit link for a particular key. * * @api * * @since 1.0 * * @param string $key * * @return string */ function itelic_get_admin_edit_key_link($key) { return add_query_arg(array('view' => 'single', 'key' => (string) $key), \ITELIC\Admin\Tab\Dispatch::get_tab_link('licenses')); }
<?php /** * Load the admin tabs code. * * @author Iron Bound Designs * @since 1.0 * @license AGPL * @copyright Iron Bound Designs, 2015. */ namespace ITELIC\Admin\Tab; use ITELIC\Admin\Tab\Controller\Licenses; use ITELIC\Admin\Tab\Controller\Logs; use ITELIC\Admin\Tab\Controller\Releases; use ITELIC\Admin\Tab\Controller\Reminders; use ITELIC\Admin\Tab\Controller\Reports; use ITELIC\Plugin; Dispatch::register_tab('licenses', __("Licenses", Plugin::SLUG), new Licenses()); Dispatch::register_tab('releases', __("Releases", Plugin::SLUG), new Releases()); Dispatch::register_tab('reminders', __("Renewal Reminders", Plugin::SLUG), new Reminders()); Dispatch::register_tab('reports', __("Reports", Plugin::SLUG), new Reports()); Dispatch::register_tab('logs', __("Logs", Plugin::SLUG), new Logs());
/** * 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); ?> <?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 }
/** * Process a request to delete a key as a row action. * * @since 1.0 */ public function process_delete_row_action() { if (!Dispatch::is_current_view('list')) { return; } if (!isset($_GET['itelic_action']) || $_GET['itelic_action'] != 'delete') { return; } if (!current_user_can('manage_options')) { return; } $key = $_GET['key']; if (!wp_verify_nonce($_GET['nonce'], 'itelic-delete-license-' . $key)) { return; } try { itelic_get_key($key)->delete(); wp_redirect(add_query_arg('msg', 'deleted', Tab_Dispatch::get_tab_link('licenses'))); exit; } catch (\Exception $e) { return; } }
/** * Override title display to show an add new button. * * @since 1.0 */ public function title() { echo '<h1>' . $this->get_title() . ' '; echo '<a href="' . add_query_arg('view', 'add-new', Dispatch::get_tab_link('releases')) . '" class="page-title-action">'; echo __("Add New", Plugin::SLUG); echo '</a>'; echo '</h1>'; }
/** * Render the view. */ public function render() { $selected = isset($_POST['type-select']) ? $_POST['type-select'] : ''; if (!array_key_exists($selected, Release::get_types())) { $selected = ''; } if (!$selected) { $style = 'style="opacity: 0;"'; } else { $style = ''; } $security_msg_hidden = $selected == Release::TYPE_SECURITY ? '' : ' hidden'; ?> <form method="POST" action="<?php echo esc_attr(add_query_arg('view', 'add-new', Dispatch::get_tab_link('releases'))); ?> "> <?php do_action('itelic_add_new_release_screen_before_types'); ?> <?php $this->render_types_tab($selected); ?> <?php if ($this->show_help) { ?> <div class="release-help"> <p class="release-help-major"> <?php echo \ITELIC\Admin\Help\get_major_release_help_text(); ?> </p> <p class="release-help-minor"> <?php echo \ITELIC\Admin\Help\get_minor_release_help_text(); ?> </p> <p class="release-help-security"> <?php echo \ITELIC\Admin\Help\get_security_release_help_text(); ?> </p> <p class="release-help-pre-release"> <?php echo \ITELIC\Admin\Help\get_pre_release_help_text(); ?> </p> </div> <?php } ?> <?php do_action('itelic_add_new_release_screen_after_types'); ?> <?php do_action('itelic_add_new_release_screen_before'); ?> <div class="main-editor" <?php echo $style; ?> > <?php do_action('itelic_add_new_release_screen_begin'); ?> <div class="row row-one"> <div class="product-select-container"> <?php $this->render_product_select(isset($_POST['product']) ? $_POST['product'] : 0); ?> </div> <div class="version-number-container"> <?php $this->render_version_number(isset($_POST['version']) ? $_POST['version'] : 0); ?> </div> </div> <div class="row row-two"> <div class="upload-container dropzone"> <?php $this->render_upload(); ?> </div> </div> <div class="row row-three"> <div class="whats-changed-container"> <?php $this->render_whats_changed(isset($_POST['whats-changed']) ? $_POST['whats-changed'] : ''); ?> </div> </div> <div class="row row-five <?php echo $security_msg_hidden; ?> " id="security-message-row"> <div class="security-message"> <?php $this->render_security_message(isset($_POST['security-message']) ? $_POST['security-message'] : ''); ?> </div> </div> <div class="row row-four"> <div class="buttons"> <?php $this->render_buttons(); ?> </div> </div> <?php do_action('itelic_add_new_release_screen_end'); ?> </div> <input type="hidden" name="itelic-action" value="add-new-release"> <?php wp_nonce_field('itelic-add-new-release'); ?> <?php do_action('itelic_add_new_release_screen_after'); ?> </form> <?php }
/** * 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 }
/** * Get the admin edit link for a particular release. * * @api * * @since 1.0 * * @param int $release Release ID * * @return string */ function itelic_get_admin_edit_release_link($release) { return add_query_arg(array('view' => 'single', 'ID' => (string) $release), \ITELIC\Admin\Tab\Dispatch::get_tab_link('releases')); }
/** * Get the view link. * * @since 1.0 * * @param string $status * * @return string */ protected function get_view_link($status) { $link = Dispatch::get_tab_link('releases'); $white_list = array('prod', 's'); foreach ($white_list as $var) { if (isset($_GET[$var])) { $link = add_query_arg($var, $_GET[$var], $link); } } return add_query_arg('status', $status, $link); }
/** * Override title display to show an add new button. * * @since 1.0 */ public function title() { echo '<h1>' . $this->get_title() . ' '; if (function_exists('it_exchange_register_manual_purchases_addon')) { echo '<a href="' . add_query_arg('view', 'add-new', Dispatch::get_tab_link('licenses')) . '" class="page-title-action">'; echo __("Add New", Plugin::SLUG); echo '</a>'; } echo '</h1>'; }