Created
February 12, 2024 12:31
-
-
Save tguruslan/5f79d22205d9690b150d9aa0085eaa83 to your computer and use it in GitHub Desktop.
udpu folder tree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: udpu folder tree | |
Plugin URI: # | |
Description: для додавання використайте: [udpu_folder_tree path=""] | |
Author: Tgu | |
Version: 1.0.0 | |
Author URI: # | |
*/ | |
add_shortcode("udpu_folder_tree", function($atts, $content = null) { | |
extract(shortcode_atts(array("path" => ''), $atts)); | |
$req = wp_remote_get('https://udpu.edu.ua/index.php?option=com_ajax&module=listdir&method=iframe&format=raw&path='.$path); | |
if(is_wp_error($req)){ | |
return; | |
}else{ | |
$dom = new DOMDocument; | |
$dom->loadHTML('<meta charset="utf-8">' .$req['body']); | |
$style = $dom->saveHTML($dom->getElementsByTagName('head')->item(0)->getElementsByTagName('style')->item(0)); | |
add_action('wp_footer', function(){ | |
?> | |
<script type="text/javascript"> | |
(function($){ | |
$(document).ready(function(){ | |
$(document).find('.rs_dir').on('click',function(){ | |
$(this).find('>folder').toggleClass('open'); | |
}); | |
}); | |
})(jQuery); | |
</script> | |
<?php | |
}); | |
return $style.$dom->saveHTML($dom->getElementsByTagName('body')->item(0)); | |
} | |
}); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment