PluginProbe
TutorMate / 3.0.1
TutorMate v3.0.1
3.0.3 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 3.0.0 3.0.1 3.0.2
tutormate / tutormate.php

tutormate.php in TutorMate 3.0.1, at tutormate.php

110 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: TutorMate
4 * Description: Companion demo importer plugin for TutorStarter theme.
5 * Version: 3.0.1
6 * Author: Themeum
7 * Author URI: https://www.themeum.com
8 * Tags: demo, import, content, data
9 * Requires at least: 5.3
10 * Tested up to: 6.7
11 * Requires PHP: 7.0
12 * License: GNU General Public License v3 or later
13 * License URI: http://www.gnu.org/licenses/gpl-3.0.html
14 * Text Domain: tutormate
15 * Domain Path: /languages
16 *
17 * @package tutormate
18 */
19
20 use TUTORMATE\DemoImporter;
21 use TUTORMATE\Enqueue;
22
23 defined( 'ABSPATH' ) || exit;
24
25 /**
26 * Main plugin class with initialization tasks.
27 */
28 class TUTORMATE_Plugin {
29
30 /**
31 * Constructor for this class.
32 */
33 public function __construct() {
34
35 /**
36 * Display admin error message if PHP version is older than 5.3.2.
37 * Otherwise execute the main plugin class.
38 */
39 if ( version_compare( phpversion(), '5.3.2', '<' ) ) {
40 add_action( 'admin_notices', array( $this, 'old_php_admin_error_notice' ) );
41 } else {
42 // Set plugin constants.
43 $this->set_plugin_constants();
44
45 // Composer autoloader.
46 require_once TUTORMATE_PATH . 'vendor/autoload.php';
47
48 new DemoImporter();
49 new Enqueue();
50
51 }
52 }
53
54 /**
55 * Display an admin error notice when PHP is older the version 5.3.2.
56 * Hook it to the 'admin_notices' action.
57 */
58 public function old_php_admin_error_notice() {
59 $message = sprintf(
60 esc_html__(
61 'The %2$sTutormate%3$s plugin requires %2$sPHP 5.3.2+%3$s to run properly. Please contact your hosting company and ask them to update the PHP version of your site to at least PHP 5.3.2.%4$s Your current version of PHP: %2$s%1$s%3$s',
62 'tutormate'
63 ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
64 phpversion(),
65 '<strong>',
66 '</strong>',
67 '<br>'
68 );
69 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
70
71 printf( '<div class="notice notice-error"><p>%1$s</p></div>', wp_kses_post( $message ) );
72 }
73
74 /**
75 * Set plugin constants.
76 *
77 * Path/URL to root of this plugin, with trailing slash and plugin version.
78 */
79 private function set_plugin_constants() {
80 // Path/URL to root of this plugin, with trailing slash.
81 if ( ! defined( 'TUTORMATE_PATH' ) ) {
82 define( 'TUTORMATE_PATH', plugin_dir_path( __FILE__ ) );
83 }
84 if ( ! defined( 'TUTORMATE_URL' ) ) {
85 define( 'TUTORMATE_URL', plugin_dir_url( __FILE__ ) );
86 }
87
88 // Action hook to set the plugin version constant.
89 add_action( 'admin_init', array( $this, 'set_plugin_version_constant' ) );
90 }
91
92 /**
93 * Set plugin version constant -> TUTORMATE_VERSION.
94 */
95 public function set_plugin_version_constant() {
96 if ( ! defined( 'TUTORMATE_VERSION' ) ) {
97 $plugin_data = get_plugin_data( __FILE__ );
98 define( 'TUTORMATE_VERSION', $plugin_data['Version'] );
99 }
100 }
101 }
102
103 // Check if TutorStarter is active.
104 $theme = wp_get_theme();
105
106 if ( 'tutorstarter' === $theme->get( 'TextDomain' ) ) :
107 // Instantiate the plugin class.
108 $tutormate_plugin = new TUTORMATE_Plugin();
109 endif;
110