@@ -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 ); |
@@ -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 |
@@ -89,8 +89,8 @@ |
||
89 | 89 | } else { |
90 | 90 | // We didn't get a reponse so print the notice out |
91 | 91 | echo '<div class="notice notice-error is-dismissible">'; |
92 | - echo '<p>'.__( 'WordPress could not connect to Splashbase and therefore images will not pull into metaboxes/thumbnails. Turn Airplane Mode off or reconnect to the Internet to get images when creating test data.', 'otm-test-content' ).'</p>'; |
|
93 | - echo '</div>'; |
|
92 | + echo '<p>'.__( 'WordPress could not connect to Splashbase and therefore images will not pull into metaboxes/thumbnails. Turn Airplane Mode off or reconnect to the Internet to get images when creating test data.', 'otm-test-content' ).'</p>'; |
|
93 | + echo '</div>'; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | } |
@@ -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 | * plugin |
@@ -45,16 +45,16 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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,17 +192,17 @@ discard block |
||
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 | - if ( $data['type'] == 'post' ){ |
|
197 | + if ($data['type'] == 'post') { |
|
198 | 198 | |
199 | 199 | $create_content = new CreatePost; |
200 | - $create_content->create_post_type_content( $data['slug'], $data['connection'], true, 1 ); |
|
200 | + $create_content->create_post_type_content($data['slug'], $data['connection'], true, 1); |
|
201 | 201 | |
202 | - } elseif( $data['type'] == 'term' ){ |
|
202 | + } elseif ($data['type'] == 'term') { |
|
203 | 203 | |
204 | 204 | $create_content = new CreateTerm; |
205 | - $create_content->create_terms( $data['slug'], true, 1 ); |
|
205 | + $create_content->create_terms($data['slug'], true, 1); |
|
206 | 206 | |
207 | 207 | } |
208 | 208 | |
@@ -213,17 +213,17 @@ discard block |
||
213 | 213 | * Choose which type of deletion needs to be accomplished and route through |
214 | 214 | * the correct method of Delete. |
215 | 215 | */ |
216 | - private function deletion_routing( $data ){ |
|
216 | + private function deletion_routing($data) { |
|
217 | 217 | |
218 | 218 | $delete_content = new Delete; |
219 | 219 | |
220 | - if ( $data['type'] == 'post' ){ |
|
220 | + if ($data['type'] == 'post') { |
|
221 | 221 | |
222 | - $delete_content->delete_posts( $data['slug'], true ); |
|
222 | + $delete_content->delete_posts($data['slug'], true); |
|
223 | 223 | |
224 | - } elseif ( $data['type'] == 'term' ){ |
|
224 | + } elseif ($data['type'] == 'term') { |
|
225 | 225 | |
226 | - $delete_content->delete_terms( $data['slug'], true ); |
|
226 | + $delete_content->delete_terms($data['slug'], true); |
|
227 | 227 | |
228 | 228 | } |
229 | 229 | |
@@ -233,36 +233,36 @@ discard block |
||
233 | 233 | /** |
234 | 234 | * Print out our admin page to control test data. |
235 | 235 | */ |
236 | - public function admin_page(){ |
|
236 | + public function admin_page() { |
|
237 | 237 | |
238 | 238 | $html = ""; |
239 | 239 | |
240 | - $html .= '<div class="wrap" id="options_editor">' . "\n"; |
|
240 | + $html .= '<div class="wrap" id="options_editor">'."\n"; |
|
241 | 241 | |
242 | - $html .= '<h2>' . __( 'Create Test Data' , 'otm-test-content' ) . '</h2>' . "\n"; |
|
242 | + $html .= '<h2>'.__('Create Test Data', 'otm-test-content').'</h2>'."\n"; |
|
243 | 243 | |
244 | 244 | $html .= "<div>"; |
245 | 245 | |
246 | 246 | $html .= "<div class='test-data-cpt'>"; |
247 | 247 | $html .= "<h3>"; |
248 | - $html .= "<span class='label'>".__( 'Quantity', 'otm-test-content' )."</span>"; |
|
249 | - $html .= "<input type='number' value='0' id='quantity-adjustment'> <small><i>".__( 'Set to 0 to keep random', 'otm-test-content' )."</i></small>"; |
|
248 | + $html .= "<span class='label'>".__('Quantity', 'otm-test-content')."</span>"; |
|
249 | + $html .= "<input type='number' value='0' id='quantity-adjustment'> <small><i>".__('Set to 0 to keep random', 'otm-test-content')."</i></small>"; |
|
250 | 250 | $html .= "</h3>"; |
251 | 251 | $html .= "</div>"; |
252 | 252 | |
253 | 253 | $html .= "<input type='hidden' id='connection-status' value='".$this->connected."'>"; |
254 | 254 | |
255 | 255 | // Loop through every post type available on the site |
256 | - $post_types = get_post_types( array( 'public' => true ), 'objects' ); |
|
256 | + $post_types = get_post_types(array('public' => true), 'objects'); |
|
257 | 257 | |
258 | - foreach ( $post_types as $post_type ) { |
|
258 | + foreach ($post_types as $post_type) { |
|
259 | 259 | |
260 | 260 | $skipped_cpts = array( |
261 | 261 | 'attachment' |
262 | 262 | ); |
263 | 263 | |
264 | 264 | // Skip banned cpts |
265 | - if ( in_array( $post_type->name, $skipped_cpts ) ){ |
|
265 | + if (in_array($post_type->name, $skipped_cpts)) { |
|
266 | 266 | continue; |
267 | 267 | } |
268 | 268 | |
@@ -271,38 +271,38 @@ discard block |
||
271 | 271 | // Create row for the post/page/cpt |
272 | 272 | $html .= "<h3>"; |
273 | 273 | |
274 | - $html .= "<span class='label'>" . $post_type->labels->name . "</span>"; |
|
275 | - $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>"; |
|
276 | - $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>"; |
|
274 | + $html .= "<span class='label'>".$post_type->labels->name."</span>"; |
|
275 | + $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>"; |
|
276 | + $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>"; |
|
277 | 277 | |
278 | 278 | $html .= "</h3>"; |
279 | 279 | |
280 | 280 | // Create row for each taxonomy associated with the post/page/cpt |
281 | - $taxonomies = get_object_taxonomies( $post_type->name ); |
|
281 | + $taxonomies = get_object_taxonomies($post_type->name); |
|
282 | 282 | |
283 | - if ( !empty( $taxonomies ) ){ |
|
283 | + if (!empty($taxonomies)) { |
|
284 | 284 | |
285 | - foreach( $taxonomies as $tax ){ |
|
285 | + foreach ($taxonomies as $tax) { |
|
286 | 286 | |
287 | 287 | $html .= "<h3 class='term-box'>"; |
288 | 288 | |
289 | 289 | $skipped_taxonomies = array( |
290 | - 'post_format', // We shouldn't be making random post format classes |
|
290 | + 'post_format', // We shouldn't be making random post format classes |
|
291 | 291 | 'product_shipping_class' // These aren't used visually and are therefore skipped |
292 | 292 | ); |
293 | 293 | |
294 | 294 | // Skip banned taxonomies |
295 | - if ( in_array( $tax, $skipped_taxonomies ) ){ |
|
295 | + if (in_array($tax, $skipped_taxonomies)) { |
|
296 | 296 | continue; |
297 | 297 | } |
298 | 298 | |
299 | - $taxonomy = get_taxonomy( $tax ); |
|
299 | + $taxonomy = get_taxonomy($tax); |
|
300 | 300 | |
301 | 301 | $html .= "<span class='label'>".$taxonomy->labels->name."</span>"; |
302 | 302 | |
303 | - $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>"; |
|
303 | + $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>"; |
|
304 | 304 | |
305 | - $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>"; |
|
305 | + $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>"; |
|
306 | 306 | |
307 | 307 | $html .= "</h3>"; |
308 | 308 |
@@ -417,29 +417,29 @@ discard block |
||
417 | 417 | } |
418 | 418 | |
419 | 419 | // Download the file |
420 | - $tmp = \download_url( $url ); |
|
420 | + $tmp = \download_url( $url ); |
|
421 | 421 | |
422 | - preg_match( '/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches ); |
|
422 | + preg_match( '/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches ); |
|
423 | 423 | |
424 | - $file_array['name'] = basename( $matches[0] ); |
|
425 | - $file_array['tmp_name'] = $tmp; |
|
424 | + $file_array['name'] = basename( $matches[0] ); |
|
425 | + $file_array['tmp_name'] = $tmp; |
|
426 | 426 | |
427 | - // Check for download errors |
|
428 | - if ( is_wp_error( $tmp ) ) { |
|
429 | - unlink( $file_array[ 'tmp_name' ] ); |
|
430 | - error_log( $tmp->get_error_message() ); |
|
431 | - } |
|
427 | + // Check for download errors |
|
428 | + if ( is_wp_error( $tmp ) ) { |
|
429 | + unlink( $file_array[ 'tmp_name' ] ); |
|
430 | + error_log( $tmp->get_error_message() ); |
|
431 | + } |
|
432 | 432 | |
433 | 433 | // Pull the image into the media library |
434 | - $image_id = media_handle_sideload( $file_array, $post_id ); |
|
434 | + $image_id = media_handle_sideload( $file_array, $post_id ); |
|
435 | 435 | |
436 | - // Check for handle sideload errors. |
|
437 | - if ( is_wp_error( $image_id ) ) { |
|
438 | - unlink( $file_array['tmp_name'] ); |
|
439 | - error_log( $image_id->get_error_message() ); |
|
440 | - } |
|
436 | + // Check for handle sideload errors. |
|
437 | + if ( is_wp_error( $image_id ) ) { |
|
438 | + unlink( $file_array['tmp_name'] ); |
|
439 | + error_log( $image_id->get_error_message() ); |
|
440 | + } |
|
441 | 441 | |
442 | - return $image_id; |
|
442 | + return $image_id; |
|
443 | 443 | |
444 | 444 | } |
445 | 445 | |
@@ -462,9 +462,9 @@ discard block |
||
462 | 462 | |
463 | 463 | // If our cURL failed |
464 | 464 | if ( $curl_response === false ) { |
465 | - $info = curl_getinfo( $curl ); |
|
466 | - curl_close( $curl ); |
|
467 | - die( 'error occured during curl exec. Additional info: ' . var_export( $info ) ); |
|
465 | + $info = curl_getinfo( $curl ); |
|
466 | + curl_close( $curl ); |
|
467 | + die( 'error occured during curl exec. Additional info: ' . var_export( $info ) ); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | curl_close( $curl ); |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * @subpackage Evans |
15 | 15 | * @author Old Town Media |
16 | 16 | */ |
17 | -class TestContent{ |
|
17 | +class TestContent { |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Title function. |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @param int $num_words Number of words to return. |
27 | 27 | * @return string Random title string. |
28 | 28 | */ |
29 | - public static function title( $num_words = '' ){ |
|
29 | + public static function title($num_words = '') { |
|
30 | 30 | |
31 | 31 | $title = ''; |
32 | 32 | |
@@ -67,16 +67,16 @@ discard block |
||
67 | 67 | ); |
68 | 68 | |
69 | 69 | // If we didn't choose a count, make one |
70 | - if ( empty( $num_words ) ){ |
|
71 | - $num_words = rand( 2, 10 ); |
|
70 | + if (empty($num_words)) { |
|
71 | + $num_words = rand(2, 10); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | // Pull random words |
75 | - for( $i = 1; $i <= $num_words; $i++ ){ |
|
76 | - $title .= $random_words[ rand( 0, 31 ) ] . " "; |
|
75 | + for ($i = 1; $i <= $num_words; $i++) { |
|
76 | + $title .= $random_words[rand(0, 31)]." "; |
|
77 | 77 | } |
78 | 78 | |
79 | - return substr( $title, 0, -1 ); |
|
79 | + return substr($title, 0, -1); |
|
80 | 80 | |
81 | 81 | } |
82 | 82 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @return string Paragraph(s) of text. |
91 | 91 | */ |
92 | - public static function paragraphs(){ |
|
92 | + public static function paragraphs() { |
|
93 | 93 | |
94 | 94 | $content = ''; |
95 | 95 | |
@@ -350,8 +350,8 @@ discard block |
||
350 | 350 | |
351 | 351 | ); |
352 | 352 | |
353 | - for( $i = 1; $i < 6; $i++ ){ |
|
354 | - $content .= $random_content_types[rand( 0, 12 )]; |
|
353 | + for ($i = 1; $i < 6; $i++) { |
|
354 | + $content .= $random_content_types[rand(0, 12)]; |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | return $content; |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | * |
367 | 367 | * @return string Plain text paragraphs. |
368 | 368 | */ |
369 | - public static function plain_text(){ |
|
369 | + public static function plain_text() { |
|
370 | 370 | |
371 | 371 | $paragraphs = array( |
372 | 372 | 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean tincidunt luctus eros, a tincidunt massa aliquet sit amet. Sed faucibus, eros non lacinia porttitor, risus odio efficitur sapien, id porta urna massa ac est. Cras efficitur lacinia magna eget tempus. Fusce ex felis, finibus consectetur mi at, finibus rhoncus augue. In ut tortor lacinia, rutrum mauris vel, maximus tortor. Praesent ac arcu nec eros pharetra tristique. Morbi congue leo sed ipsum fermentum vulputate. Ut nulla eros, porta varius pulvinar eget, bibendum quis dolor. Morbi sed diam eu dui semper ornare nec quis nisl.', |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | 'Fusce semper erat tortor, at pulvinar risus luctus suscipit. Phasellus quis enim nisl. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Maecenas semper dapibus odio, nec pellentesque sem laoreet sit amet. Maecenas ut enim tellus. Fusce malesuada mattis sem, porta interdum ex fermentum quis. Ut eget quam mi. In molestie volutpat feugiat. Nulla vel viverra nunc. Integer lobortis nisl vitae placerat egestas. Curabitur tristique nulla at libero blandit, a eleifend augue tempus.', |
382 | 382 | ); |
383 | 383 | |
384 | - return $paragraphs[ rand( 0, 9 ) ]; |
|
384 | + return $paragraphs[rand(0, 9)]; |
|
385 | 385 | |
386 | 386 | } |
387 | 387 | |
@@ -397,46 +397,46 @@ discard block |
||
397 | 397 | * @param int $post_id Post ID. |
398 | 398 | * @return mixed Attachment ID or WP Error. |
399 | 399 | */ |
400 | - public static function image( $post_id ){ |
|
400 | + public static function image($post_id) { |
|
401 | 401 | $file_array = array(); |
402 | 402 | |
403 | 403 | // Get the image from the API |
404 | 404 | $url = self::get_image_link(); |
405 | 405 | |
406 | 406 | // If the returned string is empty or it's not a string, try again. |
407 | - if ( empty( $url ) || !is_string( $url ) ){ |
|
407 | + if (empty($url) || !is_string($url)) { |
|
408 | 408 | |
409 | 409 | // Try again |
410 | 410 | $url = self::get_image_link(); |
411 | 411 | |
412 | 412 | // If it fails again, just give up |
413 | - if ( empty( $url ) || !is_string( $url ) ){ |
|
413 | + if (empty($url) || !is_string($url)) { |
|
414 | 414 | return; |
415 | 415 | } |
416 | 416 | |
417 | 417 | } |
418 | 418 | |
419 | 419 | // Download the file |
420 | - $tmp = \download_url( $url ); |
|
420 | + $tmp = \download_url($url); |
|
421 | 421 | |
422 | - preg_match( '/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches ); |
|
422 | + preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches); |
|
423 | 423 | |
424 | - $file_array['name'] = basename( $matches[0] ); |
|
424 | + $file_array['name'] = basename($matches[0]); |
|
425 | 425 | $file_array['tmp_name'] = $tmp; |
426 | 426 | |
427 | 427 | // Check for download errors |
428 | - if ( is_wp_error( $tmp ) ) { |
|
429 | - unlink( $file_array[ 'tmp_name' ] ); |
|
430 | - error_log( $tmp->get_error_message() ); |
|
428 | + if (is_wp_error($tmp)) { |
|
429 | + unlink($file_array['tmp_name']); |
|
430 | + error_log($tmp->get_error_message()); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | // Pull the image into the media library |
434 | - $image_id = media_handle_sideload( $file_array, $post_id ); |
|
434 | + $image_id = media_handle_sideload($file_array, $post_id); |
|
435 | 435 | |
436 | 436 | // Check for handle sideload errors. |
437 | - if ( is_wp_error( $image_id ) ) { |
|
438 | - unlink( $file_array['tmp_name'] ); |
|
439 | - error_log( $image_id->get_error_message() ); |
|
437 | + if (is_wp_error($image_id)) { |
|
438 | + unlink($file_array['tmp_name']); |
|
439 | + error_log($image_id->get_error_message()); |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | return $image_id; |
@@ -451,31 +451,31 @@ discard block |
||
451 | 451 | * |
452 | 452 | * @return string Image URL. |
453 | 453 | */ |
454 | - private static function get_image_link(){ |
|
454 | + private static function get_image_link() { |
|
455 | 455 | |
456 | 456 | // cURL an image API for a completely random photo |
457 | - $curl = curl_init( "http://www.splashbase.co/api/v1/images/random?images_only=true" ); |
|
457 | + $curl = curl_init("http://www.splashbase.co/api/v1/images/random?images_only=true"); |
|
458 | 458 | |
459 | - curl_setopt( $curl, CURLOPT_RETURNTRANSFER, TRUE ); |
|
459 | + curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); |
|
460 | 460 | |
461 | - $curl_response = curl_exec( $curl ); |
|
461 | + $curl_response = curl_exec($curl); |
|
462 | 462 | |
463 | 463 | // If our cURL failed |
464 | - if ( $curl_response === false ) { |
|
465 | - $info = curl_getinfo( $curl ); |
|
466 | - curl_close( $curl ); |
|
467 | - die( 'error occured during curl exec. Additional info: ' . var_export( $info ) ); |
|
464 | + if ($curl_response === false) { |
|
465 | + $info = curl_getinfo($curl); |
|
466 | + curl_close($curl); |
|
467 | + die('error occured during curl exec. Additional info: '.var_export($info)); |
|
468 | 468 | } |
469 | 469 | |
470 | - curl_close( $curl ); |
|
470 | + curl_close($curl); |
|
471 | 471 | |
472 | 472 | // Decode the data |
473 | - $response = json_decode( $curl_response, true ); |
|
473 | + $response = json_decode($curl_response, true); |
|
474 | 474 | |
475 | 475 | // Check to make sure that the return contains a valid image extensions |
476 | 476 | preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $response['url'], $matches); |
477 | 477 | |
478 | - if ( !empty( $matches ) ){ |
|
478 | + if (!empty($matches)) { |
|
479 | 479 | return $response['url']; |
480 | 480 | } |
481 | 481 | |
@@ -490,10 +490,10 @@ discard block |
||
490 | 490 | * @param string $format PHP Date format. |
491 | 491 | * @return mixed Date in the format requested. |
492 | 492 | */ |
493 | - public static function date( $format ){ |
|
493 | + public static function date($format) { |
|
494 | 494 | |
495 | - $num_days = rand( 1, 60 ); |
|
496 | - return date( $format, strtotime( " +$num_days days" ) ); |
|
495 | + $num_days = rand(1, 60); |
|
496 | + return date($format, strtotime(" +$num_days days")); |
|
497 | 497 | |
498 | 498 | } |
499 | 499 | |
@@ -505,19 +505,19 @@ discard block |
||
505 | 505 | * |
506 | 506 | * @return string Time string |
507 | 507 | */ |
508 | - public static function time(){ |
|
508 | + public static function time() { |
|
509 | 509 | |
510 | 510 | $times = array( |
511 | 511 | '8:00 am', |
512 | 512 | '5:00PM', |
513 | 513 | '13:00', |
514 | 514 | '2015', |
515 | - date( 'G:i', strtotime( " +".rand( 4, 24 )." hours" ) ), |
|
516 | - date( 'g:i', strtotime( " +".rand( 4, 24 )." hours" ) ), |
|
517 | - date( 'G:i A', strtotime( " +".rand( 4, 24 )." hours" ) ) |
|
515 | + date('G:i', strtotime(" +".rand(4, 24)." hours")), |
|
516 | + date('g:i', strtotime(" +".rand(4, 24)." hours")), |
|
517 | + date('G:i A', strtotime(" +".rand(4, 24)." hours")) |
|
518 | 518 | ); |
519 | 519 | |
520 | - return $times[ rand( 0, 6 ) ]; |
|
520 | + return $times[rand(0, 6)]; |
|
521 | 521 | |
522 | 522 | } |
523 | 523 | |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | * |
530 | 530 | * @return string Timezone |
531 | 531 | */ |
532 | - public static function timezone(){ |
|
532 | + public static function timezone() { |
|
533 | 533 | |
534 | 534 | $timezones = array( |
535 | 535 | 'America/Denver', |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | 'UTC' |
548 | 548 | ); |
549 | 549 | |
550 | - return $timezones[ rand( 0, 12 ) ]; |
|
550 | + return $timezones[rand(0, 12)]; |
|
551 | 551 | |
552 | 552 | } |
553 | 553 | |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | * |
561 | 561 | * @return string Phone #. |
562 | 562 | */ |
563 | - public static function phone(){ |
|
563 | + public static function phone() { |
|
564 | 564 | |
565 | 565 | $phone_numbers = array( |
566 | 566 | '7203893101', |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | '+43 780 0047112' |
577 | 577 | ); |
578 | 578 | |
579 | - return $phone_numbers[ rand( 0, 10 ) ]; |
|
579 | + return $phone_numbers[rand(0, 10)]; |
|
580 | 580 | |
581 | 581 | } |
582 | 582 | |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | * |
589 | 589 | * @return string Email address. |
590 | 590 | */ |
591 | - public static function email(){ |
|
591 | + public static function email() { |
|
592 | 592 | |
593 | 593 | $email_addresses = array( |
594 | 594 | '[email protected]', |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | '[email protected]' |
602 | 602 | ); |
603 | 603 | |
604 | - return $email_addresses[ rand( 0, 7 ) ]; |
|
604 | + return $email_addresses[rand(0, 7)]; |
|
605 | 605 | |
606 | 606 | } |
607 | 607 | |
@@ -615,12 +615,12 @@ discard block |
||
615 | 615 | * |
616 | 616 | * @return string URL. |
617 | 617 | */ |
618 | - public static function link(){ |
|
618 | + public static function link() { |
|
619 | 619 | |
620 | 620 | $links = array( |
621 | 621 | 'http://google.com', |
622 | 622 | 'https://www.twitter.com', |
623 | - site_url( '/?iam=anextravariable' ), |
|
623 | + site_url('/?iam=anextravariable'), |
|
624 | 624 | 'github.com', |
625 | 625 | 'http://filebase.com', |
626 | 626 | 'www.oldtownmediainc.com', |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | 'https://www.eff.org' |
629 | 629 | ); |
630 | 630 | |
631 | - return $links[ rand( 0, 7 ) ]; |
|
631 | + return $links[rand(0, 7)]; |
|
632 | 632 | |
633 | 633 | } |
634 | 634 | |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | * |
640 | 640 | * @return string URL. |
641 | 641 | */ |
642 | - public static function oembed(){ |
|
642 | + public static function oembed() { |
|
643 | 643 | |
644 | 644 | $links = array( |
645 | 645 | 'https://www.youtube.com/watch?v=A85-YQsm6pY', |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | 'https://www.instagram.com/p/-eyLo0RMfX', |
651 | 651 | ); |
652 | 652 | |
653 | - return $links[ rand( 0, 5 ) ]; |
|
653 | + return $links[rand(0, 5)]; |
|
654 | 654 | |
655 | 655 | } |
656 | 656 | |
@@ -664,10 +664,10 @@ discard block |
||
664 | 664 | * @param string $type Video service to get link from |
665 | 665 | * @return string URL. |
666 | 666 | */ |
667 | - public static function video( $type ){ |
|
667 | + public static function video($type) { |
|
668 | 668 | |
669 | 669 | // Switch through our video types. Expecting to add more in the future |
670 | - switch( $type ){ |
|
670 | + switch ($type) { |
|
671 | 671 | |
672 | 672 | // YouTube videos |
673 | 673 | case 'youtube' : |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | |
709 | 709 | } |
710 | 710 | |
711 | - return $links[ rand( 0, 8 ) ]; |
|
711 | + return $links[rand(0, 8)]; |
|
712 | 712 | |
713 | 713 | } |
714 | 714 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage Evans |
9 | 9 | * @author Old Town Media |
10 | 10 | */ |
11 | -class CreateTerm{ |
|
11 | +class CreateTerm { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Create test data posts. |
@@ -25,25 +25,25 @@ discard block |
||
25 | 25 | * @param boolean $echo Whether or not to echo. Optional. |
26 | 26 | * @param int $num Optional. Number of posts to create. |
27 | 27 | */ |
28 | - public function create_terms( $slug, $echo = false, $num = '' ){ |
|
28 | + public function create_terms($slug, $echo = false, $num = '') { |
|
29 | 29 | |
30 | 30 | // If we're missing a custom post type id - don't do anything |
31 | - if ( empty( $slug ) ){ |
|
31 | + if (empty($slug)) { |
|
32 | 32 | return; |
33 | 33 | } |
34 | 34 | |
35 | 35 | // If we forgot to put in a quantity, make one for us |
36 | - if ( empty( $num ) ){ |
|
37 | - $num = rand( 5, 30 ); |
|
36 | + if (empty($num)) { |
|
37 | + $num = rand(5, 30); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | // Create test terms |
41 | - for( $i = 0; $i < $num; $i++ ){ |
|
41 | + for ($i = 0; $i < $num; $i++) { |
|
42 | 42 | |
43 | - $return = $this->create_test_object( $slug ); |
|
43 | + $return = $this->create_test_object($slug); |
|
44 | 44 | |
45 | - if ( $echo === true ){ |
|
46 | - echo \json_encode( $return ); |
|
45 | + if ($echo === true) { |
|
46 | + echo \json_encode($return); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @param string $slug a custom post type ID. |
66 | 66 | */ |
67 | - private function create_test_object( $slug ){ |
|
67 | + private function create_test_object($slug) { |
|
68 | 68 | |
69 | 69 | // Get a random title |
70 | 70 | $title = TestContent::title(); |
@@ -74,16 +74,16 @@ discard block |
||
74 | 74 | $slug, |
75 | 75 | array( |
76 | 76 | 'description'=> TestContent::title(), |
77 | - 'slug' => sanitize_title( $title ), |
|
77 | + 'slug' => sanitize_title($title), |
|
78 | 78 | ) |
79 | 79 | ); |
80 | 80 | |
81 | 81 | // Then, set a test content flag on the new post for later deletion |
82 | - add_term_meta( $return['term_id'], 'evans_test_content', '__test__', true ); |
|
82 | + add_term_meta($return['term_id'], 'evans_test_content', '__test__', true); |
|
83 | 83 | |
84 | 84 | // Check if we have errors and return them or created message |
85 | - if ( is_wp_error( $return ) ){ |
|
86 | - error_log( $return->get_error_message() ); |
|
85 | + if (is_wp_error($return)) { |
|
86 | + error_log($return->get_error_message()); |
|
87 | 87 | return $return; |
88 | 88 | } else { |
89 | 89 | return array( |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | 'object' => 'term', |
92 | 92 | 'tid' => $return['term_id'], |
93 | 93 | 'taxonomy' => $slug, |
94 | - 'link_edit' => admin_url( '/edit-tags.php?action=edit&taxonomy='.$slug.'&tag_ID='.$return['term_id'] ), |
|
95 | - 'link_view' => get_term_link( $return['term_id'] ) |
|
94 | + 'link_edit' => admin_url('/edit-tags.php?action=edit&taxonomy='.$slug.'&tag_ID='.$return['term_id']), |
|
95 | + 'link_view' => get_term_link($return['term_id']) |
|
96 | 96 | ); |
97 | 97 | } |
98 | 98 |
@@ -65,7 +65,7 @@ |
||
65 | 65 | * @see load_plugin_textdomain |
66 | 66 | */ |
67 | 67 | public function load_textdomain() { |
68 | - load_plugin_textdomain( 'otm-test-content', FALSE, basename( dirname( $this->definitions->file ) ) . '/languages/' ); |
|
68 | + load_plugin_textdomain( 'otm-test-content', FALSE, basename( dirname( $this->definitions->file ) ) . '/languages/' ); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage Evans |
9 | 9 | * @author Old Town Media |
10 | 10 | */ |
11 | -class Plugin{ |
|
11 | +class Plugin { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Plugin definitions. |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param object $definitions Information about the plugin |
35 | 35 | * @return object $this |
36 | 36 | */ |
37 | - public function set_definitions( $definitions ) { |
|
37 | + public function set_definitions($definitions) { |
|
38 | 38 | |
39 | 39 | $this->definitions = $definitions; |
40 | 40 | return $this; |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | * @param object $provider Hook provider. |
49 | 49 | * @return object $this |
50 | 50 | */ |
51 | - public function register_hooks( $provider ) { |
|
51 | + public function register_hooks($provider) { |
|
52 | 52 | |
53 | - if ( method_exists( $provider, 'set_plugin' ) ) { |
|
54 | - $provider->set_plugin( $this ); |
|
53 | + if (method_exists($provider, 'set_plugin')) { |
|
54 | + $provider->set_plugin($this); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | $provider->hooks(); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @see load_plugin_textdomain |
66 | 66 | */ |
67 | 67 | public function load_textdomain() { |
68 | - load_plugin_textdomain( 'otm-test-content', FALSE, basename( dirname( $this->definitions->file ) ) . '/languages/' ); |
|
68 | + load_plugin_textdomain('otm-test-content', FALSE, basename(dirname($this->definitions->file)).'/languages/'); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage Evans |
9 | 9 | * @author Old Town Media |
10 | 10 | */ |
11 | -class CreatePost{ |
|
11 | +class CreatePost { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * metaboxes |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @see Metaboxes |
27 | 27 | */ |
28 | - public function __construct(){ |
|
28 | + public function __construct() { |
|
29 | 29 | |
30 | 30 | $this->metaboxes = new Metaboxes; |
31 | 31 | |
@@ -47,32 +47,32 @@ discard block |
||
47 | 47 | * @param boolean $echo Whether or not to echo. Optional. |
48 | 48 | * @param int $num Optional. Number of posts to create. |
49 | 49 | */ |
50 | - public function create_post_type_content( $slug, $connection, $echo = false, $num = '' ){ |
|
50 | + public function create_post_type_content($slug, $connection, $echo = false, $num = '') { |
|
51 | 51 | |
52 | 52 | // If we're missing a custom post type id - don't do anything |
53 | - if ( empty( $slug ) ){ |
|
53 | + if (empty($slug)) { |
|
54 | 54 | return; |
55 | 55 | } |
56 | 56 | |
57 | 57 | // Gather the necessary data to create the posts |
58 | - $supports = $this->get_cpt_supports( $slug ); |
|
59 | - $metaboxes = $this->metaboxes->get_metaboxes( $slug ); |
|
58 | + $supports = $this->get_cpt_supports($slug); |
|
59 | + $metaboxes = $this->metaboxes->get_metaboxes($slug); |
|
60 | 60 | |
61 | 61 | // Set our connection status for the rest of the methods |
62 | 62 | $this->connected = $connection; |
63 | 63 | |
64 | 64 | // If we forgot to put in a quantity, make one for us |
65 | - if ( empty( $num ) ){ |
|
66 | - $num = rand( 5, 30 ); |
|
65 | + if (empty($num)) { |
|
66 | + $num = rand(5, 30); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | // Create test posts |
70 | - for( $i = 0; $i < $num; $i++ ){ |
|
70 | + for ($i = 0; $i < $num; $i++) { |
|
71 | 71 | |
72 | - $return = $this->create_test_object( $slug, $supports, $metaboxes ); |
|
72 | + $return = $this->create_test_object($slug, $supports, $metaboxes); |
|
73 | 73 | |
74 | - if ( $echo === true ){ |
|
75 | - echo \json_encode( $return ); |
|
74 | + if ($echo === true) { |
|
75 | + echo \json_encode($return); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @param array $supports Features that the post type supports. |
96 | 96 | * @param array $supports All CMB2 metaboxes attached to the post type. |
97 | 97 | */ |
98 | - private function create_test_object( $slug, $supports, $metaboxes ){ |
|
98 | + private function create_test_object($slug, $supports, $metaboxes) { |
|
99 | 99 | $return = ''; |
100 | 100 | |
101 | 101 | // Get a random title |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | // First, insert our post |
105 | 105 | $post = array( |
106 | - 'post_name' => sanitize_title( $title ), |
|
106 | + 'post_name' => sanitize_title($title), |
|
107 | 107 | 'post_status' => 'publish', |
108 | 108 | 'post_type' => $slug, |
109 | 109 | 'ping_status' => 'closed', |
@@ -111,52 +111,52 @@ discard block |
||
111 | 111 | ); |
112 | 112 | |
113 | 113 | // Add title if supported |
114 | - if ( $supports['title'] === true ){ |
|
114 | + if ($supports['title'] === true) { |
|
115 | 115 | $post['post_title'] = $title; |
116 | 116 | } |
117 | 117 | |
118 | 118 | // Add main content if supported |
119 | - if ( $supports['editor'] === true ){ |
|
119 | + if ($supports['editor'] === true) { |
|
120 | 120 | $post['post_content'] = TestContent::paragraphs(); |
121 | 121 | } |
122 | 122 | |
123 | 123 | // Insert then post object |
124 | - $post_id = wp_insert_post( $post ); |
|
124 | + $post_id = wp_insert_post($post); |
|
125 | 125 | |
126 | 126 | // Then, set a test content flag on the new post for later deletion |
127 | - add_post_meta( $post_id, 'evans_test_content', '__test__', true ); |
|
127 | + add_post_meta($post_id, 'evans_test_content', '__test__', true); |
|
128 | 128 | |
129 | 129 | // Add thumbnail if supported |
130 | - if ( $this->connected == true && ( $supports['thumbnail'] === true || in_array( $slug, array( 'post', 'page' ) ) ) ){ |
|
131 | - update_post_meta( $post_id, '_thumbnail_id', TestContent::image( $post_id ) ); |
|
130 | + if ($this->connected == true && ($supports['thumbnail'] === true || in_array($slug, array('post', 'page')))) { |
|
131 | + update_post_meta($post_id, '_thumbnail_id', TestContent::image($post_id)); |
|
132 | 132 | } |
133 | 133 | |
134 | - $taxonomies = get_object_taxonomies( $slug ); |
|
134 | + $taxonomies = get_object_taxonomies($slug); |
|
135 | 135 | |
136 | 136 | // Assign the post to terms |
137 | - if ( !empty( $taxonomies ) ){ |
|
138 | - $return .= $this->assign_terms( $post_id, $taxonomies ); |
|
137 | + if (!empty($taxonomies)) { |
|
138 | + $return .= $this->assign_terms($post_id, $taxonomies); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | // Spin up metaboxes |
142 | - if ( !empty( $metaboxes ) ){ |
|
143 | - foreach ( $metaboxes as $cmb ) : |
|
144 | - $return .= $this->metaboxes->random_metabox_content( $post_id, $cmb, $this->connected ); |
|
142 | + if (!empty($metaboxes)) { |
|
143 | + foreach ($metaboxes as $cmb) : |
|
144 | + $return .= $this->metaboxes->random_metabox_content($post_id, $cmb, $this->connected); |
|
145 | 145 | endforeach; |
146 | 146 | } |
147 | 147 | |
148 | 148 | // Check if we have errors and return them or created message |
149 | - if ( is_wp_error( $return ) ){ |
|
150 | - error_log( $return->get_error_message() ); |
|
149 | + if (is_wp_error($return)) { |
|
150 | + error_log($return->get_error_message()); |
|
151 | 151 | return $return; |
152 | 152 | } else { |
153 | 153 | return array( |
154 | 154 | 'type' => 'created', |
155 | 155 | 'object' => 'post', |
156 | 156 | 'pid' => $post_id, |
157 | - 'post_type' => get_post_type( $post_id ), |
|
158 | - 'link_edit' => admin_url( '/post.php?post='.$post_id.'&action=edit' ), |
|
159 | - 'link_view' => get_permalink( $post_id ), |
|
157 | + 'post_type' => get_post_type($post_id), |
|
158 | + 'link_edit' => admin_url('/post.php?post='.$post_id.'&action=edit'), |
|
159 | + 'link_view' => get_permalink($post_id), |
|
160 | 160 | ); |
161 | 161 | } |
162 | 162 | |
@@ -173,12 +173,12 @@ discard block |
||
173 | 173 | * @param string $slug a custom post type ID. |
174 | 174 | * @return array Array of necessary supports booleans. |
175 | 175 | */ |
176 | - private function get_cpt_supports( $slug ){ |
|
176 | + private function get_cpt_supports($slug) { |
|
177 | 177 | |
178 | 178 | $supports = array( |
179 | - 'title' => post_type_supports( $slug, 'title' ), |
|
180 | - 'editor' => post_type_supports( $slug, 'editor' ), |
|
181 | - 'thumbnail' => post_type_supports( $slug, 'thumbnail' ) |
|
179 | + 'title' => post_type_supports($slug, 'title'), |
|
180 | + 'editor' => post_type_supports($slug, 'editor'), |
|
181 | + 'thumbnail' => post_type_supports($slug, 'thumbnail') |
|
182 | 182 | ); |
183 | 183 | |
184 | 184 | return $supports; |
@@ -199,26 +199,26 @@ discard block |
||
199 | 199 | * @param array $taxonomies taxonomies assigned to this cpt. |
200 | 200 | * @return object WP Error if there is one. |
201 | 201 | */ |
202 | - private function assign_terms( $post_id, $taxonomies ){ |
|
202 | + private function assign_terms($post_id, $taxonomies) { |
|
203 | 203 | |
204 | 204 | // Make sure it's an array & has items |
205 | - if ( empty( $taxonomies ) || !is_array( $taxonomies ) ){ |
|
205 | + if (empty($taxonomies) || !is_array($taxonomies)) { |
|
206 | 206 | return; |
207 | 207 | } |
208 | 208 | |
209 | - foreach ( $taxonomies as $tax ){ |
|
209 | + foreach ($taxonomies as $tax) { |
|
210 | 210 | |
211 | 211 | // Get the individual terms already existing |
212 | - $terms = get_terms( $tax, array( 'hide_empty' => false ) ); |
|
213 | - $count = count( $terms ) - 1; |
|
212 | + $terms = get_terms($tax, array('hide_empty' => false)); |
|
213 | + $count = count($terms) - 1; |
|
214 | 214 | |
215 | 215 | // If there are no terms, skip to the next taxonomy |
216 | - if ( empty( $terms ) ){ |
|
216 | + if (empty($terms)) { |
|
217 | 217 | continue; |
218 | 218 | } |
219 | 219 | |
220 | 220 | // Get a random index to use |
221 | - $index = rand( 0, $count ); |
|
221 | + $index = rand(0, $count); |
|
222 | 222 | |
223 | 223 | // Initialize our array |
224 | 224 | $post_data = array( |
@@ -226,14 +226,14 @@ discard block |
||
226 | 226 | ); |
227 | 227 | |
228 | 228 | // Set the term data to update |
229 | - $post_data['tax_input'][ $tax ] = array( $terms[$index]->term_id ); |
|
229 | + $post_data['tax_input'][$tax] = array($terms[$index]->term_id); |
|
230 | 230 | |
231 | 231 | // Update the post with the taxonomy info |
232 | - $return = wp_update_post( $post_data ); |
|
232 | + $return = wp_update_post($post_data); |
|
233 | 233 | |
234 | 234 | // Return the error if it exists |
235 | - if ( is_wp_error( $return ) ){ |
|
236 | - error_log( $return->get_error_messages() ); |
|
235 | + if (is_wp_error($return)) { |
|
236 | + error_log($return->get_error_messages()); |
|
237 | 237 | return $return->get_error_messages(); |
238 | 238 | } |
239 | 239 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage Evans |
9 | 9 | * @author Old Town Media |
10 | 10 | */ |
11 | -class Metaboxes{ |
|
11 | +class Metaboxes { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Decide which cmb library to try and loop to get our metaboxes. |
@@ -22,18 +22,18 @@ discard block |
||
22 | 22 | * @param string $slug Post Type slug ID. |
23 | 23 | * @return array Fields to fill in for our post object. |
24 | 24 | */ |
25 | - public function get_metaboxes( $slug ){ |
|
25 | + public function get_metaboxes($slug) { |
|
26 | 26 | |
27 | 27 | $fields = array(); |
28 | 28 | |
29 | 29 | // CMB2 |
30 | - if ( class_exists( 'CMB2', false ) ) { |
|
31 | - $fields = $this->get_cmb2_metaboxes( $slug ); |
|
30 | + if (class_exists('CMB2', false)) { |
|
31 | + $fields = $this->get_cmb2_metaboxes($slug); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | // Custom Metaboxes and Fields (CMB1) |
35 | - if ( class_exists( 'cmb_Meta_Box', false ) ) { |
|
36 | - $fields = $this->get_cmb1_metaboxes( $slug ); |
|
35 | + if (class_exists('cmb_Meta_Box', false)) { |
|
36 | + $fields = $this->get_cmb1_metaboxes($slug); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | // Return our array |
@@ -56,55 +56,55 @@ discard block |
||
56 | 56 | * @param string $slug a custom post type ID. |
57 | 57 | * @return array Array of fields. |
58 | 58 | */ |
59 | - private function get_cmb2_metaboxes( $slug ){ |
|
59 | + private function get_cmb2_metaboxes($slug) { |
|
60 | 60 | |
61 | 61 | $fields = array(); |
62 | 62 | |
63 | 63 | // Get all metaboxes from CMB2 library |
64 | - $all_metaboxes = apply_filters( 'cmb2_meta_boxes', array() ); |
|
64 | + $all_metaboxes = apply_filters('cmb2_meta_boxes', array()); |
|
65 | 65 | |
66 | 66 | // Loop through all possible sets of metaboxes added the old way |
67 | - foreach ( $all_metaboxes as $metabox_array ){ |
|
67 | + foreach ($all_metaboxes as $metabox_array) { |
|
68 | 68 | |
69 | 69 | // If the custom post type ID matches this set of fields, set & stop |
70 | - if ( in_array( $slug, $metabox_array['object_types'] ) ) { |
|
70 | + if (in_array($slug, $metabox_array['object_types'])) { |
|
71 | 71 | |
72 | 72 | // If this is the first group of fields, simply set the value |
73 | 73 | // Else, merge this group with the previous one |
74 | - if ( empty( $fields ) ){ |
|
74 | + if (empty($fields)) { |
|
75 | 75 | $fields = $metabox_array['fields']; |
76 | 76 | } else { |
77 | - $fields = array_merge( $fields, $metabox_array['fields'] ); |
|
77 | + $fields = array_merge($fields, $metabox_array['fields']); |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
81 | 81 | } |
82 | 82 | |
83 | 83 | // Loop through all metaboxes added the new way |
84 | - foreach ( \CMB2_Boxes::get_all() as $cmb ) { |
|
84 | + foreach (\CMB2_Boxes::get_all() as $cmb) { |
|
85 | 85 | |
86 | 86 | // Create the default |
87 | 87 | $match = false; |
88 | 88 | |
89 | 89 | // Establish correct cmb types |
90 | - if ( is_string( $cmb->meta_box['object_types'] ) ){ |
|
91 | - if ( $cmb->meta_box['object_types'] == $slug ){ |
|
90 | + if (is_string($cmb->meta_box['object_types'])) { |
|
91 | + if ($cmb->meta_box['object_types'] == $slug) { |
|
92 | 92 | $match = true; |
93 | 93 | } |
94 | 94 | } else { |
95 | - if ( in_array( $slug, $cmb->meta_box['object_types'] ) ){ |
|
95 | + if (in_array($slug, $cmb->meta_box['object_types'])) { |
|
96 | 96 | $match = true; |
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
100 | - if ( $match !== true ){ |
|
100 | + if ($match !== true) { |
|
101 | 101 | continue; |
102 | 102 | } |
103 | 103 | |
104 | - if ( empty( $fields ) ){ |
|
104 | + if (empty($fields)) { |
|
105 | 105 | $fields = $cmb->meta_box['fields']; |
106 | 106 | } else { |
107 | - $fields = array_merge( $fields, $cmb->meta_box['fields'] ); |
|
107 | + $fields = array_merge($fields, $cmb->meta_box['fields']); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | } |
@@ -128,25 +128,25 @@ discard block |
||
128 | 128 | * @param string $slug a custom post type ID. |
129 | 129 | * @return array Array of fields. |
130 | 130 | */ |
131 | - private function get_cmb1_metaboxes( $slug ){ |
|
131 | + private function get_cmb1_metaboxes($slug) { |
|
132 | 132 | |
133 | 133 | $fields = array(); |
134 | 134 | |
135 | 135 | // Get all metaboxes from CMB2 library |
136 | - $all_metaboxes = apply_filters( 'cmb_meta_boxes', array() ); |
|
136 | + $all_metaboxes = apply_filters('cmb_meta_boxes', array()); |
|
137 | 137 | |
138 | 138 | // Loop through all possible sets of metaboxes |
139 | - foreach ( $all_metaboxes as $metabox_array ){ |
|
139 | + foreach ($all_metaboxes as $metabox_array) { |
|
140 | 140 | |
141 | 141 | // If the custom post type ID matches this set of fields, set & stop |
142 | - if ( in_array( $slug, $metabox_array['pages'] ) ) { |
|
142 | + if (in_array($slug, $metabox_array['pages'])) { |
|
143 | 143 | |
144 | 144 | // If this is the first group of fields, simply set the value |
145 | 145 | // Else, merge this group with the previous one |
146 | - if ( empty( $fields ) ){ |
|
146 | + if (empty($fields)) { |
|
147 | 147 | $fields = $metabox_array['fields']; |
148 | 148 | } else { |
149 | - $fields = array_merge( $fields, $metabox_array['fields'] ); |
|
149 | + $fields = array_merge($fields, $metabox_array['fields']); |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
@@ -169,36 +169,36 @@ discard block |
||
169 | 169 | * @param int $post_id Single post ID. |
170 | 170 | * @param array $cmb custom metabox array from CMB2. |
171 | 171 | */ |
172 | - public function random_metabox_content( $post_id, $cmb, $connected ){ |
|
172 | + public function random_metabox_content($post_id, $cmb, $connected) { |
|
173 | 173 | $value = ''; |
174 | 174 | |
175 | 175 | // First check that our post ID & cmb array aren't empty |
176 | - if ( empty( $cmb ) || empty( $post_id ) ){ |
|
176 | + if (empty($cmb) || empty($post_id)) { |
|
177 | 177 | return; |
178 | 178 | } |
179 | 179 | |
180 | 180 | // Fetch the appropriate type of data and return |
181 | - switch( $cmb['type'] ){ |
|
181 | + switch ($cmb['type']) { |
|
182 | 182 | |
183 | 183 | case 'text': |
184 | 184 | case 'text_small': |
185 | 185 | case 'text_medium': |
186 | 186 | |
187 | 187 | // If phone is in the id, fetch a phone # |
188 | - if ( stripos( $cmb['id'], 'phone' ) ){ |
|
188 | + if (stripos($cmb['id'], 'phone')) { |
|
189 | 189 | $value = TestContent::phone(); |
190 | 190 | |
191 | 191 | // If email is in the id, fetch an email address |
192 | - } elseif ( stripos( $cmb['id'], 'email' ) ){ |
|
192 | + } elseif (stripos($cmb['id'], 'email')) { |
|
193 | 193 | $value = TestContent::email(); |
194 | 194 | |
195 | 195 | // If time is in the id, fetch a time string |
196 | - } elseif ( stripos( $cmb['id'], 'time' ) ){ |
|
196 | + } elseif (stripos($cmb['id'], 'time')) { |
|
197 | 197 | $value = TestContent::time(); |
198 | 198 | |
199 | 199 | // Otherwise, just a random text string |
200 | 200 | } else { |
201 | - $value = TestContent::title( rand( 10, 50 ) ); |
|
201 | + $value = TestContent::title(rand(10, 50)); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | break; |
@@ -229,14 +229,14 @@ discard block |
||
229 | 229 | |
230 | 230 | case 'text_date': |
231 | 231 | |
232 | - $value = TestContent::date( 'm/d/Y' ); |
|
232 | + $value = TestContent::date('m/d/Y'); |
|
233 | 233 | |
234 | 234 | break; |
235 | 235 | |
236 | 236 | case 'text_date_timestamp': |
237 | 237 | case 'text_datetime_timestamp': |
238 | 238 | |
239 | - $value = TestContent::date( 'U' ); |
|
239 | + $value = TestContent::date('U'); |
|
240 | 240 | |
241 | 241 | break; |
242 | 242 | |
@@ -244,13 +244,13 @@ discard block |
||
244 | 244 | |
245 | 245 | case 'text_money': |
246 | 246 | |
247 | - $value = rand( 0, 100000 ); |
|
247 | + $value = rand(0, 100000); |
|
248 | 248 | |
249 | 249 | break; |
250 | 250 | |
251 | 251 | case 'test_colorpicker': |
252 | 252 | |
253 | - $value = '#' . str_pad( dechex( mt_rand( 0, 0xFFFFFF ) ), 6, '0', STR_PAD_LEFT ); |
|
253 | + $value = '#'.str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT); |
|
254 | 254 | |
255 | 255 | break; |
256 | 256 | |
@@ -267,8 +267,8 @@ discard block |
||
267 | 267 | case 'radio': |
268 | 268 | |
269 | 269 | // Grab a random item out of the array and return the key |
270 | - $new_val = array_slice( $cmb['options'], rand( 0, count( $cmb['options'] ) ), 1 ); |
|
271 | - $value = key( $new_val ); |
|
270 | + $new_val = array_slice($cmb['options'], rand(0, count($cmb['options'])), 1); |
|
271 | + $value = key($new_val); |
|
272 | 272 | |
273 | 273 | break; |
274 | 274 | |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | case 'checkbox': |
280 | 280 | |
281 | 281 | // 50/50 odds of being turned on |
282 | - if ( rand( 0, 1 ) == 1 ){ |
|
282 | + if (rand(0, 1) == 1) { |
|
283 | 283 | $value = 'on'; |
284 | 284 | } |
285 | 285 | |
@@ -290,10 +290,10 @@ discard block |
||
290 | 290 | $new_option = array(); |
291 | 291 | |
292 | 292 | // Loop through each of our options |
293 | - foreach ( $cmb['options'] as $key => $value ){ |
|
293 | + foreach ($cmb['options'] as $key => $value) { |
|
294 | 294 | |
295 | 295 | // 50/50 chance of being included |
296 | - if ( rand( 0, 1 ) ){ |
|
296 | + if (rand(0, 1)) { |
|
297 | 297 | $new_option[] = $key; |
298 | 298 | } |
299 | 299 | |
@@ -311,8 +311,8 @@ discard block |
||
311 | 311 | |
312 | 312 | case 'file': |
313 | 313 | |
314 | - if ( true == $connected ){ |
|
315 | - $value = TestContent::image( $post_id ); |
|
314 | + if (true == $connected) { |
|
315 | + $value = TestContent::image($post_id); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | break; |
@@ -328,20 +328,20 @@ discard block |
||
328 | 328 | } |
329 | 329 | |
330 | 330 | // Value must exist to attempt to insert |
331 | - if ( !empty( $value ) && !is_wp_error( $value ) ){ |
|
331 | + if (!empty($value) && !is_wp_error($value)) { |
|
332 | 332 | |
333 | 333 | // Files must be treated separately - they use the attachment ID |
334 | 334 | // & url of media for separate cmb values |
335 | - if ( $cmb['type'] != 'file' ){ |
|
336 | - add_post_meta( $post_id, $cmb['id'], $value, true ); |
|
335 | + if ($cmb['type'] != 'file') { |
|
336 | + add_post_meta($post_id, $cmb['id'], $value, true); |
|
337 | 337 | } else { |
338 | - add_post_meta( $post_id, $cmb['id'].'_id', $value, true ); |
|
339 | - add_post_meta( $post_id, $cmb['id'], wp_get_attachment_url( $value ), true ); |
|
338 | + add_post_meta($post_id, $cmb['id'].'_id', $value, true); |
|
339 | + add_post_meta($post_id, $cmb['id'], wp_get_attachment_url($value), true); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | // If we're dealing with a WP Error object, just return the message for debugging |
343 | - } elseif ( is_wp_error( $value ) ){ |
|
344 | - error_log( $value->get_error_message() ); |
|
343 | + } elseif (is_wp_error($value)) { |
|
344 | + error_log($value->get_error_message()); |
|
345 | 345 | return $value->get_error_message(); |
346 | 346 | } |
347 | 347 |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | * @subpackage Evans |
18 | 18 | * @author Old Town Media |
19 | 19 | */ |
20 | -class ConnectionTest{ |
|
20 | +class ConnectionTest { |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * Run all of our connection tests. |
@@ -26,33 +26,33 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return boolean Status of connection to Internet/Splashbase. |
28 | 28 | */ |
29 | - public function test(){ |
|
29 | + public function test() { |
|
30 | 30 | |
31 | 31 | /* |
32 | 32 | * Make sure that we're looking at the correct admin page |
33 | 33 | */ |
34 | - if ( ! $this->check_admin_page() ){ |
|
34 | + if (!$this->check_admin_page()) { |
|
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
38 | 38 | /* |
39 | 39 | * Test #1 - Check for Airplane Mode plugin status |
40 | 40 | */ |
41 | - if ( ! $this->check_airplane_mode() ){ |
|
41 | + if (!$this->check_airplane_mode()) { |
|
42 | 42 | return false; |
43 | 43 | } |
44 | 44 | |
45 | 45 | /* |
46 | 46 | * Test #2 - Check Internet connection in general |
47 | 47 | */ |
48 | - if ( ! $this->check_internet() ){ |
|
48 | + if (!$this->check_internet()) { |
|
49 | 49 | return false; |
50 | 50 | } |
51 | 51 | |
52 | 52 | /* |
53 | 53 | * Test #3 - Check External URL itself (Splashbase here) |
54 | 54 | */ |
55 | - if ( ! $this->check_external_url( 'http://www.splashbase.co/api/v1/images/' ) ){ |
|
55 | + if (!$this->check_external_url('http://www.splashbase.co/api/v1/images/')) { |
|
56 | 56 | return false; |
57 | 57 | } |
58 | 58 | |
@@ -75,22 +75,22 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @return boolean Whether or not we're in the right place. |
77 | 77 | */ |
78 | - private function check_admin_page(){ |
|
78 | + private function check_admin_page() { |
|
79 | 79 | global $current_screen; |
80 | 80 | |
81 | 81 | // Only run if we're in the admin page |
82 | - if ( !is_admin() ){ |
|
82 | + if (!is_admin()) { |
|
83 | 83 | return false; |
84 | 84 | } |
85 | 85 | |
86 | 86 | // Get the current admin screen & verify that we're on the right one |
87 | 87 | // before continuing. |
88 | - if ( isset ( $current_screen ) && 'tools_page_create-test-data' != $current_screen->base ){ |
|
88 | + if (isset ($current_screen) && 'tools_page_create-test-data' != $current_screen->base) { |
|
89 | 89 | return false; |
90 | 90 | } |
91 | 91 | |
92 | - $last_uri_bit = explode( '=', $_SERVER['REQUEST_URI'] ); |
|
93 | - if ( 'create-test-data' != end( $last_uri_bit ) ){ |
|
92 | + $last_uri_bit = explode('=', $_SERVER['REQUEST_URI']); |
|
93 | + if ('create-test-data' != end($last_uri_bit)) { |
|
94 | 94 | return false; |
95 | 95 | } |
96 | 96 | |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @return boolean Connected or not. |
110 | 110 | */ |
111 | - private function check_airplane_mode(){ |
|
111 | + private function check_airplane_mode() { |
|
112 | 112 | |
113 | - if ( class_exists( 'Airplane_Mode_Core' ) ){ |
|
113 | + if (class_exists('Airplane_Mode_Core')) { |
|
114 | 114 | // Is airplane mode active? |
115 | - $airplane_mode = get_site_option( 'airplane-mode' ); |
|
115 | + $airplane_mode = get_site_option('airplane-mode'); |
|
116 | 116 | |
117 | - if ( $airplane_mode === 'on' ){ |
|
117 | + if ($airplane_mode === 'on') { |
|
118 | 118 | return false; |
119 | 119 | } |
120 | 120 | } |
@@ -133,17 +133,17 @@ discard block |
||
133 | 133 | * |
134 | 134 | * @return boolean Connected or not. |
135 | 135 | */ |
136 | - private function check_internet(){ |
|
136 | + private function check_internet() { |
|
137 | 137 | |
138 | 138 | // Attempt to open a socket connection to Google |
139 | - $connected = @fsockopen( "www.google.com", 80 ); |
|
139 | + $connected = @fsockopen("www.google.com", 80); |
|
140 | 140 | |
141 | - if ( !$connected ){ |
|
141 | + if (!$connected) { |
|
142 | 142 | return false; |
143 | 143 | } |
144 | 144 | |
145 | 145 | // Close out our 1st test |
146 | - fclose( $connected ); |
|
146 | + fclose($connected); |
|
147 | 147 | |
148 | 148 | return true; |
149 | 149 | |
@@ -160,12 +160,12 @@ discard block |
||
160 | 160 | * @param string $url External URL to attempt to reach. |
161 | 161 | * @return boolean Connected or not. |
162 | 162 | */ |
163 | - private function check_external_url( $url ){ |
|
163 | + private function check_external_url($url) { |
|
164 | 164 | |
165 | - $test_url = esc_url( $url ); |
|
166 | - $response = wp_remote_get( $test_url ); |
|
165 | + $test_url = esc_url($url); |
|
166 | + $response = wp_remote_get($test_url); |
|
167 | 167 | |
168 | - if ( !is_array( $response ) ){ |
|
168 | + if (!is_array($response)) { |
|
169 | 169 | return false; |
170 | 170 | } |
171 | 171 |
@@ -4,12 +4,12 @@ discard block |
||
4 | 4 | |
5 | 5 | // If uninstall is not called from WordPress, exit |
6 | 6 | if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
7 | - exit(); |
|
7 | + exit(); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | // Check if the current user has priveledges to run this method |
11 | 11 | if ( ! current_user_can( 'activate_plugins' ) ){ |
12 | - return; |
|
12 | + return; |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | require dirname( __FILE__ ) . '/includes/class-delete.php'; |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | $post_types = get_post_types( array( 'public' => true ), 'objects' ); |
20 | 20 | foreach ( $post_types as $post_type ) : |
21 | 21 | |
22 | - $delete->delete_posts( $post_type->name ); |
|
22 | + $delete->delete_posts( $post_type->name ); |
|
23 | 23 | |
24 | 24 | endforeach; |
25 | 25 | |
@@ -27,6 +27,6 @@ discard block |
||
27 | 27 | $taxonomies = get_taxonomies(); |
28 | 28 | foreach ( $taxonomies as $tax ) : |
29 | 29 | |
30 | - $delete->delete_terms( $tax ); |
|
30 | + $delete->delete_terms( $tax ); |
|
31 | 31 | |
32 | 32 | endforeach; |
@@ -3,30 +3,30 @@ |
||
3 | 3 | use testContent as test; |
4 | 4 | |
5 | 5 | // If uninstall is not called from WordPress, exit |
6 | -if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
6 | +if (!defined('WP_UNINSTALL_PLUGIN')) { |
|
7 | 7 | exit(); |
8 | 8 | } |
9 | 9 | |
10 | 10 | // Check if the current user has priveledges to run this method |
11 | -if ( ! current_user_can( 'activate_plugins' ) ){ |
|
11 | +if (!current_user_can('activate_plugins')) { |
|
12 | 12 | return; |
13 | 13 | } |
14 | 14 | |
15 | -require dirname( __FILE__ ) . '/includes/class-delete.php'; |
|
15 | +require dirname(__FILE__).'/includes/class-delete.php'; |
|
16 | 16 | $delete = new test\Delete; |
17 | 17 | |
18 | 18 | // Loop through all post types and remove any test data |
19 | -$post_types = get_post_types( array( 'public' => true ), 'objects' ); |
|
20 | -foreach ( $post_types as $post_type ) : |
|
19 | +$post_types = get_post_types(array('public' => true), 'objects'); |
|
20 | +foreach ($post_types as $post_type) : |
|
21 | 21 | |
22 | - $delete->delete_posts( $post_type->name ); |
|
22 | + $delete->delete_posts($post_type->name); |
|
23 | 23 | |
24 | 24 | endforeach; |
25 | 25 | |
26 | 26 | // Loop through all taxonomies and remove any data |
27 | 27 | $taxonomies = get_taxonomies(); |
28 | -foreach ( $taxonomies as $tax ) : |
|
28 | +foreach ($taxonomies as $tax) : |
|
29 | 29 | |
30 | - $delete->delete_terms( $tax ); |
|
30 | + $delete->delete_terms($tax); |
|
31 | 31 | |
32 | 32 | endforeach; |