Completed
Push — master ( f74f98...045634 )
by Mike
02:05
created
includes/class-admin-page.php 1 patch
Spacing   +41 added lines, -41 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
 	 * Hooks function.
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 * @see admin_menu, wp_ajax actions
19 19
 	 */
20
-	public function hooks(){
20
+	public function hooks() {
21 21
 
22
-		add_action( 'admin_menu' , array( $this, 'add_menu_item' ) );
23
-		add_action( 'wp_ajax_handle_test_data', array( $this, 'handle_test_data_callback' ) );
24
-		add_action( 'admin_enqueue_scripts', array( $this, 'load_scripts' ) );
22
+		add_action('admin_menu', array($this, 'add_menu_item'));
23
+		add_action('wp_ajax_handle_test_data', array($this, 'handle_test_data_callback'));
24
+		add_action('admin_enqueue_scripts', array($this, 'load_scripts'));
25 25
 
26 26
 	}
27 27
 
@@ -35,11 +35,11 @@  discard block
 block discarded – undo
35 35
 
36 36
 		add_submenu_page(
37 37
 			'tools.php',
38
-			__( 'Create Test Data', 'otm-test-content' ),
39
-			__( 'Test Data', 'otm-test-content' ),
38
+			__('Create Test Data', 'otm-test-content'),
39
+			__('Test Data', 'otm-test-content'),
40 40
 			'manage_options',
41 41
 			'create-test-data',
42
-			array( $this, 'admin_page' )
42
+			array($this, 'admin_page')
43 43
 		);
44 44
 
45 45
 	}
@@ -48,15 +48,15 @@  discard block
 block discarded – undo
48 48
 	/**
49 49
 	 * Load our script in the admin section and serve in data.
50 50
 	 */
