-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmpp-disable-anonymous-upload.php
83 lines (72 loc) · 1.61 KB
/
mpp-disable-anonymous-upload.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
* Plugin Name: MediaPress - Disable Anonymous Upload
* Plugin URI: http://github.com/mediapress/mpp-disable-anonymous-upload/
* Version: 1.0.1
* Author: BuddyDev Team
* Author URI: http://buddydev.com
* Description: Disables anonymous upload. It works with BP Anonymous upload plugin.
* License: GPL2 or Above
*/
defined( 'ABSPATH' ) || exit;
/**
* Main plugin class
*/
class MPP_DAUpload_Helper {
/**
* Singleton Instance
*
* @var MPP_DAUpload_Helper|null
*/
private static ?MPP_DAUpload_Helper $instance = null;
/**
* Constructor.
*/
private function __construct() {
$this->setup();
}
/**
* Retrieves singleton instance.
*
* @return MPP_DAUpload_Helper
*/
public static function get_instance(): MPP_DAUpload_Helper {
if ( is_null( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Sets up plugin hooks
*/
private function setup(): void {
add_action( 'mpp_init', array( $this, 'load_textdomain' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'load_js' ) );
}
/**
* Loads plugin translations
*/
public function load_textdomain(): void {
load_plugin_textdomain(
'mpp-disable-anonymous-upload',
false,
basename( dirname( __FILE__ ) ) . '/languages/'
);
}
/**
* Loads required JavaScript files
*/
public function load_js(): void {
if ( is_admin() ) {
return;
}
wp_register_script(
'mpp_daupload_js',
plugin_dir_url( __FILE__ ) . 'assets/mpp-daupload.js',
array( 'mpp_core' )
);
wp_enqueue_script( 'mpp_daupload_js' );
}
}
// Initialize plugin.
MPP_DAUpload_Helper::get_instance();