@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @see load_plugin_textdomain |
46 | 46 | */ |
47 | 47 | function load_textdomain() { |
48 | - load_plugin_textdomain( 'otm-test-content', FALSE, basename( dirname( $this->file ) ) . '/languages/' ); |
|
48 | + load_plugin_textdomain( 'otm-test-content', FALSE, basename( dirname( $this->file ) ) . '/languages/' ); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | } else { |
109 | 109 | // We didn't get a reponse so print the notice out |
110 | 110 | echo '<div class="notice notice-error is-dismissible">'; |
111 | - 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>'; |
|
112 | - echo '</div>'; |
|
111 | + 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>'; |
|
112 | + echo '</div>'; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage Evans |
9 | 9 | * @author Old Town Media |
10 | 10 | */ |
11 | -class AdminPage{ |
|
11 | +class AdminPage { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * file |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @see admin_menu, wp_ajax actions |
28 | 28 | */ |
29 | - public function hooks( $file ){ |
|
29 | + public function hooks($file) { |
|
30 | 30 | |
31 | 31 | $this->file = $file; |
32 | 32 | |
33 | - add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) ); |
|
34 | - add_action( 'admin_menu' , array( $this, 'add_menu_item' ) ); |
|
35 | - add_action( 'wp_ajax_handle_test_data', array( $this, 'handle_test_data_callback' ) ); |
|
36 | - add_filter( 'plugin_action_links_' . plugin_basename( $file ) , array( $this, 'add_settings_link' ) ); |
|
37 | - add_action( 'admin_notices', array( $this, 'internet_connected_admin_notice' ) ); |
|
33 | + add_action('plugins_loaded', array($this, 'load_textdomain')); |
|
34 | + add_action('admin_menu', array($this, 'add_menu_item')); |
|
35 | + add_action('wp_ajax_handle_test_data', array($this, 'handle_test_data_callback')); |
|
36 | + add_filter('plugin_action_links_' . plugin_basename($file), array($this, 'add_settings_link')); |
|
37 | + add_action('admin_notices', array($this, 'internet_connected_admin_notice')); |
|
38 | 38 | |
39 | 39 | } |
40 | 40 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @see load_plugin_textdomain |
46 | 46 | */ |
47 | 47 | function load_textdomain() { |
48 | - load_plugin_textdomain( 'otm-test-content', FALSE, basename( dirname( $this->file ) ) . '/languages/' ); |
|
48 | + load_plugin_textdomain('otm-test-content', FALSE, basename(dirname($this->file)) . '/languages/'); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
@@ -58,14 +58,14 @@ discard block |
||
58 | 58 | |
59 | 59 | $page = add_submenu_page( |
60 | 60 | 'tools.php', |
61 | - __( 'Create Test Content', 'otm-test-content' ), |
|
62 | - __( 'Test Content', 'otm-test-content' ), |
|
61 | + __('Create Test Content', 'otm-test-content'), |
|
62 | + __('Test Content', 'otm-test-content'), |
|
63 | 63 | 'manage_options', |
64 | 64 | 'create-test-data', |
65 | - array( $this, 'admin_page' ) |
|
65 | + array($this, 'admin_page') |
|
66 | 66 | ); |
67 | 67 | |
68 | - add_action( 'admin_print_styles-' . $page, array( $this, 'load_scripts' ) ); |
|
68 | + add_action('admin_print_styles-' . $page, array($this, 'load_scripts')); |
|
69 | 69 | |
70 | 70 | } |
71 | 71 | |
@@ -75,10 +75,10 @@ discard block |
||
75 | 75 | * @param array $links Existing links |
76 | 76 | * @return array Modified links |
77 | 77 | */ |
78 | - public function add_settings_link( $links ) { |
|
78 | + public function add_settings_link($links) { |
|
79 | 79 | |
80 | - $settings_link = '<a href="tools.php?page=create-test-data">' . __( 'Build Test Content', 'otm-test-content' ) . '</a>'; |
|
81 | - array_push( $links, $settings_link ); |
|
80 | + $settings_link = '<a href="tools.php?page=create-test-data">' . __('Build Test Content', 'otm-test-content') . '</a>'; |
|
81 | + array_push($links, $settings_link); |
|
82 | 82 | return $links; |
83 | 83 | |
84 | 84 | } |
@@ -91,24 +91,24 @@ discard block |
||
91 | 91 | * Internet, and the test fails displays a notice informing the user that |
92 | 92 | * images will not pull into test data. |
93 | 93 | */ |
94 | - public function internet_connected_admin_notice(){ |
|
94 | + public function internet_connected_admin_notice() { |
|
95 | 95 | |
96 | 96 | // Get the current admin screen & verify that we're on the right one |
97 | 97 | // before continuing. |
98 | 98 | $screen = get_current_screen(); |
99 | 99 | |
100 | - if ( $screen->base != 'tools_page_create-test-data' ){ |
|
100 | + if ($screen->base != 'tools_page_create-test-data') { |
|
101 | 101 | return; |
102 | 102 | } |
103 | 103 | |
104 | 104 | // Check the response |
105 | - if ( $this->test_splashbase_api() ) { |
|
105 | + if ($this->test_splashbase_api()) { |
|
106 | 106 | // We got a response so early return |
107 | 107 | return; |
108 | 108 | } else { |
109 | 109 | // We didn't get a reponse so print the notice out |
110 | 110 | echo '<div class="notice notice-error is-dismissible">'; |
111 | - 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>'; |
|
111 | + 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>'; |
|
112 | 112 | echo '</div>'; |
113 | 113 | } |
114 | 114 | |
@@ -131,30 +131,30 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @return boolean Status of connection to Splashbase. |
133 | 133 | */ |
134 | - private function test_splashbase_api(){ |
|
134 | + private function test_splashbase_api() { |
|
135 | 135 | |
136 | 136 | /* |
137 | 137 | * Test #1 - Check Internet connection in general |
138 | 138 | */ |
139 | 139 | // Attempt to open a socket connection to splashbase |
140 | - $connected = @fsockopen( "www.google.com", 80 ); |
|
140 | + $connected = @fsockopen("www.google.com", 80); |
|
141 | 141 | |
142 | - if ( !$connected ){ |
|
142 | + if (!$connected) { |
|
143 | 143 | return false; |
144 | 144 | } |
145 | 145 | |
146 | 146 | // Close out our 1st test |
147 | - fclose( $connected ); |
|
147 | + fclose($connected); |
|
148 | 148 | |
149 | 149 | |
150 | 150 | /* |
151 | 151 | * Test #2 - Check for Airplane Mode plugin status |
152 | 152 | */ |
153 | - if ( class_exists( 'Airplane_Mode_Core' ) ){ |
|
153 | + if (class_exists('Airplane_Mode_Core')) { |
|
154 | 154 | // Is airplane mode active? |
155 | - $airplane_mode = get_site_option( 'airplane-mode' ); |
|
155 | + $airplane_mode = get_site_option('airplane-mode'); |
|
156 | 156 | |
157 | - if ( $airplane_mode === 'on' ){ |
|
157 | + if ($airplane_mode === 'on') { |
|
158 | 158 | return false; |
159 | 159 | } |
160 | 160 | } |
@@ -164,9 +164,9 @@ discard block |
||
164 | 164 | * Test #3 - Check Splashbase itself |
165 | 165 | */ |
166 | 166 | $test_url = 'http://www.splashbase.co/api/v1/images/'; |
167 | - $response = wp_remote_get( $test_url ); |
|
167 | + $response = wp_remote_get($test_url); |
|
168 | 168 | |
169 | - if ( !is_array( $response ) ){ |
|
169 | + if (!is_array($response)) { |
|
170 | 170 | return false; |
171 | 171 | } |
172 | 172 | |
@@ -179,19 +179,19 @@ discard block |
||
179 | 179 | /** |
180 | 180 | * Load our script in the admin section and serve in data. |
181 | 181 | */ |
182 | - public function load_scripts(){ |
|
182 | + public function load_scripts() { |
|
183 | 183 | |
184 | - wp_enqueue_script( 'test-content-js', plugins_url( 'assets/admin.js' , dirname( __FILE__ ) ) ); |
|
185 | - wp_enqueue_style( 'test-content-css', plugins_url( 'assets/admin.css' , dirname( __FILE__ ) ) ); |
|
184 | + wp_enqueue_script('test-content-js', plugins_url('assets/admin.js', dirname(__FILE__))); |
|
185 | + wp_enqueue_style('test-content-css', plugins_url('assets/admin.css', dirname(__FILE__))); |
|
186 | 186 | |
187 | 187 | $data = array( |
188 | - 'nonce' => wp_create_nonce( 'handle-test-data' ), |
|
189 | - 'createdStr' => __( 'Created', 'otm-test-content' ), |
|
190 | - 'deletedStr' => __( 'Deleting', 'otm-test-content' ), |
|
191 | - 'creatingStr' => __( 'Creating', 'otm-test-content' ), |
|
188 | + 'nonce' => wp_create_nonce('handle-test-data'), |
|
189 | + 'createdStr' => __('Created', 'otm-test-content'), |
|
190 | + 'deletedStr' => __('Deleting', 'otm-test-content'), |
|
191 | + 'creatingStr' => __('Creating', 'otm-test-content'), |
|
192 | 192 | ); |
193 | 193 | |
194 | - wp_localize_script( 'test-content-js', 'test_content', $data ); |
|
194 | + wp_localize_script('test-content-js', 'test_content', $data); |
|
195 | 195 | |
196 | 196 | } |
197 | 197 | |
@@ -203,21 +203,21 @@ discard block |
||
203 | 203 | */ |
204 | 204 | public function handle_test_data_callback() { |
205 | 205 | |
206 | - $action = $_REQUEST['todo']; |
|
207 | - $nonce = $_REQUEST['nonce']; |
|
206 | + $action = $_REQUEST['todo']; |
|
207 | + $nonce = $_REQUEST['nonce']; |
|
208 | 208 | |
209 | 209 | // Verify that we have a proper logged in user and it's the right person |
210 | - if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'handle-test-data' ) ){ |
|
210 | + if (empty($nonce) || !wp_verify_nonce($nonce, 'handle-test-data')) { |
|
211 | 211 | return; |
212 | 212 | } |
213 | 213 | |
214 | - if ( $action == 'delete' ){ |
|
214 | + if ($action == 'delete') { |
|
215 | 215 | |
216 | - $this->deletion_routing( $_REQUEST ); |
|
216 | + $this->deletion_routing($_REQUEST); |
|
217 | 217 | |
218 | - } elseif ( $action == 'create' ){ |
|
218 | + } elseif ($action == 'create') { |
|
219 | 219 | |
220 | - $this->creation_routing( $_REQUEST ); |
|
220 | + $this->creation_routing($_REQUEST); |
|
221 | 221 | |
222 | 222 | } |
223 | 223 | |
@@ -230,17 +230,17 @@ discard block |
||
230 | 230 | * Choose which type of creation needs to be accomplished and route through |
231 | 231 | * the correct class. |
232 | 232 | */ |
233 | - private function creation_routing( $data ){ |
|
233 | + private function creation_routing($data) { |
|
234 | 234 | |
235 | - if ( $data['type'] == 'post' ){ |
|
235 | + if ($data['type'] == 'post') { |
|
236 | 236 | |
237 | 237 | $create_content = new CreatePost; |
238 | - $create_content->create_post_type_content( $data['slug'], true, 1 ); |
|
238 | + $create_content->create_post_type_content($data['slug'], true, 1); |
|
239 | 239 | |
240 | - } elseif( $data['type'] == 'term' ){ |
|
240 | + } elseif ($data['type'] == 'term') { |
|
241 | 241 | |
242 | 242 | $create_content = new CreateTerm; |
243 | - $create_content->create_terms( $data['slug'], true, 1 ); |
|
243 | + $create_content->create_terms($data['slug'], true, 1); |
|
244 | 244 | |
245 | 245 | } |
246 | 246 | |
@@ -251,17 +251,17 @@ discard block |
||
251 | 251 | * Choose which type of deletion needs to be accomplished and route through |
252 | 252 | * the correct method of Delete. |
253 | 253 | */ |
254 | - private function deletion_routing( $data ){ |
|
254 | + private function deletion_routing($data) { |
|
255 | 255 | |
256 | 256 | $delete_content = new Delete; |
257 | 257 | |
258 | - if ( $data['type'] == 'post' ){ |
|
258 | + if ($data['type'] == 'post') { |
|
259 | 259 | |
260 | - $delete_content->delete_posts( $data['slug'], true ); |
|
260 | + $delete_content->delete_posts($data['slug'], true); |
|
261 | 261 | |
262 | - } elseif ( $data['type'] == 'term' ){ |
|
262 | + } elseif ($data['type'] == 'term') { |
|
263 | 263 | |
264 | - $delete_content->delete_terms( $data['slug'], true ); |
|
264 | + $delete_content->delete_terms($data['slug'], true); |
|
265 | 265 | |
266 | 266 | } |
267 | 267 | |
@@ -271,35 +271,35 @@ discard block |
||
271 | 271 | /** |
272 | 272 | * Print out our admin page to control test data. |
273 | 273 | */ |
274 | - public function admin_page(){ |
|
274 | + public function admin_page() { |
|
275 | 275 | |
276 | 276 | $html = ""; |
277 | 277 | |
278 | 278 | $html .= '<div class="wrap" id="options_editor">' . "\n"; |
279 | 279 | |
280 | - $html .= '<h2>' . __( 'Create Test Data' , 'otm-test-content' ) . '</h2>' . "\n"; |
|
280 | + $html .= '<h2>' . __('Create Test Data', 'otm-test-content') . '</h2>' . "\n"; |
|
281 | 281 | |
282 | 282 | // Loop through all other cpts |
283 | - $post_types = get_post_types( array( 'public' => true ), 'objects' ); |
|
283 | + $post_types = get_post_types(array('public' => true), 'objects'); |
|
284 | 284 | |
285 | 285 | $html .= "<div>"; |
286 | 286 | |
287 | 287 | $html .= "<div class='test-data-cpt'>"; |
288 | 288 | $html .= "<h3>"; |
289 | - $html .= "<span class='label'>".__( 'Quantity', 'otm-test-content' )."</span>"; |
|
290 | - $html .= "<input type='number' value='0' id='quantity-adjustment'> <small><i>".__( 'Set to 0 to keep random', 'otm-test-content' )."</i></small>"; |
|
289 | + $html .= "<span class='label'>" . __('Quantity', 'otm-test-content') . "</span>"; |
|
290 | + $html .= "<input type='number' value='0' id='quantity-adjustment'> <small><i>" . __('Set to 0 to keep random', 'otm-test-content') . "</i></small>"; |
|
291 | 291 | $html .= "</h3>"; |
292 | 292 | $html .= "</div>"; |
293 | 293 | |
294 | 294 | // Loop through every post type available on the site |
295 | - foreach ( $post_types as $post_type ) { |
|
295 | + foreach ($post_types as $post_type) { |
|
296 | 296 | |
297 | 297 | $skipped_cpts = array( |
298 | 298 | 'attachment' |
299 | 299 | ); |
300 | 300 | |
301 | 301 | // Skip banned cpts |
302 | - if ( in_array( $post_type->name, $skipped_cpts ) ){ |
|
302 | + if (in_array($post_type->name, $skipped_cpts)) { |
|
303 | 303 | continue; |
304 | 304 | } |
305 | 305 | |
@@ -309,17 +309,17 @@ discard block |
||
309 | 309 | $html .= "<h3>"; |
310 | 310 | |
311 | 311 | $html .= "<span class='label'>" . $post_type->labels->name . "</span>"; |
312 | - $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>"; |
|
313 | - $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>"; |
|
312 | + $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>"; |
|
313 | + $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>"; |
|
314 | 314 | |
315 | 315 | $html .= "</h3>"; |
316 | 316 | |
317 | 317 | // Create row for each taxonomy associated with the post/page/cpt |
318 | - $taxonomies = get_object_taxonomies( $post_type->name ); |
|
318 | + $taxonomies = get_object_taxonomies($post_type->name); |
|
319 | 319 | |
320 | - if ( !empty( $taxonomies ) ){ |
|
320 | + if (!empty($taxonomies)) { |
|
321 | 321 | |
322 | - foreach( $taxonomies as $tax ){ |
|
322 | + foreach ($taxonomies as $tax) { |
|
323 | 323 | |
324 | 324 | $html .= "<h3>"; |
325 | 325 | |
@@ -328,17 +328,17 @@ discard block |
||
328 | 328 | ); |
329 | 329 | |
330 | 330 | // Skip banned taxonomies |
331 | - if ( in_array( $tax, $skipped_taxonomies ) ){ |
|
331 | + if (in_array($tax, $skipped_taxonomies)) { |
|
332 | 332 | continue; |
333 | 333 | } |
334 | 334 | |
335 | - $taxonomy = get_taxonomy( $tax ); |
|
335 | + $taxonomy = get_taxonomy($tax); |
|
336 | 336 | |
337 | - $html .= "<span class='label term-label'> ".$taxonomy->labels->name."</span>"; |
|
337 | + $html .= "<span class='label term-label'> " . $taxonomy->labels->name . "</span>"; |
|
338 | 338 | |
339 | - $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>"; |
|
339 | + $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>"; |
|
340 | 340 | |
341 | - $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>"; |
|
341 | + $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>"; |
|
342 | 342 | |
343 | 343 | $html .= "</h3>"; |
344 | 344 |
@@ -8,7 +8,7 @@ discard block |
||
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 test data posts. |
@@ -23,11 +23,11 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @param string $slug a custom post type ID. |
25 | 25 | */ |
26 | - public function delete_posts( $slug, $echo = false ){ |
|
26 | + public function delete_posts($slug, $echo = false) { |
|
27 | 27 | |
28 | 28 | // Check that $cptslg has a string. |
29 | 29 | // Also make sure that the current user is logged in & has full permissions. |
30 | - if ( empty( $slug ) || !is_user_logged_in() || !current_user_can( 'delete_posts' ) ){ |
|
30 | + if (empty($slug) || !is_user_logged_in() || !current_user_can('delete_posts')) { |
|
31 | 31 | return; |
32 | 32 | } |
33 | 33 | |
@@ -44,39 +44,39 @@ discard block |
||
44 | 44 | ), |
45 | 45 | ); |
46 | 46 | |
47 | - $objects = new \WP_Query( $query ); |
|
47 | + $objects = new \WP_Query($query); |
|
48 | 48 | |
49 | - if ( $objects->have_posts() ){ |
|
49 | + if ($objects->have_posts()) { |
|
50 | 50 | |
51 | 51 | $events = array(); |
52 | 52 | |
53 | - while ( $objects->have_posts() ) : $objects->the_post(); |
|
53 | + while ($objects->have_posts()) : $objects->the_post(); |
|
54 | 54 | |
55 | 55 | // Find any media associated with the test post and delete it as well |
56 | - $this->delete_associated_media( get_the_id() ); |
|
56 | + $this->delete_associated_media(get_the_id()); |
|
57 | 57 | |
58 | - if ( $echo === true ){ |
|
58 | + if ($echo === true) { |
|
59 | 59 | $events[] = array( |
60 | 60 | 'type' => 'deleted', |
61 | 61 | 'pid' => get_the_id(), |
62 | - 'post_type' => get_post_type( get_the_id() ), |
|
62 | + 'post_type' => get_post_type(get_the_id()), |
|
63 | 63 | 'link' => '' |
64 | 64 | ); |
65 | 65 | } |
66 | 66 | |
67 | 67 | // Force delete the post |
68 | - wp_delete_post( get_the_id(), true ); |
|
68 | + wp_delete_post(get_the_id(), true); |
|
69 | 69 | |
70 | 70 | endwhile; |
71 | 71 | |
72 | - $obj = get_post_type_object( $slug ); |
|
72 | + $obj = get_post_type_object($slug); |
|
73 | 73 | |
74 | 74 | $events[] = array( |
75 | 75 | 'type' => 'general', |
76 | - 'message' => __( 'Deleted', 'otm-test-content' ) . ' ' . $obj->labels->all_items |
|
76 | + 'message' => __('Deleted', 'otm-test-content') . ' ' . $obj->labels->all_items |
|
77 | 77 | ); |
78 | 78 | |
79 | - echo \json_encode( $events ); |
|
79 | + echo \json_encode($events); |
|
80 | 80 | |
81 | 81 | } |
82 | 82 | |
@@ -96,20 +96,20 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @param int $pid a custom post type ID. |
98 | 98 | */ |
99 | - private function delete_associated_media( $pid ){ |
|
99 | + private function delete_associated_media($pid) { |
|
100 | 100 | |
101 | - if ( !is_int( $pid ) ){ |
|
101 | + if (!is_int($pid)) { |
|
102 | 102 | return; |
103 | 103 | } |
104 | 104 | |
105 | 105 | // Get our images |
106 | - $media = get_attached_media( 'image', $pid ); |
|
106 | + $media = get_attached_media('image', $pid); |
|
107 | 107 | |
108 | - if ( !empty( $media ) ){ |
|
108 | + if (!empty($media)) { |
|
109 | 109 | |
110 | 110 | // Loop through the media & delete each one |
111 | - foreach ( $media as $attachment ){ |
|
112 | - wp_delete_attachment( $attachment->ID, true ); |
|
111 | + foreach ($media as $attachment) { |
|
112 | + wp_delete_attachment($attachment->ID, true); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @param string $slug a custom post type ID. |
131 | 131 | */ |
132 | - public function delete_terms( $slug, $echo = false ){ |
|
132 | + public function delete_terms($slug, $echo = false) { |
|
133 | 133 | |
134 | 134 | // Query for our terms |
135 | 135 | $args = array( |
@@ -143,15 +143,15 @@ discard block |
||
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 |
||
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 |