| 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 |
/** |
| 22 |
* @param $sm |
| 23 |
*/ |
| 24 |
public function module_init( $sm ) { |
| 25 |
// exclude randomize_filename from LearnDash page |
| 26 |
add_filter( 'stateless_skip_cache_busting', array( $this, 'skip_cache_busting' ), 10, 2 ); |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Whether skip cache busting or not. |
| 31 |
* |
| 32 |
* @param $return |
| 33 |
* @param $filename |
| 34 |
* @return mixed |
| 35 |
*/ |
| 36 |
public function skip_cache_busting( $return, $filename ) { |
| 37 |
if( strpos( $filename, 'sfwd-' ) === 0 || $this->hook_from_learndash() ) { |
| 38 |
return $filename; |
| 39 |
} |
| 40 |
return $return; |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Determine where we hook from |
| 45 |
* We need to do this only for something specific in LearnDash plugin |
| 46 |
* |
| 47 |
* @return bool |
| 48 |
*/ |
| 49 |
private function hook_from_learndash() { |
| 50 |
$call_stack = debug_backtrace(); |
| 51 |
if( |
| 52 |
!empty($call_stack[6]['function']) && |
| 53 |
$call_stack[6]['function'] == 'sanitize_file_name' && |
| 54 |
( |
| 55 |
strpos( $call_stack[6]['file'], 'class-ld-semper-fi-module.php' ) || |
| 56 |
strpos( $call_stack[6]['file'], 'class-ld-cpt-instance.php' ) |
| 57 |
) |
| 58 |
) { |
| 59 |
return true; |
| 60 |
} |
| 61 |
|
| 62 |
return false; |
| 63 |
} |
| 64 |
|
| 65 |
} |
| 66 |
|
| 67 |
} |
| 68 |
|
| 69 |
} |
| 70 |
|