Completed
Push — master ( c6a753...e758eb )
by Mike
02:16
created
includes/class-delete.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,6 @@
 block discarded – undo
48 48
 	 *
49 49
 	 * @see WP_Query, wp_delete_post
50 50
 	 *
51
-	 * @param string $slug a custom post type ID.
52 51
 	 * @param boolean $echo Whether or not to echo the result
53 52
 	 */
54 53
 	public function delete_objects( $echo = false, $data ){
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 		$post_types = get_post_types( array( 'public' => true ), 'objects' );
26 26
 		foreach ( $post_types as $post_type ) :
27 27
 
28
-		    $this->delete_posts( $post_type->name, $echo );
28
+			$this->delete_posts( $post_type->name, $echo );
29 29
 
30 30
 		endforeach;
31 31
 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 		$taxonomies = get_taxonomies();
34 34
 		foreach ( $taxonomies as $tax ) :
35 35
 
36
-		    $this->delete_terms( $tax, $echo );
36
+			$this->delete_terms( $tax, $echo );
37 37
 
38 38
 		endforeach;
39 39
 
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -8,32 +8,32 @@  discard block
 block discarded – undo
8 8
  * @subpackage Evans
9 9
  * @author     Old Town Media
10 10
  */
11
-class Delete{
11
+class Delete {
12 12
 
13 13
 	/**
14 14
 	 * Delete all test content created ever.
15 15
 	 *
16 16
 	 * @access private
17 17
 	 */
18
-	public function delete_all_test_data( $echo = false ){
18
+	public function delete_all_test_data($echo = false) {
19 19
 
20
-		if ( !$this->user_can_delete() ){
20
+		if (!$this->user_can_delete()) {
21 21
 			return;
22 22
 		}
23 23
 
24 24
 		// Loop through all post types and remove any test data
25
-		$post_types = get_post_types( array( 'public' => true ), 'objects' );
26
-		foreach ( $post_types as $post_type ) :
25
+		$post_types = get_post_types(array('public' => true), 'objects');
26
+		foreach ($post_types as $post_type) :
27 27
 
28
-		    $this->delete_posts( $post_type->name, $echo );
28
+		    $this->delete_posts($post_type->name, $echo);
29 29
 
30 30
 		endforeach;
31 31
 
32 32
 		// Loop through all taxonomies and remove any data
33 33
 		$taxonomies = get_taxonomies();
34
-		foreach ( $taxonomies as $tax ) :
34
+		foreach ($taxonomies as $tax) :
35 35
 
36
-		    $this->delete_terms( $tax, $echo );
36
+		    $this->delete_terms($tax, $echo);
37 37
 
38 38
 		endforeach;
39 39
 
@@ -51,22 +51,22 @@  discard block
 block discarded – undo
51 51
 	 * @param string $slug a custom post type ID.
52 52
 	 * @param boolean $echo Whether or not to echo the result
53 53
 	 */
54
-	public function delete_objects( $echo = false, $data ){
54
+	public function delete_objects($echo = false, $data) {
55 55
 
56 56
 		// Make sure that the current user is logged in & has full permissions.
57
-		if ( !$this->user_can_delete() ){
57
+		if (!$this->user_can_delete()) {
58 58
 			return;
59 59
 		}
60 60
 
61
-		if ( empty( $data ) ){
61
+		if (empty($data)) {
62 62
 			return;
63 63
 		}
64 64
 
65
-		$type = 'testContent\Types\\' . ucwords( $data['type'] );
65
+		$type = 'testContent\Types\\'.ucwords($data['type']);
66 66
 		$slug = $data['slug'];
67 67
 
68 68
 		$object = new $type();
69
-		$object->delete( $slug, $echo );
69
+		$object->delete($slug, $echo);
70 70
 
71 71
 	}
72 72
 
@@ -76,15 +76,15 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @see is_user_logged_in, current_user_can
78 78
 	 */
79
-	public function user_can_delete(){
79
+	public function user_can_delete() {
80 80
 
81 81
 		// User must be logged in
82
-		if ( !is_user_logged_in() ){
82
+		if (!is_user_logged_in()) {
83 83
 			return false;
84 84
 		}
85 85
 
86 86
 		// User must have editor priveledges, at a minimum
87
-		if ( !current_user_can( 'delete_others_posts' ) ){
87
+		if (!current_user_can('delete_others_posts')) {
88 88
 			return false;
89 89
 		}
90 90
 
Please login to merge, or discard this patch.
test-content.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * @param string $class Class name.
23 23
  */
24
-function test_content_autoloader( $class ) {
25
-	$namespace = explode( '\\', $class );
24
+function test_content_autoloader($class) {
25
+	$namespace = explode('\\', $class);
26 26
 
27
- 	if ( __NAMESPACE__ !== $namespace[0] ){
27
+ 	if (__NAMESPACE__ !== $namespace[0]) {
28 28
  		return;
29 29
  	}
30 30
 
31
-    $class = str_replace( __NAMESPACE__ . '\\', '', $class );
31
+    $class = str_replace(__NAMESPACE__.'\\', '', $class);
32 32
 
33 33
 	$nss = array(
34 34
 		'Abstracts',
@@ -36,20 +36,20 @@  discard block
 block discarded – undo
36 36
 		'Views'
37 37
 	);
38 38
 
39
-	if ( in_array( $namespace[1], $nss ) ){
40
-        $class = strtolower( preg_replace( '/(?<!^)([A-Z])/', '/\1', $class ) );
41
-        $class = str_replace( '\\', '', $class );
42
-     	$file  = dirname( __FILE__ ) . '/' . $class . '.php';
39
+	if (in_array($namespace[1], $nss)) {
40
+        $class = strtolower(preg_replace('/(?<!^)([A-Z])/', '/\1', $class));
41
+        $class = str_replace('\\', '', $class);
42
+     	$file  = dirname(__FILE__).'/'.$class.'.php';
43 43
     } else {
44
-        $class = strtolower( preg_replace( '/(?<!^)([A-Z])/', '-\\1', $class ) );
45
-     	$file  = dirname( __FILE__ ) . '/includes/class-' . $class . '.php';
44
+        $class = strtolower(preg_replace('/(?<!^)([A-Z])/', '-\\1', $class));
45
+     	$file  = dirname(__FILE__).'/includes/class-'.$class.'.php';
46 46
     }
47 47
 
48
- 	if ( is_readable( $file ) ) {
49
- 		require_once( $file );
48
+ 	if (is_readable($file)) {
49
+ 		require_once($file);
50 50
  	}
51 51
  }
52
- spl_autoload_register( __NAMESPACE__ . '\test_content_autoloader' );
52
+ spl_autoload_register(__NAMESPACE__.'\test_content_autoloader');
53 53
 
54 54
 
55 55
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
  function plugin() {
62 62
  	static $instance;
63 63
 
64
- 	if ( null === $instance ) {
64
+ 	if (null === $instance) {
65 65
  		$instance = new Plugin();
66 66
  	}
67 67
 
@@ -71,19 +71,19 @@  discard block
 block discarded – undo
71 71
 // Set our definitions for later use
72 72
  plugin()->set_definitions(
73 73
 	(object) array(
74
-		'basename'	=> plugin_basename( __FILE__ ),
75
-		'directory'	=> plugin_dir_path( __FILE__ ),
74
+		'basename'	=> plugin_basename(__FILE__),
75
+		'directory'	=> plugin_dir_path(__FILE__),
76 76
 		'file'		=> __FILE__,
77 77
 		'slug' 		=> 'structure',
78
-		'url'		=> plugin_dir_url( __FILE__ )
78
+		'url'		=> plugin_dir_url(__FILE__)
79 79
 	)
80 80
 );
81 81
 
82 82
  // Register hook providers and views.
83
- plugin()->register_hooks( new AdminPage() )
84
-         ->register_views( new Views\Posts() )
85
-         ->register_views( new Views\Terms() )
86
-		 ->register_views( new Views\Various() );
83
+ plugin()->register_hooks(new AdminPage())
84
+         ->register_views(new Views\Posts())
85
+         ->register_views(new Views\Terms())
86
+		 ->register_views(new Views\Various());
87 87
 
88 88
 // Load textdomain hook
89
-add_action( 'plugins_loaded', array( plugin(), 'load_textdomain' ) );
89
+add_action('plugins_loaded', array(plugin(), 'load_textdomain'));
Please login to merge, or discard this patch.
views/terms.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
  * @subpackage Test Content
11 11
  * @author     Old Town Media
12 12
  */
13
-class Terms extends Abs\View{
13
+class Terms extends Abs\View {
14 14
 
15 15
 	protected $title	= 'Terms';
16 16
 	protected $type		= 'term';
17
-	protected $priority	= 2;
17
+	protected $priority = 2;
18 18
 
19 19
 
20 20
 	/**
@@ -24,25 +24,25 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @return string HTML content.
26 26
 	 */
27
-	protected function actions_section(){
27
+	protected function actions_section() {
28 28
 		$html = '';
29 29
 
30 30
 		$taxonomies = get_taxonomies();
31 31
 
32
-		foreach ( $taxonomies as $tax ) :
32
+		foreach ($taxonomies as $tax) :
33 33
 
34 34
 			$skipped_taxonomies = array(
35
-				'post_format',				// We shouldn't be making random post format classes
36
-				'product_shipping_class',	// These aren't used visually and are therefore skipped
37
-				'nav_menu',					// Menus are handled seperately of taxonomies
35
+				'post_format', // We shouldn't be making random post format classes
36
+				'product_shipping_class', // These aren't used visually and are therefore skipped
37
+				'nav_menu', // Menus are handled seperately of taxonomies
38 38
 			);
39 39
 
40 40
 			// Skip banned taxonomies
41
-			if ( in_array( $tax, $skipped_taxonomies ) ){
41
+			if (in_array($tax, $skipped_taxonomies)) {
42 42
 				continue;
43 43
 			}
44 44
 
45
-			$taxonomy = get_taxonomy( $tax );
45
+			$taxonomy = get_taxonomy($tax);
46 46
 
47 47
 			$html .= "<div class='test-data-cpt'>";
48 48
 
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 
51 51
 				$html .= "<span class='label'>".$taxonomy->labels->name."</span>";
52 52
 
53
-				$html .= $this->build_button( 'create', $tax, __( 'Create', 'otm-test-content' )." ".$taxonomy->labels->name );
54
-				$html .= $this->build_button( 'delete', $tax, __( 'Delete', 'otm-test-content' )." ".$taxonomy->labels->name );
53
+				$html .= $this->build_button('create', $tax, __('Create', 'otm-test-content')." ".$taxonomy->labels->name);
54
+				$html .= $this->build_button('delete', $tax, __('Delete', 'otm-test-content')." ".$taxonomy->labels->name);
55 55
 
56 56
 				$html .= "</h3>";
57 57
 
Please login to merge, or discard this patch.
views/posts.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
  * @subpackage Test Content
11 11
  * @author     Old Town Media
12 12
  */
13
-class Posts extends Abs\View{
13
+class Posts extends Abs\View {
14 14
 
15 15
 	protected $title	= 'Posts';
16 16
 	protected $type		= 'post';
17
-	protected $priority	= 1;
17
+	protected $priority = 1;
18 18
 
19 19
 	/**
20 20
 	 * Our sections action block - button to create and delete.
@@ -23,20 +23,20 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @return string HTML content.
25 25
 	 */
26
-	protected function actions_section(){
26
+	protected function actions_section() {
27 27
 		$html = '';
28 28
 
29 29
 		// Loop through every post type available on the site
30
-		$post_types = get_post_types( array( 'public' => true ), 'objects' );
30
+		$post_types = get_post_types(array('public' => true), 'objects');
31 31
 
32
-		foreach ( $post_types as $post_type ) :
32
+		foreach ($post_types as $post_type) :
33 33
 
34 34
 			$skipped_cpts = array(
35 35
 				'attachment'
36 36
 			);
37 37
 
38 38
 			// Skip banned cpts
39
-			if ( in_array( $post_type->name, $skipped_cpts ) ){
39
+			if (in_array($post_type->name, $skipped_cpts)) {
40 40
 				continue;
41 41
 			}
42 42
 
@@ -44,9 +44,9 @@  discard block
 block discarded – undo
44 44
 
45 45
 				$html .= "<h3>";
46 46
 
47
-					$html .= "<span class='label'>" . $post_type->labels->name . "</span>";
48
-					$html .= $this->build_button( 'create', $post_type->name, __( 'Create Test Data', 'otm-test-content' ) );
49
-					$html .= $this->build_button( 'delete', $post_type->name, __( 'Delete Test Data', 'otm-test-content' ) );
47
+					$html .= "<span class='label'>".$post_type->labels->name."</span>";
48
+					$html .= $this->build_button('create', $post_type->name, __('Create Test Data', 'otm-test-content'));
49
+					$html .= $this->build_button('delete', $post_type->name, __('Delete Test Data', 'otm-test-content'));
50 50
 
51 51
 				$html .= "</h3>";
52 52
 
Please login to merge, or discard this patch.
views/various.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
  * @subpackage Test Content
11 11
  * @author     Old Town Media
12 12
  */
13
-class Various extends Abs\View{
13
+class Various extends Abs\View {
14 14
 
15 15
 	protected $title	= 'Various';
16 16
 	protected $type		= 'all';
17
-	protected $priority	= 3;
17
+	protected $priority = 3;
18 18
 
19 19
 
20 20
 	/**
@@ -24,15 +24,15 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @return string HTML content.
26 26
 	 */
27
-	protected function actions_section(){
27
+	protected function actions_section() {
28 28
 		$html = '';
29 29
 
30 30
 		$html .= "<div class='test-data-cpt'>";
31 31
 
32 32
 			$html .= "<h3>";
33 33
 
34
-				$html .= "<span class='label'>" . __( 'Clean Site', 'otm-test-content' ) . "</span>";
35
-				$html .= $this->build_button( 'delete', 'all', __( 'Delete All Test Data', 'otm-test-content' ) );
34
+				$html .= "<span class='label'>".__('Clean Site', 'otm-test-content')."</span>";
35
+				$html .= $this->build_button('delete', 'all', __('Delete All Test Data', 'otm-test-content'));
36 36
 
37 37
 			$html .= "</h3>";
38 38
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 * @param string $html Existing HTML content.
51 51
 	 * @return string HTML section content.
52 52
 	 */
53
-	protected function options_section( $html = '' ){
53
+	protected function options_section($html = '') {
54 54
 		return $html;
55 55
 	}
56 56
 
Please login to merge, or discard this patch.
types/term.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -133,14 +133,14 @@
 block discarded – undo
133 133
 
134 134
 		// Query for our terms
135 135
 		$args = array(
136
-		    'hide_empty' => false,
137
-		    'meta_query' => array(
138
-		        array(
139
-		           'key'       => 'evans_test_content',
140
-		           'value'     => '__test__',
141
-		           'compare'   => '='
142
-		        )
143
-		    )
136
+			'hide_empty' => false,
137
+			'meta_query' => array(
138
+				array(
139
+				   'key'       => 'evans_test_content',
140
+				   'value'     => '__test__',
141
+				   'compare'   => '='
142
+				)
143
+			)
144 144
 		);
145 145
 
146 146
 		$terms = get_terms( $slug, $args );
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  * @subpackage Evans
13 13
  * @author     Old Town Media
14 14
  */
15
-class Term extends Abs\Type{
15
+class Term extends Abs\Type {
16 16
 
17 17
 	protected $type = 'term';
18 18
 
@@ -31,25 +31,25 @@  discard block
 block discarded – undo
31 31
 	 * @param boolean $echo Whether or not to echo. Optional.
32 32
 	 * @param int $num Optional. Number of posts to create.
33 33
 	 */
34
-	public function create_objects( $slug, $connection, $echo = false, $num = '' ){
34
+	public function create_objects($slug, $connection, $echo = false, $num = '') {
35 35
 
36 36
 		// If we're missing a custom post type id - don't do anything
37
-		if ( empty( $slug ) ){
37
+		if (empty($slug)) {
38 38
 			return;
39 39
 		}
40 40
 
41 41
 		// If we forgot to put in a quantity, make one for us
42
-		if ( empty( $num ) ){
43
-			$num = rand( 5, 30 );
42
+		if (empty($num)) {
43
+			$num = rand(5, 30);
44 44
 		}
45 45
 
46 46
 		// Create test terms
47
-		for( $i = 0; $i < $num; $i++ ){
47
+		for ($i = 0; $i < $num; $i++) {
48 48
 
49
-			$return = $this->create_test_object( $slug );
49
+			$return = $this->create_test_object($slug);
50 50
 
51
-			if ( $echo === true ){
52
-				echo \json_encode( $return );
51
+			if ($echo === true) {
52
+				echo \json_encode($return);
53 53
 			}
54 54
 
55 55
 		}
@@ -70,27 +70,27 @@  discard block
 block discarded – undo
70 70
 	 *
71 71
 	 * @param string $slug a custom post type ID.
72 72
 	 */
73
-	private function create_test_object( $slug ){
73
+	private function create_test_object($slug) {
74 74
 
75 75
 		// Get a random title
76
-		$title = apply_filters( "tc_{$slug}_term_title", TestContent::title() );
76
+		$title = apply_filters("tc_{$slug}_term_title", TestContent::title());
77 77
 
78 78
 		$return = wp_insert_term(
79 79
 			$title,
80 80
 			$slug,
81
-			apply_filters( "tc_{$slug}_term_arguments", array(
81
+			apply_filters("tc_{$slug}_term_arguments", array(
82 82
 					'description'=> TestContent::title(),
83
-					'slug' => sanitize_title( $title ),
83
+					'slug' => sanitize_title($title),
84 84
 				)
85 85
 			)
86 86
 		);
87 87
 
88 88
 		// Then, set a test content flag on the new post for later deletion
89
-		add_term_meta( $return['term_id'], 'evans_test_content', '__test__', true );
89
+		add_term_meta($return['term_id'], 'evans_test_content', '__test__', true);
90 90
 
91 91
 		// Check if we have errors and return them or created message
92
-		if ( is_wp_error( $return ) ){
93
-			error_log( $return->get_error_message() );
92
+		if (is_wp_error($return)) {
93
+			error_log($return->get_error_message());
94 94
 			return $return;
95 95
 		} else {
96 96
 			return array(
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
 				'object'	=> 'term',
99 99
 				'tid'		=> $return['term_id'],
100 100
 				'taxonomy'	=> $slug,
101
-				'link_edit'	=> admin_url( '/edit-tags.php?action=edit&taxonomy='.$slug.'&tag_ID='.$return['term_id'] ),
102
-				'link_view'	=> get_term_link( $return['term_id'] )
101
+				'link_edit'	=> admin_url('/edit-tags.php?action=edit&taxonomy='.$slug.'&tag_ID='.$return['term_id']),
102
+				'link_view'	=> get_term_link($return['term_id'])
103 103
 			);
104 104
 		}
105 105
 
@@ -117,17 +117,17 @@  discard block
 block discarded – undo
117 117
 	 * @param string $slug a custom post type ID.
118 118
 	 * @param boolean $echo Whether or not to echo the result
119 119
 	 */
120
-	public function delete( $slug, $echo = false ){
120
+	public function delete($slug, $echo = false) {
121 121
 
122
-		$delete =  new Delete;
122
+		$delete = new Delete;
123 123
 
124 124
 		// Make sure that the current user is logged in & has full permissions.
125
-		if ( !$delete->user_can_delete() ){
125
+		if (!$delete->user_can_delete()) {
126 126
 			return;
127 127
 		}
128 128
 
129 129
 		// Check that $cptslg has a string.
130
-		if ( empty( $slug ) ){
130
+		if (empty($slug)) {
131 131
 			return;
132 132
 		}
133 133
 
@@ -143,15 +143,15 @@  discard block
 block discarded – undo
143 143
 		    )
144 144
 		);
145 145
 
146
-		$terms = get_terms( $slug, $args );
146
+		$terms = get_terms($slug, $args);
147 147
 
148
-		if ( !empty( $terms ) ){
148
+		if (!empty($terms)) {
149 149
 
150 150
 			$events = array();
151 151
 
152
-			foreach ( $terms as $term ){
152
+			foreach ($terms as $term) {
153 153
 
154
-				if ( $echo === true ){
154
+				if ($echo === true) {
155 155
 					$events[] = array(
156 156
 						'type'		=> 'deleted',
157 157
 						'pid'		=> $term->term_id,
@@ -161,18 +161,18 @@  discard block
 block discarded – undo
161 161
 				}
162 162
 
163 163
 				// Delete our term
164
-				wp_delete_term( $term->term_id, $slug );
164
+				wp_delete_term($term->term_id, $slug);
165 165
 
166 166
 			}
167 167
 
168
-			$taxonomy = get_taxonomy( $slug );
168
+			$taxonomy = get_taxonomy($slug);
169 169
 
170 170
 			$events[] = array(
171 171
 				'type'		=> 'general',
172
-				'message'	=> __( 'Deleted', 'otm-test-content' ) . ' ' . $taxonomy->labels->name
172
+				'message'	=> __('Deleted', 'otm-test-content').' '.$taxonomy->labels->name
173 173
 			);
174 174
 
175
-			echo \json_encode( $events );
175
+			echo \json_encode($events);
176 176
 
177 177
 		}
178 178
 
Please login to merge, or discard this patch.
types/post.php 1 patch
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * @subpackage Evans
14 14
  * @author     Old Town Media
15 15
  */
16
-class Post extends Abs\Type{
16
+class Post extends Abs\Type {
17 17
 
18 18
 	/**
19 19
 	 * metaboxes
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @see Metaboxes
33 33
 	 */
34
-	public function __construct(){
34
+	public function __construct() {
35 35
 
36 36
 		$this->metaboxes = new Main\Metaboxes;
37 37
 
@@ -53,32 +53,32 @@  discard block
 block discarded – undo
53 53
 	 * @param boolean $echo Whether or not to echo. Optional.
54 54
 	 * @param int $num Optional. Number of posts to create.
55 55
 	 */
56
-	public function create_objects( $slug, $connection, $echo = false, $num = '' ){
56
+	public function create_objects($slug, $connection, $echo = false, $num = '') {
57 57
 
58 58
 		// If we're missing a custom post type id - don't do anything
59
-		if ( empty( $slug ) ){
59
+		if (empty($slug)) {
60 60
 			return;
61 61
 		}
62 62
 
63 63
 		// Gather the necessary data to create the posts
64
-		$supports 	= $this->get_cpt_supports( $slug );
65
-		$metaboxes	= $this->metaboxes->get_metaboxes( $slug );
64
+		$supports 	= $this->get_cpt_supports($slug);
65
+		$metaboxes	= $this->metaboxes->get_metaboxes($slug);
66 66
 
67 67
 		// Set our connection status for the rest of the methods
68 68
 		$this->connected = $connection;
69 69
 
70 70
 		// If we forgot to put in a quantity, make one for us
71
-		if ( empty( $num ) ){
72
-			$num = rand( 5, 30 );
71
+		if (empty($num)) {
72
+			$num = rand(5, 30);
73 73
 		}
74 74
 
75 75
 		// Create test posts
76
-		for( $i = 0; $i < $num; $i++ ){
76
+		for ($i = 0; $i < $num; $i++) {
77 77
 
78
-			$return = $this->create_test_object( $slug, $supports, $metaboxes );
78
+			$return = $this->create_test_object($slug, $supports, $metaboxes);
79 79
 
80
-			if ( $echo === true ){
81
-				echo \json_encode( $return );
80
+			if ($echo === true) {
81
+				echo \json_encode($return);
82 82
 			}
83 83
 
84 84
 		}
@@ -101,15 +101,15 @@  discard block
 block discarded – undo
101 101
 	 * @param array $supports Features that the post type supports.
102 102
 	 * @param array $supports All CMB2 metaboxes attached to the post type.
103 103
 	 */
104
-	private function create_test_object( $slug, $supports, $metaboxes ){
104
+	private function create_test_object($slug, $supports, $metaboxes) {
105 105
 		$return = '';
106 106
 
107 107
 		// Get a random title
108
-		$title = apply_filters( "tc_{$slug}_post_title", TestContent::title() );
108
+		$title = apply_filters("tc_{$slug}_post_title", TestContent::title());
109 109
 
110 110
 		// First, insert our post
111 111
 		$post = array(
112
-		  'post_name'      => sanitize_title( $title ),
112
+		  'post_name'      => sanitize_title($title),
113 113
 		  'post_status'    => 'publish',
114 114
 		  'post_type'      => $slug,
115 115
 		  'ping_status'    => 'closed',
@@ -117,57 +117,57 @@  discard block
 block discarded – undo
117 117
 		);
118 118
 
119 119
 		// Add title if supported
120
-		if ( $supports['title'] === true ){
120
+		if ($supports['title'] === true) {
121 121
 			$post['post_title'] = $title;
122 122
 		}
123 123
 
124 124
 		// Add main content if supported
125
-		if ( $supports['editor'] === true ){
126
-			$post['post_content'] = apply_filters( "tc_{$slug}_post_content", TestContent::paragraphs() );
125
+		if ($supports['editor'] === true) {
126
+			$post['post_content'] = apply_filters("tc_{$slug}_post_content", TestContent::paragraphs());
127 127
 		}
128 128
 
129 129
 		// Add excerpt content if supported
130
-		if ( $supports['excerpt'] === true ){
131
-			$post['post_excerpt'] = apply_filters( "tc_{$slug}_post_excerpt", TestContent::plain_text() );
130
+		if ($supports['excerpt'] === true) {
131
+			$post['post_excerpt'] = apply_filters("tc_{$slug}_post_excerpt", TestContent::plain_text());
132 132
 		}
133 133
 
134 134
 		// Insert then post object
135
-		$post_id = wp_insert_post( apply_filters( "tc_{$slug}_post_arguments", $post ) );
135
+		$post_id = wp_insert_post(apply_filters("tc_{$slug}_post_arguments", $post));
136 136
 
137 137
 		// Then, set a test content flag on the new post for later deletion
138
-		add_post_meta( $post_id, 'evans_test_content', '__test__', true );
138
+		add_post_meta($post_id, 'evans_test_content', '__test__', true);
139 139
 
140 140
 		// Add thumbnail if supported
141
-		if ( $this->connected == true && ( $supports['thumbnail'] === true || in_array( $slug, array( 'post', 'page' ) ) ) ){
142
-			 update_post_meta( $post_id, '_thumbnail_id', TestContent::image( $post_id ) );
141
+		if ($this->connected == true && ($supports['thumbnail'] === true || in_array($slug, array('post', 'page')))) {
142
+			 update_post_meta($post_id, '_thumbnail_id', TestContent::image($post_id));
143 143
 		}
144 144
 
145
-		$taxonomies = get_object_taxonomies( $slug );
145
+		$taxonomies = get_object_taxonomies($slug);
146 146
 
147 147
 		// Assign the post to terms
148
-		if ( !empty( $taxonomies ) ){
149
-			$return .= $this->assign_terms( $post_id, $taxonomies );
148
+		if (!empty($taxonomies)) {
149
+			$return .= $this->assign_terms($post_id, $taxonomies);
150 150
 		}
151 151
 
152 152
 		// Spin up metaboxes
153
-		if ( !empty( $metaboxes ) ){
154
-			foreach ( $metaboxes as $cmb ) :
155
-				$return .= $this->metaboxes->random_metabox_content( $post_id, $cmb, $this->connected );
153
+		if (!empty($metaboxes)) {
154
+			foreach ($metaboxes as $cmb) :
155
+				$return .= $this->metaboxes->random_metabox_content($post_id, $cmb, $this->connected);
156 156
 			endforeach;
157 157
 		}
158 158
 
159 159
 		// Check if we have errors and return them or created message
160
-		if ( is_wp_error( $return ) ){
161
-			error_log( $return->get_error_message() );
160
+		if (is_wp_error($return)) {
161
+			error_log($return->get_error_message());
162 162
 			return $return;
163 163
 		} else {
164 164
 			return array(
165 165
 				'type'		=> 'created',
166 166
 				'object'	=> 'post',
167 167
 				'pid'		=> $post_id,
168
-				'post_type'	=> get_post_type( $post_id ),
169
-				'link_edit'	=> admin_url( '/post.php?post='.$post_id.'&action=edit' ),
170
-				'link_view'	=> get_permalink( $post_id ),
168
+				'post_type'	=> get_post_type($post_id),
169
+				'link_edit'	=> admin_url('/post.php?post='.$post_id.'&action=edit'),
170
+				'link_view'	=> get_permalink($post_id),
171 171
 			);
172 172
 		}
173 173
 
@@ -184,13 +184,13 @@  discard block
 block discarded – undo
184 184
 	 * @param string $slug a custom post type ID.
185 185
 	 * @return array Array of necessary supports booleans.
186 186
 	 */
187
-	private function get_cpt_supports( $slug ){
187
+	private function get_cpt_supports($slug) {
188 188
 
189 189
 		$supports = array(
190
-			'title'		=> post_type_supports( $slug, 'title' ),
191
-			'editor'	=> post_type_supports( $slug, 'editor' ),
192
-			'excerpt'	=> post_type_supports( $slug, 'excerpt' ),
193
-			'thumbnail'	=> post_type_supports( $slug, 'thumbnail' )
190
+			'title'		=> post_type_supports($slug, 'title'),
191
+			'editor'	=> post_type_supports($slug, 'editor'),
192
+			'excerpt'	=> post_type_supports($slug, 'excerpt'),
193
+			'thumbnail'	=> post_type_supports($slug, 'thumbnail')
194 194
 		);
195 195
 
196 196
 		return $supports;
@@ -211,26 +211,26 @@  discard block
 block discarded – undo
211 211
 	 * @param array $taxonomies taxonomies assigned to this cpt.
212 212
 	 * @return object WP Error if there is one.
213 213
 	 */
214
-	private function assign_terms( $post_id, $taxonomies ){
214
+	private function assign_terms($post_id, $taxonomies) {
215 215
 
216 216
 		// Make sure it's an array & has items
217
-		if ( empty( $taxonomies ) || !is_array( $taxonomies ) ){
217
+		if (empty($taxonomies) || !is_array($taxonomies)) {
218 218
 			return;
219 219
 		}
220 220
 
221
-		foreach ( $taxonomies as $tax ){
221
+		foreach ($taxonomies as $tax) {
222 222
 
223 223
 			// Get the individual terms already existing
224
-			$terms = get_terms( $tax, array( 'hide_empty'	=> false ) );
225
-			$count = count( $terms ) - 1;
224
+			$terms = get_terms($tax, array('hide_empty'	=> false));
225
+			$count = count($terms) - 1;
226 226
 
227 227
 			// If there are no terms, skip to the next taxonomy
228
-			if ( empty( $terms ) ){
228
+			if (empty($terms)) {
229 229
 				continue;
230 230
 			}
231 231
 
232 232
 			// Get a random index to use
233
-			$index = rand( 0, $count );
233
+			$index = rand(0, $count);
234 234
 
235 235
 			// Initialize our array
236 236
 			$post_data = array(
@@ -238,14 +238,14 @@  discard block
 block discarded – undo
238 238
 			);
239 239
 
240 240
 			// Set the term data to update
241
-			$post_data['tax_input'][ $tax ] = array( $terms[$index]->term_id );
241
+			$post_data['tax_input'][$tax] = array($terms[$index]->term_id);
242 242
 
243 243
 			// Update the post with the taxonomy info
244
-			$return = wp_update_post( $post_data );
244
+			$return = wp_update_post($post_data);
245 245
 
246 246
 			// Return the error if it exists
247
-			if ( is_wp_error( $return ) ){
248
-				error_log( $return->get_error_messages() );
247
+			if (is_wp_error($return)) {
248
+				error_log($return->get_error_messages());
249 249
 				return $return->get_error_messages();
250 250
 			}
251 251
 
@@ -265,17 +265,17 @@  discard block
 block discarded – undo
265 265
 	 * @param string $slug a custom post type ID.
266 266
 	 * @param boolean $echo Whether or not to echo the result
267 267
 	 */
268
-	public function delete( $slug, $echo = false ){
268
+	public function delete($slug, $echo = false) {
269 269
 
270
-		$delete =  new Delete;
270
+		$delete = new Delete;
271 271
 
272 272
 		// Make sure that the current user is logged in & has full permissions.
273
-		if ( !$delete->user_can_delete() ){
273
+		if (!$delete->user_can_delete()) {
274 274
 			return;
275 275
 		}
276 276
 
277 277
 		// Check that $cptslg has a string.
278
-		if ( empty( $slug ) ){
278
+		if (empty($slug)) {
279 279
 			return;
280 280
 		}
281 281
 
@@ -292,39 +292,39 @@  discard block
 block discarded – undo
292 292
 			),
293 293
 		);
294 294
 
295
-		$objects = new \WP_Query( $query );
295
+		$objects = new \WP_Query($query);
296 296
 
297
-		if ( $objects->have_posts() ){
297
+		if ($objects->have_posts()) {
298 298
 
299 299
 			$events = array();
300 300
 
301
-			while ( $objects->have_posts() ) : $objects->the_post();
301
+			while ($objects->have_posts()) : $objects->the_post();
302 302
 
303 303
 				// Find any media associated with the test post and delete it as well
304
-				$this->delete_associated_media( get_the_id() );
304
+				$this->delete_associated_media(get_the_id());
305 305
 
306
-				if ( $echo === true ){
306
+				if ($echo === true) {
307 307
 					$events[] = array(
308 308
 						'type'		=> 'deleted',
309 309
 						'pid'		=> get_the_id(),
310
-						'post_type'	=> get_post_type( get_the_id() ),
310
+						'post_type'	=> get_post_type(get_the_id()),
311 311
 						'link'		=> ''
312 312
 					);
313 313
 				}
314 314
 
315 315
 				// Force delete the post
316
-				wp_delete_post( get_the_id(), true );
316
+				wp_delete_post(get_the_id(), true);
317 317
 
318 318
 			endwhile;
319 319
 
320
-			$obj = get_post_type_object( $slug );
320
+			$obj = get_post_type_object($slug);
321 321
 
322 322
 			$events[] = array(
323 323
 				'type'		=> 'general',
324
-				'message'	=> __( 'Deleted', 'otm-test-content' ) . ' ' . $obj->labels->all_items
324
+				'message'	=> __('Deleted', 'otm-test-content').' '.$obj->labels->all_items
325 325
 			);
326 326
 
327
-			echo \json_encode( $events );
327
+			echo \json_encode($events);
328 328
 
329 329
 		}
330 330
 
@@ -344,28 +344,28 @@  discard block
 block discarded – undo
344 344
 	 *
345 345
 	 * @param int $pid a custom post type ID.
346 346
 	 */
347
-	private function delete_associated_media( $pid ){
347
+	private function delete_associated_media($pid) {
348 348
 
349
-		$delete =  new Delete;
349
+		$delete = new Delete;
350 350
 
351 351
 		// Make sure that the current user is logged in & has full permissions.
352
-		if ( !$delete->user_can_delete() ){
352
+		if (!$delete->user_can_delete()) {
353 353
 			return;
354 354
 		}
355 355
 
356 356
 		// Make sure $pid is, in fact, an ID
357
-		if ( !is_int( $pid ) ){
357
+		if (!is_int($pid)) {
358 358
 			return;
359 359
 		}
360 360
 
361 361
 		// Get our images
362
-		$media = get_attached_media( 'image', $pid );
362
+		$media = get_attached_media('image', $pid);
363 363
 
364
-		if ( !empty( $media ) ){
364
+		if (!empty($media)) {
365 365
 
366 366
 			// Loop through the media & delete each one
367
-			foreach ( $media as $attachment ){
368
-				wp_delete_attachment( $attachment->ID, true );
367
+			foreach ($media as $attachment) {
368
+				wp_delete_attachment($attachment->ID, true);
369 369
 			}
370 370
 
371 371
 		}
Please login to merge, or discard this patch.
abstracts/type.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @subpackage Test Content
11 11
  * @author     Old Town Media
12 12
  */
13
-abstract class Type{
13
+abstract class Type {
14 14
 
15 15
 	/**
16 16
 	 * type
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
 	protected $type;
23 23
 
24 24
 
25
-	public function register_type(){
25
+	public function register_type() {
26 26
 
27
-		add_action( 'tc_types', 'set_type' );
27
+		add_action('tc_types', 'set_type');
28 28
 
29 29
 	}
30 30
 
31
-	public function set_type( $types ){
31
+	public function set_type($types) {
32 32
 
33 33
 		$types[] = $this->type;
34 34
 
Please login to merge, or discard this patch.
includes/class-admin-page.php 1 patch
Spacing   +47 added lines, -47 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
@@ -45,16 +45,16 @@  discard block
 block discarded – undo
45 45
 	 *
46 46
 	 * @see admin_menu, wp_ajax actions
47 47
 	 */
48
-	public function hooks(){
48
+	public function hooks() {
49 49
 
50 50
 		$connection = new ConnectionTest;
51
-		$this->definitions	= $this->plugin->get_definitions();
52
-		$this->connected	= $connection->test();
51
+		$this->definitions = $this->plugin->get_definitions();
52
+		$this->connected = $connection->test();
53 53
 
54
-		add_action( 'admin_menu' , array( $this, 'add_menu_item' ) );
55
-		add_action( 'wp_ajax_handle_test_data', array( $this, 'handle_test_data_callback' ) );
56
-		add_filter( 'plugin_action_links_' . $this->definitions->basename , array( $this, 'add_settings_link' ) );
57
-		add_action( 'admin_notices', array( $this, 'internet_connected_admin_notice' ) );
54
+		add_action('admin_menu', array($this, 'add_menu_item'));
55
+		add_action('wp_ajax_handle_test_data', array($this, 'handle_test_data_callback'));
56
+		add_filter('plugin_action_links_'.$this->definitions->basename, array($this, 'add_settings_link'));
57
+		add_action('admin_notices', array($this, 'internet_connected_admin_notice'));
58 58
 
59 59
 	}
60 60
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @param Plugin $plugin Main plugin instance.
66 66
 	 */
67
-	public function set_plugin( $plugin ) {
67
+	public function set_plugin($plugin) {
68 68
 
69 69
 		$this->plugin = $plugin;
70 70
 		return $this;
@@ -81,14 +81,14 @@  discard block
 block discarded – undo
81 81
 
82 82
 		$page = add_submenu_page(
83 83
 			'tools.php',
84
-			__( 'Create Test Content', 'otm-test-content' ),
85
-			__( 'Test Content', 'otm-test-content' ),
84
+			__('Create Test Content', 'otm-test-content'),
85
+			__('Test Content', 'otm-test-content'),
86 86
 			'manage_options',
87 87
 			'create-test-data',
88
-			array( $this, 'admin_page' )
88
+			array($this, 'admin_page')
89 89
 		);
90 90
 
91
-		add_action( 'admin_print_styles-' . $page, array( $this, 'load_scripts' ) );
91
+		add_action('admin_print_styles-'.$page, array($this, 'load_scripts'));
92 92
 
93 93
 	}
94 94
 
@@ -98,10 +98,10 @@  discard block
 block discarded – undo
98 98
 	 * @param  array $links Existing links
99 99
 	 * @return array 		Modified links
100 100
 	 */
101
-	public function add_settings_link( $links ) {
101
+	public function add_settings_link($links) {
102 102
 
103
-		$settings_link = '<a href="tools.php?page=create-test-data">' . __( 'Build Test Content', 'otm-test-content' ) . '</a>';
104
-  		array_push( $links, $settings_link );
103
+		$settings_link = '<a href="tools.php?page=create-test-data">'.__('Build Test Content', 'otm-test-content').'</a>';
104
+  		array_push($links, $settings_link);
105 105
   		return $links;
106 106
 
107 107
 	}
@@ -114,24 +114,24 @@  discard block
 block discarded – undo
114 114
 	 * Internet, and the test fails displays a notice informing the user that
115 115
 	 * images will not pull into test data.
116 116
 	 */
117
-	public function internet_connected_admin_notice(){
117
+	public function internet_connected_admin_notice() {
118 118
 
119 119
 		// Get the current admin screen & verify that we're on the right one
120 120
 		// before continuing.
121 121
 		$screen = get_current_screen();
122 122
 
123
-		if ( $screen->base != 'tools_page_create-test-data' ){
123
+		if ($screen->base != 'tools_page_create-test-data') {
124 124
 			return;
125 125
 		}
126 126
 
127 127
 		// Check the response
128
-		if ( $this->connected ) {
128
+		if ($this->connected) {
129 129
 			// We got a response so early return
130 130
 			return;
131 131
 		} else {
132 132
 			// We didn't get a reponse so print the notice out
133 133
 			echo '<div class="notice notice-error">';
134
-		        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>';
134
+		        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>';
135 135
 		    echo '</div>';
136 136
 		}
137 137
 
@@ -141,19 +141,19 @@  discard block
 block discarded – undo
141 141
 	/**
142 142
 	 * Load our script in the admin section and serve in data.
143 143
 	 */
144
-	public function load_scripts(){
144
+	public function load_scripts() {
145 145
 
146
-		wp_enqueue_script( 'test-content-js', plugins_url( 'assets/admin.js' , dirname( __FILE__ ) ) );
147
-		wp_enqueue_style( 'test-content-css', plugins_url( 'assets/admin.css' , dirname( __FILE__ ) ) );
146
+		wp_enqueue_script('test-content-js', plugins_url('assets/admin.js', dirname(__FILE__)));
147
+		wp_enqueue_style('test-content-css', plugins_url('assets/admin.css', dirname(__FILE__)));
148 148
 
149 149
 		$data = array(
150
-			'nonce'			=> wp_create_nonce( 'handle-test-data' ),
151
-			'createdStr'	=> __( 'Created', 'otm-test-content' ),
152
-			'deletedStr'	=> __( 'Deleting', 'otm-test-content' ),
153
-			'creatingStr'	=> __( 'Creating', 'otm-test-content' ),
150
+			'nonce'			=> wp_create_nonce('handle-test-data'),
151
+			'createdStr'	=> __('Created', 'otm-test-content'),
152
+			'deletedStr'	=> __('Deleting', 'otm-test-content'),
153
+			'creatingStr'	=> __('Creating', 'otm-test-content'),
154 154
 		);
155 155
 
156
-		wp_localize_script( 'test-content-js', 'test_content', $data );
156
+		wp_localize_script('test-content-js', 'test_content', $data);
157 157
 
158 158
 	}
159 159
 
@@ -165,21 +165,21 @@  discard block
 block discarded – undo
165 165
 	 */
166 166
 	public function handle_test_data_callback() {
167 167
 
168
-		$action		= $_REQUEST['todo'];
169
-		$nonce		= $_REQUEST['nonce'];
168
+		$action = $_REQUEST['todo'];
169
+		$nonce = $_REQUEST['nonce'];
170 170
 
171 171
 		// Verify that we have a proper logged in user and it's the right person
172
-		if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'handle-test-data' ) ){
172
+		if (empty($nonce) || !wp_verify_nonce($nonce, 'handle-test-data')) {
173 173
 			return;
174 174
 		}
175 175
 
176
-		if ( $action == 'delete' ){
176
+		if ($action == 'delete') {
177 177
 
178
-			$this->deletion_routing( $_REQUEST );
178
+			$this->deletion_routing($_REQUEST);
179 179
 
180
-		} elseif ( $action == 'create' ){
180
+		} elseif ($action == 'create') {
181 181
 
182
-			$this->creation_routing( $_REQUEST );
182
+			$this->creation_routing($_REQUEST);
183 183
 
184 184
 		}
185 185
 
@@ -192,11 +192,11 @@  discard block
 block discarded – undo
192 192
 	 * Choose which type of creation needs to be accomplished and route through
193 193
 	 * the correct class.
194 194
 	 */
195
-	private function creation_routing( $data ){
195
+	private function creation_routing($data) {
196 196
 
197
-		$type = 'testContent\Types\\' . ucwords( $data['type'] );
197
+		$type = 'testContent\Types\\'.ucwords($data['type']);
198 198
 		$object = new $type();
199
-		$object->create_objects( $data['slug'], $data['connection'], true, 1 );
199
+		$object->create_objects($data['slug'], $data['connection'], true, 1);
200 200
 
201 201
 	}
202 202
 
@@ -205,17 +205,17 @@  discard block
 block discarded – undo
205 205
 	 * Choose which type of deletion needs to be accomplished and route through
206 206
 	 * the correct method of Delete.
207 207
 	 */
208
-	private function deletion_routing( $data ){
208
+	private function deletion_routing($data) {
209 209
 
210 210
 		$delete_content = new Delete;
211 211
 
212
-		if ( $data['type'] == 'all' ){
212
+		if ($data['type'] == 'all') {
213 213
 
214
-			$delete_content->delete_all_test_data( true );
214
+			$delete_content->delete_all_test_data(true);
215 215
 
216 216
 		} else {
217 217
 
218
-			$delete_content->delete_objects( true, $data );
218
+			$delete_content->delete_objects(true, $data);
219 219
 
220 220
 		}
221 221
 
@@ -225,20 +225,20 @@  discard block
 block discarded – undo
225 225
 	/**
226 226
 	 * Print out our admin page to control test data.
227 227
 	 */
228
-	public function admin_page(){
229
-		echo '<div class="wrap" id="options_editor">' . "\n";
228
+	public function admin_page() {
229
+		echo '<div class="wrap" id="options_editor">'."\n";
230 230
 
231
-			echo '<h2>' . __( 'Create Test Data' , 'otm-test-content' ) . '</h2>' . "\n";
231
+			echo '<h2>'.__('Create Test Data', 'otm-test-content').'</h2>'."\n";
232 232
 
233 233
 			echo "<div class='nav-tab-wrapper'>";
234 234
 
235
-				do_action( 'tc-admin-tabs', '' );
235
+				do_action('tc-admin-tabs', '');
236 236
 
237 237
 			echo "</div>";
238 238
 
239 239
 			echo "";
240 240
 
241
-				do_action( 'tc-admin-sections', '' );
241
+				do_action('tc-admin-sections', '');
242 242
 
243 243
 			echo "";
244 244
 
Please login to merge, or discard this patch.