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_Settings_Tabs.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
70 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 | add_action( 'in_plugin_update_message-tutor/tutor.php', array( $this, 'in_plugin_update_message' ), 10, 2 ); |
| 15 | } |
| 16 | |
| 17 | public function init_upgrader(){ |
| 18 | $upgrades = $this->available_upgrades(); |
| 19 | |
| 20 | if (tutor_utils()->count($upgrades)){ |
| 21 | foreach ($upgrades as $upgrade){ |
| 22 | $this->{$upgrade}(); |
| 23 | } |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | public function available_upgrades(){ |
| 28 | $version = get_option('tutor_version'); |
| 29 | |
| 30 | $upgrades = array(); |
| 31 | if ($version){ |
| 32 | $upgrades[] = 'upgrade_to_1_3_1'; |
| 33 | } |
| 34 | |
| 35 | return $upgrades; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Upgrade to version 1.3.1 |
| 40 | */ |
| 41 | public function upgrade_to_1_3_1(){ |
| 42 | if (version_compare(get_option('tutor_version'), '1.3.1', '<')) { |
| 43 | global $wpdb; |
| 44 | |
| 45 | if ( ! get_option('is_course_post_type_updated')){ |
| 46 | $wpdb->update($wpdb->posts, array('post_type' => 'courses'), array('post_type' => 'course')); |
| 47 | update_option('is_course_post_type_updated', true); |
| 48 | update_option('tutor_version', '1.3.1'); |
| 49 | flush_rewrite_rules(); |
| 50 | } |
| 51 | |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | |
| 56 | public function in_plugin_update_message( $args, $response ){ |
| 57 | $upgrade_notice = strip_tags(tutils()->array_get('upgrade_notice', $response)); |
| 58 | if ($upgrade_notice){ |
| 59 | |
| 60 | $upgrade_notice = "<span class='version'><code>v.{$response->new_version}</code></span> <br />".$upgrade_notice; |
| 61 | |
| 62 | echo apply_filters( 'tutor_in_plugin_update_message', $upgrade_notice ? '</p> <div class="tutor_plugin_update_notice">' .$upgrade_notice. '</div> <p class="dummy">' : '' ); |
| 63 | } |
| 64 | |
| 65 | } |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | } |