Skip to content

Commit

Permalink
Adds check for minimum PHP version
Browse files Browse the repository at this point in the history
  • Loading branch information
fpcorso committed Jul 19, 2018
1 parent fff4743 commit 48dc994
Showing 1 changed file with 46 additions and 39 deletions.
85 changes: 46 additions & 39 deletions qsm-leaderboards.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@
* Description: Adds some basic leaderboards to Quiz And Survey Master
* Author: Frank Corso
* Author URI: https://quizandsurveymaster.com
* Version: 1.0.1
* Version: 1.0.2
*
* @author Frank Corso
* @version 1.0.1
* @version 1.0.2
*/

if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}

// If the PHP version is less then our minimum requirements, end.
if ( version_compare( PHP_VERSION, '5.4.0', '<' ) ) {
return;
}


/**
Expand All @@ -20,16 +27,16 @@
* When loaded, it loads the included plugin files and add functions to hooks or filters. The class also handles the admin menu
*
* @since 1.0.0
*/
*/
class QSM_Leaderboards {

/**
* Version Number
*
* @var string
* @since 1.0.0
*/
public $version = '1.0.1';
*/
public $version = '1.0.2';

/**
* Main Construct Function
Expand All @@ -40,8 +47,8 @@ class QSM_Leaderboards {
* @uses QSM_Leaderboards::load_dependencies() Loads required filed
* @uses QSM_Leaderboards::add_hooks() Adds actions to hooks and filters
* @return void
*/
function __construct() {
*/
public function __construct() {
$this->load_dependencies();
$this->add_hooks();
$this->check_license();
Expand All @@ -52,13 +59,13 @@ function __construct() {
*
* @since 1.0.0
* @return void
*/
*/
public function load_dependencies() {
include( "php/addon-settings-tab-content.php" );
include( "php/quiz-settings-tab-content.php" );
include( "php/leaderboard-function.php" );
include( "php/shortcodes.php" );
include( "php/widgets.php" );
include 'php/addon-settings-tab-content.php';
include 'php/quiz-settings-tab-content.php';
include 'php/leaderboard-function.php';
include 'php/shortcodes.php';
include 'php/widgets.php';
}

/**
Expand All @@ -68,14 +75,16 @@ public function load_dependencies() {
*
* @since 1.0.0
* @return void
*/
*/
public function add_hooks() {
add_action( 'init', array( $this, 'register_fields' ) );
add_action( 'init', array( $this, 'backwards_compatibility' ) );
add_action( 'init', array( $this, 'register_fields' ) );
add_action( 'init', array( $this, 'backwards_compatibility' ) );
add_action( 'admin_init', 'qsm_addon_leaderboards_register_quiz_settings_tabs' );
add_action( 'admin_init', 'qsm_addon_leaderboards_register_addon_settings_tabs' );
add_shortcode( 'qsm_leaderboard', 'qsm_addon_leaderboards_shortcode' );
add_action('widgets_init', create_function('', 'return register_widget("QSM_Leaderboards_Widget");') );
add_action( 'widgets_init', function() {
return register_widget( 'QSM_Leaderboards_Widget' );
});
}

/**
Expand Down Expand Up @@ -125,30 +134,29 @@ public function register_fields() {
*
* @since 1.0.0
* @return void
*/
*/
public function check_license() {

if( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) {
// load our custom updater
include( 'php/EDD_SL_Plugin_Updater.php' );
}
if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) {
// Loads our custom updater.
include 'php/EDD_SL_Plugin_Updater.php';
}

// retrieve our license key from the DB
$leaderboard_data = get_option( 'qsm_addon_leaderboard_settings', '' );
if ( isset( $leaderboard_data["license_key"] ) ) {
$license_key = trim( $leaderboard_data["license_key"] );
} else {
$license_key = '';
}
// Retrieves our license key from the DB.
$leaderboard_data = get_option( 'qsm_addon_leaderboard_settings', '' );
if ( isset( $leaderboard_data['license_key'] ) ) {
$license_key = trim( $leaderboard_data['license_key'] );
} else {
$license_key = '';
}

// setup the updater
// Sets up the updater.
$edd_updater = new EDD_SL_Plugin_Updater( 'https://quizandsurveymaster.com', __FILE__, array(
'version' => $this->version, // current version number
'license' => $license_key, // license key (used get_option above to retrieve from DB)
'item_name' => 'Leaderboards', // name of this plugin
'author' => 'Frank Corso' // author of this plugin
)
);
'version' => $this->version,
'license' => $license_key,
'item_name' => 'Leaderboards',
'author' => 'Frank Corso',
));
}
}

Expand All @@ -159,7 +167,7 @@ public function check_license() {
* @return void
*/
function qsm_addon_leaderboard_load() {
// Make sure QSM is active
// Makes sure QSM is active.
if ( class_exists( 'MLWQuizMasterNext' ) ) {
$qsm_leaderboards = new QSM_Leaderboards();
} else {
Expand All @@ -176,4 +184,3 @@ function qsm_addon_leaderboard_load() {
function qsm_addon_leaderboard_missing_qsm() {
echo '<div class="error"><p>QSM - Leaderboards requires Quiz And Survey Master. Please install and activate the Quiz And Survey Master plugin.</p></div>';
}
?>

0 comments on commit 48dc994

Please sign in to comment.