51
-	public function load_scripts(){
51
+	public function load_scripts() {
52 52
 
53
-		wp_enqueue_script( 'test-content-js', plugins_url( 'assets/admin.js' , dirname( __FILE__ ) ) );
53
+		wp_enqueue_script('test-content-js', plugins_url('assets/admin.js', dirname(__FILE__)));
54 54
 
55 55
 		$data = array(
56
-			'nonce'	=> wp_create_nonce( 'handle-test-data' )
56
+			'nonce'	=> wp_create_nonce('handle-test-data')
57 57
 		);
58 58
 
59
-		wp_localize_script( 'test-content-js', 'test_content', $data );
59
+		wp_localize_script('test-content-js', 'test_content', $data);
60 60
 
61 61
 	}
62 62
 
@@ -68,21 +68,21 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	public function handle_test_data_callback() {
70 70
 
71
-		$action		= $_REQUEST['todo'];
72
-		$nonce		= $_REQUEST['nonce'];
71
+		$action = $_REQUEST['todo'];
72
+		$nonce = $_REQUEST['nonce'];
73 73
 
74 74
 		// Verify that we have a proper logged in user and it's the right person
75
-		if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'handle-test-data' ) ){
75
+		if (empty($nonce) || !wp_verify_nonce($nonce, 'handle-test-data')) {
76 76
 			return;
77 77
 		}
78 78
 
79
-		if ( $action == 'delete' ){
79
+		if ($action == 'delete') {
80 80
 
81
-			$this->deletion_routing( $_REQUEST );
81
+			$this->deletion_routing($_REQUEST);
82 82
 
83
-		} elseif ( $action == 'create' ){
83
+		} elseif ($action == 'create') {
84 84
 
85
-			$this->creation_routing( $_REQUEST );
85
+			$this->creation_routing($_REQUEST);
86 86
 
87 87
 		}
88 88
 
@@ -95,17 +95,17 @@  discard block
 block discarded – undo
95 95
 	 * Choose which type of creation needs to be accomplished and route through
96 96
 	 * the correct class.
97 97
 	 */
98
-	private function creation_routing( $data ){
98
+	private function creation_routing($data) {
99 99
 
100
-		if ( $data['type'] == 'post' ){
100
+		if ($data['type'] == 'post') {
101 101
 
102 102
 			$create_content = new CreatePost;
103
-			$create_content->create_post_type_content( $data['slug'], true, 1 );
103
+			$create_content->create_post_type_content($data['slug'], true, 1);
104 104
 
105
-		} elseif( $data['type'] == 'term' ){
105
+		} elseif ($data['type'] == 'term') {
106 106
 
107 107
 			$create_content = new CreateTerm;
108
-			$create_content->create_terms( $data['slug'], true, 1 );
108
+			$create_content->create_terms($data['slug'], true, 1);
109 109
 
110 110
 		}
111 111
 
@@ -116,13 +116,13 @@  discard block
 block discarded – undo
116 116
 	 * Choose which type of deletion needs to be accomplished and route through
117 117
 	 * the correct method of Delete.
118 118
 	 */
119
-	private function deletion_routing( $data ){
119
+	private function deletion_routing($data) {
120 120
 
121 121
 		$delete_content = new Delete;
122 122
 
123
-		if ( $data['type'] == 'post' ){
123
+		if ($data['type'] == 'post') {
124 124
 
125
-			$delete_content->delete_post( $data['slug'], true );
125
+			$delete_content->delete_post($data['slug'], true);
126 126
 
127 127
 		}
128 128
 
@@ -132,16 +132,16 @@  discard block
 block discarded – undo
132 132
 	/**
133 133
 	 * Print out our admin page to control test data.
134 134
 	 */
135
-	public function admin_page(){
135
+	public function admin_page() {
136 136
 
137 137
 		$html = "";
138 138
 
139 139
 		$html .= '<div class="wrap" id="options_editor">' . "\n";
140 140
 
141
-			$html .= '<h2>' . __( 'Create Test Data' , 'otm-test-content' ) . '</h2>' . "\n";
141
+			$html .= '<h2>' . __('Create Test Data', 'otm-test-content') . '</h2>' . "\n";
142 142
 
143 143
 			// Loop through all other cpts
144
-			$post_types = get_post_types( array( 'public' => true ), 'objects' );
144
+			$post_types = get_post_types(array('public' => true), 'objects');
145 145
 
146 146
 			$html .= "<div>";
147 147
 
@@ -153,14 +153,14 @@  discard block
 block discarded – undo
153 153
 			$html .= "</div>";
154 154
 
155 155
 			// Loop through every post type available on the site
156
-			foreach ( $post_types as $post_type ) {
156
+			foreach ($post_types as $post_type) {
157 157
 
158 158
 				$skipped_cpts = array(
159 159
 					'attachment'
160 160
 				);
161 161
 
162 162
 				// Skip banned cpts
163
-				if ( in_array( $post_type->name, $skipped_cpts ) ){
163
+				if (in_array($post_type->name, $skipped_cpts)) {
164 164
 					continue;
165 165
 				}
166 166
 
@@ -170,17 +170,17 @@  discard block
 block discarded – undo
170 170
 					$html .= "<h3>";
171 171
 
172 172
 						$html .= "<span style='width: 20%; display: inline-block;'>" . $post_type->labels->name . "</span>";
173
-						$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' style='margin-top: 6px; font-size: 1.2em'></span> ".__( 'Create Test Data', 'otm-test-content' )."</a>";
174
-						$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' style='margin-top: 4px; font-size: 1.2em'></span> ".__( 'Delete Test Data', 'otm-test-content' )."</a>";
173
+						$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' style='margin-top: 6px; font-size: 1.2em'></span> " . __('Create Test Data', 'otm-test-content') . "</a>";
174
+						$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' style='margin-top: 4px; font-size: 1.2em'></span> " . __('Delete Test Data', 'otm-test-content') . "</a>";
175 175
 
176 176
 					$html .= "</h3>";
177 177
 
178 178
 					// Create row for each taxonomy associated with the post/page/cpt
179
-					$taxonomies = get_object_taxonomies( $post_type->name );
179
+					$taxonomies = get_object_taxonomies($post_type->name);
180 180
 
181
-						if ( !empty( $taxonomies ) ){
181
+						if (!empty($taxonomies)) {
182 182
 
183
-							foreach( $taxonomies as $tax ){
183
+							foreach ($taxonomies as $tax) {
184 184
 
185 185
 								$html .= "<h3>";
186 186
 
@@ -189,15 +189,15 @@  discard block
 block discarded – undo
189 189
 								);
190 190
 
191 191
 								// Skip banned taxonomies
192
-								if ( in_array( $tax, $skipped_taxonomies ) ){
192
+								if (in_array($tax, $skipped_taxonomies)) {
193 193
 									continue;
194 194
 								}
195 195
 
196
-								$taxonomy = get_taxonomy( $tax );
196
+								$taxonomy = get_taxonomy($tax);
197 197
 
198
-								$html .= "<span style='width: 20%; display: inline-block; font-size: .9em'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$taxonomy->labels->name."</span>";
198
+								$html .= "<span style='width: 20%; display: inline-block; font-size: .9em'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $taxonomy->labels->name . "</span>";
199 199
 
200
-								$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' style='margin-top: 4px; font-size: 1.2em'></span> ".__( 'Create', 'otm-test-content' )." ".$taxonomy->labels->name."</a>";
200
+								$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' style='margin-top: 4px; font-size: 1.2em'></span> " . __('Create', 'otm-test-content') . " " . $taxonomy->labels->name . "</a>";
201 201
 
202 202
 								$html .= "</h3>";
203 203
 
Please login to merge, or discard this patch.