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