/
llms-functions-updates-343.php
55 lines (46 loc) · 1.12 KB
/
llms-functions-updates-343.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
<?php
/**
* Update functions for version 3.4.3
*
* @package LifterLMS/Functions/Updates
*
* @since 3.39.0
* @version 3.39.0
*/
defined( 'ABSPATH' ) || exit;
/**
* Rename meta keys for parent section and parent course relationships for all LifterLMS Lessons and Sections
*
* @since 3.4.3
*
* @return void
*/
function llms_update_343_update_relationships() {
global $wpdb;
// Update parent course key for courses and lessons.
$wpdb->query(
"UPDATE {$wpdb->postmeta} AS m
JOIN {$wpdb->posts} AS p ON p.ID = m.post_id
SET m.meta_key = '_llms_parent_course'
WHERE m.meta_key = '_parent_course'
AND ( p.post_type = 'lesson' OR p.post_type = 'section' );"
);
// Update parent section key for lessons.
$wpdb->query(
"UPDATE {$wpdb->postmeta} AS m
JOIN {$wpdb->posts} AS p ON p.ID = m.post_id
SET m.meta_key = '_llms_parent_section'
WHERE m.meta_key = '_parent_section'
AND p.post_type = 'lesson';"
);
}
/**
* Update db version at conclusion of 3.4.3 updates
*
* @since 3.4.3
*
* @return void
*/
function llms_update_343_update_db_version() {
LLMS_Install::update_db_version( '3.4.3' );
}