|
1 | 1 | <?php |
| 2 | +/** |
| 3 | + * Main Plugin Class |
| 4 | + * |
| 5 | + * @package WordPress |
| 6 | + */ |
2 | 7 |
|
3 | 8 | namespace PHX_WP_DEVKIT\V_3_0; |
4 | 9 |
|
5 | 10 | use PHX_WP_DEVKIT\V_3_0\Admin; |
6 | | -use WPAZ_Plugin_Base\V_2_6\Abstract_Plugin as Base; |
| 11 | +use WPAZ_Plugin_Base\V_2_6\Abstract_Plugin; |
7 | 12 |
|
8 | 13 | /** |
9 | 14 | * Class Plugin |
| 15 | + * |
10 | 16 | * @package Wordpress_development_toolkit |
11 | 17 | */ |
12 | | -class Plugin extends Base { |
| 18 | +class Plugin extends Abstract_Plugin { |
13 | 19 |
|
14 | 20 | /** |
15 | | - * @var string |
| 21 | + * Use magic constant to tell abstract class current namespace as prefix for all other namespaces in the plugin. |
| 22 | + * |
| 23 | + * @var string $autoload_class_prefix magic constant |
16 | 24 | */ |
17 | 25 | public static $autoload_class_prefix = __NAMESPACE__; |
18 | 26 |
|
19 | 27 | /** |
20 | | - * @var string |
21 | | - */ |
22 | | - public static $autoload_type = 'psr-4'; |
23 | | - |
24 | | - /** |
25 | | - * @var int |
26 | | - */ |
27 | | - public static $autoload_ns_match_depth = 2; |
28 | | - |
29 | | - /** |
30 | | - * @var string |
| 28 | + * Magic constant trick that allows extended classes to pull actual server file location, copy into subclass. |
| 29 | + * |
| 30 | + * @var string $current_file |
31 | 31 | */ |
32 | 32 | protected static $current_file = __FILE__; |
33 | 33 |
|
34 | 34 | /** |
35 | | - * @param mixed $instance |
| 35 | + * Initialize the plugin - for public (front end) |
| 36 | + * |
| 37 | + * @param mixed $instance Parent instance passed through to child. |
| 38 | + * |
| 39 | + * @return void |
36 | 40 | */ |
37 | 41 | public function onload( $instance ) { |
38 | 42 | } |
39 | 43 |
|
40 | 44 | /** |
41 | | - * Initialize public / shared functionality |
| 45 | + * Initialize the plugin - for public (front end) |
| 46 | + * Example of building a module of the plugin into init |
| 47 | + * ```$this->modules->FS_Mail = new FS_Mail( $this, $this->plugin_object_basedir );``` |
| 48 | + * |
| 49 | + * @since 0.1 |
| 50 | + * @return void |
42 | 51 | */ |
43 | 52 | public function init() { |
44 | 53 | do_action( get_called_class() . '_before_init' ); |
45 | | - // silence is golden :) |
| 54 | + // Add hooks and filters, or other init scopped code here. |
46 | 55 | do_action( get_called_class() . '_after_init' ); |
47 | 56 | } |
48 | 57 |
|
49 | 58 | /** |
50 | | - * Initialize functionality only loaded for logged-in users |
| 59 | + * Initialize the plugin - for admin (back end) |
| 60 | + * You would expected this to be handled on action admin_init, but it does not properly handle |
| 61 | + * the use case for all logged in user actions. Always keep is_user_logged_in() wrapper within |
| 62 | + * this function for proper usage. |
| 63 | + * |
| 64 | + * @return void |
51 | 65 | */ |
52 | 66 | public function authenticated_init() { |
53 | 67 | if ( is_user_logged_in() ) { |
54 | 68 | do_action( get_called_class() . '_before_authenticated_init' ); |
55 | 69 | new Admin\Init( |
56 | | - trailingslashit( $this->installed_dir ), |
57 | | - trailingslashit( $this->installed_url ), |
58 | | - $this->version |
59 | | - ); |
| 70 | + trailingslashit( $this->installed_dir ), |
| 71 | + trailingslashit( $this->installed_url ), |
| 72 | + $this->version |
| 73 | + ); |
60 | 74 | do_action( get_called_class() . '_after_authenticated_init' ); |
61 | 75 | } |
62 | 76 | } |
63 | 77 |
|
64 | 78 | /** |
| 79 | + * Enforce that the plugin prepare any defines or globals in a standard location. |
| 80 | + * |
65 | 81 | * @return mixed|void |
66 | 82 | */ |
67 | 83 | protected function defines_and_globals() { |
|
0 commit comments