Skip to content

Commit 9404f65

Browse files
author
Md. Alimuzzaman Alim
committed
conflict with Learndash plugin #292
Conflict with Cache busting feature.
1 parent e1b8772 commit 9404f65

File tree

5 files changed

+73
-0
lines changed

5 files changed

+73
-0
lines changed

lib/classes/class-compatibility.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ public function __construct(){
9191
* Support for Divi
9292
*/
9393
new Divi();
94+
95+
/**
96+
* Support for LearnDash
97+
*/
98+
new LearnDash();
9499
}
95100

96101
/**

lib/classes/class-utility.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ public static function normalize_path( $path ) {
7272
* @return string
7373
*/
7474
public static function randomize_filename( $filename ) {
75+
$return = apply_filters('stateless_skip_cache_busting', null, $filename);
76+
if($return){
77+
return $return;
78+
}
7579
$info = pathinfo($filename);
7680
$ext = empty($info['extension']) ? '' : '' . $info['extension'];
7781
$_parts = array();
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
}

vendor/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
'wpCloud\\StatelessMedia\\GravityForm' => $baseDir . '/lib/classes/compatibility/gravity-forms.php',
3939
'wpCloud\\StatelessMedia\\ICompatibility' => $baseDir . '/lib/classes/compatibility/ICompatibility.php',
4040
'wpCloud\\StatelessMedia\\Imagify' => $baseDir . '/lib/classes/compatibility/imagify.php',
41+
'wpCloud\\StatelessMedia\\LearnDash' => $baseDir . '/lib/classes/compatibility/LearnDash.php',
4142
'wpCloud\\StatelessMedia\\Logger' => $baseDir . '/lib/classes/class-logger.php',
4243
'wpCloud\\StatelessMedia\\Module' => $baseDir . '/lib/classes/class-compatibility.php',
4344
'wpCloud\\StatelessMedia\\SOCSS' => $baseDir . '/lib/classes/compatibility/siteorigin-css.php',

vendor/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class ComposerStaticInitc00cd3c666f8dfa818cb7edfd488ed20
6363
'wpCloud\\StatelessMedia\\GravityForm' => __DIR__ . '/../..' . '/lib/classes/compatibility/gravity-forms.php',
6464
'wpCloud\\StatelessMedia\\ICompatibility' => __DIR__ . '/../..' . '/lib/classes/compatibility/ICompatibility.php',
6565
'wpCloud\\StatelessMedia\\Imagify' => __DIR__ . '/../..' . '/lib/classes/compatibility/imagify.php',
66+
'wpCloud\\StatelessMedia\\LearnDash' => __DIR__ . '/../..' . '/lib/classes/compatibility/LearnDash.php',
6667
'wpCloud\\StatelessMedia\\Logger' => __DIR__ . '/../..' . '/lib/classes/class-logger.php',
6768
'wpCloud\\StatelessMedia\\Module' => __DIR__ . '/../..' . '/lib/classes/class-compatibility.php',
6869
'wpCloud\\StatelessMedia\\SOCSS' => __DIR__ . '/../..' . '/lib/classes/compatibility/siteorigin-css.php',

0 commit comments

Comments
 (0)