Completed
Push — master ( e1139d...01ce3b )
by Mike
02:22
created
includes/class-admin-page.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -89,8 +89,8 @@
 block discarded – undo
89 89
 		} else {
90 90
 			// We didn't get a reponse so print the notice out
91 91
 			echo '<div class="notice notice-error is-dismissible">';
92
-		        echo '<p>'.__( 'WordPress could not connect to Splashbase and therefore images will not pull into metaboxes/thumbnails. Turn Airplane Mode off or reconnect to the Internet to get images when creating test data.', 'otm-test-content' ).'</p>';
93
-		    echo '</div>';
92
+				echo '<p>'.__( 'WordPress could not connect to Splashbase and therefore images will not pull into metaboxes/thumbnails. Turn Airplane Mode off or reconnect to the Internet to get images when creating test data.', 'otm-test-content' ).'</p>';
93
+			echo '</div>';
94 94
 		}
95 95
 
96 96
 	}
Please login to merge, or discard this patch.
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @subpackage Evans
9 9
  * @author     Old Town Media
10 10
  */
11
-class AdminPage{
11
+class AdminPage {
12 12
 
13 13
 	/**
14 14
 	 * plugin
@@ -36,14 +36,14 @@  discard block
 block discarded – undo
36 36
 	 *
37 37
 	 * @see admin_menu, wp_ajax actions
38 38
 	 */
39
-	public function hooks(){
39
+	public function hooks() {
40 40
 
41 41
 		$this->definitions = $this->plugin->get_definitions();
42 42
 
43
-		add_action( 'admin_menu' , array( $this, 'add_menu_item' ) );
44
-		add_action( 'wp_ajax_handle_test_data', array( $this, 'handle_test_data_callback' ) );
45
-		add_filter( 'plugin_action_links_' . $this->definitions->basename , array( $this, 'add_settings_link' ) );
46
-		add_action( 'admin_notices', array( $this, 'internet_connected_admin_notice' ) );
43
+		add_action('admin_menu', array($this, 'add_menu_item'));
44
+		add_action('wp_ajax_handle_test_data', array($this, 'handle_test_data_callback'));
45
+		add_filter('plugin_action_links_'.$this->definitions->basename, array($this, 'add_settings_link'));
46
+		add_action('admin_notices', array($this, 'internet_connected_admin_notice'));
47 47
 
48 48
 	}
49 49
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @param Plugin $plugin Main plugin instance.
55 55
 	 */
56
-	public function set_plugin( $plugin ) {
56
+	public function set_plugin($plugin) {
57 57
 
58 58
 		$this->plugin = $plugin;
59 59
 		return $this;
@@ -70,14 +70,14 @@  discard block
 block discarded – undo
70 70
 
71 71
 		$page = add_submenu_page(
72 72
 			'tools.php',
73
-			__( 'Create Test Content', 'otm-test-content' ),
74
-			__( 'Test Content', 'otm-test-content' ),
73
+			__('Create Test Content', 'otm-test-content'),
74
+			__('Test Content', 'otm-test-content'),
75 75
 			'manage_options',
76 76
 			'create-test-data',
77
-			array( $this, 'admin_page' )
77
+			array($this, 'admin_page')
78 78
 		);
79 79
 
80
-		add_action( 'admin_print_styles-' . $page, array( $this, 'load_scripts' ) );
80
+		add_action('admin_print_styles-'.$page, array($this, 'load_scripts'));
81 81
 
82 82
 	}
83 83
 
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
 	 * @param  array $links Existing links
88 88
 	 * @return array 		Modified links
89 89
 	 */
90
-	public function add_settings_link( $links ) {
90
+	public function add_settings_link($links) {
91 91
 
92
-		$settings_link = '<a href="tools.php?page=create-test-data">' . __( 'Build Test Content', 'otm-test-content' ) . '</a>';
93
-  		array_push( $links, $settings_link );
92
+		$settings_link = '<a href="tools.php?page=create-test-data">'.__('Build Test Content', 'otm-test-content').'</a>';
93
+  		array_push($links, $settings_link);
94 94
   		return $links;
95 95
 
96 96
 	}
@@ -103,24 +103,24 @@  discard block
 block discarded – undo
103 103
 	 * Internet, and the test fails displays a notice informing the user that
104 104
 	 * images will not pull into test data.
105 105
 	 */
106
-	public function internet_connected_admin_notice(){
106
+	public function internet_connected_admin_notice() {
107 107
 
108 108
 		// Get the current admin screen & verify that we're on the right one
109 109
 		// before continuing.
110 110
 		$screen = get_current_screen();
111 111
 
112
-		if ( $screen->base != 'tools_page_create-test-data' ){
112
+		if ($screen->base != 'tools_page_create-test-data') {
113 113
 			return;
114 114
 		}
115 115
 
116 116
 		// Check the response
117
-		if ( $this->test_splashbase_api() ) {
117
+		if ($this->test_splashbase_api()) {
118 118
 			// We got a response so early return
119 119
 			return;
120 120
 		} else {
121 121
 			// We didn't get a reponse so print the notice out
122 122
 			echo '<div class="notice notice-error is-dismissible">';
123
-		        echo '<p>'.__( 'WordPress could not connect to Splashbase and therefore images will not pull into metaboxes/thumbnails. Turn Airplane Mode off or reconnect to the Internet to get images when creating test data.', 'otm-test-content' ).'</p>';
123
+		        echo '<p>'.__('WordPress could not connect to Splashbase and therefore images will not pull into metaboxes/thumbnails. Turn Airplane Mode off or reconnect to the Internet to get images when creating test data.', 'otm-test-content').'</p>';
124 124
 		    echo '</div>';
125 125
 		}
126 126
 
@@ -143,16 +143,16 @@  discard block
 block discarded – undo
143 143
 	 *
144 144
 	 * @return boolean Status of connection to Splashbase.
145 145
 	 */
146
-	private function test_splashbase_api(){
146
+	private function test_splashbase_api() {
147 147
 
148 148
 		/*
149 149
 		 * Test #1 - Check for Airplane Mode plugin status
150 150
 		 */
151
-		if ( class_exists( 'Airplane_Mode_Core' ) ){
151
+		if (class_exists('Airplane_Mode_Core')) {
152 152
 			// Is airplane mode active?
153
-			$airplane_mode = get_site_option( 'airplane-mode' );
153
+			$airplane_mode = get_site_option('airplane-mode');
154 154
 
155
-			if ( $airplane_mode === 'on' ){
155
+			if ($airplane_mode === 'on') {
156 156
 				return false;
157 157
 			}
158 158
 		}
@@ -161,22 +161,22 @@  discard block
 block discarded – undo
161 161
 		 * Test #2 - Check Internet connection in general
162 162
 		 */
163 163
 		// Attempt to open a socket connection to Google
164
-		$connected = @fsockopen( "www.google.com", 80 );
164
+		$connected = @fsockopen("www.google.com", 80);
165 165
 
166
-		if ( !$connected ){
166
+		if (!$connected) {
167 167
 			return false;
168 168
 		}
169 169
 
170 170
 		// Close out our 1st test
171
-		fclose( $connected );
171
+		fclose($connected);
172 172
 
173 173
 		/*
174 174
 		 * Test #3 - Check Splashbase itself
175 175
 		 */
176 176
 		$test_url = 'http://www.splashbase.co/api/v1/images/';
177
-		$response = wp_remote_get( $test_url );
177
+		$response = wp_remote_get($test_url);
178 178
 
179
-		if ( !is_array( $response ) ){
179
+		if (!is_array($response)) {
180 180
 			return false;
181 181
 		}
182 182
 
@@ -189,19 +189,19 @@  discard block
 block discarded – undo
189 189
 	/**
190 190
 	 * Load our script in the admin section and serve in data.
191 191
 	 */
192
-	public function load_scripts(){
192
+	public function load_scripts() {
193 193
 
194
-		wp_enqueue_script( 'test-content-js', plugins_url( 'assets/admin.js' , dirname( __FILE__ ) ) );
195
-		wp_enqueue_style( 'test-content-css', plugins_url( 'assets/admin.css' , dirname( __FILE__ ) ) );
194
+		wp_enqueue_script('test-content-js', plugins_url('assets/admin.js', dirname(__FILE__)));
195
+		wp_enqueue_style('test-content-css', plugins_url('assets/admin.css', dirname(__FILE__)));
196 196
 
197 197
 		$data = array(
198
-			'nonce'			=> wp_create_nonce( 'handle-test-data' ),
199
-			'createdStr'	=> __( 'Created', 'otm-test-content' ),
200
-			'deletedStr'	=> __( 'Deleting', 'otm-test-content' ),
201
-			'creatingStr'	=> __( 'Creating', 'otm-test-content' ),
198
+			'nonce'			=> wp_create_nonce('handle-test-data'),
199
+			'createdStr'	=> __('Created', 'otm-test-content'),
200
+			'deletedStr'	=> __('Deleting', 'otm-test-content'),
201
+			'creatingStr'	=> __('Creating', 'otm-test-content'),
202 202
 		);
203 203
 
204
-		wp_localize_script( 'test-content-js', 'test_content', $data );
204
+		wp_localize_script('test-content-js', 'test_content', $data);
205 205
 
206 206
 	}
207 207
 
@@ -213,21 +213,21 @@  discard block
 block discarded – undo
213 213
 	 */
214 214
 	public function handle_test_data_callback() {
215 215
 
216
-		$action		= $_REQUEST['todo'];
217
-		$nonce		= $_REQUEST['nonce'];
216
+		$action = $_REQUEST['todo'];
217
+		$nonce = $_REQUEST['nonce'];
218 218
 
219 219
 		// Verify that we have a proper logged in user and it's the right person
220
-		if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'handle-test-data' ) ){
220
+		if (empty($nonce) || !wp_verify_nonce($nonce, 'handle-test-data')) {
221 221
 			return;
222 222
 		}
223 223
 
224
-		if ( $action == 'delete' ){
224
+		if ($action == 'delete') {
225 225
 
226
-			$this->deletion_routing( $_REQUEST );
226
+			$this->deletion_routing($_REQUEST);
227 227
 
228
-		} elseif ( $action == 'create' ){
228
+		} elseif ($action == 'create') {
229 229
 
230
-			$this->creation_routing( $_REQUEST );
230
+			$this->creation_routing($_REQUEST);
231 231
 
232 232
 		}
233 233
 
@@ -240,17 +240,17 @@  discard block
 block discarded – undo
240 240
 	 * Choose which type of creation needs to be accomplished and route through
241 241
 	 * the correct class.
242 242
 	 */
243
-	private function creation_routing( $data ){
243
+	private function creation_routing($data) {
244 244
 
245
-		if ( $data['type'] == 'post' ){
245
+		if ($data['type'] == 'post') {
246 246
 
247 247
 			$create_content = new CreatePost;
248
-			$create_content->create_post_type_content( $data['slug'], true, 1 );
248
+			$create_content->create_post_type_content($data['slug'], true, 1);
249 249
 
250
-		} elseif( $data['type'] == 'term' ){
250
+		} elseif ($data['type'] == 'term') {
251 251
 
252 252
 			$create_content = new CreateTerm;
253
-			$create_content->create_terms( $data['slug'], true, 1 );
253
+			$create_content->create_terms($data['slug'], true, 1);
254 254
 
255 255
 		}
256 256
 
@@ -261,17 +261,17 @@  discard block
 block discarded – undo
261 261
 	 * Choose which type of deletion needs to be accomplished and route through
262 262
 	 * the correct method of Delete.
263 263
 	 */
264
-	private function deletion_routing( $data ){
264
+	private function deletion_routing($data) {
265 265
 
266 266
 		$delete_content = new Delete;
267 267
 
268
-		if ( $data['type'] == 'post' ){
268
+		if ($data['type'] == 'post') {
269 269
 
270
-			$delete_content->delete_posts( $data['slug'], true );
270
+			$delete_content->delete_posts($data['slug'], true);
271 271
 
272
-		} elseif ( $data['type'] == 'term' ){
272
+		} elseif ($data['type'] == 'term') {
273 273
 
274
-			$delete_content->delete_terms( $data['slug'], true );
274
+			$delete_content->delete_terms($data['slug'], true);
275 275
 
276 276
 		}
277 277
 
@@ -281,35 +281,35 @@  discard block
 block discarded – undo
281 281
 	/**
282 282
 	 * Print out our admin page to control test data.
283 283
 	 */
284
-	public function admin_page(){
284
+	public function admin_page() {
285 285
 
286 286
 		$html = "";
287 287
 
288
-		$html .= '<div class="wrap" id="options_editor">' . "\n";
288
+		$html .= '<div class="wrap" id="options_editor">'."\n";
289 289
 
290
-			$html .= '<h2>' . __( 'Create Test Data' , 'otm-test-content' ) . '</h2>' . "\n";
290
+			$html .= '<h2>'.__('Create Test Data', 'otm-test-content').'</h2>'."\n";
291 291
 
292 292
 			// Loop through all other cpts
293
-			$post_types = get_post_types( array( 'public' => true ), 'objects' );
293
+			$post_types = get_post_types(array('public' => true), 'objects');
294 294
 
295 295
 			$html .= "<div>";
296 296
 
297 297
 			$html .= "<div class='test-data-cpt'>";
298 298
 				$html .= "<h3>";
299
-					$html .= "<span class='label'>".__( 'Quantity', 'otm-test-content' )."</span>";
300
-					$html .= "<input type='number' value='0' id='quantity-adjustment'> <small><i>".__( 'Set to 0 to keep random', 'otm-test-content' )."</i></small>";
299
+					$html .= "<span class='label'>".__('Quantity', 'otm-test-content')."</span>";
300
+					$html .= "<input type='number' value='0' id='quantity-adjustment'> <small><i>".__('Set to 0 to keep random', 'otm-test-content')."</i></small>";
301 301
 				$html .= "</h3>";
302 302
 			$html .= "</div>";
303 303
 
304 304
 			// Loop through every post type available on the site
305
-			foreach ( $post_types as $post_type ) {
305
+			foreach ($post_types as $post_type) {
306 306
 
307 307
 				$skipped_cpts = array(
308 308
 					'attachment'
309 309
 				);
310 310
 
311 311
 				// Skip banned cpts
312
-				if ( in_array( $post_type->name, $skipped_cpts ) ){
312
+				if (in_array($post_type->name, $skipped_cpts)) {
313 313
 					continue;
314 314
 				}
315 315
 
@@ -318,38 +318,38 @@  discard block
 block discarded – undo
318 318
 					// Create row for the post/page/cpt
319 319
 					$html .= "<h3>";
320 320
 
321
-						$html .= "<span class='label'>" . $post_type->labels->name . "</span>";
322
-						$html .= " <a href='javascript:void(0);' data-type='post' data-slug='".$post_type->name."' data-todo='create' class='button-primary handle-test-data' /><span class='dashicons dashicons-plus'></span> ".__( 'Create Test Data', 'otm-test-content' )."</a>";
323
-						$html .= " <a href='javascript:void(0);' data-type='post' data-slug='".$post_type->name."' data-todo='delete' class='button-primary handle-test-data' /><span class='dashicons dashicons-trash'></span> ".__( 'Delete Test Data', 'otm-test-content' )."</a>";
321
+						$html .= "<span class='label'>".$post_type->labels->name."</span>";
322
+						$html .= " <a href='javascript:void(0);' data-type='post' data-slug='".$post_type->name."' data-todo='create' class='button-primary handle-test-data' /><span class='dashicons dashicons-plus'></span> ".__('Create Test Data', 'otm-test-content')."</a>";
323
+						$html .= " <a href='javascript:void(0);' data-type='post' data-slug='".$post_type->name."' data-todo='delete' class='button-primary handle-test-data' /><span class='dashicons dashicons-trash'></span> ".__('Delete Test Data', 'otm-test-content')."</a>";
324 324
 
325 325
 					$html .= "</h3>";
326 326
 
327 327
 					// Create row for each taxonomy associated with the post/page/cpt
328
-					$taxonomies = get_object_taxonomies( $post_type->name );
328
+					$taxonomies = get_object_taxonomies($post_type->name);
329 329
 
330
-						if ( !empty( $taxonomies ) ){
330
+						if (!empty($taxonomies)) {
331 331
 
332
-							foreach( $taxonomies as $tax ){
332
+							foreach ($taxonomies as $tax) {
333 333
 
334 334
 								$html .= "<h3 class='term-box'>";
335 335
 
336 336
 								$skipped_taxonomies = array(
337
-									'post_format',				// We shouldn't be making random post format classes
337
+									'post_format', // We shouldn't be making random post format classes
338 338
 									'product_shipping_class'	// These aren't used visually and are therefore skipped
339 339
 								);
340 340
 
341 341
 								// Skip banned taxonomies
342
-								if ( in_array( $tax, $skipped_taxonomies ) ){
342
+								if (in_array($tax, $skipped_taxonomies)) {
343 343
 									continue;
344 344
 								}
345 345
 
346
-								$taxonomy = get_taxonomy( $tax );
346
+								$taxonomy = get_taxonomy($tax);
347 347
 
348 348
 								$html .= "<span class='label'>".$taxonomy->labels->name."</span>";
349 349
 
350
-								$html .= " <a href='javascript:void(0);' data-type='term' data-slug='".$tax."' data-todo='create' class='button-primary handle-test-data' /><span class='dashicons dashicons-category'></span> ".__( 'Create', 'otm-test-content' )." ".$taxonomy->labels->name."</a>";
350
+								$html .= " <a href='javascript:void(0);' data-type='term' data-slug='".$tax."' data-todo='create' class='button-primary handle-test-data' /><span class='dashicons dashicons-category'></span> ".__('Create', 'otm-test-content')." ".$taxonomy->labels->name."</a>";
351 351
 
352
-								$html .= " <a href='javascript:void(0);' data-type='term' data-slug='".$tax."' data-todo='delete' class='button-primary handle-test-data' /><span class='dashicons dashicons-trash'></span> ".__( 'Delete', 'otm-test-content' )." ".$taxonomy->labels->name."</a>";
352
+								$html .= " <a href='javascript:void(0);' data-type='term' data-slug='".$tax."' data-todo='delete' class='button-primary handle-test-data' /><span class='dashicons dashicons-trash'></span> ".__('Delete', 'otm-test-content')." ".$taxonomy->labels->name."</a>";
353 353
 
354 354
 								$html .= "</h3>";
355 355
 
Please login to merge, or discard this patch.
includes/class-plugin.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@
 block discarded – undo
65 65
 	 * @see load_plugin_textdomain
66 66
 	 */
67 67
 	public function load_textdomain() {
68
-	    load_plugin_textdomain( 'otm-test-content', FALSE, basename( dirname( $this->definitions->file ) ) . '/languages/' );
68
+		load_plugin_textdomain( 'otm-test-content', FALSE, basename( dirname( $this->definitions->file ) ) . '/languages/' );
69 69
 	}
70 70
 
71 71
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @subpackage Evans
9 9
  * @author     Old Town Media
10 10
  */
11
-class Plugin{
11
+class Plugin {
12 12
 
13 13
 	/**
14 14
 	 * Plugin definitions.
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @param  object $definitions Information about the plugin
35 35
 	 * @return object $this
36 36
 	 */
37
-	public function set_definitions( $definitions ) {
37
+	public function set_definitions($definitions) {
38 38
 
39 39
 		$this->definitions = $definitions;
40 40
 		return $this;
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
 	 * @param  object $provider Hook provider.
49 49
 	 * @return object $this
50 50
 	 */
51
-	public function register_hooks( $provider ) {
51
+	public function register_hooks($provider) {
52 52
 
53
-		if ( method_exists( $provider, 'set_plugin' ) ) {
54
-			$provider->set_plugin( $this );
53
+		if (method_exists($provider, 'set_plugin')) {
54
+			$provider->set_plugin($this);
55 55
 		}
56 56
 
57 57
 		$provider->hooks();
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 * @see load_plugin_textdomain
66 66
 	 */
67 67
 	public function load_textdomain() {
68
-	    load_plugin_textdomain( 'otm-test-content', FALSE, basename( dirname( $this->definitions->file ) ) . '/languages/' );
68
+	    load_plugin_textdomain('otm-test-content', FALSE, basename(dirname($this->definitions->file)).'/languages/');
69 69
 	}
70 70
 
71 71
 }
Please login to merge, or discard this patch.
test-content.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -21,21 +21,21 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * @param string $class Class name.
23 23
  */
24
-function test_content_autoloader( $class ) {
25
- 	if ( __NAMESPACE__ !== explode( '\\', $class )[0] ){
24
+function test_content_autoloader($class) {
25
+ 	if (__NAMESPACE__ !== explode('\\', $class)[0]) {
26 26
  		return;
27 27
  	}
28 28
 
29
-	$class = str_replace( __NAMESPACE__ . '\\', '', $class );
30
-	$class = strtolower( preg_replace( '/(?<!^)([A-Z])/', '-\\1', $class ) );
29
+	$class = str_replace(__NAMESPACE__.'\\', '', $class);
30
+	$class = strtolower(preg_replace('/(?<!^)([A-Z])/', '-\\1', $class));
31 31
 
32
- 	$file  = dirname( __FILE__ ) . '/includes/class-' . $class . '.php';
32
+ 	$file = dirname(__FILE__).'/includes/class-'.$class.'.php';
33 33
 
34
- 	if ( file_exists( $file ) ) {
35
- 		require_once( $file );
34
+ 	if (file_exists($file)) {
35
+ 		require_once($file);
36 36
  	}
37 37
  }
38
- spl_autoload_register( __NAMESPACE__ . '\test_content_autoloader' );
38
+ spl_autoload_register(__NAMESPACE__.'\test_content_autoloader');
39 39
 
40 40
 
41 41
  /**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
  function plugin() {
47 47
  	static $instance;
48 48
 
49
- 	if ( null === $instance ) {
49
+ 	if (null === $instance) {
50 50
  		$instance = new Plugin();
51 51
  	}
52 52
 
@@ -56,16 +56,16 @@  discard block
 block discarded – undo
56 56
 // Set our definitions for later use
57 57
  plugin()->set_definitions(
58 58
 	(object) array(
59
-		'basename'	=> plugin_basename( __FILE__ ),
60
-		'directory'	=> plugin_dir_path( __FILE__ ),
59
+		'basename'	=> plugin_basename(__FILE__),
60
+		'directory'	=> plugin_dir_path(__FILE__),
61 61
 		'file'		=> __FILE__,
62 62
 		'slug' 		=> 'structure',
63
-		'url'		=> plugin_dir_url( __FILE__ )
63
+		'url'		=> plugin_dir_url(__FILE__)
64 64
 	)
65 65
 );
66 66
 
67 67
  // Register hook providers.
68
- plugin()->register_hooks( new AdminPage() );
68
+ plugin()->register_hooks(new AdminPage());
69 69
 
70 70
  // Load textdomain hook
71
- add_action( 'plugins_loaded', array( plugin(), 'load_textdomain' ) );
71
+ add_action('plugins_loaded', array(plugin(), 'load_textdomain'));
Please login to merge, or discard this patch.