| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Compatibility Plugin Name: WordPress LMS Plugin by LearnDash® |
| 5 |
* Compatibility Plugin URI: https://www.learndash.com/ |
| 6 |
* |
| 7 |
* Compatibility Description: Ensures compatibility with LearnDash®. |
| 8 |
* |
| 9 |
*/ |
| 10 |
|
| 11 |
namespace wpCloud\StatelessMedia { |
| 12 |
|
| 13 |
if (!class_exists('wpCloud\StatelessMedia\LearnDash')) { |
| 14 |
|
| 15 |
class LearnDash extends Compatibility { |
| 16 |
protected $id = 'sfwd-lms'; |
| 17 |
protected $title = 'LearnDash LMS'; |
| 18 |
protected $constant = 'WP_STATELESS_COMPATIBILITY_LEARNDASH_LMS'; |
| 19 |
protected $description = 'Ensures compatibility with LearnDash.'; |
| 20 |
protected $plugin_file = ['sfwd-lms/sfwd_lms.php']; |
| 21 |
protected $enabled = false; |
| 22 |
protected $is_internal = true; |
| 23 |
|
| 24 |
/** |
| 25 |
* @param $sm |
| 26 |
*/ |
| 27 |
public function module_init($sm) { |
| 28 |
// exclude randomize_filename from LearnDash page |
| 29 |
add_filter('stateless_skip_cache_busting', array($this, 'skip_cache_busting'), 10, 2); |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Whether skip cache busting or not. |
| 34 |
* |
| 35 |
* @param $return |
| 36 |
* @param $filename |
| 37 |
* @return mixed |
| 38 |
*/ |
| 39 |
public function skip_cache_busting($return, $filename) { |
| 40 |
if (strpos($filename, 'sfwd-') === 0 || $this->hook_from_learndash()) { |
| 41 |
return $filename; |
| 42 |
} |
| 43 |
return $return; |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Determine where we hook from |
| 48 |
* We need to do this only for something specific in LearnDash plugin |
| 49 |
* |
| 50 |
* @return bool |
| 51 |
*/ |
| 52 |
private function hook_from_learndash() { |
| 53 |
$call_stack = debug_backtrace(); |
| 54 |
if ( |
| 55 |
!empty($call_stack[6]['function']) && |
| 56 |
$call_stack[6]['function'] == 'sanitize_file_name' && |
| 57 |
(strpos($call_stack[6]['file'], 'class-ld-semper-fi-module.php') || |
| 58 |
strpos($call_stack[6]['file'], 'class-ld-cpt-instance.php')) |
| 59 |
) { |
| 60 |
return true; |
| 61 |
} |
| 62 |
|
| 63 |
return false; |
| 64 |
} |
| 65 |
} |
| 66 |
} |
| 67 |
} |
| 68 |
|