Myslideshow::run()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 2
rs 10
1
<?php
2
3
/**
4
 * The file that defines the core plugin class
5
 *
6
 * A class definition that includes attributes and functions used across both the
7
 * public-facing side of the site and the admin area.
8
 *
9
 * @link       rahicodes.wordpress.com
10
 * @since      1.0.0
11
 *
12
 * @package    Myslideshow
13
 * @subpackage Myslideshow/includes
14
 */
15
16
/**
17
 * The core plugin class.
18
 *
19
 * This is used to define internationalization, admin-specific hooks, and
20
 * public-facing site hooks.
21
 *
22
 * Also maintains the unique identifier of this plugin as well as the current
23
 * version of the plugin.
24
 *
25
 * @since      1.0.0
26
 * @package    Myslideshow
27
 * @subpackage Myslideshow/includes
28
 * @author     Rahi Prajapati <[email protected]>
29
 */
30
class Myslideshow {
31
32
	/**
33
	 * The loader that's responsible for maintaining and registering all hooks that power
34
	 * the plugin.
35
	 *
36
	 * @since    1.0.0
37
	 * @access   protected
38
	 * @var      Myslideshow_Loader    $loader    Maintains and registers all hooks for the plugin.
39
	 */
40
	protected $loader;
41
42
	/**
43
	 * The unique identifier of this plugin.
44
	 *
45
	 * @since    1.0.0
46
	 * @access   protected
47
	 * @var      string    $plugin_name    The string used to uniquely identify this plugin.
48
	 */
49
	protected $plugin_name;
50
51
	/**
52
	 * The current version of the plugin.
53
	 *
54
	 * @since    1.0.0
55
	 * @access   protected
56
	 * @var      string    $version    The current version of the plugin.
57
	 */
58
	protected $version;
59
60
	/**
61
	 * Define the core functionality of the plugin.
62
	 *
63
	 * Set the plugin name and the plugin version that can be used throughout the plugin.
64
	 * Load the dependencies, define the locale, and set the hooks for the admin area and
65
	 * the public-facing side of the site.
66
	 *
67
	 * @since    1.0.0
68
	 */
69
	public function __construct() {
70
		if ( defined( 'MYSLIDESHOW_VERSION' ) ) {
71
			$this->version = MYSLIDESHOW_VERSION;
72
		} else {
73
			$this->version = '1.0.0';
74
		}
75
		$this->plugin_name = 'myslideshow';
76
77
		$this->load_dependencies();
78
		$this->set_locale();
79
		$this->define_admin_hooks();
80
		$this->define_public_hooks();
81
82
	}
83
84
	/**
85
	 * Load the required dependencies for this plugin.
86
	 *
87
	 * Include the following files that make up the plugin:
88
	 *
89
	 * - Myslideshow_Loader. Orchestrates the hooks of the plugin.
90
	 * - Myslideshow_i18n. Defines internationalization functionality.
91
	 * - Myslideshow_Admin. Defines all hooks for the admin area.
92
	 * - Myslideshow_Public. Defines all hooks for the public side of the site.
93
	 *
94
	 * Create an instance of the loader which will be used to register the hooks
95
	 * with WordPress.
96
	 *
97
	 * @since    1.0.0
98
	 * @access   private
99
	 */
100
	private function load_dependencies() {
101
102
		/**
103
		 * The class responsible for orchestrating the actions and filters of the
104
		 * core plugin.
105
		 */
106
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-myslideshow-loader.php';
0 ignored issues
show
Bug introduced by
The function plugin_dir_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

106
		require_once /** @scrutinizer ignore-call */ plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-myslideshow-loader.php';
Loading history...
107
108
		/**
109
		 * The class responsible for defining internationalization functionality
110
		 * of the plugin.
111
		 */
112
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-myslideshow-i18n.php';
113
114
		/**
115
		 * The class responsible for defining all actions that occur in the admin area.
116
		 */
117
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-myslideshow-admin.php';
118
119
		/**
120
		 * The class responsible for defining all actions that occur in the public-facing
121
		 * side of the site.
122
		 */
123
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-myslideshow-public.php';
124
125
		/**
126
		 * this file contains all admin-side rendering
127
		 */
128
		require_once( plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/myslideshow-admin-display.php' );
129
130
131
		$this->loader = new Myslideshow_Loader();
132
133
	}
134
135
	/**
136
	 * Define the locale for this plugin for internationalization.
137
	 *
138
	 * Uses the Myslideshow_i18n class in order to set the domain and to register the hook
139
	 * with WordPress.
140
	 *
141
	 * @since    1.0.0
142
	 * @access   private
143
	 */
144
	private function set_locale() {
145
146
		$plugin_i18n = new Myslideshow_i18n();
147
148
		$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
149
150
	}
151
152
	/**
153
	 * Register all of the hooks related to the admin area functionality
154
	 * of the plugin.
155
	 *
156
	 * @since    1.0.0
157
	 * @access   private
158
	 */
159
	private function define_admin_hooks() {
160
161
		$plugin_admin = new Myslideshow_Admin( $this->get_plugin_name(), $this->get_version() );
162
163
		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
164
		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
165
166
		// Hook for slideshow settings page
167
		$this->loader->add_action( 'admin_menu', $plugin_admin, 'mss_settings_page' );
168
169
		// Hook for registering settings
170
		$this->loader->add_action( 'admin_init', $plugin_admin, 'mss_register_settings' );
171
172
		 // Hook for registering shortcode
173
		 $this->loader->add_action( 'init', $plugin_admin, 'mss_register_shortcodes' );
174
175
	}
176
177
	/**
178
	 * Register all of the hooks related to the public-facing functionality
179
	 * of the plugin.
180
	 *
181
	 * @since    1.0.0
182
	 * @access   private
183
	 */
184
	private function define_public_hooks() {
185
186
		$plugin_public = new Myslideshow_Public( $this->get_plugin_name(), $this->get_version() );
187
188
		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
189
		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
190
191
	}
192
193
	/**
194
	 * Run the loader to execute all of the hooks with WordPress.
195
	 *
196
	 * @since    1.0.0
197
	 */
198
	public function run() {
199
		$this->loader->run();
200
	}
201
202
	/**
203
	 * The name of the plugin used to uniquely identify it within the context of
204
	 * WordPress and to define internationalization functionality.
205
	 *
206
	 * @since     1.0.0
207
	 * @return    string    The name of the plugin.
208
	 */
209
	public function get_plugin_name() {
210
		return $this->plugin_name;
211
	}
212
213
	/**
214
	 * The reference to the class that orchestrates the hooks with the plugin.
215
	 *
216
	 * @since     1.0.0
217
	 * @return    Myslideshow_Loader    Orchestrates the hooks of the plugin.
218
	 */
219
	public function get_loader() {
220
		return $this->loader;
221
	}
222
223
	/**
224
	 * Retrieve the version number of the plugin.
225
	 *
226
	 * @since     1.0.0
227
	 * @return    string    The version number of the plugin.
228
	 */
229
	public function get_version() {
230
		return $this->version;
231
	}
232
233
}
234