/** * Save settings */ public function save() { $settings = $this->get_settings(); SP_Admin_Settings::save_fields($settings); if (isset($_POST['prosports_event_teams_delimiter'])) { update_option('prosports_event_teams_delimiter', $_POST['prosports_event_teams_delimiter']); } }
/** * Save settings */ public function save() { global $current_section; $settings = $this->get_settings(); SP_Admin_Settings::save_fields($settings); if ($current_section) { do_action('prosports_update_options_' . $this->id . '_' . $current_section); } }
/** * Save settings */ public function save() { $settings = $this->get_settings(); SP_Admin_Settings::save_fields($settings); update_option('sportspress_header_sponsor_width', (int) sp_array_value($_POST, 'sportspress_header_sponsor_width', 128)); update_option('sportspress_header_sponsor_height', (int) sp_array_value($_POST, 'sportspress_header_sponsor_height', 64)); update_option('sportspress_header_sponsors_top', (int) sp_array_value($_POST, 'sportspress_header_sponsors_top', 10)); update_option('sportspress_header_sponsors_right', (int) sp_array_value($_POST, 'sportspress_header_sponsors_right', 10)); update_option('sportspress_footer_sponsor_width', (int) sp_array_value($_POST, 'sportspress_footer_sponsor_width', 256)); update_option('sportspress_footer_sponsor_height', (int) sp_array_value($_POST, 'sportspress_footer_sponsor_height', 128)); }
/** * Save settings */ public function save() { $settings = $this->get_settings(); SP_Admin_Settings::save_fields($settings); if (isset($_POST['sp_branding_icon_removed'])) { delete_option('prosports_branding_icon'); } update_option('prosports_enable_branding_css', isset($_POST['prosports_enable_branding_css']) ? 'yes' : 'no'); if (isset($_POST['prosports_branding_css_base'])) { // Save settings $base = !empty($_POST['prosports_branding_css_base']) ? sp_format_hex($_POST['prosports_branding_css_base']) : ''; $highlight = !empty($_POST['prosports_branding_css_highlight']) ? sp_format_hex($_POST['prosports_branding_css_highlight']) : ''; $notifications = !empty($_POST['prosports_branding_css_notifications']) ? sp_format_hex($_POST['prosports_branding_css_notifications']) : ''; $actions = !empty($_POST['prosports_branding_css_actions']) ? sp_format_hex($_POST['prosports_branding_css_actions']) : ''; $text = !empty($_POST['prosports_branding_css_text']) ? sp_format_hex($_POST['prosports_branding_css_text']) : ''; $colors = array('base' => $base, 'highlight' => $highlight, 'notifications' => $notifications, 'actions' => $actions, 'text' => $text); update_option('prosports_branding_css_colors', $colors); } }
/** * Save settings */ public function save() { if (isset($_POST['sportspress_sport']) && !empty($_POST['sportspress_sport']) && get_option('sportspress_sport', null) != $_POST['sportspress_sport']) { $sport = $_POST['sportspress_sport']; SP_Admin_Sports::apply_preset($sport); update_option('_sp_needs_welcome', 0); } if (isset($_POST['add_sample_data'])) { SP_Admin_Sample_Data::delete_posts(); SP_Admin_Sample_Data::insert_posts(); } $settings = $this->get_settings(); SP_Admin_Settings::save_fields($settings); // Map UTC+- timezones to gmt_offsets and set timezone_string to empty. if (!empty($_POST['timezone_string']) && preg_match('/^UTC[+-]/', $_POST['timezone_string'])) { $_POST['gmt_offset'] = $_POST['timezone_string']; $_POST['gmt_offset'] = preg_replace('/UTC\\+?/', '', $_POST['gmt_offset']); $_POST['timezone_string'] = ''; } if (isset($_POST['timezone_string'])) { update_option('timezone_string', $_POST['timezone_string']); } if (isset($_POST['gmt_offset'])) { update_option('gmt_offset', $_POST['gmt_offset']); } if (isset($_POST['sportspress_frontend_css_primary'])) { // Save settings $primary = !empty($_POST['sportspress_frontend_css_primary']) ? sp_format_hex($_POST['sportspress_frontend_css_primary']) : ''; $background = !empty($_POST['sportspress_frontend_css_background']) ? sp_format_hex($_POST['sportspress_frontend_css_background']) : ''; $text = !empty($_POST['sportspress_frontend_css_text']) ? sp_format_hex($_POST['sportspress_frontend_css_text']) : ''; $heading = !empty($_POST['sportspress_frontend_css_heading']) ? sp_format_hex($_POST['sportspress_frontend_css_heading']) : ''; $link = !empty($_POST['sportspress_frontend_css_link']) ? sp_format_hex($_POST['sportspress_frontend_css_link']) : ''; $customize = !empty($_POST['sportspress_frontend_css_customize']) ? 1 : ''; $colors = array('primary' => $primary, 'background' => $background, 'text' => $text, 'heading' => $heading, 'link' => $link, 'customize' => $customize); // Merge with existing options if available $options = get_option('themeboy'); if (is_array($options)) { $colors = array_merge($options, $colors); } update_option('themeboy', $colors); } }
/** * Include the settings page classes */ public static function get_settings_pages() { if (empty(self::$settings)) { $settings = array(); include_once 'class-sp-admin-sports.php'; include_once 'settings/class-sp-settings-page.php'; $settings[] = (include 'settings/class-sp-settings-general.php'); $settings[] = (include 'settings/class-sp-settings-events.php'); $settings[] = (include 'settings/class-sp-settings-teams.php'); $settings[] = (include 'settings/class-sp-settings-players.php'); $settings[] = (include 'settings/class-sp-settings-staff.php'); $settings = apply_filters('prosports_get_settings_pages', $settings); $settings[] = (include 'settings/class-sp-settings-text.php'); if (current_user_can('manage_options')) { $settings[] = (include 'settings/class-sp-settings-status.php'); } self::$settings = apply_filters('prosports_get_settings_config_pages', $settings); } return self::$settings; }
/** * Save settings */ public function save() { $settings = $this->get_settings(); SP_Admin_Settings::save_fields($settings); if (isset($_POST['sportspress_league_menu_teams'])) { $teams = $_POST['sportspress_league_menu_teams']; } else { $teams = array(); } update_option('sportspress_league_menu_teams', $teams); if (isset($_POST['sp_league_menu_logo_removed'])) { delete_option('sportspress_league_menu_logo'); } update_option('sportspress_league_menu_logo_width', sp_array_value($_POST, 'sportspress_league_menu_logo_width', 64)); update_option('sportspress_league_menu_logo_height', sp_array_value($_POST, 'sportspress_league_menu_logo_height', 32)); update_option('sportspress_league_menu_logo_bottom', sp_array_value($_POST, 'sportspress_league_menu_logo_bottom', 0)); update_option('sportspress_league_menu_logo_left', sp_array_value($_POST, 'sportspress_league_menu_logo_left', 0)); update_option('sportspress_league_menu_team_width', sp_array_value($_POST, 'sportspress_league_menu_team_width', 32)); update_option('sportspress_league_menu_team_height', sp_array_value($_POST, 'sportspress_league_menu_team_height', 32)); }
/** * Save settings */ public function save() { global $current_section; $settings = $this->get_settings(); SP_Admin_Settings::save_fields($settings); if ($current_section) { do_action('sportspress_update_options_' . $this->template . '_' . $current_section); } if (!empty($this->templates)) { update_option('sportspress_' . $this->template . '_template_order', sp_array_value($_POST, 'sportspress_' . $this->template . '_template_order', false)); } if (isset($_POST['sportspress_template_visibility']) && is_array($_POST['sportspress_template_visibility'])) { foreach ($_POST['sportspress_template_visibility'] as $option => $toggled) { if ($toggled) { update_option($option, 'yes'); } else { update_option($option, 'no'); } } } }
/** * Include the settings page classes */ public static function get_settings_pages() { if (empty(self::$settings)) { $settings = array(); include_once 'class-sp-admin-sports.php'; include_once 'settings/class-sp-settings-page.php'; $settings[] = (include 'settings/class-sp-settings-modules.php'); $settings[] = (include 'settings/class-sp-settings-general.php'); $settings[] = (include 'settings/class-sp-settings-events.php'); $settings[] = (include 'settings/class-sp-settings-teams.php'); $settings[] = (include 'settings/class-sp-settings-players.php'); $settings[] = (include 'settings/class-sp-settings-staff.php'); $settings = apply_filters('sportspress_get_settings_pages', $settings); $settings[] = (include 'settings/class-sp-settings-text.php'); if (!is_multisite() && current_user_can('manage_options') || is_multisite() && current_user_can('manage_network_options')) { $settings[] = (include 'settings/class-sp-settings-licenses.php'); } if (current_user_can('manage_options')) { $settings[] = (include 'settings/class-sp-settings-status.php'); } self::$settings = apply_filters('sportspress_get_settings_config_pages', $settings); } return self::$settings; }
/** * Output the about screen. */ public function about_screen() { include_once 'class-sp-admin-settings.php'; $class = 'chosen-select' . (is_rtl() ? ' chosen-rtl' : ''); ?> <div class="wrap about-wrap about-sportspress-wrap"> <?php $this->intro(); ?> <?php // Save settings if (isset($_POST['timezone_string'])) { update_option('timezone_string', $_POST['timezone_string']); update_option('sportspress_basic_setup', 1); } if (isset($_POST['sportspress_sport']) && !empty($_POST['sportspress_sport'])) { $sport = $_POST['sportspress_sport']; SP_Admin_Sports::apply_preset($sport); update_option('sportspress_sport', $_POST['sportspress_sport']); update_option('_sportspress_needs_welcome', 1); ?> <div id="message" class="updated sportspress-message"> <p><strong><?php _e('Your settings have been saved.', 'sportspress'); ?> </strong></p> </div> <?php } if (isset($_POST['add_sample_data'])) { SP_Admin_Sample_Data::delete_posts(); SP_Admin_Sample_Data::insert_posts(); } ?> <div class="sp-feature feature-section col two-col"> <div> <?php if (get_option('sportspress_basic_setup')) { ?> <h4><?php _e('Sport', 'sportspress'); ?> </h4> <?php $sport = get_option('sportspress_sport'); $sport_options = SP_Admin_Sports::get_preset_options(); foreach ($sport_options as $options) { foreach ($options as $slug => $name) { if ($sport === $slug) { $sport = $name; break; } } } echo $sport; ?> <a href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'sportspress', 'tab' => 'general'), 'admin.php'))); ?> "><i class="dashicons dashicons-edit"></i> <?php _e('Change', 'sportspress'); ?> </a> <h4><?php _e('Next Steps', 'sportspress'); ?> </h4> <p><?php _e('We’ve assembled some links to get you started:', 'sportspress'); ?> </p> <?php $steps = apply_filters('sportspress_next_steps', array('teams' => array('link' => admin_url(add_query_arg(array('post_type' => 'sp_team'), 'edit.php')), 'icon' => 'sp-icon-shield', 'label' => __('Add New Team', 'sportspress')), 'players' => array('link' => admin_url(add_query_arg(array('post_type' => 'sp_player'), 'edit.php')), 'icon' => 'sp-icon-tshirt', 'label' => __('Add New Player', 'sportspress')), 'events' => array('link' => admin_url(add_query_arg(array('post_type' => 'sp_event'), 'edit.php')), 'icon' => 'sp-icon-calendar', 'label' => __('Add New Event', 'sportspress')))); ?> <?php if (sizeof($steps)) { ?> <div class="sportspress-steps"> <ul> <?php foreach ($steps as $step) { ?> <li><a href="<?php echo esc_url($step['link']); ?> " class="welcome-icon sp-welcome-icon"><i class="<?php echo sp_array_value($step, 'icon'); ?> "></i> <?php echo $step['label']; ?> </a></li> <?php } ?> </ul> </div> <?php } ?> <h4><?php _e('Settings', 'sportspress'); ?> </h4> <a href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'sportspress', 'tab' => 'general'), 'admin.php'))); ?> "><?php _e('Go to SportsPress Settings', 'sportspress'); ?> </a> <?php } else { ?> <form method="post" id="mainform" action="" enctype="multipart/form-data"> <h4><?php _e('Basic Setup', 'sportspress'); ?> </h4> <p><?php _e('Select your timezone and sport to get started.', 'sportspress'); ?> </p> <table class="form-table"> <tbody> <tr valign="top"> <th scope="row" class="titledesc"> <label for="timezone_string"><?php _e('Timezone', 'sportspress'); ?> <i class="dashicons dashicons-editor-help sp-desc-tip" title="<?php _e('Choose a city in the same timezone as you.', 'sportspress'); ?> "></i></label> </th> <td> <select id="timezone_string" name="timezone_string" class="<?php echo $class; ?> "> <?php $current_offset = get_option('gmt_offset'); $tzstring = get_option('timezone_string'); $check_zone_info = true; // Remove old Etc mappings. Fallback to gmt_offset. if (false !== strpos($tzstring, 'Etc/GMT')) { $tzstring = ''; } if (empty($tzstring)) { // Create a UTC+- zone if no timezone string exists $check_zone_info = false; if (0 == $current_offset) { $tzstring = 'UTC+0'; } elseif ($current_offset < 0) { $tzstring = 'UTC' . $current_offset; } else { $tzstring = 'UTC+' . $current_offset; } } echo wp_timezone_choice($tzstring); ?> </select> </td> </tr> <?php $sport_options = SP_Admin_Sports::get_preset_options(); $settings = array(array('id' => 'sportspress_sport', 'default' => 'custom', 'type' => 'sport', 'title' => __('Sport', 'sportspress'), 'welcome' => true, 'class' => $class, 'options' => $sport_options)); SP_Admin_Settings::output_fields($settings); ?> </tbody> </table> <p class="submit sportspress-actions"> <input name="save" class="button-primary" type="submit" value="<?php _e('Save Changes', 'sportspress'); ?> " /> <input type="hidden" name="subtab" id="last_tab" /> <?php wp_nonce_field('sportspress-settings'); ?> </p> </form> <?php } ?> </div> <?php if (current_user_can('install_themes') && !current_theme_supports('sportspress')) { ?> <div class="last-feature"> <h4><?php _e('Free SportsPress Theme', 'sportspress'); ?> </h4> <a href="<?php echo add_query_arg(array('theme' => 'rookie'), network_admin_url('theme-install.php')); ?> " class="sp-theme-screenshot"><img src="<?php echo plugin_dir_url(SP_PLUGIN_FILE); ?> /assets/images/modules/rookie.png"></a> <p><?php _e('Have you tried the free Rookie theme yet?', 'sportspress'); ?> </p> <p><?php _e('Rookie is a free starter theme for SportsPress designed by ThemeBoy.', 'sportspress'); ?> </p> <p class="sp-module-actions"> <a class="button button-large" href="<?php echo add_query_arg(array('theme' => 'rookie'), network_admin_url('theme-install.php')); ?> "><?php _e('Install Now', 'sportspress'); ?> </a> </p> </div> <?php } ?> </div> </div> <?php }
/** * Default options * * Sets up the default options used on the settings page * * @access public */ function create_options() { // Include settings so that we can run through defaults include_once 'admin/class-sp-admin-settings.php'; $settings = SP_Admin_Settings::get_settings_pages(); foreach ($settings as $section) { foreach ($section->get_settings() as $value) { if (isset($value['default']) && isset($value['id'])) { $autoload = isset($value['autoload']) ? (bool) $value['autoload'] : true; add_option($value['id'], $value['default'], '', $autoload ? 'yes' : 'no'); } } } // Default color scheme add_option('sportspress_frontend_css_primary', '#2b353e'); add_option('sportspress_frontend_css_background', '#f4f4f4'); add_option('sportspress_frontend_css_text', '#222222'); add_option('sportspress_frontend_css_heading', '#ffffff'); add_option('sportspress_frontend_css_link', '#00a69c'); if (!get_option('sportspress_installed')) { // Configure default sport $sport = 'custom'; update_option('sportspress_sport', $sport); // Flag as installed update_option('sportspress_installed', 1); } }
/** * Deactivate license */ public function deactivate($id) { // return if a license key isn't set if (!isset($_POST['sp_license_key_' . $id])) { return; } // retrieve the license key $license = trim($_POST['sp_license_key_' . $id]); // get the name of the product $name = $this->licenses[$id]['name']; // data to send in our API request $api_params = array('edd_action' => 'deactivate_license', 'license' => $license, 'item_name' => urlencode($name), 'url' => home_url()); // Call the custom API. $response = wp_remote_post($this->licenses[$id]['url'], array('timeout' => 15, 'sslverify' => false, 'body' => $api_params)); // make sure the response came back okay if (is_wp_error($response)) { SP_Admin_Settings::add_error(__('Sorry, there has been an error.', 'sportspress')); return false; } // decode the license data $license_data = json_decode(wp_remote_retrieve_body($response)); // $license_data->license will be either "deactivated" or "failed" if ($license_data->license == 'deactivated') { delete_site_option('sportspress_' . $id . '_license_status'); SP_Admin_Settings::add_override(__('License deactivated.', 'sportspress')); } else { SP_Admin_Settings::add_error(__('Sorry, there has been an error.', 'sportspress')); } }
/** * Init the settings page */ public function settings_page() { include_once 'class-sp-admin-settings.php'; SP_Admin_Settings::output(); }
/** * Output the about screen. */ public function about_screen() { include_once 'class-sp-admin-settings.php'; $class = 'chosen-select' . (is_rtl() ? ' chosen-rtl' : ''); ?> <div class="wrap about-wrap about-sportspress-wrap"> <?php $this->intro(); ?> <?php // Save settings if (isset($_POST['timezone_string'])) { update_option('timezone_string', $_POST['timezone_string']); update_option('sportspress_basic_setup', 1); } if (isset($_POST['sportspress_sport']) && !empty($_POST['sportspress_sport'])) { $sport = $_POST['sportspress_sport']; SP_Admin_Sports::apply_preset($sport); update_option('sportspress_sport', $_POST['sportspress_sport']); update_option('sportspress_installed', 1); ?> <div id="message" class="updated sportspress-message"> <p><strong><?php _e('Your settings have been saved.', 'sportspress'); ?> </strong></p> </div> <?php } if (isset($_POST['add_sample_data'])) { SP_Admin_Sample_Data::delete_posts(); SP_Admin_Sample_Data::insert_posts(); } ?> <?php if (get_option('sportspress_installed')) { ?> <div class="headline-feature feature-video sp-fitvids" style="background-color:#191E23;"> <iframe width="990" height="557" src="https://www.youtube.com/embed/KQyga_C5a6M?rel=0&showinfo=0" frameborder="0" allowfullscreen></iframe> </div> <hr> <div class="feature-section three-col"> <h2>Event Organization</h2> <div class="col"> <img src="https://cdn-themeboy.netdna-ssl.com/wp-content/uploads/match-days.png" alt="Match Days"/> <h3>Match Days</h3> <p>A match day can be added to any event and displayed directly inside the event details section. It can also be used as a filter for shortcodes and widgets.</p> </div> <div class="col"> <img src="https://cdn-themeboy.netdna-ssl.com/wp-content/uploads/event-status.gif" alt="Event Status"/> <h3>Event Status</h3> <p>For undecided, postponed, and cancelled events, a status can be displayed in place of the time. Leave the status alone to display the actual time of the event.</p> </div> <div class="col"> <img src="https://cdn-themeboy.netdna-ssl.com/wp-content/uploads/box-score-minutes.png" alt="Box Score Minutes"/> <h3>Box Score Minutes</h3> <p>You can now can enter the time of goals or any other statistic for each player, and display them directly within the box score section of event pages.</p> </div> </div> <hr> <div class="feature-section three-col"> <h2>Layout Enhancements</h2> <div class="col"> <img src="https://cdn-themeboy.netdna-ssl.com/wp-content/uploads/template-tabs.gif" alt=""/> <h3>Template Tabs</h3> <p>Simply drag and drop any of the layout items to automatically group them into tabs. This will make your templates more compact and intuitive.</p> </div> <div class="col"> <img src="https://cdn-themeboy.netdna-ssl.com/wp-content/uploads/event-logo-options.png" alt=""/> <h3>Event Logo Options</h3> <p>Display the teams playing using an inline layout or as a block section, with logos on either side and the date and time/results in the middle.</p> </div> <div class="col"> <img src="https://cdn-themeboy.netdna-ssl.com/wp-content/uploads/player-profile-switching.png" alt=""/> <h3>Player Profile Switching</h3> <p>We also added a dropdown above the player details box which allows your visitors to quickly switch to another player's profile.</p> </div> </div> <hr /> <div class="changelog"> <h2>Under the Hood</h2> <div class="under-the-hood three-col"> <div class="col"> <h3>Fixtures Importer</h3> <p>A new, simpler importer has been added for quickly scheduling events. Supports CSV files generated by <a href="http://tboy.co/leaguelobster" target="_blank">LeagueLobster</a>.</p> </div> <div class="col"> <h3>Tutorials for Everyone</h3> <p>If you've enabled the Tutorials module, all SportsPress users will now be able to access them from the dashboard.</p> </div> <div class="col"> <h3>REST API Improvements</h3> <p>The REST API has been updated to support meta query vars, allowing you to retrieve data for a specific team or player.</p> </div> </div> </div> <a href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'sportspress', 'tab' => 'general'), 'admin.php'))); ?> "><?php _e('Go to SportsPress Settings', 'sportspress'); ?> </a> <?php } else { ?> <div class="sp-feature feature-section col two-col"> <div> <form method="post" id="mainform" action="" enctype="multipart/form-data"> <h4><?php _e('Basic Setup', 'sportspress'); ?> </h4> <p><?php _e('Select your timezone and sport to get started.', 'sportspress'); ?> </p> <table class="form-table"> <tbody> <tr valign="top"> <th scope="row" class="titledesc"> <label for="timezone_string"><?php _e('Timezone', 'sportspress'); ?> <i class="dashicons dashicons-editor-help sp-desc-tip" title="<?php _e('Choose a city in the same timezone as you.', 'sportspress'); ?> "></i></label> </th> <td> <select id="timezone_string" name="timezone_string" class="<?php echo $class; ?> "> <?php $current_offset = get_option('gmt_offset'); $tzstring = get_option('timezone_string'); $check_zone_info = true; // Remove old Etc mappings. Fallback to gmt_offset. if (false !== strpos($tzstring, 'Etc/GMT')) { $tzstring = ''; } if (empty($tzstring)) { // Create a UTC+- zone if no timezone string exists $check_zone_info = false; if (0 == $current_offset) { $tzstring = 'UTC+0'; } elseif ($current_offset < 0) { $tzstring = 'UTC' . $current_offset; } else { $tzstring = 'UTC+' . $current_offset; } } echo wp_timezone_choice($tzstring); ?> </select> </td> </tr> <?php $sport_options = SP_Admin_Sports::get_preset_options(); $settings = array(array('id' => 'sportspress_sport', 'default' => 'custom', 'type' => 'sport', 'title' => __('Sport', 'sportspress'), 'welcome' => true, 'class' => $class, 'options' => $sport_options)); SP_Admin_Settings::output_fields($settings); ?> </tbody> </table> <p class="submit sportspress-actions"> <input name="save" class="button-primary" type="submit" value="<?php _e('Save Changes', 'sportspress'); ?> " /> <input type="hidden" name="subtab" id="last_tab" /> <?php wp_nonce_field('sportspress-settings'); ?> </p> </form> </div> <?php if (current_user_can('install_themes') && !current_theme_supports('sportspress')) { ?> <div class="last-feature"> <h4><?php _e('Free SportsPress Theme', 'sportspress'); ?> </h4> <a href="<?php echo add_query_arg(array('theme' => 'rookie'), network_admin_url('theme-install.php')); ?> " class="sp-theme-screenshot"><img src="<?php echo plugin_dir_url(SP_PLUGIN_FILE); ?> /assets/images/modules/rookie.png"></a> <p><?php _e('Have you tried the free Rookie theme yet?', 'sportspress'); ?> </p> <p><?php _e('Rookie is a free starter theme for SportsPress designed by ThemeBoy.', 'sportspress'); ?> </p> <p class="sp-module-actions"> <a class="button button-large" href="<?php echo add_query_arg(array('theme' => 'rookie'), network_admin_url('theme-install.php')); ?> "><?php _e('Install Now', 'sportspress'); ?> </a> </p> </div> <?php } ?> </div> <?php } ?> </div> <?php }
/** * Save license key */ public function save() { if (!isset($_POST['sp_save_license'])) { return; } // Prevent default module saving remove_all_actions('sportspress_settings_save_modules'); unset($_POST['sportspress_update_modules']); // Detect license type $this->detect(); // Activate or deactivate license if (isset($_POST['sportspress_pro_license_key_deactivate'])) { $key = $_POST['sportspress_pro_license_key']; if ($key) { $url = 'https://app.sellwire.net/api/1/deactivate_license'; $args = array('license' => $key, 'file' => $this->file); $response = wp_remote_get(add_query_arg($args, $url), array('timeout' => 15, 'sslverify' => false)); if ($response && !is_wp_error($response)) { $body = sp_array_value($response, 'body', '{}'); $json = json_decode($body, true); if (array_key_exists('error', $json)) { SP_Admin_Settings::add_error($json['error']); } elseif (array_key_exists('license', $json)) { SP_Admin_Settings::add_override(__('License deactivated.', 'sportspress')); } delete_site_option('sportspress_pro_license_key'); update_site_option('sportspress_pro_license_status', 'deactivated'); } else { SP_Admin_Settings::add_error(__('Sorry, there has been an error.', 'sportspress')); } } } elseif (isset($_POST['sportspress_pro_license_key'])) { $key = $_POST['sportspress_pro_license_key']; if (!$key) { SP_Admin_Settings::add_error(__('License invalid.', 'sportspress')); return; } $url = 'https://app.sellwire.net/api/1/activate_license'; $args = array('license' => $key, 'file' => $this->file); $response = wp_remote_get(add_query_arg($args, $url), array('timeout' => 15, 'sslverify' => false)); if ($response && !is_wp_error($response)) { $body = sp_array_value($response, 'body', '{}'); $json = json_decode($body, true); if (array_key_exists('error', $json)) { SP_Admin_Settings::add_error($json['error']); } elseif (array_key_exists('license', $json)) { SP_Admin_Settings::add_override(__('License activated.', 'sportspress')); update_site_option('sportspress_pro_license_key', $_POST['sportspress_pro_license_key']); update_site_option('sportspress_pro_license_status', 'valid'); } } else { SP_Admin_Settings::add_error(__('Sorry, there has been an error.', 'sportspress')); } } else { SP_Admin_Settings::add_error(__('License invalid.', 'sportspress')); } }