PluginProbe
WP-Stateless – Google Cloud Storage / trunk
WP-Stateless – Google Cloud Storage vtrunk
4.4.3 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.3.0 2.3.1 2.3.2 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 All 62 releases
wp-stateless / lib / classes / compatibility / learn-dash.php

learn-dash.php in WP-Stateless – Google Cloud Storage trunk, at lib/classes/compatibility/learn-dash.php

68 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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