-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass-learndash.php
59 lines (52 loc) · 1.47 KB
/
class-learndash.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
<?php
namespace WPSL\LearnDash;
use wpCloud\StatelessMedia\Compatibility;
use wpCloud\StatelessMedia\Utility;
/**
* @todo make testable and test
*/
class LearnDash extends Compatibility {
protected $id = 'sfwd-lms';
protected $title = 'LearnDash LMS';
protected $constant = 'WP_STATELESS_COMPATIBILITY_LEARNDASH_LMS';
protected $description = 'Ensures compatibility with LearnDash.';
protected $plugin_file = ['sfwd-lms/sfwd_lms.php'];
/**
* @param $sm
*/
public function module_init($sm) {
// exclude randomize_filename from LearnDash page
add_filter('stateless_skip_cache_busting', array($this, 'skip_cache_busting'), 10, 2);
}
/**
* Whether skip cache busting or not.
*
* @param $return
* @param $filename
* @return mixed
*/
public function skip_cache_busting($return, $filename) {
if (strpos($filename, 'sfwd-') === 0 || $this->hook_from_learndash()) {
return $filename;
}
return $return;
}
/**
* Determine where we hook from
* We need to do this only for something specific in LearnDash plugin
*
* @return bool
*/
private function hook_from_learndash() {
$call_stack = debug_backtrace();
if (
!empty($call_stack[6]['function']) &&
$call_stack[6]['function'] == 'sanitize_file_name' &&
(strpos($call_stack[6]['file'], 'class-ld-semper-fi-module.php') ||
strpos($call_stack[6]['file'], 'class-ld-cpt-instance.php'))
) {
return true;
}
return false;
}
}