This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmlw_quizmaster2.php
273 lines (255 loc) · 8.13 KB
/
mlw_quizmaster2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
<?php
/**
* Plugin Name: Quiz Master Next
* Description: Use this plugin to add multiple quizzes, tests, or surveys to your website.
* Version: 4.5.1
* Author: Frank Corso
* Author URI: http://www.mylocalwebstop.com/
* Plugin URI: http://www.quizmasternext.com/
* Text Domain: quiz-master-next
* Domain Path: /languages
*
* @author Frank Corso
* @version 4.5.1
*/
if ( ! defined( 'ABSPATH' ) ) exit;
/**
* This class is the main class of the plugin
*
* When loaded, it loads the included plugin files and add functions to hooks or filters. The class also handles the admin menu
*
* @since 3.6.1
*/
class MLWQuizMasterNext
{
/**
* QMN Version Number
*
* @var string
* @since 4.0.0
*/
public $version = '4.5.1';
/**
* QMN Alert Manager Object
*
* @var object
* @since 3.7.1
*/
public $alertManager;
/**
* QMN Plugin Helper Object
*
* @var object
* @since 4.0.0
*/
public $pluginHelper;
/**
* QMN Quiz Creator Object
*
* @var object
* @since 3.7.1
*/
public $quizCreator;
/**
* QMN Log Manager Object
*
* @var object
* @since 4.5.0
*/
public $log_manager;
/**
* Main Construct Function
*
* Call functions within class
*
* @since 3.6.1
* @uses MLWQuizMasterNext::load_dependencies() Loads required filed
* @uses MLWQuizMasterNext::add_hooks() Adds actions to hooks and filters
* @return void
*/
public function __construct()
{
$this->load_dependencies();
$this->add_hooks();
}
/**
* Load File Dependencies
*
* @since 3.6.1
* @return void
*/
private function load_dependencies()
{
include("php/class-qmn-log-manager.php");
$this->log_manager = new QMN_Log_Manager;
if (is_admin())
{
include("php/qmn-stats-page.php");
include("php/qmn_quiz_admin.php");
include("php/qmn_quiz_options.php");
include("php/qmn_results.php");
include("php/qmn_results_details.php");
include("php/qmn_tools.php");
include("php/qmn_credits.php");
include("php/qmn_help.php");
include("php/qmn_dashboard_widgets.php");
include("php/qmn_options_questions_tab.php");
include("php/qmn_options_text_tab.php");
include("php/qmn_options_option_tab.php");
include("php/qmn_options_leaderboard_tab.php");
include("php/qmn_options_certificate_tab.php");
include("php/qmn_options_email_tab.php");
include("php/qmn_options_results_page_tab.php");
include("php/qmn_options_style_tab.php");
include("php/qmn_options_tools_tab.php");
include("php/qmn_options_preview_tab.php");
include("php/qmn_addons.php");
include("php/qmn_global_settings.php");
include("php/qmn_usage_tracking.php");
include("php/class-qmn-review-message.php");
}
include("php/qmn_quiz.php");
include("php/qmn_quiz_install.php");
include("php/qmn_leaderboard.php");
include("php/qmn_update.php");
include("php/qmn_widgets.php");
include("php/qmn_template_variables.php");
include("php/qmn_adverts.php");
include("php/qmn_question_types.php");
include("php/qmn-default-templates.php");
include("php/qmn_alerts.php");
$this->alertManager = new MlwQmnAlertManager();
include("php/qmn_quiz_creator.php");
$this->quizCreator = new QMNQuizCreator();
include("php/qmn_helper.php");
$this->pluginHelper = new QMNPluginHelper();
}
/**
* Add Hooks
*
* Adds functions to relavent hooks and filters
*
* @since 3.6.1
* @return void
*/
private function add_hooks()
{
add_action('admin_menu', array( $this, 'setup_admin_menu'));
add_action('admin_head', array( $this, 'admin_head'), 900);
add_action('admin_init', 'mlw_quiz_update');
add_action('widgets_init', create_function('', 'return register_widget("Mlw_Qmn_Leaderboard_Widget");'));
add_shortcode('mlw_quizmaster_leaderboard', 'mlw_quiz_leaderboard_shortcode');
add_action('plugins_loaded', array( $this, 'setup_translations'));
add_action('init', array( $this, 'register_quiz_post_types'));
}
/**
* Creates Custom Quiz Post Type
*
* @since 4.1.0
* @return void
*/
public function register_quiz_post_types()
{
$quiz_labels = array(
'name' => 'Quizzes',
'singular_name' => 'Quiz',
'menu_name' => 'Quiz',
'name_admin_bar' => 'Quiz',
'add_new' => 'Add New',
'add_new_item' => 'Add New Quiz',
'new_item' => 'New Quiz',
'edit_item' => 'Edit Quiz',
'view_item' => 'View Quiz',
'all_items' => 'All Quizzes',
'search_items' => 'Search Quizzes',
'parent_item_colon' => 'Parent Quiz:',
'not_found' => 'No Quiz Found',
'not_found_in_trash' => 'No Quiz Found In Trash'
);
$has_archive = true;
$exclude_search = false;
$cpt_slug = 'quiz';
$settings = (array) get_option( 'qmn-settings' );
if (isset($settings['cpt_archive']) && $settings['cpt_archive'] == '1')
{
$has_archive = false;
}
if (isset($settings['cpt_search']) && $settings['cpt_search'] == '1')
{
$exclude_search = true;
}
if (isset($settings['cpt_slug']))
{
$cpt_slug = trim(strtolower(str_replace(" ", "-", $settings['cpt_slug'])));
}
$quiz_args = array(
'show_ui' => false,
'show_in_nav_menus' => true,
'labels' => $quiz_labels,
'publicly_queryable' => true,
'exclude_from_search' => $exclude_search,
'label' => 'Quizzes',
'rewrite' => array('slug' => $cpt_slug),
'has_archive' => $has_archive,
'supports' => array( 'title', 'author', 'comments' )
);
register_post_type( 'quiz', $quiz_args );
}
/**
* Setup Admin Menu
*
* Creates the admin menu and pages for the plugin and attaches functions to them
*
* @since 3.6.1
* @return void
*/
public function setup_admin_menu()
{
if (function_exists('add_menu_page'))
{
add_menu_page('Quiz Master Next', __('Quizzes', 'quiz-master-next'), 'moderate_comments', __FILE__, 'mlw_generate_quiz_admin', 'dashicons-feedback');
add_submenu_page(__FILE__, __('Quiz Settings', 'quiz-master-next'), __('Quiz Settings', 'quiz-master-next'), 'moderate_comments', 'mlw_quiz_options', 'mlw_generate_quiz_options');
add_submenu_page(__FILE__, __('Quiz Results', 'quiz-master-next'), __('Quiz Results', 'quiz-master-next'), 'moderate_comments', 'mlw_quiz_results', 'mlw_generate_quiz_results');
add_submenu_page(__FILE__, __('Quiz Result Details', 'quiz-master-next'), __('Quiz Result Details', 'quiz-master-next'), 'moderate_comments', 'mlw_quiz_result_details', 'mlw_generate_result_details');
add_submenu_page(__FILE__, __('Settings', 'quiz-master-next'), __('Settings', 'quiz-master-next'), 'manage_options', 'qmn_global_settings', array('QMNGlobalSettingsPage', 'display_page'));
add_submenu_page(__FILE__, __('Tools', 'quiz-master-next'), __('Tools', 'quiz-master-next'), 'manage_options', 'mlw_quiz_tools', 'mlw_generate_quiz_tools');
add_submenu_page(__FILE__, __('Stats', 'quiz-master-next'), __('Stats', 'quiz-master-next'), 'moderate_comments', 'qmn_stats', 'qmn_generate_stats_page');
add_submenu_page(__FILE__, __('Addon Settings', 'quiz-master-next'), __('Addon Settings', 'quiz-master-next'), 'manage_options', 'qmn_addons', 'qmn_addons_page');
add_submenu_page(__FILE__, __('Help', 'quiz-master-next'), __('Help', 'quiz-master-next'), 'moderate_comments', 'mlw_quiz_help', 'mlw_generate_help_page');
add_dashboard_page(
__( 'QMN About', 'quiz' ),
__( 'QMN About', 'quiz' ),
'manage_options',
'mlw_qmn_about',
'mlw_generate_about_page'
);
}
}
/**
* Removes Unnecessary Admin Page
*
* Removes the update, quiz settings, and quiz results pages from the Quiz Menu
*
* @since 4.1.0
* @return void
*/
public function admin_head()
{
remove_submenu_page( 'index.php', 'mlw_qmn_about' );
remove_submenu_page( 'quiz-master-next/mlw_quizmaster2.php', 'mlw_quiz_options' );
remove_submenu_page( 'quiz-master-next/mlw_quizmaster2.php', 'mlw_quiz_result_details' );
}
/**
* Loads the plugin language files
*
* @since 3.6.1
* @return void
*/
public function setup_translations()
{
load_plugin_textdomain( 'quiz-master-next', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
}
$mlwQuizMasterNext = new MLWQuizMasterNext();
register_activation_hook( __FILE__, 'mlw_quiz_activate');
?>