-
Notifications
You must be signed in to change notification settings - Fork 0
/
class-plugin.php
131 lines (104 loc) · 2.65 KB
/
class-plugin.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php namespace WPDevsClub_Lesson_Var_Vars;
/**
* Lesson Variable Variables
*
* @category Lesson - Variable Variables & Variable Functions in WordPress
* @package Lesson
* @since 1.0.3
* @author Tonya <[email protected]>
* @link http://wpdevelopersclub.com/
*
* @license dual GNU General Public License 2.0+
*
* ------------------------------------------------------------------------
* Copyright (c) wpdevelopersclub.com
* ------------------------------------------------------------------------
*/
//* Oh no you don't. Exit if accessed directly
defined( 'ABSPATH' ) OR exit( 'Cheatin’ uh?' );
class Lesson {
/**
* The plugin's version
*
* @var string
*/
const VERSION = '1.0.0';
/**
* The plugin's minimum WordPress requirement
*
* @var string
*/
const MIN_WP_VERSION = '3.2';
/*************************
* Getters
************************/
public function version() {
return self::VERSION;
}
public function min_wp_version() {
return self::MIN_WP_VERSION;
}
/**
* Vanilla getter
*
* @since 1.0.0
*
* @param string $property_name
* @return mixed
*/
public function __get( $property_name ) {
return property_exists( $this, $property_name )
? $this->$property_name
: null;
}
/*************************
* Instantiate & Init
************************/
/**
* Instantiate the plugin
*
* @since 1.0.0
*
* @return self
*/
public function __construct() {
$this->init_hooks();
}
/**
* Init the hooks for actions and filters
*
* @since 1.0.0
*
* @return void
*/
protected function init_hooks() {
if ( ! is_admin() ) {
// add_action( 'init', array( $this, 'lesson1' ) );
add_action( 'init', array( $this, 'lesson2' ) );
}
}
/*******************************************
* Lesson 1 -
* variable variables processing $config, $meta, and via get()
******************************************/
public function lesson1() {
$config = include( trailingslashit( __DIR__ ) . 'lib/config/meta.php' );
$meta = new Meta( $config, 1 );
var_dump( $meta );
var_dump( $meta->get( '_subtitle' ) );
}
/*******************************************
* Lesson 2 -
* variable variables processing $config, $meta, and via get()
******************************************/
public function lesson2() {
$path = trailingslashit( __DIR__ );
$objects = include( $path . 'lib/config/objects.php' );
foreach ( $objects as $object => $objects_config ) {
$config = include( $path . $objects_config['config'] );
$meta = new $objects_config['classname']( $config, 1 );
var_dump( $meta );
var_dump( $meta->get( '_subtitle' ) );
}
}
}