PluginProbe ʕ •ᴥ•ʔ
Auto Post Cleaner / 3.10.2
Auto Post Cleaner v3.10.2
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 10 months ago class-delete-old-posts-redirects.php 10 months ago class-delete-old-posts.php 10 months ago class-enqueue-assets.php 10 months ago
class-enqueue-assets.php
73 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 ( 'alpine_script', plugin_dir_url( __FILE__ ) . '../assets/js/deloldp_alpine.js', [], $vers, true);
42 wp_enqueue_script ( 'multi_select', plugin_dir_url( __FILE__ ) . '../assets/js/delp_multi_select.js', [], $vers, true);
43 wp_enqueue_style ( 'multi_select', plugin_dir_url( __FILE__ ) . '../assets/css/delp_multi_select.css', false, $vers, 'all');
44 wp_enqueue_script ( 'delp_script', plugin_dir_url( __FILE__ ) . '../assets/js/delp_script.js', ['jquery', 'chosen'], $vers, true);
45 }
46 }
47
48 /**
49 * Strip WP Version in Stylesheets/Scripts
50 */
51 function deloldp_StyleandScriptSrcVerStrip( $src, $handle ) {
52 /**
53 * use it for external css or js
54 */
55 if(stristr($src,'alpinejs')) $src = remove_query_arg( 'ver', $src );
56 return $src;
57 }
58
59 function delop_get_plugin_version(){
60 if ( is_admin() ) {
61 if( ! function_exists('get_plugin_data') ){
62 require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
63 }
64 $plugin_data = get_plugin_data( dirname(__DIR__, 1) . '/' . basename(dirname(__DIR__, 1)) . '.php' );
65
66 if( isset($plugin_data['Version']) && $plugin_data['Version'] != '' ) return $plugin_data['Version'];
67 else return date('d_m_Y_H');
68 }
69 }
70 }
71
72 // new Enqueue_Assets();
73