PluginProbe ʕ •ᴥ•ʔ
Auto Post Cleaner / 3.7.6
Auto Post Cleaner v3.7.6
3.12.0 3.13.1 3.2.4 3.2.5 3.3.0 3.3.10 3.3.11 3.3.8 3.4.2 3.5.3 3.6.0 3.7.0 3.7.1 3.7.2 3.7.3 3.7.5 3.7.6 3.8.0 3.9.0 3.9.4 3.9.6 3.9.7 trunk 3.0.0 3.1.0 3.10.1 3.10.2 3.11.4
delete-old-posts-programmatically / inc / class-enqueue-assets.php
delete-old-posts-programmatically / inc Last commit date
class-delete-old-posts-filters.php 2 years ago class-delete-old-posts-redirects.php 2 years ago class-delete-old-posts.php 2 years ago class-enqueue-assets.php 2 years ago
class-enqueue-assets.php
70 lines
1 <?php
2 namespace DEL\OLD\Posts\Cls\Assets;
3
4 /**
5 * Enqueue Assets
6 */
7
8 class Enqueue_Assets {
9
10 /**
11 * Constructor.
12 */
13 public function __construct() {
14 /**
15 * Actions.
16 */
17 add_action( 'admin_enqueue_scripts', [ $this, 'deloldp_EnqueueAssets' ] );
18 add_filter( 'style_loader_src', [ $this, 'deloldp_StyleandScriptSrcVerStrip' ], 10, 2 );
19 add_filter( 'script_loader_src', [ $this, 'deloldp_StyleandScriptSrcVerStrip' ], 10, 2 );
20 }
21
22 /**
23 * Enqueue editor scripts & styles.
24 *
25 */
26 public function deloldp_EnqueueAssets() {
27 global $wp;
28
29 /**
30 * check the page url
31 */
32 $current_url = home_url($_SERVER['REQUEST_URI']);
33
34 /**
35 * load assets only if is page of the plugin
36 */
37 if( stristr( $current_url, 'page=delete-old-posts' ) !== false || stristr( $current_url, 'page=delete-old-posts-filters' ) !== false ) {
38 $vers = $this->delop_get_plugin_version();
39 wp_enqueue_style ( 'tailwind', plugin_dir_url( __FILE__ ) . '../assets/css/tailwind.css', false, $vers, 'all');
40 wp_enqueue_script ( 'alpine', plugin_dir_url( __FILE__ ) . '../assets/js/alpine.min.js', [], $vers, true);
41 wp_enqueue_script ( 'script', plugin_dir_url( __FILE__ ) . '../assets/js/deloldp_script.js', [], $vers, true);
42 }
43 }
44
45 /**
46 * Strip WP Version in Stylesheets/Scripts
47 */
48 function deloldp_StyleandScriptSrcVerStrip( $src, $handle ) {
49 /**
50 * use it for external css or js
51 */
52 if(stristr($src,'alpinejs')) $src = remove_query_arg( 'ver', $src );
53 return $src;
54 }
55
56 function delop_get_plugin_version(){
57 if ( is_admin() ) {
58 if( ! function_exists('get_plugin_data') ){
59 require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
60 }
61 $plugin_data = get_plugin_data( dirname(__DIR__, 1) . '/' . basename(dirname(__DIR__, 1)) . '.php' );
62
63 if( isset($plugin_data['Version']) && $plugin_data['Version'] != '' ) return $plugin_data['Version'];
64 else return date('d_m_Y_H');
65 }
66 }
67 }
68
69 // new Enqueue_Assets();
70