Addons.php
6 years ago
Admin.php
6 years ago
Ajax.php
6 years ago
Assets.php
6 years ago
Course.php
6 years ago
Course_Widget.php
6 years ago
Dashboard.php
6 years ago
Gutenberg.php
6 years ago
Instructor.php
6 years ago
Instructors_List.php
6 years ago
Lesson.php
6 years ago
Options.php
6 years ago
Post_types.php
6 years ago
Q_and_A.php
6 years ago
Question.php
6 years ago
Question_Answers_List.php
6 years ago
Quiz.php
6 years ago
Quiz_Attempts_List.php
6 years ago
Rewrite_Rules.php
6 years ago
Shortcode.php
6 years ago
Student.php
6 years ago
Students_List.php
6 years ago
Taxonomies.php
6 years ago
Template.php
6 years ago
Theme_Compatibility.php
6 years ago
Tools.php
6 years ago
Tutor.php
6 years ago
TutorEDD.php
6 years ago
Tutor_Base.php
6 years ago
Tutor_List_Table.php
6 years ago
Upgrader.php
6 years ago
User.php
6 years ago
Utils.php
6 years ago
Video_Stream.php
6 years ago
Withdraw.php
6 years ago
Withdraw_Requests_List.php
6 years ago
WooCommerce.php
6 years ago
Upgrader.php
54 lines
| 1 | <?php |
| 2 | |
| 3 | namespace TUTOR; |
| 4 | |
| 5 | |
| 6 | if ( ! defined( 'ABSPATH' ) ) |
| 7 | exit; |
| 8 | |
| 9 | class Upgrader { |
| 10 | |
| 11 | public function __construct() { |
| 12 | add_action('admin_init', array($this, 'init_upgrader')); |
| 13 | } |
| 14 | |
| 15 | public function init_upgrader(){ |
| 16 | $upgrades = $this->available_upgrades(); |
| 17 | |
| 18 | if (tutor_utils()->count($upgrades)){ |
| 19 | foreach ($upgrades as $upgrade){ |
| 20 | $this->{$upgrade}(); |
| 21 | } |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | public function available_upgrades(){ |
| 26 | $version = get_option('tutor_version'); |
| 27 | |
| 28 | $upgrades = array(); |
| 29 | if ($version){ |
| 30 | $upgrades[] = 'upgrade_to_1_3_1'; |
| 31 | } |
| 32 | |
| 33 | return $upgrades; |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Upgrade to version 1.3.1 |
| 38 | */ |
| 39 | public function upgrade_to_1_3_1(){ |
| 40 | if (version_compare(get_option('tutor_version'), '1.3.1', '<')) { |
| 41 | global $wpdb; |
| 42 | |
| 43 | if ( ! get_option('is_course_post_type_updated')){ |
| 44 | $wpdb->update($wpdb->posts, array('post_type' => 'courses'), array('post_type' => 'course')); |
| 45 | update_option('is_course_post_type_updated', true); |
| 46 | update_option('tutor_version', '1.3.1'); |
| 47 | flush_rewrite_rules(); |
| 48 | } |
| 49 | |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | |
| 54 | } |