| @@ -1,673 +1,231 @@ | ||
| 1 | 1 | <?php |
| 2 | -/** | |
| 3 | - * Initialize all the dependency classes | |
| 4 | - * | |
| 5 | - * @package Tutor | |
| 6 | - * @author Themeum <support@themeum.com> | |
| 7 | - * @link https://themeum.com | |
| 8 | - * @since 1.0.0 | |
| 9 | - */ | |
| 10 | - | |
| 11 | 2 | namespace TUTOR; |
| 12 | 3 | |
| 13 | -use Tutor\Models\CourseModel; | |
| 14 | -use Tutor\Ecommerce\Ecommerce; | |
| 15 | -use Tutor\Helpers\QueryHelper; | |
| 16 | -use Tutor\Migrations\Migration; | |
| 17 | - | |
| 18 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 4 | +if ( ! defined( 'ABSPATH' ) ) | |
| 19 | 5 | exit; |
| 20 | -} | |
| 21 | 6 | |
| 22 | -/** | |
| 23 | - * Tutor final class | |
| 24 | - * | |
| 25 | - * @since 1.0.0 | |
| 26 | - */ | |
| 27 | -final class Tutor extends Singleton { | |
| 28 | - /** | |
| 29 | - * Tutor version | |
| 30 | - * | |
| 31 | - * @since 1.0.0 | |
| 32 | - * | |
| 33 | - * @var string | |
| 34 | - */ | |
| 7 | +final class Tutor{ | |
| 35 | 8 | public $version = TUTOR_VERSION; |
| 36 | - | |
| 37 | - /** | |
| 38 | - * Plugin dir path | |
| 39 | - * | |
| 40 | - * @since 1.0.0 | |
| 41 | - * | |
| 42 | - * @var string | |
| 43 | - */ | |
| 44 | 9 | public $path; |
| 45 | - | |
| 46 | - /** | |
| 47 | - * Plugin dir path | |
| 48 | - * | |
| 49 | - * @since 1.0.0 | |
| 50 | - * | |
| 51 | - * @var string | |
| 52 | - */ | |
| 53 | 10 | public $url; |
| 11 | + public $basename; | |
| 54 | 12 | |
| 55 | 13 | /** |
| 56 | - * Plugin dir name | |
| 14 | + * The single instance of the class. | |
| 57 | 15 | * |
| 58 | - * @since 1.0.0 | |
| 59 | - * | |
| 60 | - * @var string | |
| 16 | + * @since v.1.2.0 | |
| 61 | 17 | */ |
| 62 | - public $basename; | |
| 18 | + protected static $_instance = null; | |
| 63 | 19 | |
| 64 | - /** | |
| 65 | - * Utils class object | |
| 66 | - * | |
| 67 | - * @since 1.1.0 | |
| 68 | - * | |
| 69 | - * @var object | |
| 70 | - */ | |
| 20 | + //Components | |
| 71 | 21 | public $utils; |
| 72 | - | |
| 73 | - /** | |
| 74 | - * Admin class object | |
| 75 | - * | |
| 76 | - * @since 1.1.0 | |
| 77 | - * | |
| 78 | - * @var object | |
| 79 | - */ | |
| 80 | 22 | public $admin; |
| 81 | - | |
| 82 | - /** | |
| 83 | - * Ajax class object | |
| 84 | - * | |
| 85 | - * @since 1.1.0 | |
| 86 | - * | |
| 87 | - * @var object | |
| 88 | - */ | |
| 89 | 23 | public $ajax; |
| 90 | - | |
| 91 | - /** | |
| 92 | - * Options class object | |
| 93 | - * | |
| 94 | - * @since 1.1.0 | |
| 95 | - * | |
| 96 | - * @var object | |
| 97 | - */ | |
| 98 | 24 | public $options; |
| 99 | - | |
| 100 | - /** | |
| 101 | - * Short code class object | |
| 102 | - * | |
| 103 | - * @since 1.1.0 | |
| 104 | - * | |
| 105 | - * @var object | |
| 106 | - */ | |
| 107 | 25 | public $shortcode; |
| 108 | 26 | |
| 109 | - /** | |
| 110 | - * Addons class object | |
| 111 | - * | |
| 112 | - * @since 1.1.0 | |
| 113 | - * | |
| 114 | - * @var object | |
| 115 | - */ | |
| 116 | 27 | private $addons; |
| 117 | - | |
| 118 | - /** | |
| 119 | - * PostType class object | |
| 120 | - * | |
| 121 | - * @since 1.1.0 | |
| 122 | - * | |
| 123 | - * @var object | |
| 124 | - */ | |
| 125 | 28 | private $post_types; |
| 126 | - | |
| 127 | - /** | |
| 128 | - * Taxonomies class object | |
| 129 | - * | |
| 130 | - * @since 1.1.0 | |
| 131 | - * | |
| 132 | - * @var object | |
| 133 | - */ | |
| 134 | 29 | private $taxonomies; |
| 135 | - | |
| 136 | - /** | |
| 137 | - * Assets class object | |
| 138 | - * | |
| 139 | - * @since 1.1.0 | |
| 140 | - * | |
| 141 | - * @var object | |
| 142 | - */ | |
| 143 | 30 | private $assets; |
| 144 | - | |
| 145 | - /** | |
| 146 | - * Course class object | |
| 147 | - * | |
| 148 | - * @since 1.1.0 | |
| 149 | - * | |
| 150 | - * @var object | |
| 151 | - */ | |
| 152 | 31 | private $course; |
| 153 | - | |
| 154 | - /** | |
| 155 | - * Lesson class object | |
| 156 | - * | |
| 157 | - * @since 1.1.0 | |
| 158 | - * | |
| 159 | - * @var object | |
| 160 | - */ | |
| 161 | - public $lesson; | |
| 162 | - | |
| 163 | - /** | |
| 164 | - * Rewrite_Rules class object | |
| 165 | - * | |
| 166 | - * @since 1.1.0 | |
| 167 | - * | |
| 168 | - * @var object | |
| 169 | - */ | |
| 32 | + private $lesson; | |
| 170 | 33 | private $rewrite_rules; |
| 171 | - | |
| 172 | - /** | |
| 173 | - * Template class object | |
| 174 | - * | |
| 175 | - * @since 1.1.0 | |
| 176 | - * | |
| 177 | - * @var object | |
| 178 | - */ | |
| 179 | 34 | private $template; |
| 180 | - | |
| 181 | - /** | |
| 182 | - * Instructor class object | |
| 183 | - * | |
| 184 | - * @since 1.1.0 | |
| 185 | - * | |
| 186 | - * @var object | |
| 187 | - */ | |
| 188 | 35 | private $instructor; |
| 189 | - | |
| 190 | - /** | |
| 191 | - * Student class object | |
| 192 | - * | |
| 193 | - * @since 1.1.0 | |
| 194 | - * | |
| 195 | - * @var object | |
| 196 | - */ | |
| 197 | 36 | private $student; |
| 198 | - | |
| 199 | - /** | |
| 200 | - * Q_And_A class object | |
| 201 | - * | |
| 202 | - * @since 1.1.0 | |
| 203 | - * | |
| 204 | - * @var object | |
| 205 | - */ | |
| 206 | 37 | private $q_and_a; |
| 207 | - | |
| 208 | - /** | |
| 209 | - * Quiz class object | |
| 210 | - * | |
| 211 | - * @since 1.1.0 | |
| 212 | - * | |
| 213 | - * @var object | |
| 214 | - */ | |
| 215 | 38 | private $quiz; |
| 216 | - | |
| 217 | - /** | |
| 218 | - * Tools class object | |
| 219 | - * | |
| 220 | - * @since 1.1.0 | |
| 221 | - * | |
| 222 | - * @var object | |
| 223 | - */ | |
| 224 | 39 | private $tools; |
| 225 | - | |
| 226 | - /** | |
| 227 | - * User class object | |
| 228 | - * | |
| 229 | - * @since 1.1.0 | |
| 230 | - * | |
| 231 | - * @var object | |
| 232 | - */ | |
| 233 | 40 | private $user; |
| 234 | - | |
| 235 | - /** | |
| 236 | - * Theme_Compatibility class object | |
| 237 | - * | |
| 238 | - * @since 1.1.0 | |
| 239 | - * | |
| 240 | - * @var object | |
| 241 | - */ | |
| 242 | 41 | private $theme_compatibility; |
| 243 | - | |
| 244 | - /** | |
| 245 | - * Gutenberg class object | |
| 246 | - * | |
| 247 | - * @since 1.1.0 | |
| 248 | - * | |
| 249 | - * @var object | |
| 250 | - */ | |
| 251 | 42 | private $gutenberg; |
| 252 | - | |
| 253 | - /** | |
| 254 | - * Course_Settings_Tabs class object | |
| 255 | - * | |
| 256 | - * @since 1.1.0 | |
| 257 | - * | |
| 258 | - * @var object | |
| 259 | - */ | |
| 260 | 43 | private $course_settings_tabs; |
| 261 | - | |
| 262 | - /** | |
| 263 | - * Withdraw class object | |
| 264 | - * | |
| 265 | - * @since 1.1.0 | |
| 266 | - * | |
| 267 | - * @var object | |
| 268 | - */ | |
| 269 | 44 | private $withdraw; |
| 270 | 45 | |
| 271 | - /** | |
| 272 | - * Course_Widget class object | |
| 273 | - * | |
| 274 | - * @since 1.1.0 | |
| 275 | - * | |
| 276 | - * @var object | |
| 277 | - */ | |
| 278 | 46 | private $course_widget; |
| 279 | - | |
| 280 | - /** | |
| 281 | - * Upgrader class object | |
| 282 | - * | |
| 283 | - * @since 1.1.0 | |
| 284 | - * | |
| 285 | - * @var object | |
| 286 | - */ | |
| 287 | 47 | private $upgrader; |
| 288 | - | |
| 289 | - /** | |
| 290 | - * Dashboard class object | |
| 291 | - * | |
| 292 | - * @since 1.1.0 | |
| 293 | - * | |
| 294 | - * @var object | |
| 295 | - */ | |
| 296 | 48 | private $dashboard; |
| 297 | - | |
| 298 | - /** | |
| 299 | - * FormHandler class object | |
| 300 | - * | |
| 301 | - * @since 1.1.0 | |
| 302 | - * | |
| 303 | - * @var object | |
| 304 | - */ | |
| 305 | 49 | private $form_handler; |
| 306 | - | |
| 307 | - /** | |
| 308 | - * Frontend class object | |
| 309 | - * | |
| 310 | - * @since 1.1.0 | |
| 311 | - * | |
| 312 | - * @var object | |
| 313 | - */ | |
| 314 | 50 | private $frontend; |
| 315 | - | |
| 316 | - /** | |
| 317 | - * Email property | |
| 318 | - * | |
| 319 | - * @since 1.1.0 | |
| 320 | - * | |
| 321 | - * @var object | |
| 322 | - */ | |
| 323 | 51 | private $email; |
| 324 | 52 | |
| 325 | - /** | |
| 326 | - * WooCommerce integration class object | |
| 327 | - * | |
| 328 | - * @since 1.1.0 | |
| 329 | - * | |
| 330 | - * @var object | |
| 331 | - */ | |
| 53 | + //Integrations | |
| 332 | 54 | private $woocommerce; |
| 333 | - | |
| 334 | - /** | |
| 335 | - * Tutor_EDD class object | |
| 336 | - * | |
| 337 | - * @since 1.1.0 | |
| 338 | - * | |
| 339 | - * @var object | |
| 340 | - */ | |
| 341 | 55 | private $edd; |
| 342 | 56 | |
| 343 | 57 | /** |
| 344 | - * Announcement | |
| 58 | + * @return null|Tutor | |
| 345 | 59 | * |
| 346 | - * @since 2.0.0 | |
| 60 | + * Run the TUTOR | |
| 347 | 61 | * |
| 348 | - * @var object | |
| 62 | + * @since 1.2.0 | |
| 349 | 63 | */ |
| 350 | - public $announcements; | |
| 64 | + public static function instance() { | |
| 65 | + if ( is_null( self::$_instance ) ) { | |
| 66 | + self::$_instance = new self(); | |
| 67 | + } | |
| 68 | + return self::$_instance; | |
| 69 | + } | |
| 351 | 70 | |
| 352 | - /** | |
| 353 | - * Reviews class object | |
| 354 | - * | |
| 355 | - * @since 1.1.0 | |
| 356 | - * | |
| 357 | - * @var object | |
| 358 | - */ | |
| 359 | - private $reviews; | |
| 71 | + function __construct() { | |
| 360 | 72 | |
| 361 | - /** | |
| 362 | - * Withdraw_List class object | |
| 363 | - * | |
| 364 | - * @since 1.1.0 | |
| 365 | - * | |
| 366 | - * @var object | |
| 367 | - */ | |
| 368 | - public $withdraw_list; | |
| 73 | + $this->path = plugin_dir_path(TUTOR_FILE); | |
| 74 | + $this->url = plugin_dir_url(TUTOR_FILE); | |
| 75 | + $this->basename = plugin_basename(TUTOR_FILE); | |
| 369 | 76 | |
| 370 | - /** | |
| 371 | - * Student_List class object | |
| 372 | - * | |
| 373 | - * @since 1.1.0 | |
| 374 | - * | |
| 375 | - * @var object | |
| 376 | - */ | |
| 377 | - public $student_list; | |
| 378 | - | |
| 379 | - /** | |
| 380 | - * Instructor_List class object | |
| 381 | - * | |
| 382 | - * @since 1.1.0 | |
| 383 | - * | |
| 384 | - * @var object | |
| 385 | - */ | |
| 386 | - public $instructor_list; | |
| 387 | - | |
| 388 | - /** | |
| 389 | - * Course List | |
| 390 | - * | |
| 391 | - * @var Course_List | |
| 392 | - * | |
| 393 | - * @since 2.0.0 | |
| 394 | - */ | |
| 395 | - public $course_list; | |
| 396 | - | |
| 397 | - //phpcs:disable | |
| 398 | - public $q_and_a_list; | |
| 399 | - public $q_attempt; | |
| 400 | - public $rest_api; | |
| 401 | - public $setup; | |
| 402 | - public $private_course_access; | |
| 403 | - public $course_filter; | |
| 404 | - //phpcs:enable | |
| 405 | - | |
| 406 | - /** | |
| 407 | - * Course Embed | |
| 408 | - * | |
| 409 | - * @var $course_embed | |
| 410 | - * | |
| 411 | - * @since 2.1.0 | |
| 412 | - */ | |
| 413 | - private $course_embed; | |
| 414 | - | |
| 415 | - /** | |
| 416 | - * Rest Authentication | |
| 417 | - * | |
| 418 | - * @var $rest_auth | |
| 419 | - * | |
| 420 | - * @since 2.1.0 | |
| 421 | - */ | |
| 422 | - private $rest_auth; | |
| 423 | - | |
| 424 | - /** | |
| 425 | - * Permalink | |
| 426 | - * | |
| 427 | - * @var Permalink | |
| 428 | - */ | |
| 429 | - private $permalink; | |
| 430 | - | |
| 431 | - /** | |
| 432 | - * Initialize props & other dependencies | |
| 433 | - * | |
| 434 | - * @since 1.0.0 | |
| 435 | - */ | |
| 436 | - public function __construct() { | |
| 437 | - | |
| 438 | - $this->path = plugin_dir_path( TUTOR_FILE ); | |
| 439 | - $this->url = plugin_dir_url( TUTOR_FILE ); | |
| 440 | - $this->basename = plugin_basename( TUTOR_FILE ); | |
| 441 | - | |
| 442 | 77 | /** |
| 443 | 78 | * Adding Tutor Database table to $wpdb; |
| 444 | - * | |
| 445 | - * @since 1.4.2 | |
| 79 | + * @since v.1.4.2 | |
| 446 | 80 | */ |
| 447 | 81 | global $wpdb; |
| 448 | - $wpdb->tutor_earnings = $wpdb->prefix . 'tutor_earnings'; | |
| 449 | - $wpdb->tutor_gradebooks = $wpdb->prefix . 'tutor_gradebooks'; | |
| 450 | - $wpdb->tutor_gradebooks_results = $wpdb->prefix . 'tutor_gradebooks_results'; | |
| 451 | - $wpdb->tutor_quiz_attempts = $wpdb->prefix . 'tutor_quiz_attempts'; | |
| 452 | - $wpdb->tutor_quiz_attempt_answers = $wpdb->prefix . 'tutor_quiz_attempt_answers'; | |
| 453 | - $wpdb->tutor_quiz_questions = $wpdb->prefix . 'tutor_quiz_questions'; | |
| 454 | - $wpdb->tutor_quiz_question_answers = $wpdb->prefix . 'tutor_quiz_question_answers'; | |
| 455 | - $wpdb->tutor_withdraws = $wpdb->prefix . 'tutor_withdraws'; | |
| 456 | - $wpdb->tutor_email_queue = $wpdb->prefix . 'tutor_email_queue'; | |
| 457 | - $wpdb->tutor_order_items = $wpdb->prefix . 'tutor_order_items'; | |
| 458 | - $wpdb->tutor_orders = $wpdb->prefix . 'tutor_orders'; | |
| 459 | - $wpdb->tutor_ordermeta = $wpdb->prefix . 'tutor_ordermeta'; | |
| 460 | - $wpdb->tutor_subscription_plan_items = $wpdb->prefix . 'tutor_subscription_plan_items'; | |
| 461 | - $wpdb->tutor_subscription_plans = $wpdb->prefix . 'tutor_subscription_plans'; | |
| 462 | - $wpdb->tutor_subscriptions = $wpdb->prefix . 'tutor_subscriptions'; | |
| 463 | - $wpdb->tutor_subscriptionmeta = $wpdb->prefix . 'tutor_subscriptionmeta'; | |
| 464 | - $wpdb->tutor_order_itemmeta = $wpdb->prefix . 'tutor_order_itemmeta'; | |
| 82 | + $wpdb->tutor_earnings = $wpdb->prefix.'tutor_earnings'; | |
| 83 | + $wpdb->tutor_gradebooks = $wpdb->prefix.'tutor_gradebooks'; | |
| 84 | + $wpdb->tutor_gradebooks_results = $wpdb->prefix.'tutor_gradebooks_results'; | |
| 85 | + $wpdb->tutor_quiz_attempts = $wpdb->prefix.'tutor_quiz_attempts'; | |
| 86 | + $wpdb->tutor_quiz_attempt_answers = $wpdb->prefix.'tutor_quiz_attempt_answers'; | |
| 87 | + $wpdb->tutor_quiz_questions = $wpdb->prefix.'tutor_quiz_questions'; | |
| 88 | + $wpdb->tutor_quiz_question_answers = $wpdb->prefix.'tutor_quiz_question_answers'; | |
| 89 | + $wpdb->tutor_withdraws = $wpdb->prefix.'tutor_withdraws'; | |
| 90 | + $wpdb->tutor_email_queue = $wpdb->prefix.'tutor_email_queue'; | |
| 465 | 91 | |
| 466 | 92 | /** |
| 467 | 93 | * Changing default wp doing ajax return based on tutor ajax action |
| 468 | 94 | */ |
| 469 | - add_filter( 'wp_doing_ajax', array( $this, 'wp_doing_ajax' ) ); | |
| 95 | + add_filter('wp_doing_ajax', array($this, 'wp_doing_ajax')); | |
| 470 | 96 | |
| 471 | 97 | /** |
| 472 | 98 | * Include Files |
| 473 | 99 | */ |
| 100 | + //add_action( 'init', array( $this, 'includes' ), 11 ); | |
| 474 | 101 | $this->includes(); |
| 475 | 102 | |
| 476 | - do_action( 'tutor_before_load' ); | |
| 477 | - | |
| 478 | - $this->addons = new Addons(); | |
| 479 | - $this->post_types = new Post_types(); | |
| 480 | - $this->taxonomies = new Taxonomies(); | |
| 481 | - $this->assets = new Assets(); | |
| 482 | - $this->admin = new Admin(); | |
| 483 | - $this->ajax = new Ajax(); | |
| 484 | - $this->options = new Options_V2(); | |
| 485 | - $this->shortcode = new Shortcode(); | |
| 486 | - $this->course = new Course(); | |
| 487 | - $this->lesson = new Lesson(); | |
| 488 | - $this->rewrite_rules = new Rewrite_Rules(); | |
| 489 | - $this->template = new Template(); | |
| 490 | - $this->instructor = new Instructor(); | |
| 491 | - $this->student = new Student(); | |
| 492 | - $this->q_and_a = new Q_And_A(); | |
| 493 | - $this->q_and_a_list = new Question_Answers_List(); | |
| 494 | - $this->q_attempt = new Quiz_Attempts_List(); | |
| 495 | - $this->quiz = new Quiz(); | |
| 496 | - $this->tools = new Tools(); | |
| 497 | - $this->user = new User(); | |
| 498 | - $this->theme_compatibility = new Theme_Compatibility(); | |
| 499 | - $this->gutenberg = new Gutenberg(); | |
| 500 | - $this->course_settings_tabs = new Course_Settings_Tabs(); | |
| 501 | - $this->withdraw = new Withdraw(); | |
| 502 | - $this->upgrader = new Upgrader(); | |
| 503 | - $this->dashboard = new Dashboard(); | |
| 504 | - $this->form_handler = new FormHandler(); | |
| 505 | - $this->frontend = new Frontend(); | |
| 506 | - $this->rest_api = new RestAPI(); | |
| 507 | - $this->setup = new Tutor_Setup(); | |
| 508 | - $this->private_course_access = new Private_Course_Access(); | |
| 509 | - $this->course_filter = new Course_Filter(); | |
| 510 | - $this->permalink = new Permalink(); | |
| 511 | - | |
| 512 | - // Integrations. | |
| 513 | - $this->woocommerce = new WooCommerce(); | |
| 514 | - $this->edd = new TutorEDD(); | |
| 515 | - | |
| 516 | 103 | /** |
| 517 | - * Init obj | |
| 518 | - * | |
| 519 | - * @since 2.0.0 | |
| 104 | + * Loading Autoloader | |
| 520 | 105 | */ |
| 521 | - $this->announcements = new Announcements(); | |
| 522 | - $this->course_list = new Course_List(); | |
| 523 | - $this->reviews = new Reviews(); | |
| 524 | - $this->withdraw_list = new Withdraw_Requests_List(); | |
| 525 | - $this->student_list = new Students_List(); | |
| 526 | - $this->instructor_list = new Instructors_List(); | |
| 527 | - $this->course_embed = new Course_Embed(); | |
| 528 | - $this->rest_auth = new RestAuth(); | |
| 529 | 106 | |
| 530 | - /** | |
| 531 | - * New Course Builder. | |
| 532 | - * | |
| 533 | - * @since 3.0.0 | |
| 534 | - */ | |
| 535 | - new QuizBuilder(); | |
| 107 | + if ( function_exists( '__autoload' ) ) { | |
| 108 | + spl_autoload_register( '__autoload' ); | |
| 109 | + } | |
| 110 | + spl_autoload_register(array($this, 'loader')); | |
| 536 | 111 | |
| 537 | - /** | |
| 538 | - * Tutor native e-commerce | |
| 539 | - * | |
| 540 | - * @since 3.0.0 | |
| 541 | - */ | |
| 542 | - new Ecommerce(); | |
| 112 | + do_action('tutor_before_load'); | |
| 543 | 113 | |
| 544 | - /** | |
| 545 | - * Data migrations | |
| 546 | - * | |
| 547 | - * @since 3.8.0 | |
| 548 | - */ | |
| 549 | - new Migration(); | |
| 114 | + $this->addons = new Addons(); | |
| 115 | + $this->post_types = new Post_types(); | |
| 116 | + $this->taxonomies = new Taxonomies(); | |
| 117 | + $this->assets = new Assets(); | |
| 118 | + $this->admin = new Admin(); | |
| 119 | + $this->ajax = new Ajax(); | |
| 120 | + $this->options = new Options(); | |
| 121 | + $this->shortcode = new Shortcode(); | |
| 122 | + $this->course = new Course(); | |
| 123 | + $this->lesson = new Lesson(); | |
| 124 | + $this->rewrite_rules = new Rewrite_Rules(); | |
| 125 | + $this->template = new Template(); | |
| 126 | + $this->instructor = new Instructor(); | |
| 127 | + $this->student = new Student(); | |
| 128 | + $this->q_and_a = new Q_and_A(); | |
| 129 | + $this->quiz = new Quiz(); | |
| 130 | + $this->tools = new Tools(); | |
| 131 | + $this->user = new User(); | |
| 132 | + $this->theme_compatibility = new Theme_Compatibility(); | |
| 133 | + $this->gutenberg = new Gutenberg(); | |
| 134 | + $this->course_settings_tabs = new Course_Settings_Tabs(); | |
| 135 | + $this->withdraw = new Withdraw(); | |
| 136 | + $this->course_widget = new Course_Widget(); | |
| 137 | + $this->upgrader = new Upgrader(); | |
| 138 | + $this->dashboard = new Dashboard(); | |
| 139 | + $this->form_handler = new FormHandler(); | |
| 140 | + $this->frontend = new Frontend(); | |
| 141 | + $this->email = new Email(); | |
| 142 | + $this->rest_api = new RestAPI(); | |
| 143 | + $this->setup = new Tutor_Setup(); | |
| 144 | + $this->private_course_access = new Private_Course_Access(); | |
| 145 | + $this->course_filter = new Course_Filter(); | |
| 550 | 146 | |
| 147 | + //Integrations | |
| 148 | + $this->woocommerce = new WooCommerce(); | |
| 149 | + $this->edd = new TutorEDD(); | |
| 150 | + | |
| 551 | 151 | /** |
| 552 | 152 | * Run Method |
| 553 | - * | |
| 554 | - * @since 1.2.0 | |
| 153 | + * @since v.1.2.0 | |
| 555 | 154 | */ |
| 556 | 155 | $this->run(); |
| 557 | 156 | |
| 558 | - do_action( 'tutor_loaded' ); | |
| 157 | + do_action('tutor_loaded'); | |
| 559 | 158 | |
| 560 | 159 | add_action( 'init', array( $this, 'init_action' ) ); |
| 561 | 160 | |
| 562 | - /** | |
| 563 | - * Check activated plugin | |
| 564 | - * | |
| 565 | - * @since 1.5.7 | |
| 566 | - */ | |
| 161 | + /** | |
| 162 | + * redirect to the wizard page | |
| 163 | + * @since v.1.5.7 | |
| 164 | + * | |
| 165 | + */ | |
| 567 | 166 | |
| 568 | 167 | add_action( 'activated_plugin', array( $this, 'activated_tutor' ), 10, 2 ); |
| 569 | - | |
| 570 | - /** | |
| 571 | - * Redirect to setup page | |
| 572 | - * | |
| 573 | - * @since 2.8.0 | |
| 574 | - */ | |
| 575 | - add_action( 'admin_init', array( $this, 'redirect_to_setup_page' ) ); | |
| 576 | 168 | } |
| 577 | 169 | |
| 578 | - /** | |
| 579 | - * Check activated plugin | |
| 580 | - * | |
| 581 | - * @since 1.5.7 | |
| 582 | - * | |
| 583 | - * @param mixed $plugin plugin. | |
| 584 | - * @param mixed $network_wide network wide. | |
| 585 | - * | |
| 586 | - * @return void | |
| 587 | - */ | |
| 170 | + /** | |
| 171 | + * @param $plugin | |
| 172 | + * | |
| 173 | + * redirect to the wizard page | |
| 174 | + * @since v.1.5.7 | |
| 175 | + * | |
| 176 | + */ | |
| 588 | 177 | public function activated_tutor( $plugin, $network_wide = null ) { |
| 589 | - if ( tutor()->basename === $plugin ) { | |
| 590 | - $this->redirect_to_setup_page(); | |
| 591 | - } | |
| 592 | - } | |
| 593 | - | |
| 594 | - /** | |
| 595 | - * Redirect to setup page | |
| 596 | - * | |
| 597 | - * @since 2.8.0 | |
| 598 | - * | |
| 599 | - * @return void | |
| 600 | - */ | |
| 601 | - public function redirect_to_setup_page() { | |
| 602 | - if ( ( ! get_option( 'tutor_wizard' ) ) && version_compare( TUTOR_VERSION, '1.5.6', '>' ) ) { | |
| 603 | - if ( ! wp_doing_ajax() ) { | |
| 604 | - update_option( 'tutor_wizard', 'active' ); | |
| 605 | - $is_wp_cli = defined( 'WP_CLI' ) && WP_CLI; | |
| 606 | - if ( ! $is_wp_cli ) { | |
| 607 | - wp_safe_redirect( admin_url( 'admin.php?page=tutor-setup' ) ); | |
| 608 | - } | |
| 609 | - exit; | |
| 178 | + if( $plugin == tutor()->basename ) { | |
| 179 | + if( (! get_option('tutor_wizard') ) && version_compare(TUTOR_VERSION, '1.5.6', '>') ) { | |
| 180 | + update_option('tutor_wizard', 'active'); | |
| 181 | + exit(wp_redirect(admin_url('admin.php?page=tutor-setup'))); | |
| 610 | 182 | } |
| 611 | 183 | } |
| 612 | 184 | } |
| 613 | 185 | |
| 614 | 186 | /** |
| 615 | - * Include utility functions | |
| 187 | + * @param $className | |
| 616 | 188 | * |
| 617 | - * @return void | |
| 189 | + * Auto Load class and the files | |
| 618 | 190 | */ |
| 619 | - public function includes() { | |
| 620 | - $tutor_path = plugin_dir_path( TUTOR_FILE ); | |
| 191 | + private function loader($className) { | |
| 192 | + if ( ! class_exists($className)){ | |
| 193 | + $className = preg_replace( | |
| 194 | + array('/([a-z])([A-Z])/', '/\\\/'), | |
| 195 | + array('$1$2', DIRECTORY_SEPARATOR), | |
| 196 | + $className | |
| 197 | + ); | |
| 621 | 198 | |
| 622 | - include $tutor_path . 'includes/tutor-general-functions.php'; | |
| 623 | - include $tutor_path . 'includes/tutor-template-functions.php'; | |
| 624 | - include $tutor_path . 'includes/tutor-template-hook.php'; | |
| 625 | - include $tutor_path . 'includes/translate-text.php'; | |
| 626 | - include $tutor_path . 'includes/country.php'; | |
| 627 | - include $tutor_path . 'includes/ecommerce-functions.php'; | |
| 199 | + $className = str_replace('TUTOR'.DIRECTORY_SEPARATOR, 'classes'.DIRECTORY_SEPARATOR, $className); | |
| 200 | + $file_name = $this->path.$className.'.php'; | |
| 628 | 201 | |
| 629 | - if ( ! function_exists( 'is_plugin_active' ) ) { | |
| 630 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; | |
| 631 | - } | |
| 632 | - | |
| 633 | - // Only kirki latest has class KirkiMain. | |
| 634 | - $is_kirki_active = \is_plugin_active( 'kirki-pro/kirki-pro.php' ) && class_exists( 'KirkiProMain' ); | |
| 635 | - | |
| 636 | - if ( $is_kirki_active ) { | |
| 637 | - $tutor_kirki_path = $tutor_path . 'includes/kirki/kirki.php'; | |
| 638 | - if ( file_exists( $tutor_kirki_path ) ) { | |
| 639 | - include $tutor_kirki_path; | |
| 202 | + if (file_exists($file_name) ) { | |
| 203 | + require_once $file_name; | |
| 640 | 204 | } |
| 641 | - } else { | |
| 642 | - $is_droip_active = \is_plugin_active( 'droip/droip.php' ); | |
| 643 | - $tutor_droip_path = $tutor_path . 'includes/droip/droip.php'; | |
| 644 | - if ( $is_droip_active && file_exists( $tutor_droip_path ) ) { | |
| 645 | - include $tutor_droip_path; | |
| 646 | - } | |
| 647 | 205 | } |
| 206 | + } | |
| 648 | 207 | |
| 208 | + public function includes(){ | |
| 209 | + include tutor()->path.'includes/tutor-general-functions.php'; | |
| 210 | + include tutor()->path.'includes/tutor-template-functions.php'; | |
| 211 | + include tutor()->path.'includes/tutor-template-hook.php'; | |
| 649 | 212 | } |
| 650 | 213 | |
| 651 | - /** | |
| 652 | - * Providing hooks | |
| 653 | - * | |
| 654 | - * @return void | |
| 655 | - */ | |
| 656 | - public function run() { | |
| 657 | - do_action( 'tutor_before_run' ); | |
| 658 | - do_action( 'tutor_after_run' ); | |
| 214 | + //Run the TUTOR right now | |
| 215 | + public function run(){ | |
| 216 | + do_action('tutor_before_run'); | |
| 217 | + | |
| 218 | + do_action('tutor_after_run'); | |
| 659 | 219 | } |
| 660 | 220 | |
| 661 | 221 | /** |
| 662 | 222 | * Tutor Action Via do_action |
| 663 | - * | |
| 664 | 223 | * @since 1.2.14 |
| 665 | 224 | */ |
| 666 | - public function init_action() { | |
| 667 | - $tutor_action = Input::sanitize_request_data( 'tutor_action' ); | |
| 668 | - if ( '' !== $tutor_action ) { | |
| 669 | - do_action( 'tutor_action_' . $tutor_action ); | |
| 225 | + public function init_action(){ | |
| 226 | + if (isset($_REQUEST['tutor_action'])){ | |
| 227 | + do_action('tutor_action_'.$_REQUEST['tutor_action']); | |
| 670 | 228 | } |
| 671 | 229 | } |
| 672 | 230 | |
| 673 | 231 | /** |
| @@ -672,62 +230,59 @@ | ||
| 672 | 230 | |
| 673 | 231 | /** |
| 674 | 232 | * Do some task during plugin activation |
| 675 | 233 | */ |
| 676 | - public static function tutor_activate() { | |
| 677 | - $version = get_option( 'tutor_version' ); | |
| 678 | - if ( ! function_exists( 'tutor_time' ) ) { | |
| 679 | - include tutor()->path . 'includes/tutor-general-functions.php'; | |
| 234 | + public static function tutor_activate(){ | |
| 235 | + $version = get_option('tutor_version'); | |
| 236 | + if ( ! function_exists('tutor_time')){ | |
| 237 | + include tutor()->path.'includes/tutor-general-functions.php'; | |
| 680 | 238 | } |
| 239 | + //Save Option | |
| 240 | + if ( ! $version ){ | |
| 241 | + //Create Database | |
| 242 | + self::create_database(); | |
| 681 | 243 | |
| 682 | - // Create Database. | |
| 683 | - self::create_database(); | |
| 684 | - | |
| 685 | - // Save Option. | |
| 686 | - if ( ! $version ) { | |
| 687 | - | |
| 688 | 244 | $options = self::default_options(); |
| 689 | - update_option( 'tutor_option', $options ); | |
| 245 | + update_option('tutor_option', $options); | |
| 690 | 246 | |
| 691 | - // Rewrite Flush. | |
| 692 | - Permalink::set_permalink_flag(); | |
| 247 | + //Rewrite Flush | |
| 248 | + update_option('required_rewrite_flush', tutor_time()); | |
| 693 | 249 | self::manage_tutor_roles_and_permissions(); |
| 694 | 250 | |
| 695 | - // Save initial Page. | |
| 696 | - self::save_data(); | |
| 697 | - update_option( 'tutor_version', TUTOR_VERSION ); | |
| 251 | + self::save_data();//Save initial Page | |
| 252 | + update_option('tutor_version', TUTOR_VERSION); | |
| 698 | 253 | } |
| 699 | 254 | |
| 700 | - // Set Schedule. | |
| 701 | - if ( ! wp_next_scheduled( 'tutor_once_in_day_run_schedule' ) ) { | |
| 702 | - wp_schedule_event( tutor_time(), 'twicedaily', 'tutor_once_in_day_run_schedule' ); | |
| 255 | + //Set Schedule | |
| 256 | + if (! wp_next_scheduled ( 'tutor_once_in_day_run_schedule' )) { | |
| 257 | + wp_schedule_event(tutor_time(), 'twicedaily', 'tutor_once_in_day_run_schedule'); | |
| 703 | 258 | } |
| 704 | 259 | |
| 705 | 260 | /** |
| 706 | 261 | * Backward Compatibility for version < 1.2.0 |
| 707 | 262 | */ |
| 708 | - if ( version_compare( get_option( 'tutor_version' ), '1.2.0', '<' ) ) { | |
| 263 | + if (version_compare(get_option('tutor_version'), '1.2.0', '<')){ | |
| 709 | 264 | /** |
| 710 | 265 | * Creating New Database |
| 711 | 266 | */ |
| 712 | 267 | self::create_withdraw_database(); |
| 713 | - // Update the tutor version. | |
| 714 | - update_option( 'tutor_version', '1.2.0' ); | |
| 715 | - // Rewrite Flush. | |
| 716 | - Permalink::set_permalink_flag(); | |
| 268 | + //Update the tutor version | |
| 269 | + update_option('tutor_version', '1.2.0'); | |
| 270 | + //Rewrite Flush | |
| 271 | + update_option('required_rewrite_flush', tutor_time()); | |
| 717 | 272 | } |
| 718 | 273 | |
| 719 | 274 | /** |
| 720 | 275 | * Backward Compatibility to < 1.3.1 for make course plural |
| 721 | 276 | */ |
| 722 | - if ( version_compare( get_option( 'tutor_version' ), '1.3.1', '<' ) ) { | |
| 277 | + if (version_compare(get_option('tutor_version'), '1.3.1', '<')){ | |
| 723 | 278 | global $wpdb; |
| 724 | 279 | |
| 725 | - if ( ! get_option( 'is_course_post_type_updated' ) ) { | |
| 726 | - $wpdb->update( $wpdb->posts, array( 'post_type' => tutor()->course_post_type ), array( 'post_type' => 'course' ) ); | |
| 727 | - update_option( 'is_course_post_type_updated', true ); | |
| 728 | - update_option( 'tutor_version', '1.3.1' ); | |
| 729 | - Permalink::set_permalink_flag(); | |
| 280 | + if ( ! get_option('is_course_post_type_updated')){ | |
| 281 | + $wpdb->update($wpdb->posts, array('post_type' => 'courses'), array('post_type' => 'course')); | |
| 282 | + update_option('is_course_post_type_updated', true); | |
| 283 | + update_option('tutor_version', '1.3.1'); | |
| 284 | + flush_rewrite_rules(); | |
| 730 | 285 | } |
| 731 | 286 | } |
| 732 | 287 | |
| 733 | 288 | /** |
| @@ -732,31 +287,20 @@ | ||
| 732 | 287 | |
| 733 | 288 | /** |
| 734 | 289 | * Save First activation Time |
| 735 | 290 | */ |
| 736 | - $first_activation_date = get_option( 'tutor_first_activation_time' ); | |
| 737 | - if ( ! $first_activation_date ) { | |
| 738 | - update_option( 'tutor_first_activation_time', tutor_time() ); | |
| 291 | + $first_activation_date = get_option('tutor_first_activation_time'); | |
| 292 | + if ( ! $first_activation_date){ | |
| 293 | + update_option('tutor_first_activation_time', tutor_time()); | |
| 739 | 294 | } |
| 740 | 295 | } |
| 741 | 296 | |
| 742 | - /** | |
| 743 | - * Run task on deactivation | |
| 744 | - * | |
| 745 | - * @since 1.0.0 | |
| 746 | - * | |
| 747 | - * @return void | |
| 748 | - */ | |
| 297 | + //Run task on deactivation | |
| 749 | 298 | public static function tutor_deactivation() { |
| 750 | - wp_clear_scheduled_hook( 'tutor_once_in_day_run_schedule' ); | |
| 299 | + wp_clear_scheduled_hook('tutor_once_in_day_run_schedule'); | |
| 751 | 300 | } |
| 752 | 301 | |
| 753 | - /** | |
| 754 | - * Create database | |
| 755 | - * | |
| 756 | - * @return void | |
| 757 | - */ | |
| 758 | - public static function create_database() { | |
| 302 | + public static function create_database(){ | |
| 759 | 303 | global $wpdb; |
| 760 | 304 | |
| 761 | 305 | $charset_collate = $wpdb->get_charset_collate(); |
| 762 | 306 | |
| @@ -769,15 +313,15 @@ | ||
| 769 | 313 | * {$wpdb->prefix}tutor_quiz_question_answers |
| 770 | 314 | * {$wpdb->prefix}tutor_earnings |
| 771 | 315 | * {$wpdb->prefix}tutor_withdraws |
| 772 | 316 | * |
| 773 | - * @since 1.0.0 | |
| 317 | + * @since v.1.0.0 | |
| 774 | 318 | */ |
| 775 | 319 | $quiz_attempts_sql = "CREATE TABLE {$wpdb->prefix}tutor_quiz_attempts ( |
| 776 | - attempt_id bigint(20) NOT NULL AUTO_INCREMENT, | |
| 777 | - course_id bigint(20) DEFAULT NULL, | |
| 778 | - quiz_id bigint(20) DEFAULT NULL, | |
| 779 | - user_id bigint(20) DEFAULT NULL, | |
| 320 | + attempt_id int(11) NOT NULL AUTO_INCREMENT, | |
| 321 | + course_id int(11) DEFAULT NULL, | |
| 322 | + quiz_id int(11) DEFAULT NULL, | |
| 323 | + user_id int(11) DEFAULT NULL, | |
| 780 | 324 | total_questions int(11) DEFAULT NULL, |
| 781 | 325 | total_answered_questions int(11) DEFAULT NULL, |
| 782 | 326 | total_marks decimal(9,2) DEFAULT NULL, |
| 783 | 327 | earned_marks decimal(9,2) DEFAULT NULL, |
| @@ -787,22 +331,17 @@ | ||
| 787 | 331 | attempt_started_at datetime DEFAULT NULL, |
| 788 | 332 | attempt_ended_at datetime DEFAULT NULL, |
| 789 | 333 | is_manually_reviewed int(1) DEFAULT NULL, |
| 790 | 334 | manually_reviewed_at datetime DEFAULT NULL, |
| 791 | - result varchar(10) DEFAULT NULL, | |
| 792 | - PRIMARY KEY (attempt_id), | |
| 793 | - INDEX (course_id), | |
| 794 | - INDEX (quiz_id), | |
| 795 | - INDEX (user_id), | |
| 796 | - INDEX (result) | |
| 335 | + PRIMARY KEY (attempt_id) | |
| 797 | 336 | ) $charset_collate;"; |
| 798 | 337 | |
| 799 | 338 | $quiz_attempt_answers = "CREATE TABLE {$wpdb->prefix}tutor_quiz_attempt_answers ( |
| 800 | - attempt_answer_id bigint(20) NOT NULL AUTO_INCREMENT, | |
| 801 | - user_id bigint(20) DEFAULT NULL, | |
| 802 | - quiz_id bigint(20) DEFAULT NULL, | |
| 803 | - question_id bigint(20) DEFAULT NULL, | |
| 804 | - quiz_attempt_id bigint(20) DEFAULT NULL, | |
| 339 | + attempt_answer_id int(11) NOT NULL AUTO_INCREMENT, | |
| 340 | + user_id int(11) DEFAULT NULL, | |
| 341 | + quiz_id int(11) DEFAULT NULL, | |
| 342 | + question_id int(11) DEFAULT NULL, | |
| 343 | + quiz_attempt_id int(11) DEFAULT NULL, | |
| 805 | 344 | given_answer longtext, |
| 806 | 345 | question_mark decimal(8,2) DEFAULT NULL, |
| 807 | 346 | achieved_mark decimal(8,2) DEFAULT NULL, |
| 808 | 347 | minus_mark decimal(8,2) DEFAULT NULL, |
| @@ -810,13 +349,12 @@ | ||
| 810 | 349 | PRIMARY KEY (attempt_answer_id) |
| 811 | 350 | ) $charset_collate;"; |
| 812 | 351 | |
| 813 | 352 | $tutor_quiz_questions = "CREATE TABLE {$wpdb->prefix}tutor_quiz_questions ( |
| 814 | - question_id bigint(20) NOT NULL AUTO_INCREMENT, | |
| 815 | - quiz_id bigint(20) DEFAULT NULL, | |
| 353 | + question_id int(11) NOT NULL AUTO_INCREMENT, | |
| 354 | + quiz_id int(11) DEFAULT NULL, | |
| 816 | 355 | question_title text, |
| 817 | 356 | question_description longtext, |
| 818 | - answer_explanation longtext DEFAULT '', | |
| 819 | 357 | question_type varchar(50) DEFAULT NULL, |
| 820 | 358 | question_mark decimal(9,2) DEFAULT NULL, |
| 821 | 359 | question_settings longtext, |
| 822 | 360 | question_order int(11) DEFAULT NULL, |
| @@ -823,14 +361,14 @@ | ||
| 823 | 361 | PRIMARY KEY (question_id) |
| 824 | 362 | ) $charset_collate;"; |
| 825 | 363 | |
| 826 | 364 | $tutor_quiz_question_answers = "CREATE TABLE {$wpdb->prefix}tutor_quiz_question_answers ( |
| 827 | - answer_id bigint(20) NOT NULL AUTO_INCREMENT, | |
| 828 | - belongs_question_id bigint(20) DEFAULT NULL, | |
| 365 | + answer_id int(11) NOT NULL AUTO_INCREMENT, | |
| 366 | + belongs_question_id int(11) DEFAULT NULL, | |
| 829 | 367 | belongs_question_type varchar(250) DEFAULT NULL, |
| 830 | 368 | answer_title text, |
| 831 | 369 | is_correct tinyint(4) DEFAULT NULL, |
| 832 | - image_id bigint(20) DEFAULT NULL, | |
| 370 | + image_id int(11) DEFAULT NULL, | |
| 833 | 371 | answer_two_gap_match text, |
| 834 | 372 | answer_view_format varchar(250) DEFAULT NULL, |
| 835 | 373 | answer_settings text, |
| 836 | 374 | answer_order int(11) DEFAULT '0', |
| @@ -837,12 +375,12 @@ | ||
| 837 | 375 | PRIMARY KEY (answer_id) |
| 838 | 376 | ) $charset_collate;"; |
| 839 | 377 | |
| 840 | 378 | $earning_table = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}tutor_earnings ( |
| 841 | - earning_id bigint(20) NOT NULL AUTO_INCREMENT, | |
| 842 | - user_id bigint(20) DEFAULT NULL, | |
| 843 | - course_id bigint(20) DEFAULT NULL, | |
| 844 | - order_id bigint(20) DEFAULT NULL, | |
| 379 | + earning_id int(11) NOT NULL AUTO_INCREMENT, | |
| 380 | + user_id int(11) DEFAULT NULL, | |
| 381 | + course_id int(11) DEFAULT NULL, | |
| 382 | + order_id int(11) DEFAULT NULL, | |
| 845 | 383 | order_status varchar(50) DEFAULT NULL, |
| 846 | 384 | course_price_total decimal(16,2) DEFAULT NULL, |
| 847 | 385 | course_price_grand_total decimal(16,2) DEFAULT NULL, |
| 848 | 386 | instructor_amount decimal(16,2) DEFAULT NULL, |
| @@ -854,18 +392,14 @@ | ||
| 854 | 392 | deduct_fees_name varchar(250) DEFAULT NULL, |
| 855 | 393 | deduct_fees_type varchar(20) DEFAULT NULL, |
| 856 | 394 | process_by varchar(20) DEFAULT NULL, |
| 857 | 395 | created_at datetime DEFAULT NULL, |
| 858 | - PRIMARY KEY (earning_id), | |
| 859 | - INDEX (user_id), | |
| 860 | - INDEX (course_id), | |
| 861 | - INDEX (order_id), | |
| 862 | - INDEX (process_by) | |
| 396 | + PRIMARY KEY (earning_id) | |
| 863 | 397 | ) $charset_collate;"; |
| 864 | 398 | |
| 865 | 399 | $withdraw_table = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}tutor_withdraws ( |
| 866 | - withdraw_id bigint(20) NOT NULL AUTO_INCREMENT, | |
| 867 | - user_id bigint(20) DEFAULT NULL, | |
| 400 | + withdraw_id int(11) NOT NULL AUTO_INCREMENT, | |
| 401 | + user_id int(11) DEFAULT NULL, | |
| 868 | 402 | amount decimal(16,2) DEFAULT NULL, |
| 869 | 403 | method_data text DEFAULT NULL, |
| 870 | 404 | status varchar(50) DEFAULT NULL, |
| 871 | 405 | updated_at datetime DEFAULT NULL, |
| @@ -872,161 +406,9 @@ | ||
| 872 | 406 | created_at datetime DEFAULT NULL, |
| 873 | 407 | PRIMARY KEY (withdraw_id) |
| 874 | 408 | ) $charset_collate;"; |
| 875 | 409 | |
| 876 | - $orders_table = "CREATE TABLE {$wpdb->prefix}tutor_orders ( | |
| 877 | - id BIGINT(20) UNSIGNED AUTO_INCREMENT, | |
| 878 | - parent_id BIGINT(20) UNSIGNED DEFAULT 0, -- for subscription order, store subscription record id | |
| 879 | - transaction_id VARCHAR(255) COMMENT 'Transaction id from payment gateway', | |
| 880 | - user_id BIGINT(20) UNSIGNED NOT NULL, | |
| 881 | - order_type VARCHAR(50) NOT NULL, -- single_order, subscription | |
| 882 | - order_status VARCHAR(50) NOT NULL, | |
| 883 | - payment_status VARCHAR(50) NOT NULL, | |
| 884 | - subtotal_price DECIMAL(13, 2) NOT NULL, -- price calculation based on course sale price | |
| 885 | - pre_tax_price DECIMAL(13, 2) NOT NULL, -- total price before adding tax | |
| 886 | - tax_type VARCHAR(50), | |
| 887 | - tax_rate DECIMAL(13, 2) COMMENT 'Tax percentage', | |
| 888 | - tax_amount DECIMAL(13, 2), | |
| 889 | - total_price DECIMAL(13, 2) NOT NULL, -- final price | |
| 890 | - net_payment DECIMAL(13, 2) NOT NULL, -- calculated price if any refund is done else same as total_price | |
| 891 | - coupon_code VARCHAR(255), | |
| 892 | - coupon_amount DECIMAL(13, 2), | |
| 893 | - discount_type ENUM('percentage', 'flat') DEFAULT NULL, | |
| 894 | - discount_amount DECIMAL(13, 2), | |
| 895 | - discount_reason TEXT, | |
| 896 | - fees DECIMAL(13, 2), -- payment gateway fees | |
| 897 | - earnings DECIMAL(13, 2), -- net earning | |
| 898 | - refund_amount DECIMAL(13, 2), -- Refund amount | |
| 899 | - payment_method VARCHAR(255), | |
| 900 | - payment_payloads LONGTEXT, | |
| 901 | - note TEXT, | |
| 902 | - created_at_gmt DATETIME NOT NULL, | |
| 903 | - created_by BIGINT(20) UNSIGNED NOT NULL, | |
| 904 | - updated_at_gmt DATETIME, | |
| 905 | - updated_by BIGINT(20) UNSIGNED NOT NULL, | |
| 906 | - PRIMARY KEY (id), | |
| 907 | - KEY user_id (user_id), | |
| 908 | - KEY order_type (order_type), | |
| 909 | - KEY payment_status (payment_status), | |
| 910 | - KEY order_status (order_status), | |
| 911 | - KEY transaction_id (transaction_id) | |
| 912 | - ) $charset_collate;"; | |
| 913 | - | |
| 914 | - $order_meta_table = "CREATE TABLE {$wpdb->prefix}tutor_ordermeta ( | |
| 915 | - id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, | |
| 916 | - order_id BIGINT(20) UNSIGNED NOT NULL, | |
| 917 | - meta_key VARCHAR(255) NOT NULL, | |
| 918 | - meta_value LONGTEXT NOT NULL, | |
| 919 | - created_at_gmt DATETIME NOT NULL, | |
| 920 | - created_by BIGINT(20) UNSIGNED NOT NULL, | |
| 921 | - updated_at_gmt DATETIME, | |
| 922 | - updated_by BIGINT(20) UNSIGNED NOT NULL, | |
| 923 | - PRIMARY KEY (id), | |
| 924 | - KEY order_id (order_id), | |
| 925 | - KEY meta_key (meta_key), | |
| 926 | - CONSTRAINT fk_tutor_ordermeta_order_id FOREIGN KEY (order_id) REFERENCES {$wpdb->prefix}tutor_orders(id) ON DELETE CASCADE | |
| 927 | - ) $charset_collate;"; | |
| 928 | - | |
| 929 | - $order_items_table = "CREATE TABLE {$wpdb->prefix}tutor_order_items ( | |
| 930 | - id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, | |
| 931 | - order_id BIGINT(20) UNSIGNED NOT NULL, | |
| 932 | - item_id BIGINT(20) UNSIGNED NOT NULL, -- course id/plan id | |
| 933 | - regular_price DECIMAL(13, 2) NOT NULL, -- course regular price | |
| 934 | - sale_price VARCHAR(13) DEFAULT NULL, -- course sale price | |
| 935 | - discount_price VARCHAR(13) DEFAULT NULL, -- course discount price | |
| 936 | - coupon_code VARCHAR(255) DEFAULT NULL, -- coupon code | |
| 937 | - PRIMARY KEY (id), | |
| 938 | - KEY order_id (order_id), | |
| 939 | - KEY item_id (item_id), | |
| 940 | - CONSTRAINT fk_tutor_order_item_order_id FOREIGN KEY (order_id) REFERENCES {$wpdb->prefix}tutor_orders(id) ON DELETE CASCADE | |
| 941 | - ) $charset_collate;"; | |
| 942 | - | |
| 943 | - $coupons_table = "CREATE TABLE {$wpdb->prefix}tutor_coupons ( | |
| 944 | - id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, | |
| 945 | - coupon_status VARCHAR(50), | |
| 946 | - coupon_type VARCHAR(100) DEFAULT 'code', -- coupon type 'code' or 'automatic' | |
| 947 | - coupon_code VARCHAR(50) NOT NULL, | |
| 948 | - coupon_title VARCHAR(255) NOT NULL, | |
| 949 | - coupon_description TEXT, | |
| 950 | - discount_type ENUM('percentage', 'flat') NOT NULL, | |
| 951 | - discount_amount DECIMAL(13, 2) NOT NULL, | |
| 952 | - applies_to VARCHAR(100) DEFAULT 'all_courses_and_bundles', -- possible values 'all_courses_and_bundles', 'all_courses', 'all_bundles', 'specific_courses', 'specific_bundles', 'specific_category' | |
| 953 | - total_usage_limit INT(10) UNSIGNED DEFAULT NULL, -- null for unlimited usage | |
| 954 | - per_user_usage_limit TINYINT(4) UNSIGNED DEFAULT NULL, -- null for unlimited usage | |
| 955 | - purchase_requirement VARCHAR(50) DEFAULT 'no_minimum', -- possible values 'no_minimum', 'minimum_purchase', 'minimum_quantity' | |
| 956 | - purchase_requirement_value DECIMAL(13, 2), | |
| 957 | - start_date_gmt DATETIME NOT NULL, | |
| 958 | - expire_date_gmt DATETIME DEFAULT NULL, | |
| 959 | - created_at_gmt DATETIME NOT NULL, | |
| 960 | - created_by BIGINT(20) UNSIGNED NOT NULL, | |
| 961 | - updated_at_gmt DATETIME, | |
| 962 | - updated_by BIGINT(20) UNSIGNED NOT NULL, | |
| 963 | - PRIMARY KEY (id), | |
| 964 | - UNIQUE KEY coupon_code (coupon_code), | |
| 965 | - KEY start_date_gmt (start_date_gmt), | |
| 966 | - KEY expire_date_gmt (expire_date_gmt) | |
| 967 | - ) $charset_collate;"; | |
| 968 | - | |
| 969 | - $coupon_applications_table = "CREATE TABLE {$wpdb->prefix}tutor_coupon_applications ( | |
| 970 | - coupon_code VARCHAR(50) NOT NULL, | |
| 971 | - reference_id BIGINT(20) UNSIGNED NOT NULL, | |
| 972 | - KEY coupon_code (coupon_code), | |
| 973 | - KEY reference_id (reference_id), | |
| 974 | - CONSTRAINT fk_tutor_coupon_application_coupon_code FOREIGN KEY (coupon_code) REFERENCES {$wpdb->prefix}tutor_coupons(coupon_code) ON DELETE CASCADE | |
| 975 | - ) $charset_collate;"; | |
| 976 | - | |
| 977 | - $coupon_usage_table = "CREATE TABLE {$wpdb->prefix}tutor_coupon_usages ( | |
| 978 | - id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, | |
| 979 | - coupon_code VARCHAR(50) NOT NULL, | |
| 980 | - user_id BIGINT(20) UNSIGNED NOT NULL, | |
| 981 | - PRIMARY KEY (id), | |
| 982 | - KEY coupon_code (coupon_code), | |
| 983 | - KEY user_id (user_id), | |
| 984 | - CONSTRAINT fk_tutor_coupon_usage_coupon_code FOREIGN KEY (coupon_code) REFERENCES {$wpdb->prefix}tutor_coupons(coupon_code) ON DELETE CASCADE, | |
| 985 | - CONSTRAINT fk_tutor_coupon_usage_user_id FOREIGN KEY (user_id) REFERENCES {$wpdb->prefix}users(ID) ON DELETE CASCADE | |
| 986 | - ) $charset_collate;"; | |
| 987 | - | |
| 988 | - $cart_table = "CREATE TABLE {$wpdb->prefix}tutor_carts ( | |
| 989 | - id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, | |
| 990 | - user_id BIGINT(20) UNSIGNED DEFAULT NULL, | |
| 991 | - coupon_code VARCHAR(50) DEFAULT NULL, | |
| 992 | - created_at_gmt DATETIME NOT NULL, | |
| 993 | - updated_at_gmt DATETIME, | |
| 994 | - PRIMARY KEY (id), | |
| 995 | - KEY user_id (user_id), | |
| 996 | - KEY coupon_code (coupon_code), | |
| 997 | - CONSTRAINT fk_tutor_cart_user_id FOREIGN KEY (user_id) REFERENCES {$wpdb->prefix}users(ID) ON DELETE CASCADE | |
| 998 | - ) $charset_collate;"; | |
| 999 | - | |
| 1000 | - $cart_items_table = "CREATE TABLE {$wpdb->prefix}tutor_cart_items ( | |
| 1001 | - id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, | |
| 1002 | - cart_id BIGINT(20) UNSIGNED NOT NULL, | |
| 1003 | - course_id BIGINT(20) UNSIGNED NOT NULL, | |
| 1004 | - PRIMARY KEY (id), | |
| 1005 | - KEY cart_id (cart_id), | |
| 1006 | - KEY course_id (course_id), | |
| 1007 | - CONSTRAINT fk_tutor_cart_item_cart_id FOREIGN KEY (cart_id) REFERENCES {$wpdb->prefix}tutor_carts(id) ON DELETE CASCADE, | |
| 1008 | - CONSTRAINT fk_tutor_cart_item_course_id FOREIGN KEY (course_id) REFERENCES {$wpdb->prefix}posts(ID) ON DELETE CASCADE | |
| 1009 | - ) $charset_collate;"; | |
| 1010 | - | |
| 1011 | - $customer_table = "CREATE TABLE {$wpdb->prefix}tutor_customers ( | |
| 1012 | - id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, | |
| 1013 | - user_id BIGINT(20) UNSIGNED DEFAULT NULL, | |
| 1014 | - billing_first_name VARCHAR(255) NOT NULL, | |
| 1015 | - billing_last_name VARCHAR(255) NOT NULL, | |
| 1016 | - billing_email VARCHAR(255) NOT NULL, | |
| 1017 | - billing_phone VARCHAR(20) NOT NULL, | |
| 1018 | - billing_zip_code VARCHAR(20) NOT NULL, | |
| 1019 | - billing_address TEXT NOT NULL, | |
| 1020 | - billing_country VARCHAR(100) NOT NULL, | |
| 1021 | - billing_state VARCHAR(100) NOT NULL, | |
| 1022 | - billing_city VARCHAR(100) NOT NULL, | |
| 1023 | - PRIMARY KEY (id), | |
| 1024 | - KEY user_id (user_id), | |
| 1025 | - KEY billing_email (billing_email) | |
| 1026 | - ) $charset_collate;"; | |
| 1027 | - | |
| 1028 | - require_once ABSPATH . 'wp-admin/includes/upgrade.php'; | |
| 410 | + require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); | |
| 1029 | 411 | dbDelta( $quiz_attempts_sql ); |
| 1030 | 412 | dbDelta( $quiz_attempt_answers ); |
| 1031 | 413 | dbDelta( $tutor_quiz_questions ); |
| 1032 | 414 | dbDelta( $tutor_quiz_question_answers ); |
| @@ -1031,38 +413,24 @@ | ||
| 1031 | 413 | dbDelta( $tutor_quiz_questions ); |
| 1032 | 414 | dbDelta( $tutor_quiz_question_answers ); |
| 1033 | 415 | dbDelta( $earning_table ); |
| 1034 | 416 | dbDelta( $withdraw_table ); |
| 1035 | - dbDelta( $orders_table ); | |
| 1036 | - dbDelta( $order_meta_table ); | |
| 1037 | - dbDelta( $order_items_table ); | |
| 1038 | - dbDelta( $coupons_table ); | |
| 1039 | - dbDelta( $coupon_applications_table ); | |
| 1040 | - dbDelta( $coupon_usage_table ); | |
| 1041 | - dbDelta( $cart_table ); | |
| 1042 | - dbDelta( $cart_items_table ); | |
| 1043 | - dbDelta( $customer_table ); | |
| 1044 | 417 | } |
| 1045 | 418 | |
| 1046 | - /** | |
| 1047 | - * Manage tutor roles & permission | |
| 1048 | - * | |
| 1049 | - * @return void | |
| 1050 | - */ | |
| 1051 | - public static function manage_tutor_roles_and_permissions() { | |
| 419 | + public static function manage_tutor_roles_and_permissions(){ | |
| 1052 | 420 | /** |
| 1053 | 421 | * Add role for instructor |
| 1054 | 422 | */ |
| 1055 | 423 | $instructor_role = tutor()->instructor_role; |
| 1056 | 424 | |
| 1057 | - remove_role( $instructor_role ); | |
| 1058 | - add_role( $instructor_role, __( 'Tutor Instructor', 'tutor' ), array() ); | |
| 425 | + remove_role($instructor_role); | |
| 426 | + add_role( $instructor_role, __('Tutor Instructor', 'tutor'), array() ); | |
| 1059 | 427 | |
| 1060 | 428 | $custom_post_type_permission = array( |
| 1061 | - // Manage Instructor. | |
| 429 | + //Manage Instructor | |
| 1062 | 430 | 'manage_tutor_instructor', |
| 1063 | 431 | |
| 1064 | - // Tutor Posts Type Permission. | |
| 432 | + //Tutor Posts Type Permission | |
| 1065 | 433 | 'edit_tutor_course', |
| 1066 | 434 | 'read_tutor_course', |
| 1067 | 435 | 'delete_tutor_course', |
| 1068 | 436 | 'delete_tutor_courses', |
| @@ -1103,22 +471,22 @@ | ||
| 1103 | 471 | ); |
| 1104 | 472 | |
| 1105 | 473 | $instructor = get_role( $instructor_role ); |
| 1106 | 474 | if ( $instructor ) { |
| 1107 | - $instructor_cap = array( | |
| 475 | + $instructor_cap = array ( | |
| 1108 | 476 | 'edit_posts', |
| 1109 | 477 | 'read', |
| 1110 | 478 | 'upload_files', |
| 1111 | 479 | ); |
| 1112 | 480 | |
| 1113 | - $instructor_cap = array_merge( $instructor_cap, $custom_post_type_permission ); | |
| 481 | + $instructor_cap = array_merge($instructor_cap, $custom_post_type_permission); | |
| 1114 | 482 | |
| 1115 | - $can_publish_course = (bool) tutor_utils()->get_option( 'instructor_can_publish_course' ); | |
| 1116 | - if ( $can_publish_course ) { | |
| 483 | + $can_publish_course = (bool) tutor_utils()->get_option('instructor_can_publish_course'); | |
| 484 | + if ($can_publish_course){ | |
| 1117 | 485 | $instructor_cap[] = 'publish_tutor_courses'; |
| 1118 | 486 | } |
| 1119 | 487 | |
| 1120 | - foreach ( $instructor_cap as $cap ) { | |
| 488 | + foreach ($instructor_cap as $cap){ | |
| 1121 | 489 | $instructor->add_cap( $cap ); |
| 1122 | 490 | } |
| 1123 | 491 | } |
| 1124 | 492 | |
| @@ -1124,15 +492,15 @@ | ||
| 1124 | 492 | |
| 1125 | 493 | $administrator = get_role( 'administrator' ); |
| 1126 | 494 | if ( $administrator ) { |
| 1127 | 495 | |
| 1128 | - $administrator_cap = array( | |
| 496 | + $administrator_cap = array ( | |
| 1129 | 497 | 'manage_tutor', |
| 1130 | 498 | ); |
| 1131 | - $administrator_cap = array_merge( $administrator_cap, $custom_post_type_permission ); | |
| 499 | + $administrator_cap = array_merge($administrator_cap, $custom_post_type_permission); | |
| 1132 | 500 | $administrator_cap[] = 'publish_tutor_courses'; |
| 1133 | 501 | |
| 1134 | - foreach ( $administrator_cap as $cap ) { | |
| 502 | + foreach ($administrator_cap as $cap){ | |
| 1135 | 503 | $administrator->add_cap( $cap ); |
| 1136 | 504 | } |
| 1137 | 505 | } |
| 1138 | 506 | |
| @@ -1138,111 +506,85 @@ | ||
| 1138 | 506 | |
| 1139 | 507 | /** |
| 1140 | 508 | * Add Instructor role to administrator |
| 1141 | 509 | */ |
| 1142 | - if ( current_user_can( 'administrator' ) ) { | |
| 1143 | - tutor_utils()->add_instructor_role( get_current_user_id() ); | |
| 510 | + if (current_user_can('administrator')){ | |
| 511 | + tutor_utils()->add_instructor_role(get_current_user_id()); | |
| 1144 | 512 | } |
| 513 | + | |
| 1145 | 514 | } |
| 1146 | 515 | |
| 1147 | 516 | /** |
| 1148 | - * On plugin activate save initial data | |
| 1149 | - * Like: generate tutor pages | |
| 1150 | - * | |
| 1151 | - * @since 1.0.0 | |
| 1152 | - * | |
| 1153 | - * @return void | |
| 517 | + * Save data like page | |
| 1154 | 518 | */ |
| 1155 | - public static function save_data() { | |
| 1156 | - | |
| 1157 | - $student_dashboard_args = array( | |
| 1158 | - 'post_title' => __( 'Dashboard', 'tutor' ), | |
| 1159 | - 'post_content' => '', | |
| 1160 | - 'post_type' => 'page', | |
| 1161 | - 'post_status' => 'publish', | |
| 519 | + public static function save_data(){ | |
| 520 | + $student_dashboard_args = array( | |
| 521 | + 'post_title' => __('Dashboard', 'tutor'), | |
| 522 | + 'post_content' => '', | |
| 523 | + 'post_type' => 'page', | |
| 524 | + 'post_status' => 'publish', | |
| 1162 | 525 | ); |
| 1163 | 526 | $student_dashboard_page_id = wp_insert_post( $student_dashboard_args ); |
| 1164 | - tutor_utils()->update_option( 'tutor_dashboard_page_id', $student_dashboard_page_id ); | |
| 527 | + tutor_utils()->update_option('tutor_dashboard_page_id', $student_dashboard_page_id); | |
| 1165 | 528 | |
| 1166 | 529 | $student_registration_args = array( |
| 1167 | - 'post_title' => __( 'Student Registration', 'tutor' ), | |
| 1168 | - 'post_content' => '[tutor_student_registration_form]', | |
| 1169 | - 'post_type' => 'page', | |
| 1170 | - 'post_status' => 'publish', | |
| 530 | + 'post_title' => __('Student Registration', 'tutor'), | |
| 531 | + 'post_content' => '[tutor_student_registration_form]', | |
| 532 | + 'post_type' => 'page', | |
| 533 | + 'post_status' => 'publish', | |
| 1171 | 534 | ); |
| 1172 | - $student_register_page_id = wp_insert_post( $student_registration_args ); | |
| 1173 | - tutor_utils()->update_option( 'student_register_page', $student_register_page_id ); | |
| 535 | + $student_register_page_id = wp_insert_post( $student_registration_args ); | |
| 536 | + tutor_utils()->update_option('student_register_page', $student_register_page_id); | |
| 1174 | 537 | |
| 1175 | 538 | $instructor_registration_args = array( |
| 1176 | - 'post_title' => __( 'Instructor Registration', 'tutor' ), | |
| 1177 | - 'post_content' => '[tutor_instructor_registration_form]', | |
| 1178 | - 'post_type' => 'page', | |
| 1179 | - 'post_status' => 'publish', | |
| 539 | + 'post_title' => __('Instructor Registration', 'tutor'), | |
| 540 | + 'post_content' => '[tutor_instructor_registration_form]', | |
| 541 | + 'post_type' => 'page', | |
| 542 | + 'post_status' => 'publish', | |
| 1180 | 543 | ); |
| 1181 | - $instructor_registration_id = wp_insert_post( $instructor_registration_args ); | |
| 1182 | - tutor_utils()->update_option( 'instructor_register_page', $instructor_registration_id ); | |
| 544 | + $instructor_registration_id = wp_insert_post( $instructor_registration_args ); | |
| 545 | + tutor_utils()->update_option('instructor_register_page', $instructor_registration_id); | |
| 1183 | 546 | } |
| 1184 | 547 | |
| 1185 | - /** | |
| 1186 | - * Default options | |
| 1187 | - * | |
| 1188 | - * @since 1.0.0 | |
| 1189 | - * | |
| 1190 | - * @since 3.4.1 Supported video sources added | |
| 1191 | - * | |
| 1192 | - * @return array | |
| 1193 | - */ | |
| 1194 | - public static function default_options() { | |
| 1195 | - $options = array( | |
| 548 | + public static function default_options(){ | |
| 549 | + $options = array ( | |
| 1196 | 550 | 'pagination_per_page' => '20', |
| 551 | + 'load_tutor_css' => '1', | |
| 552 | + 'load_tutor_js' => '1', | |
| 1197 | 553 | 'course_allow_upload_private_files' => '1', |
| 1198 | 554 | 'display_course_instructors' => '1', |
| 1199 | 555 | 'enable_q_and_a_on_course' => '1', |
| 1200 | 556 | 'courses_col_per_row' => '3', |
| 1201 | 557 | 'courses_per_page' => '12', |
| 1202 | - 'course_permalink_base' => 'courses', | |
| 1203 | - 'lesson_permalink_base' => 'lessons', | |
| 558 | + 'lesson_permalink_base' => 'lesson', | |
| 559 | + 'quiz_time_limit' => | |
| 560 | + array ( | |
| 561 | + 'value' => '0', | |
| 562 | + 'time' => 'minutes', | |
| 563 | + ), | |
| 1204 | 564 | 'quiz_when_time_expires' => 'autosubmit', |
| 1205 | 565 | 'quiz_attempts_allowed' => '10', |
| 1206 | 566 | 'quiz_grade_method' => 'highest_grade', |
| 1207 | - 'enable_public_profile' => '1', | |
| 567 | + 'enable_public_profile' => '1', | |
| 1208 | 568 | 'email_to_students' => |
| 1209 | - array( | |
| 1210 | - 'quiz_completed' => '1', | |
| 569 | + array ( | |
| 570 | + 'quiz_completed' => '1', | |
| 1211 | 571 | 'completed_course' => '1', |
| 1212 | 572 | ), |
| 1213 | - 'email_to_instructors' => | |
| 1214 | - array( | |
| 1215 | - 'a_student_enrolled_in_course' => '1', | |
| 1216 | - 'a_student_completed_course' => '1', | |
| 1217 | - 'a_student_completed_lesson' => '1', | |
| 1218 | - 'a_student_placed_question' => '1', | |
| 573 | + 'email_to_instructors' => | |
| 574 | + array ( | |
| 575 | + 'a_student_enrolled_in_course' => '1', | |
| 576 | + 'a_student_completed_course' => '1', | |
| 577 | + 'a_student_completed_lesson' => '1', | |
| 578 | + 'a_student_placed_question' => '1', | |
| 1219 | 579 | ), |
| 1220 | - 'email_from_name' => get_option( 'blogname' ), | |
| 1221 | - 'email_from_address' => get_option( 'admin_email' ), | |
| 580 | + 'email_from_name' => get_option('blogname'), | |
| 581 | + 'email_from_address' => get_option('admin_email'), | |
| 1222 | 582 | 'email_footer_text' => '', |
| 1223 | - 'earning_admin_commission' => '20', | |
| 1224 | - 'earning_instructor_commission' => '80', | |
| 1225 | - 'color_preset_type' => 'default', | |
| 1226 | - | |
| 1227 | - // Default options for tutor ecommerce. | |
| 1228 | - 'monetize_by' => Ecommerce::MONETIZE_BY, | |
| 1229 | - 'currency_code' => 'USD', | |
| 1230 | - 'currency_position' => 'left', | |
| 1231 | - 'thousand_separator' => ',', | |
| 1232 | - 'decimal_separator' => '.', | |
| 1233 | - 'number_of_decimals' => '2', | |
| 1234 | - 'is_coupon_applicable' => 'on', | |
| 1235 | - 'supported_video_sources' => array( | |
| 1236 | - 'html5', | |
| 1237 | - 'external_url', | |
| 1238 | - 'youtube', | |
| 1239 | - 'vimeo', | |
| 1240 | - 'embedded', | |
| 1241 | - 'shortcode', | |
| 1242 | - ), | |
| 583 | + 'earning_admin_commission' => '20', | |
| 584 | + 'earning_admin_commission' => '20', | |
| 585 | + 'earning_instructor_commission' => '80' | |
| 1243 | 586 | ); |
| 1244 | - | |
| 1245 | 587 | return $options; |
| 1246 | 588 | } |
| 1247 | 589 | |
| 1248 | 590 | |
| @@ -1248,11 +590,11 @@ | ||
| 1248 | 590 | |
| 1249 | 591 | /** |
| 1250 | 592 | * Create withdraw database |
| 1251 | 593 | * |
| 1252 | - * @since 1.2.0 | |
| 594 | + * @since v.1.2.0 | |
| 1253 | 595 | */ |
| 1254 | - public static function create_withdraw_database() { | |
| 596 | + public static function create_withdraw_database(){ | |
| 1255 | 597 | global $wpdb; |
| 1256 | 598 | |
| 1257 | 599 | $charset_collate = $wpdb->get_charset_collate(); |
| 1258 | 600 | |
| @@ -1261,16 +603,16 @@ | ||
| 1261 | 603 | * |
| 1262 | 604 | * {$wpdb->prefix}tutor_earnings |
| 1263 | 605 | * {$wpdb->prefix}tutor_withdraws |
| 1264 | 606 | * |
| 1265 | - * @since 1.2.0 | |
| 607 | + * @since v.1.2.0 | |
| 1266 | 608 | */ |
| 1267 | 609 | |
| 1268 | 610 | $earning_table = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}tutor_earnings ( |
| 1269 | - earning_id bigint(20) NOT NULL AUTO_INCREMENT, | |
| 1270 | - user_id bigint(20) DEFAULT NULL, | |
| 1271 | - course_id bigint(20) DEFAULT NULL, | |
| 1272 | - order_id bigint(20) DEFAULT NULL, | |
| 611 | + earning_id int(11) NOT NULL AUTO_INCREMENT, | |
| 612 | + user_id int(11) DEFAULT NULL, | |
| 613 | + course_id int(11) DEFAULT NULL, | |
| 614 | + order_id int(11) DEFAULT NULL, | |
| 1273 | 615 | order_status varchar(50) DEFAULT NULL, |
| 1274 | 616 | course_price_total decimal(16,2) DEFAULT NULL, |
| 1275 | 617 | course_price_grand_total decimal(16,2) DEFAULT NULL, |
| 1276 | 618 | instructor_amount decimal(16,2) DEFAULT NULL, |
| @@ -1286,10 +628,10 @@ | ||
| 1286 | 628 | PRIMARY KEY (earning_id) |
| 1287 | 629 | ) $charset_collate;"; |
| 1288 | 630 | |
| 1289 | 631 | $withdraw_table = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}tutor_withdraws ( |
| 1290 | - withdraw_id bigint(20) NOT NULL AUTO_INCREMENT, | |
| 1291 | - user_id bigint(20) DEFAULT NULL, | |
| 632 | + withdraw_id int(11) NOT NULL AUTO_INCREMENT, | |
| 633 | + user_id int(11) DEFAULT NULL, | |
| 1292 | 634 | amount decimal(16,2) DEFAULT NULL, |
| 1293 | 635 | method_data text DEFAULT NULL, |
| 1294 | 636 | status varchar(50) DEFAULT NULL, |
| 1295 | 637 | updated_at datetime DEFAULT NULL, |
| @@ -1296,9 +638,9 @@ | ||
| 1296 | 638 | created_at datetime DEFAULT NULL, |
| 1297 | 639 | PRIMARY KEY (withdraw_id) |
| 1298 | 640 | ) $charset_collate;"; |
| 1299 | 641 | |
| 1300 | - require_once ABSPATH . 'wp-admin/includes/upgrade.php'; | |
| 642 | + require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); | |
| 1301 | 643 | dbDelta( $earning_table ); |
| 1302 | 644 | dbDelta( $withdraw_table ); |
| 1303 | 645 | |
| 1304 | 646 | /** |
| @@ -1303,119 +645,26 @@ | ||
| 1303 | 645 | |
| 1304 | 646 | /** |
| 1305 | 647 | * Setting previous dashboard to new dashboard |
| 1306 | 648 | */ |
| 1307 | - $previous_dashboard_page_id = (int) tutor_utils()->get_option( 'student_dashboard' ); | |
| 1308 | - tutor_utils()->update_option( 'tutor_dashboard_page_id', $previous_dashboard_page_id ); | |
| 649 | + $previous_dashboard_page_id = (int) tutor_utils()->get_option('student_dashboard'); | |
| 650 | + tutor_utils()->update_option('tutor_dashboard_page_id', $previous_dashboard_page_id); | |
| 1309 | 651 | } |
| 1310 | 652 | |
| 1311 | 653 | /** |
| 1312 | - * Filter the wp_doing_ajax from tutor requests to get advanced | |
| 1313 | - * advantages from Tutor | |
| 654 | + * @param $bool | |
| 1314 | 655 | * |
| 1315 | - * @since 1.3.4 | |
| 656 | + * @return bool | |
| 1316 | 657 | * |
| 1317 | - * @param bool $bool default value. | |
| 658 | + * Filter the wp_doing_ajax from tutor requests to get advanced advantages from Tutor | |
| 1318 | 659 | * |
| 1319 | - * @return bool | |
| 660 | + * @since v.1.3.4 | |
| 1320 | 661 | */ |
| 1321 | - public function wp_doing_ajax( $bool ) { | |
| 1322 | - // Don't use Input::has helper to avoid conflict. | |
| 1323 | - if ( isset( $_REQUEST['tutor_ajax_action'] ) ) { | |
| 662 | + public function wp_doing_ajax($bool){ | |
| 663 | + if (isset($_REQUEST['tutor_ajax_action'])){ | |
| 1324 | 664 | return true; |
| 1325 | 665 | } |
| 1326 | 666 | return $bool; |
| 1327 | 667 | } |
| 1328 | 668 | |
| 1329 | - /** | |
| 1330 | - * Handle plugin un-installation | |
| 1331 | - * | |
| 1332 | - * @since 2.6.2 | |
| 1333 | - * | |
| 1334 | - * @return void | |
| 1335 | - */ | |
| 1336 | - public static function tutor_uninstall() { | |
| 1337 | - self::erase_tutor_data(); | |
| 1338 | - } | |
| 1339 | 669 | |
| 1340 | - /** | |
| 1341 | - * Erase tutor data | |
| 1342 | - * | |
| 1343 | - * @since 2.6.2 | |
| 1344 | - * | |
| 1345 | - * @return void | |
| 1346 | - */ | |
| 1347 | - public static function erase_tutor_data() { | |
| 1348 | - global $wpdb; | |
| 1349 | - | |
| 1350 | - $is_erase_data = tutor_utils()->get_option( 'delete_on_uninstall' ); | |
| 1351 | - // Deleting Data. | |
| 1352 | - | |
| 1353 | - if ( $is_erase_data ) { | |
| 1354 | - /** | |
| 1355 | - * Deleting Post Type, Meta Data, taxonomy | |
| 1356 | - */ | |
| 1357 | - $course_post_type = tutor()->course_post_type; | |
| 1358 | - $lesson_post_type = tutor()->lesson_post_type; | |
| 1359 | - | |
| 1360 | - $post_types = array( | |
| 1361 | - $course_post_type, | |
| 1362 | - $lesson_post_type, | |
| 1363 | - 'tutor_quiz', | |
| 1364 | - 'tutor_enrolled', | |
| 1365 | - 'topics', | |
| 1366 | - 'tutor_enrolled', | |
| 1367 | - 'tutor_announcements', | |
| 1368 | - ); | |
| 1369 | - | |
| 1370 | - $in_clause = QueryHelper::prepare_in_clause( $post_types ); | |
| 1371 | - $tutor_posts = $wpdb->get_col( $wpdb->prepare( "SELECT ID from {$wpdb->posts} WHERE post_type IN({$in_clause}) ;" ) ); //phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared | |
| 1372 | - | |
| 1373 | - if ( is_array( $tutor_posts ) && count( $tutor_posts ) ) { | |
| 1374 | - foreach ( $tutor_posts as $post_id ) { | |
| 1375 | - // Delete categories. | |
| 1376 | - $terms = wp_get_object_terms( $post_id, CourseModel::COURSE_CATEGORY ); | |
| 1377 | - foreach ( $terms as $term ) { | |
| 1378 | - wp_remove_object_terms( $post_id, array( $term->term_id ), CourseModel::COURSE_CATEGORY ); | |
| 1379 | - } | |
| 1380 | - | |
| 1381 | - // Delete tags if available. | |
| 1382 | - $terms = wp_get_object_terms( $post_id, CourseModel::COURSE_TAG ); | |
| 1383 | - foreach ( $terms as $term ) { | |
| 1384 | - wp_remove_object_terms( $post_id, array( $term->term_id ), CourseModel::COURSE_TAG ); | |
| 1385 | - } | |
| 1386 | - | |
| 1387 | - // Delete All Meta. | |
| 1388 | - $wpdb->delete( $wpdb->postmeta, array( 'post_id' => $post_id ) ); | |
| 1389 | - $wpdb->delete( $wpdb->posts, array( 'ID' => $post_id ) ); | |
| 1390 | - } | |
| 1391 | - } | |
| 1392 | - | |
| 1393 | - /** | |
| 1394 | - * Deleting Comments (reviews, questions, quiz_answers, etc) | |
| 1395 | - */ | |
| 1396 | - $tutor_comments = $wpdb->get_col( "SELECT comment_ID from {$wpdb->comments} WHERE comment_agent = 'comment_agent' ;" ); | |
| 1397 | - if ( is_array( $tutor_comments ) && count( $tutor_comments ) ) { | |
| 1398 | - $in_clause = QueryHelper::prepare_in_clause( $tutor_comments ); | |
| 1399 | - $wpdb->query( $wpdb->prepare( "DELETE from {$wpdb->commentmeta} WHERE comment_ID in({$in_clause}) " ) ); //phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared | |
| 1400 | - } | |
| 1401 | - $wpdb->delete( $wpdb->comments, array( 'comment_agent' => 'comment_agent' ) ); | |
| 1402 | - | |
| 1403 | - /** | |
| 1404 | - * Delete Options | |
| 1405 | - */ | |
| 1406 | - | |
| 1407 | - delete_option( 'tutor_option' ); | |
| 1408 | - $wpdb->delete( $wpdb->usermeta, array( 'meta_key' => '_is_tutor_student' ) ); | |
| 1409 | - $wpdb->delete( $wpdb->usermeta, array( 'meta_key' => '_tutor_instructor_approved' ) ); | |
| 1410 | - $wpdb->delete( $wpdb->usermeta, array( 'meta_key' => '_tutor_instructor_status' ) ); | |
| 1411 | - $wpdb->delete( $wpdb->usermeta, array( 'meta_key' => '_is_tutor_instructor' ) ); | |
| 1412 | - $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '%_tutor_completed_lesson_id_%' " ); | |
| 1413 | - | |
| 1414 | - // Deleting Table. | |
| 1415 | - $prefix = $wpdb->prefix; | |
| 1416 | - //phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared | |
| 1417 | - $wpdb->query( "DROP TABLE IF EXISTS {$prefix}tutor_quiz_attempts, {$prefix}tutor_quiz_attempt_answers, {$prefix}tutor_quiz_questions, {$prefix}tutor_quiz_question_answers, {$prefix}tutor_earnings, {$prefix}tutor_withdraws " ); | |
| 1418 | - | |
| 1419 | - } | |
| 1420 | - } | |
| 1421 | -} | |
| 670 | +} | |