PluginProbe
Protect Uploads / 0.2
Protect Uploads v0.2
0.7.1 trunk 0.1 0.2 0.3 0.4 0.5.1 0.5.2 0.6.0 0.7.0
protect-uploads / includes / class-protect-uploads.php

class-protect-uploads.php in Protect Uploads 0.2, at includes/class-protect-uploads.php

92 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class Alti_ProtectUploads {
4
5 protected $version;
6 protected $plugin_name;
7 protected $loader;
8
9 /**
10 * constructor
11 */
12 public function __construct() {
13
14 $this->version = '0.1';
15 $this->plugin_name = 'protect-uploads';
16
17 $this->load_dependencies();
18 $this->set_locale();
19 $this->define_admin_hooks();
20
21 }
22
23 /**
24 * load seperate files needed to trigger actions or filters, translation and admin class only since public class has to be autonomous.
25 */
26 private function load_dependencies() {
27
28 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-protect-uploads-loader.php';
29 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-protect-uploads-i18n.php';
30 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-protect-uploads-admin.php';
31
32 $this->loader = new Alti_ProtectUploads_Loader();
33
34 }
35
36 /**
37 * set locale for translation ends.
38 */
39 private function set_locale() {
40
41 $plugin_i18n = new Alti_ProtectUploads_i18n();
42 $plugin_i18n->set_domain( $this->get_plugin_name() );
43
44 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
45
46 }
47
48 /**
49 * action and filter for admin side
50 */
51 private function define_admin_hooks() {
52
53 $plugin_admin = new Alti_ProtectUploads_Admin( $this->get_plugin_name(), $this->get_version() );
54
55 $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_submenu_page' );
56 $this->loader->add_filter( 'plugin_action_links_' . $this->get_plugin_name() . '/' . $this->get_plugin_name() . '.php', $plugin_admin, 'add_settings_link' );
57 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
58 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
59
60 }
61
62 /**
63 * run the whole logic of the plugin
64 */
65 public function run() {
66 $this->loader->run();
67 }
68
69 /**
70 * get plugin name from constructor
71 * @return string plugin name
72 */
73 public function get_plugin_name() {
74 return $this->plugin_name;
75 }
76
77 /**
78 * get loader
79 */
80 public function get_loader() {
81 return $this->loader;
82 }
83
84 /**
85 * get version of plugin from constructor
86 * @return string current version
87 */
88 public function get_version() {
89 return $this->version;
90 }
91
92 }