diff --git a/qsm-leaderboards.php b/qsm-leaderboards.php index 8e1d778..99e3270 100644 --- a/qsm-leaderboards.php +++ b/qsm-leaderboards.php @@ -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; +} /** @@ -20,7 +27,7 @@ * 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 { /** @@ -28,8 +35,8 @@ class QSM_Leaderboards { * * @var string * @since 1.0.0 - */ - public $version = '1.0.1'; + */ + public $version = '1.0.2'; /** * Main Construct Function @@ -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(); @@ -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'; } /** @@ -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' ); + }); } /** @@ -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', + )); } } @@ -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 { @@ -176,4 +184,3 @@ function qsm_addon_leaderboard_load() { function qsm_addon_leaderboard_missing_qsm() { echo '
QSM - Leaderboards requires Quiz And Survey Master. Please install and activate the Quiz And Survey Master plugin.