-
Notifications
You must be signed in to change notification settings - Fork 0
/
wordpress-developer-reports.php
329 lines (272 loc) · 10.8 KB
/
wordpress-developer-reports.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
<?php
/*
Plugin Name: WordPress Developer Reports
Plugin URI: http://zoerooney.com
Description: Simple but useful reports on core, themes, and plugins for Wordpress.
Version: 0.0.7
Author: Zoe Rooney
Author URI: http://zoerooney.com
License: GPL2
Copyright 2013 Zoe Rooney (email : [email protected])
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* Enqueue our scripts and stylesheets
=============================================*/
function wp_dev_reports_init() {
if ( is_admin() ) {
wp_register_style('fontawesome', WP_PLUGIN_URL . '/'.basename(dirname(__FILE__)).'/admin/font-awesome.min.css');
wp_enqueue_style('fontawesome');
// Not using this currently, just a placeholder for now
// wp_register_script('wp_dev_reportsjs', WP_PLUGIN_URL . '/'.basename(dirname(__FILE__)).'/jquery.wp_dev_reports.js', array('jquery'), false, false);
// wp_enqueue_script('wp_dev_reportsjs');
}
}
add_action('init', 'wp_dev_reports_init');
/* Create menu link to the settings page
=============================================*/
add_action('admin_menu', 'wp_dev_reports_menu_register_page');
function wp_dev_reports_menu_register_page() {
add_submenu_page( 'tools.php', 'Generate Developer Reports', 'Developer Reports', 'manage_options', 'wp-dev-reports', 'wp_dev_reports_page_callback' );
}
/* Create the settings page
=============================================*/
function wp_dev_reports_page_callback() {
$options = get_option( 'wp_dev_reports_settings' );
/* Make sure the user has permission to access these settings */
if ( !current_user_can( 'manage_options' ) ) {
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
} ?>
<!-- Set up our basic page structure -->
<div class="wrap">
<h2 id="wp_dev_reports">Generate Developer Reports</h2>
<div class="module">
<h3>Right Now</h3>
<p>Your data is current as of <? echo date( 'F d, Y h:ia', current_time( 'timestamp', 0 ) ); ?> (right now).</p>
<p><em>Not your current local time? <a href="/wp-admin/options-general.php#default_role">Update your time zone.</a></em></p>
</div>
<div class="module">
<h3>About WordPress</h3>
<?php
// Check version of WP installed, assign to variable
$version = get_bloginfo('version');
// Check current version of WP available, assign just version number to variable
$url = 'http://wordpress.org/latest';
stream_context_set_default(
array( 'http' => array( 'method' => 'HEAD' ) )
);
$headers = get_headers( $url );
$file = $headers[8]; // Get just the content info including filename
$latest = str_replace( array('Content-Disposition: attachment; filename=wordpress-','.tar.gz'), '', $file ); // Get rid of everything except the version number
?>
<p>You are running WordPress <strong><?php echo $version; ?></strong>.</p>
<?php if ( $latest !== $version ) : ?>
<p>The latest version of WordPress is <?php echo $latest; ?>. Please <a href="/wp-admin/update-core.php">update WordPress</a>!</p>
<?php endif; ?>
</div>
<div class="module">
<h3>Currently Installed Plugins</h3>
<?php
// assign get_plugins() to a variable
$current_plugins = get_plugins();
// something should happen if no plugins are installed
if ( empty( $current_plugins ) ) :
echo '<p>Unable to display plugins. This could mean there are no plugins installed, or that the plugins directory is inaccessible.</p>';
endif;
// format as description list
echo '<dl>';
// loop through each plugin retrieved
foreach ( $current_plugins as $current_plugin => $plugin_data ) : ?>
<dt>
<!-- Display linked title -->
<a href="<?php echo $plugin_data['PluginURI']; ?>">
<?php echo $plugin_data['Title']; ?>
</a>
</dt>
<dd>
<!-- Display Plugin Info -->
Author: <?php echo $plugin_data['Author']; ?><br>
Version: <?php echo $plugin_data['Version']; ?><br>
This plugin is currently <?php if ( is_plugin_active( $current_plugin ) ) : echo 'active'; else : echo 'inactive'; endif; ?>
</dd>
<?php endforeach;
echo '</dl>';
?>
</div>
<!--<form action="options.php" method="post">
<?php settings_fields('wp_dev_reports_options'); ?>
<?php do_settings_sections('wp_dev_reports'); ?>
<input name="Submit" type="submit" value="<?php esc_attr_e('Save Changes'); ?>" />
</form>-->
</div>
<?php }
/* Register all the necessary settings
=============================================*/
/*
add_action('admin_init', 'wp_dev_reports_admin_init');
function wp_dev_reports_admin_init(){
// TO DO: NEED TO FIGURE OUT WHAT I WANT HERE, THIS IS ALL STUFF FROM JOYRIDE
register_setting(
'wp_dev_reports_options',
'wp_dev_reports_options',
'wp_dev_reports_validation'
);
add_settings_section(
'wp_dev_reports_display_options',
'Display Options <i class="icon-cog"></i>',
'wp_dev_reports_display_options_text',
'wp_dev_reports'
);
add_settings_section(
'wp_dev_reports_feature_tips',
'Feature Tour Tips <i class="icon-map-marker"></i>',
'wp_dev_reports_feature_tips_text',
'wp_dev_reports'
);
// wp_dev_reports Options
add_settings_field(
'wp_dev_reports_tiplocation',
'Tip location relative to the parent element',
'wp_dev_reports_tiplocation_input',
'wp_dev_reports',
'wp_dev_reports_display_options'
);
add_settings_field(
'wp_dev_reports_scrollspeed',
'Page scroll speed, in ms',
'wp_dev_reports_scrollspeed_input',
'wp_dev_reports',
'wp_dev_reports_display_options'
);
add_settings_field(
'wp_dev_reports_timer',
'Duration of each tour stop, 0 = off',
'wp_dev_reports_timer_input',
'wp_dev_reports',
'wp_dev_reports_display_options'
);
add_settings_field(
'wp_dev_reports_starttimeronclick',
'Start the timer on the first click',
'wp_dev_reports_starttimeronclick_input',
'wp_dev_reports',
'wp_dev_reports_display_options'
);
add_settings_field(
'wp_dev_reports_nextbutton',
'Show the "Next" button',
'wp_dev_reports_nextbutton_input',
'wp_dev_reports',
'wp_dev_reports_display_options'
);
add_settings_field(
'wp_dev_reports_tipanimation',
'Animation style',
'wp_dev_reports_tipanimation_input',
'wp_dev_reports',
'wp_dev_reports_display_options'
);
add_settings_field(
'wp_dev_reports_tipanimationfadespeed',
'Speed of the fade animation',
'wp_dev_reports_tipanimationfadespeed_input',
'wp_dev_reports',
'wp_dev_reports_display_options'
);
// The tips
add_settings_field(
'wp_dev_reports_tipid',
'Tip ID (all lowercase, no spaces)',
'wp_dev_reports_tipid_input',
'wp_dev_reports',
'wp_dev_reports_feature_tips'
);
add_settings_field(
'wp_dev_reports_tipcontent',
'Tip Content',
'wp_dev_reports_tipcontent_input',
'wp_dev_reports',
'wp_dev_reports_feature_tips'
);
}
*/
/* Now, display all those settings
=============================================*/
// TO DO: UPDATE FOR THIS PLUGIN
/*
// Section header text
function wp_dev_reports_section_text() {
}
// Form fields
function wp_dev_reports_tiplocation_input() {
$options = get_option( 'wp_dev_reports_options' );?>
<select name="wp_dev_reports_options[tiplocation]" value="<?php echo $options[tiplocation]; ?>" />
<option value="top" <?php if ( $options['tiplocation'] == 'top' ) echo " selected='selected'";?>>Top</option>
<option value="bottom" <?php if ( $options['tiplocation'] == 'bottom' ) echo " selected='selected'";?>>Bottom</option>
</select>
<?php }
function wp_dev_reports_scrollspeed_input() {
$options = get_option( 'wp_dev_reports_options' );
echo '<input name="wp_dev_reports_options[scrollspeed]" type="text" size="5" value="' . $options[scrollspeed] . '" placeholder="300" /> ms';
}
function wp_dev_reports_timer_input() {
$options = get_option( 'wp_dev_reports_options' );
echo '<input name="wp_dev_reports_options[timer]" type="text" size="5" value="' . $options[timer] . '" placeholder="2000" /> ms';
}
function wp_dev_reports_starttimeronclick_input() {
$options = get_option( 'wp_dev_reports_options' ); ?>
<input type="checkbox" name="wp_dev_reports_options[starttimeronclick]" value="true" <?php checked( "true", $options['starttimeronclick'] ); ?> />
<?php }
function wp_dev_reports_nextbutton_input() {
$options = get_option( 'wp_dev_reports_options' ); ?>
<input type="checkbox" name="wp_dev_reports_options[nextbutton]" value="true" <?php checked( "true", $options['nextbutton'] ); ?> />
<?php }
function wp_dev_reports_tipanimation_input() {
$options = get_option( 'wp_dev_reports_options' );?>
<select name="wp_dev_reports_options[tipanimation]" value="<?php echo $options[tipanimation]; ?>" />
<option value="pop" <?php if ( $options['tipanimation'] == 'pop' ) echo " selected='selected'";?>>Pop</option>
<option value="fade" <?php if ( $options['tipanimation'] == 'fade' ) echo " selected='selected'";?>>Fade</option>
</select>
<?php }
function wp_dev_reports_tipanimationfadespeed_input() {
$options = get_option( 'wp_dev_reports_options' );
echo '<input name="wp_dev_reports_options[tipanimationfadespeed]" type="text" size="5" value="' . $options[tipanimationfadespeed] . '" placeholder="300" /> ms';
}
function wp_dev_reports_tipid_input() {
$options = get_option( 'wp_dev_reports_options' );
echo '<div><input name="wp_dev_reports_options[tipid]" type="text" value="' . $options[tipid] . '" />';
echo '<input name="shortcode" type="text" value="[tourstop id=' . $options[tipid] . ']" readonly/>';
}
function wp_dev_reports_tipcontent_input() {
echo '<textarea name="wp_dev_reports_options[tipcontent]">' . $options[tipcontent] . '</textarea></div>';
}
*/
/**
* Let's validate this stuff
function wp_dev_reports_validation( $input ) {
// TO DO: VALIDATION
if ( ! $input['scrollspeed'] )
$input['scrollspeed'] = '300';
if ( ! $input['timer'] )
$input['timer'] = '2000';
if ( ! $input['tipanimationfadespeed'] )
$input['tipanimationfadespeed'] = '300';
if ( ! isset( $input['starttimeronclick'] ) )
$input['starttimeronclick'] = null;
$input['starttimeronclick'] = ( $input['starttimeronclick'] == "true" ? "true" : "false" );
if ( ! isset( $input['nextbutton'] ) )
$input['nextbutton'] = null;
$input['nextbutton'] = ( $input['nextbutton'] == "true" ? "true" : "false" );
return $input;
}
*/
// TO DO: NEED TO OUTPUT THIS STUFF SOMEPLACE...
// Close it down ?>