function install_screen() { //If we can't get the API key we must inform the user if (false === op_sl_get_key()) { $this->error = __('API key missing or invalid', OP_SN); } //Set the data array for the template $data = array('error' => $this->error, 'notification' => $this->notification); //Load the template echo op_tpl('install/index', $data); }
function __construct() { if (current_user_can('edit_theme_options')) { add_action('admin_enqueue_scripts', array($this, 'print_scripts')); if (op_get_option('installed') != 'Y' || false === op_sl_get_key()) { require_once OP_ADMIN . 'install.php'; } else { $this->installed = true; add_action(OP_SN . '-print-footer-scripts', array($this, 'print_footer_scripts'), 5); add_action('edit_form_after_title', array($this, 'remove_content_editor')); add_filter('page_row_actions', array($this, 'addOpLinks'), 10, 2); $this->initalize_theme(); $this->include_admin_files(); if (isset($_REQUEST['op_uploader']) && $_REQUEST['op_uploader'] == 'true') { add_filter(OP_SN . '-script-localize', array($this, 'op_localize')); add_action('admin_print_scripts-media-upload-popup', array($this, 'media_js')); } } add_action('admin_init', array($this, 'init_admin')); } //add_action('admin_menu',array($this,'admin_menu')); }
_e('Welcome to OptimizePress. To get started please provide API key below so we can verify the legitmacy of this copy. You will only need to do this once.', OP_SN); ?> </p> </div> <!-- end .op-bsw-main-content --> <div class="op-bsw-grey-panel-fixed" style="border-top: 1px solid #ccc;" > <div class="op-bsw-main-content"> <p> <label for="op_install_order_number" style="font-weight:bold"><?php _e('API Key', OP_SN); ?> </label> <input type="text" name="op[install][order_number]" id="op_install_order_number" value="<?php echo esc_attr(op_sl_get_key()); ?> " /> </p> </div> </div> <fieldset class="form-actions cf"> <div class="form-actions-content"> <input type="hidden" name="<?php echo OP_SN; ?> _install" value="save" /> <?php wp_nonce_field('op_install', '_wpnonce', false); ?>
/** * Checks API key and URL combo validity * * Saves intermediate results to transient to avoid constant pinging of OP SL * @return void */ function checkApiKeyValidity() { /* * Transient is not found */ if (false === ($validity = get_transient(OptimizePress_Sl_Api::OPTION_API_KEY_STATUS))) { $validity = array('api_key' => op_sl_get_key(), 'installation_url' => op_sl_get_url(), 'status' => op_sl_ping() === true ? 1 : 0); } /* * If API key and URL combo is valid we are done */ if ((int) $validity['status'] === 1 && $validity['api_key'] === op_sl_get_key() && $validity['installation_url'] === op_sl_get_url()) { set_transient(OptimizePress_Sl_Api::OPTION_API_KEY_STATUS, $validity, HOUR_IN_SECONDS * 6); return; } /* * We are nagging the user with our message */ echo '<div class="update-nag">' . sprintf(__('There seems to be a problem with your OptimizePress API Key. Please recheck it is entered correctly and if you still have problems <a href="%s" target="_blank">contact support</a>.', OP_SN), OP_SUPPORT_LINK) . '</div>'; }
/** * Checks if user is eligible for updates and show him nag message * @since 2.2.2 * @return void */ function checkEligibility() { /* * User can disable eligibility notice, in that case nag won't be shown */ if ('disabled' === get_transient(OptimizePress_Sl_Api::OPTION_ELIGIBILITY_STATUS . '_disabled')) { return; } /* * We need to skip if user hasn't added API key yet */ $apiKey = op_sl_get_key(); if (empty($apiKey)) { return; } /* * Lets check transients */ if (false === ($eligibility = get_transient(OptimizePress_Sl_Api::OPTION_ELIGIBILITY_STATUS))) { $eligibility = array('installation_url' => op_sl_get_url(), 'status' => op_sl_eligible() === true ? 1 : 0); } set_transient(OptimizePress_Sl_Api::OPTION_ELIGIBILITY_STATUS, $eligibility, MINUTE_IN_SECONDS * 15); /* * If API key and URL combo is valid we are done */ if ((int) $eligibility['status'] === 1 && $eligibility['installation_url'] === op_sl_get_url()) { return; } /* * We are nagging the user with our message */ echo '<div class="update-nag">' . sprintf(__('You are not eligible for new updates. You can <a href="%s" target="_blank">prolong your subscription</a> or <a href="%s">disable this notification</a>.', OP_SN), 'http://www.optimizepress.com/updates-renewal/', admin_url('admin.php?action=optimizepress-disable-eligibility')) . '</div>'; }
<div class="op-bsw-grey-panel-content op-bsw-grey-panel-no-sidebar cf"> <?php if ($error = $this->error('op_sections_' . OptimizePress_Sl_Api::OPTION_API_KEY_PARAM)) { ?> <span class="error"><?php echo $error; ?> </span> <?php } ?> <label for="op_favicon" class="form-title"><?php _e('Enter API Key', OP_SN); ?> </label> <p class="op-micro-copy"><?php _e('You should have received your API Key when subscribing/paying.', OP_SN); ?> </p> <input type="text" name="op[sections][<?php echo OptimizePress_Sl_Api::OPTION_API_KEY_PARAM; ?> ]" id="op_api_key" value="<?php echo op_sl_get_key(); ?> " /> <div class="clear"></div> </div>