1 | <?php |
||
11 | class AdminPage { |
||
12 | |||
13 | /** |
||
14 | * plugin |
||
15 | * Access to plugin definitions. |
||
16 | * |
||
17 | * @var Plugin |
||
18 | * @access private |
||
19 | */ |
||
20 | private $plugin; |
||
21 | |||
22 | /** |
||
23 | * definitions |
||
24 | * Easy way to access all of our defined paths & info. |
||
25 | * |
||
26 | * @var object |
||
27 | * @access private |
||
28 | */ |
||
29 | private $definitions; |
||
30 | |||
31 | /** |
||
32 | * connected |
||
33 | * Whether or not we're successfully connected to the Internet. |
||
34 | * |
||
35 | * @var boolean |
||
36 | * @access private |
||
37 | */ |
||
38 | private $connected; |
||
39 | |||
40 | |||
41 | /** |
||
42 | * Hooks function. |
||
43 | * |
||
44 | * This function is used to avoid loading any unnecessary functions/code. |
||
45 | * |
||
46 | * @see admin_menu, wp_ajax actions |
||
47 | */ |
||
48 | public function hooks() { |
||
59 | |||
60 | |||
61 | /** |
||
62 | * Set a reference to the main plugin instance. |
||
63 | * |
||
64 | * @param Plugin $plugin Main plugin instance. |
||
65 | */ |
||
66 | public function set_plugin( $plugin ) { |
||
72 | |||
73 | |||
74 | /** |
||
75 | * Add the admin-side menu item for creating & deleting test data. |
||
76 | * |
||
77 | * @see add_submenu_page |
||
78 | */ |
||
79 | public function add_menu_item() { |
||
80 | |||
81 | $page = add_submenu_page( |
||
82 | 'tools.php', |
||
83 | __( 'Create Dummy Content', 'dummybot' ), |
||
84 | __( 'DummyBot', 'dummybot' ), |
||
85 | 'manage_options', |
||
86 | 'create-test-data', |
||
87 | array( $this, 'admin_page' ) |
||
88 | ); |
||
89 | |||
90 | add_action( 'admin_print_styles-' . $page, array( $this, 'load_scripts' ) ); |
||
91 | |||
92 | } |
||
93 | |||
94 | /** |
||
95 | * Add 'build test content' link to plugin list table. |
||
96 | * |
||
97 | * @param array $links Existing links |
||
98 | * @return array Modified links |
||
99 | */ |
||
100 | public function add_settings_link( $links ) { |
||
107 | |||
108 | |||
109 | /** |
||
110 | * Admin notice to notify a user that images won't work on test dat. |
||
111 | * |
||
112 | * Adds an admin notice that first checks if a user is connected to the |
||
113 | * Internet, and the test fails displays a notice informing the user that |
||
114 | * images will not pull into test data. |
||
115 | */ |
||
116 | public function internet_connected_admin_notice() { |
||
138 | |||
139 | |||
140 | /** |
||
141 | * Load our script in the admin section and serve in data. |
||
142 | */ |
||
143 | public function load_scripts() { |
||
160 | |||
161 | |||
162 | /** |
||
163 | * Print out our admin page to control test data. |
||
164 | */ |
||
165 | public function admin_page() { |
||
189 | |||
190 | } |
||
191 |