@@ -10,11 +10,11 @@ discard block |
||
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 |
||
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 |
||
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 |
@@ -133,14 +133,14 @@ |
||
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 ); |
@@ -12,7 +12,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -13,7 +13,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -10,7 +10,7 @@ discard block |
||
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 |
||
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 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @subpackage Test Content |
11 | 11 | * @author Old Town Media |
12 | 12 | */ |
13 | -abstract class View{ |
|
13 | +abstract class View { |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * title |
@@ -44,10 +44,10 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @see tab, view |
46 | 46 | */ |
47 | - public function register_view(){ |
|
47 | + public function register_view() { |
|
48 | 48 | |
49 | - add_action( 'tc-admin-tabs', array( $this, 'tab' ), $this->priority ); |
|
50 | - add_action( 'tc-admin-sections', array( $this, 'view' ), $this->priority ); |
|
49 | + add_action('tc-admin-tabs', array($this, 'tab'), $this->priority); |
|
50 | + add_action('tc-admin-sections', array($this, 'view'), $this->priority); |
|
51 | 51 | |
52 | 52 | } |
53 | 53 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * Each view has a tab and tab navigation - this function compiles our |
59 | 59 | * navigation tab. Rarely extended. |
60 | 60 | */ |
61 | - public function tab(){ |
|
61 | + public function tab() { |
|
62 | 62 | $html = ""; |
63 | 63 | |
64 | 64 | $html .= "<a class='nav-tab' href='javascript:void(0)'>"; |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @see actions_section, options_section |
80 | 80 | */ |
81 | - public function view(){ |
|
81 | + public function view() { |
|
82 | 82 | $html = ''; |
83 | 83 | |
84 | 84 | $html .= "<section class='test-content-tab'>"; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @return string HTML content. |
100 | 100 | */ |
101 | - protected function actions_section(){ |
|
101 | + protected function actions_section() { |
|
102 | 102 | $html = ''; |
103 | 103 | return $html; |
104 | 104 | } |
@@ -115,11 +115,11 @@ discard block |
||
115 | 115 | * @param string $html Existing HTML content. |
116 | 116 | * @return string HTML section content. |
117 | 117 | */ |
118 | - protected function options_section( $html = '' ){ |
|
118 | + protected function options_section($html = '') { |
|
119 | 119 | $html .= "<div class='test-data-cpt'>"; |
120 | 120 | $html .= "<h3>"; |
121 | - $html .= "<span class='label'>".__( 'Quantity', 'otm-test-content' )."</span>"; |
|
122 | - $html .= "<input type='number' value='0' class='quantity-adjustment' for='".$this->type."' placeholder='".__( '', 'otm-test-content' )."'> "; |
|
121 | + $html .= "<span class='label'>".__('Quantity', 'otm-test-content')."</span>"; |
|
122 | + $html .= "<input type='number' value='0' class='quantity-adjustment' for='".$this->type."' placeholder='".__('', 'otm-test-content')."'> "; |
|
123 | 123 | $html .= "</h3>"; |
124 | 124 | $html .= "</div>"; |
125 | 125 | |
@@ -137,22 +137,22 @@ discard block |
||
137 | 137 | * @param string $text Text to display in the button. |
138 | 138 | * @return string HTML. |
139 | 139 | */ |
140 | - protected function build_button( $action, $slug, $text ){ |
|
140 | + protected function build_button($action, $slug, $text) { |
|
141 | 141 | $html = $dashicon = ''; |
142 | 142 | |
143 | - if ( $action == 'create' ){ |
|
143 | + if ($action == 'create') { |
|
144 | 144 | $dashicon = 'dashicons-plus'; |
145 | - } elseif ( $action == 'delete' ){ |
|
145 | + } elseif ($action == 'delete') { |
|
146 | 146 | $dashicon = 'dashicons-trash'; |
147 | 147 | } |
148 | 148 | |
149 | 149 | $html .= "<a href='javascript:void(0);' "; |
150 | - $html .= " data-type='" . $this->type . "'"; |
|
151 | - $html .= " data-slug='" . $slug . "'"; |
|
152 | - $html .= " data-todo='" . $action . "'"; |
|
150 | + $html .= " data-type='".$this->type."'"; |
|
151 | + $html .= " data-slug='".$slug."'"; |
|
152 | + $html .= " data-todo='".$action."'"; |
|
153 | 153 | $html .= " class='button-primary handle-test-data'"; |
154 | 154 | $html .= "/>"; |
155 | - $html .= "<span class='dashicons " . $dashicon . "'></span>"; |
|
155 | + $html .= "<span class='dashicons ".$dashicon."'></span>"; |
|
156 | 156 | $html .= $text; |
157 | 157 | $html .= "</a>"; |
158 | 158 |