@@ -56,7 +56,7 @@ |
||
56 | 56 | /** |
57 | 57 | * Retrieve the plugin instance. |
58 | 58 | * |
59 | - * @return object Plugin |
|
59 | + * @return Plugin Plugin |
|
60 | 60 | */ |
61 | 61 | function plugin() { |
62 | 62 | static $instance; |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | return; |
29 | 29 | } |
30 | 30 | |
31 | - $class = str_replace( __NAMESPACE__ . '\\', '', $class ); |
|
31 | + $class = str_replace( __NAMESPACE__ . '\\', '', $class ); |
|
32 | 32 | |
33 | 33 | $nss = array( |
34 | 34 | 'Abstracts', |
@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | ); |
38 | 38 | |
39 | 39 | if ( in_array( $namespace[1], $nss ) ){ |
40 | - $class = strtolower( preg_replace( '/(?<!^)([A-Z])/', '/\1', $class ) ); |
|
41 | - $class = str_replace( '\\', '', $class ); |
|
42 | - $file = dirname( __FILE__ ) . '/' . $class . '.php'; |
|
43 | - } else { |
|
44 | - $class = strtolower( preg_replace( '/(?<!^)([A-Z])/', '-\\1', $class ) ); |
|
45 | - $file = dirname( __FILE__ ) . '/includes/class-' . $class . '.php'; |
|
46 | - } |
|
40 | + $class = strtolower( preg_replace( '/(?<!^)([A-Z])/', '/\1', $class ) ); |
|
41 | + $class = str_replace( '\\', '', $class ); |
|
42 | + $file = dirname( __FILE__ ) . '/' . $class . '.php'; |
|
43 | + } else { |
|
44 | + $class = strtolower( preg_replace( '/(?<!^)([A-Z])/', '-\\1', $class ) ); |
|
45 | + $file = dirname( __FILE__ ) . '/includes/class-' . $class . '.php'; |
|
46 | + } |
|
47 | 47 | |
48 | 48 | if ( is_readable( $file ) ) { |
49 | 49 | require_once( $file ); |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | // Register hook providers and views. |
83 | 83 | plugin()->register_hooks( new AdminPage() ) |
84 | 84 | ->register_hooks( new Ajax() ) |
85 | - ->register_view( new Views\Posts() ) |
|
86 | - ->register_view( new Views\Terms() ) |
|
85 | + ->register_view( new Views\Posts() ) |
|
86 | + ->register_view( new Views\Terms() ) |
|
87 | 87 | ->register_view( new Views\Users() ) |
88 | 88 | ->register_view( new Views\Various() ) |
89 | 89 | ->register_type( new Types\Post() ) |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param string $class Class name. |
23 | 23 | */ |
24 | -function dummypress_autoloader( $class ) { |
|
25 | - $namespace = explode( '\\', $class ); |
|
24 | +function dummypress_autoloader($class) { |
|
25 | + $namespace = explode('\\', $class); |
|
26 | 26 | |
27 | - if ( __NAMESPACE__ !== $namespace[0] ){ |
|
27 | + if (__NAMESPACE__ !== $namespace[0]) { |
|
28 | 28 | return; |
29 | 29 | } |
30 | 30 | |
31 | - $class = str_replace( __NAMESPACE__ . '\\', '', $class ); |
|
31 | + $class = str_replace(__NAMESPACE__ . '\\', '', $class); |
|
32 | 32 | |
33 | 33 | $nss = array( |
34 | 34 | 'Abstracts', |
@@ -36,20 +36,20 @@ discard block |
||
36 | 36 | 'Views' |
37 | 37 | ); |
38 | 38 | |
39 | - if ( in_array( $namespace[1], $nss ) ){ |
|
40 | - $class = strtolower( preg_replace( '/(?<!^)([A-Z])/', '/\1', $class ) ); |
|
41 | - $class = str_replace( '\\', '', $class ); |
|
42 | - $file = dirname( __FILE__ ) . '/' . $class . '.php'; |
|
39 | + if (in_array($namespace[1], $nss)) { |
|
40 | + $class = strtolower(preg_replace('/(?<!^)([A-Z])/', '/\1', $class)); |
|
41 | + $class = str_replace('\\', '', $class); |
|
42 | + $file = dirname(__FILE__) . '/' . $class . '.php'; |
|
43 | 43 | } else { |
44 | - $class = strtolower( preg_replace( '/(?<!^)([A-Z])/', '-\\1', $class ) ); |
|
45 | - $file = dirname( __FILE__ ) . '/includes/class-' . $class . '.php'; |
|
44 | + $class = strtolower(preg_replace('/(?<!^)([A-Z])/', '-\\1', $class)); |
|
45 | + $file = dirname(__FILE__) . '/includes/class-' . $class . '.php'; |
|
46 | 46 | } |
47 | 47 | |
48 | - if ( is_readable( $file ) ) { |
|
49 | - require_once( $file ); |
|
48 | + if (is_readable($file)) { |
|
49 | + require_once($file); |
|
50 | 50 | } |
51 | 51 | } |
52 | - spl_autoload_register( __NAMESPACE__ . '\dummypress_autoloader' ); |
|
52 | + spl_autoload_register(__NAMESPACE__ . '\dummypress_autoloader'); |
|
53 | 53 | |
54 | 54 | |
55 | 55 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | function plugin() { |
62 | 62 | static $instance; |
63 | 63 | |
64 | - if ( null === $instance ) { |
|
64 | + if (null === $instance) { |
|
65 | 65 | $instance = new Plugin(); |
66 | 66 | } |
67 | 67 | |
@@ -71,24 +71,24 @@ discard block |
||
71 | 71 | // Set our definitions for later use |
72 | 72 | plugin()->set_definitions( |
73 | 73 | (object) array( |
74 | - 'basename' => plugin_basename( __FILE__ ), |
|
75 | - 'directory' => plugin_dir_path( __FILE__ ), |
|
74 | + 'basename' => plugin_basename(__FILE__), |
|
75 | + 'directory' => plugin_dir_path(__FILE__), |
|
76 | 76 | 'file' => __FILE__, |
77 | 77 | 'slug' => 'test-content', |
78 | - 'url' => plugin_dir_url( __FILE__ ) |
|
78 | + 'url' => plugin_dir_url(__FILE__) |
|
79 | 79 | ) |
80 | 80 | ); |
81 | 81 | |
82 | 82 | // Register hook providers and views. |
83 | - plugin()->register_hooks( new AdminPage() ) |
|
84 | - ->register_hooks( new Ajax() ) |
|
85 | - ->register_view( new Views\Posts() ) |
|
86 | - ->register_view( new Views\Terms() ) |
|
87 | - ->register_view( new Views\Users() ) |
|
88 | - ->register_view( new Views\Various() ) |
|
89 | - ->register_type( new Types\Post() ) |
|
90 | - ->register_type( new Types\Term() ) |
|
91 | - ->register_type( new Types\User() ); |
|
83 | + plugin()->register_hooks(new AdminPage()) |
|
84 | + ->register_hooks(new Ajax()) |
|
85 | + ->register_view(new Views\Posts()) |
|
86 | + ->register_view(new Views\Terms()) |
|
87 | + ->register_view(new Views\Users()) |
|
88 | + ->register_view(new Views\Various()) |
|
89 | + ->register_type(new Types\Post()) |
|
90 | + ->register_type(new Types\Term()) |
|
91 | + ->register_type(new Types\User()); |
|
92 | 92 | |
93 | 93 | // Load textdomain hook |
94 | -add_action( 'plugins_loaded', array( plugin(), 'load_textdomain' ) ); |
|
94 | +add_action('plugins_loaded', array(plugin(), 'load_textdomain')); |
@@ -1,6 +1,5 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace DummyPress; |
3 | -use DummyPress\Views\Users as Users; |
|
4 | 3 | |
5 | 4 | /** |
6 | 5 | * Class to handle deletion of test data for the plugin. |
@@ -9,27 +9,27 @@ discard block |
||
9 | 9 | * @subpackage Evans |
10 | 10 | * @author Old Town Media |
11 | 11 | */ |
12 | -class Delete{ |
|
12 | +class Delete { |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * Delete all test content created ever. |
16 | 16 | * |
17 | 17 | * @access private |
18 | 18 | */ |
19 | - public function delete_all_test_data(){ |
|
19 | + public function delete_all_test_data() { |
|
20 | 20 | $return = ''; |
21 | 21 | |
22 | - if ( ! $this->user_can_delete() ){ |
|
22 | + if (!$this->user_can_delete()) { |
|
23 | 23 | return; |
24 | 24 | } |
25 | 25 | |
26 | - $types = apply_filters( 'tc-types', array() ); |
|
26 | + $types = apply_filters('tc-types', array()); |
|
27 | 27 | |
28 | - if ( !empty( $types ) ){ |
|
28 | + if (!empty($types)) { |
|
29 | 29 | |
30 | - foreach ( $types as $type ){ |
|
30 | + foreach ($types as $type) { |
|
31 | 31 | |
32 | - $class = 'DummyPress\Types\\' . ucwords( $type ); |
|
32 | + $class = 'DummyPress\Types\\' . ucwords($type); |
|
33 | 33 | $object = new $class(); |
34 | 34 | |
35 | 35 | $return .= $object->delete_all(); |
@@ -53,23 +53,23 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @param string $data Information about the type. |
55 | 55 | */ |
56 | - public function delete_objects( $data ){ |
|
56 | + public function delete_objects($data) { |
|
57 | 57 | |
58 | 58 | // Make sure that the current user is logged in & has full permissions. |
59 | - if ( !$this->user_can_delete() ){ |
|
59 | + if (!$this->user_can_delete()) { |
|
60 | 60 | return; |
61 | 61 | } |
62 | 62 | |
63 | - if ( empty( $data ) ){ |
|
63 | + if (empty($data)) { |
|
64 | 64 | return; |
65 | 65 | } |
66 | 66 | |
67 | - $type = 'DummyPress\Types\\' . ucwords( $data['type'] ); |
|
67 | + $type = 'DummyPress\Types\\' . ucwords($data['type']); |
|
68 | 68 | $slug = $data['slug']; |
69 | 69 | |
70 | 70 | $object = new $type(); |
71 | 71 | |
72 | - return $object->delete( $slug ); |
|
72 | + return $object->delete($slug); |
|
73 | 73 | |
74 | 74 | } |
75 | 75 | |
@@ -79,15 +79,15 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @see is_user_logged_in, current_user_can |
81 | 81 | */ |
82 | - public function user_can_delete(){ |
|
82 | + public function user_can_delete() { |
|
83 | 83 | |
84 | 84 | // User must be logged in |
85 | - if ( !is_user_logged_in() ){ |
|
85 | + if (!is_user_logged_in()) { |
|
86 | 86 | return false; |
87 | 87 | } |
88 | 88 | |
89 | 89 | // User must have editor priveledges, at a minimum |
90 | - if ( !current_user_can( 'delete_others_posts' ) ){ |
|
90 | + if (!current_user_can('delete_others_posts')) { |
|
91 | 91 | return false; |
92 | 92 | } |
93 | 93 |
@@ -1,6 +1,5 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace DummyPress\Types; |
3 | -use DummyPress as Main; |
|
4 | 3 | use DummyPress\TestContent as TestContent; |
5 | 4 | use DummyPress\Delete as Delete; |
6 | 5 | use DummyPress\Abstracts as Abs; |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | global $wp_roles; |
138 | 138 | $clean_roles = array(); |
139 | 139 | |
140 | - $role_names = $wp_roles->get_names(); |
|
140 | + $role_names = $wp_roles->get_names(); |
|
141 | 141 | $flipped = array_flip( $role_names ); |
142 | 142 | |
143 | 143 | // Loop through all available roles |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | $post_types = get_post_types( array( 'public' => true ), 'objects' ); |
184 | 184 | foreach ( $post_types as $post_type ) : |
185 | 185 | |
186 | - $this->delete( $post_type->name ); |
|
186 | + $this->delete( $post_type->name ); |
|
187 | 187 | |
188 | 188 | endforeach; |
189 | 189 | |
@@ -228,10 +228,10 @@ discard block |
||
228 | 228 | 'number' => 500, |
229 | 229 | 'meta_query' => array( |
230 | 230 | 'relation' => 'OR', |
231 | - array( |
|
232 | - 'key' => 'dummypress_test_data', |
|
233 | - 'value' => '__test__', |
|
234 | - 'compare' => '=' |
|
231 | + array( |
|
232 | + 'key' => 'dummypress_test_data', |
|
233 | + 'value' => '__test__', |
|
234 | + 'compare' => '=' |
|
235 | 235 | ), |
236 | 236 | array( |
237 | 237 | 'key' => 'evans_test_content', |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * @subpackage Evans |
14 | 14 | * @author Old Town Media |
15 | 15 | */ |
16 | -class User extends Abs\Type{ |
|
16 | +class User extends Abs\Type { |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * type |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | * @param boolean $connection Whether or not we're connected to the Internet. |
40 | 40 | * @param int $num Optional. Number of posts to create. |
41 | 41 | */ |
42 | - public function create_objects( $slug, $connection, $num = '' ){ |
|
42 | + public function create_objects($slug, $connection, $num = '') { |
|
43 | 43 | |
44 | 44 | // If we're missing a custom post type id - don't do anything |
45 | - if ( empty( $slug ) ){ |
|
45 | + if (empty($slug)) { |
|
46 | 46 | return; |
47 | 47 | } |
48 | 48 | |
@@ -50,14 +50,14 @@ discard block |
||
50 | 50 | $this->connected = $connection; |
51 | 51 | |
52 | 52 | // If we forgot to put in a quantity, make one for us |
53 | - if ( empty( $num ) ){ |
|
54 | - $num = rand( 5, 30 ); |
|
53 | + if (empty($num)) { |
|
54 | + $num = rand(5, 30); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | // Create test posts |
58 | - for( $i = 0; $i < $num; $i++ ){ |
|
58 | + for ($i = 0; $i < $num; $i++) { |
|
59 | 59 | |
60 | - $return = $this->create_test_object( $slug ); |
|
60 | + $return = $this->create_test_object($slug); |
|
61 | 61 | |
62 | 62 | return $return; |
63 | 63 | |
@@ -79,36 +79,36 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @param string $slug a custom post type ID. |
81 | 81 | */ |
82 | - private function create_test_object( $slug ){ |
|
82 | + private function create_test_object($slug) { |
|
83 | 83 | |
84 | - if ( !is_user_logged_in() ){ |
|
84 | + if (!is_user_logged_in()) { |
|
85 | 85 | return false; |
86 | 86 | } |
87 | 87 | |
88 | - $name = apply_filters( "tc_{$slug}_user_name", TestContent::name() ); |
|
88 | + $name = apply_filters("tc_{$slug}_user_name", TestContent::name()); |
|
89 | 89 | |
90 | 90 | // First, insert our post |
91 | 91 | $userdata = array( |
92 | - 'user_pass' => wp_generate_password( 12, true, true ), |
|
93 | - 'user_login' => strtolower( $name['first'] . $name['last'] ) . rand( 10, 100 ), |
|
94 | - 'user_email' => apply_filters( "tc_{$slug}_user_email", TestContent::email( true ) ), |
|
95 | - 'display_name' => strtolower( $name['first'] . $name['last'] ), |
|
92 | + 'user_pass' => wp_generate_password(12, true, true), |
|
93 | + 'user_login' => strtolower($name['first'] . $name['last']) . rand(10, 100), |
|
94 | + 'user_email' => apply_filters("tc_{$slug}_user_email", TestContent::email(true)), |
|
95 | + 'display_name' => strtolower($name['first'] . $name['last']), |
|
96 | 96 | 'first_name' => $name['first'], |
97 | 97 | 'last_name' => $name['last'], |
98 | 98 | 'description' => TestContent::title(), |
99 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
99 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
100 | 100 | 'role' => $slug, |
101 | 101 | ); |
102 | 102 | |
103 | 103 | // Insert the user |
104 | - $user_id = wp_insert_user( apply_filters( "tc_{$slug}_user_arguments", $userdata ) ); |
|
104 | + $user_id = wp_insert_user(apply_filters("tc_{$slug}_user_arguments", $userdata)); |
|
105 | 105 | |
106 | 106 | // Then, set a test content flag on the new post for later deletion |
107 | - add_user_meta( $user_id, 'dummypress_test_data', '__test__', true ); |
|
107 | + add_user_meta($user_id, 'dummypress_test_data', '__test__', true); |
|
108 | 108 | |
109 | 109 | // Check if we have errors and return them or created message |
110 | - if ( is_wp_error( $user_id ) ){ |
|
111 | - error_log( $user_id->get_error_message() ); |
|
110 | + if (is_wp_error($user_id)) { |
|
111 | + error_log($user_id->get_error_message()); |
|
112 | 112 | return $user_id; |
113 | 113 | } else { |
114 | 114 | return array( |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | 'object' => 'user', |
117 | 117 | 'oid' => $user_id, |
118 | 118 | 'type' => $slug, |
119 | - 'link_edit' => admin_url( '/user-edit.php?user_id=' . $user_id ), |
|
120 | - 'link_view' => get_author_posts_url( $user_id ) |
|
119 | + 'link_edit' => admin_url('/user-edit.php?user_id=' . $user_id), |
|
120 | + 'link_view' => get_author_posts_url($user_id) |
|
121 | 121 | ); |
122 | 122 | } |
123 | 123 | |
@@ -133,12 +133,12 @@ discard block |
||
133 | 133 | * |
134 | 134 | * @return array Array of roles for use in creation and deletion |
135 | 135 | */ |
136 | - public function get_roles(){ |
|
136 | + public function get_roles() { |
|
137 | 137 | global $wp_roles; |
138 | 138 | $clean_roles = array(); |
139 | 139 | |
140 | 140 | $role_names = $wp_roles->get_names(); |
141 | - $flipped = array_flip( $role_names ); |
|
141 | + $flipped = array_flip($role_names); |
|
142 | 142 | |
143 | 143 | // Loop through all available roles |
144 | 144 | $roles = get_editable_roles(); |
@@ -147,15 +147,15 @@ discard block |
||
147 | 147 | 'Administrator' |
148 | 148 | ); |
149 | 149 | |
150 | - foreach ( $roles as $role ){ |
|
150 | + foreach ($roles as $role) { |
|
151 | 151 | |
152 | - if ( in_array( $role['name'], $skipped_roles ) ){ |
|
152 | + if (in_array($role['name'], $skipped_roles)) { |
|
153 | 153 | continue; |
154 | 154 | } |
155 | 155 | |
156 | 156 | $clean_roles[] = array( |
157 | 157 | 'name' => $role['name'], |
158 | - 'slug' => $flipped[ $role['name'] ] |
|
158 | + 'slug' => $flipped[$role['name']] |
|
159 | 159 | ); |
160 | 160 | |
161 | 161 | } |
@@ -170,27 +170,27 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @see Delete |
172 | 172 | */ |
173 | - public function delete_all(){ |
|
173 | + public function delete_all() { |
|
174 | 174 | |
175 | - $delete = new Delete; |
|
175 | + $delete = new Delete; |
|
176 | 176 | |
177 | 177 | // Make sure that the current user is logged in & has full permissions. |
178 | - if ( ! $delete->user_can_delete() ){ |
|
178 | + if (!$delete->user_can_delete()) { |
|
179 | 179 | return; |
180 | 180 | } |
181 | 181 | |
182 | 182 | // Loop through all post types and remove any test data |
183 | - $post_types = get_post_types( array( 'public' => true ), 'objects' ); |
|
184 | - foreach ( $post_types as $post_type ) : |
|
183 | + $post_types = get_post_types(array('public' => true), 'objects'); |
|
184 | + foreach ($post_types as $post_type) : |
|
185 | 185 | |
186 | - $this->delete( $post_type->name ); |
|
186 | + $this->delete($post_type->name); |
|
187 | 187 | |
188 | 188 | endforeach; |
189 | 189 | |
190 | 190 | // Loop through all user roles and remove any data |
191 | - foreach ( $this->get_roles() as $role ) : |
|
191 | + foreach ($this->get_roles() as $role) : |
|
192 | 192 | |
193 | - $this->delete( $role['slug'] ); |
|
193 | + $this->delete($role['slug']); |
|
194 | 194 | |
195 | 195 | endforeach; |
196 | 196 | |
@@ -208,17 +208,17 @@ discard block |
||
208 | 208 | * |
209 | 209 | * @param string $slug a custom post type ID. |
210 | 210 | */ |
211 | - public function delete( $slug ){ |
|
211 | + public function delete($slug) { |
|
212 | 212 | |
213 | 213 | $delete = new Delete; |
214 | 214 | |
215 | 215 | // Make sure that the current user is logged in & has full permissions. |
216 | - if ( !$delete->user_can_delete() ){ |
|
216 | + if (!$delete->user_can_delete()) { |
|
217 | 217 | return; |
218 | 218 | } |
219 | 219 | |
220 | 220 | // Check that $cptslg has a string. |
221 | - if ( empty( $slug ) ){ |
|
221 | + if (empty($slug)) { |
|
222 | 222 | return; |
223 | 223 | } |
224 | 224 | |
@@ -241,22 +241,22 @@ discard block |
||
241 | 241 | ), |
242 | 242 | ); |
243 | 243 | |
244 | - $objects = new \WP_User_Query( $query ); |
|
245 | - $users = $objects->get_results(); |
|
244 | + $objects = new \WP_User_Query($query); |
|
245 | + $users = $objects->get_results(); |
|
246 | 246 | |
247 | - if ( !empty( $users ) ){ |
|
247 | + if (!empty($users)) { |
|
248 | 248 | |
249 | 249 | $events = array(); |
250 | 250 | |
251 | - foreach ( $users as $user ){ |
|
251 | + foreach ($users as $user) { |
|
252 | 252 | |
253 | 253 | // Make sure we can't delete ourselves by accident |
254 | - if ( $user->ID == get_current_user_id() ){ |
|
254 | + if ($user->ID == get_current_user_id()) { |
|
255 | 255 | continue; |
256 | 256 | } |
257 | 257 | |
258 | 258 | // Double check our set user meta value |
259 | - if ( '__test__' != get_user_meta( $user->ID, 'dummypress_test_data', true ) && '__test__' != get_user_meta( $user->ID, 'evans_test_content', true ) ){ |
|
259 | + if ('__test__' != get_user_meta($user->ID, 'dummypress_test_data', true) && '__test__' != get_user_meta($user->ID, 'evans_test_content', true)) { |
|
260 | 260 | continue; |
261 | 261 | } |
262 | 262 | |
@@ -268,13 +268,13 @@ discard block |
||
268 | 268 | ); |
269 | 269 | |
270 | 270 | // Force delete the user |
271 | - wp_delete_user( $user->ID ); |
|
271 | + wp_delete_user($user->ID); |
|
272 | 272 | |
273 | 273 | } |
274 | 274 | |
275 | 275 | $events[] = array( |
276 | 276 | 'action' => 'general', |
277 | - 'message' => __( 'Deleted', 'dummybot' ) . ' ' . $slug |
|
277 | + 'message' => __('Deleted', 'dummybot') . ' ' . $slug |
|
278 | 278 | ); |
279 | 279 | |
280 | 280 | return $events; |
@@ -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 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage Evans |
9 | 9 | * @author Old Town Media |
10 | 10 | */ |
11 | -class Ajax{ |
|
11 | +class Ajax { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * reporting |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | /** |
40 | 40 | * Instantiate any WP hooks that need to be fired. |
41 | 41 | */ |
42 | - public function hooks(){ |
|
42 | + public function hooks() { |
|
43 | 43 | |
44 | 44 | $this->reporting = new Reporting; |
45 | 45 | $this->action = 'handle_test_data'; |
46 | 46 | |
47 | - add_action( "wp_ajax_{$this->action}" , array( $this, 'handle_ajax' ) ); |
|
48 | - add_filter( 'option_active_plugins', array( $this, 'ajax_exclude_plugins' ) ); |
|
47 | + add_action("wp_ajax_{$this->action}", array($this, 'handle_ajax')); |
|
48 | + add_filter('option_active_plugins', array($this, 'ajax_exclude_plugins')); |
|
49 | 49 | |
50 | 50 | } |
51 | 51 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @param $plugin Plugin instance. |
57 | 57 | * @return Ajax instance |
58 | 58 | */ |
59 | - public function set_plugin( $plugin ) { |
|
59 | + public function set_plugin($plugin) { |
|
60 | 60 | |
61 | 61 | $this->plugin = $plugin; |
62 | 62 | return $this; |
@@ -75,19 +75,19 @@ discard block |
||
75 | 75 | * @param array $plugins All active plugins. |
76 | 76 | * @return array Whitelisted plugins. |
77 | 77 | */ |
78 | - public function ajax_exclude_plugins( $plugins ) { |
|
78 | + public function ajax_exclude_plugins($plugins) { |
|
79 | 79 | |
80 | - if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX || ! isset( $_POST['action'] ) || false === strpos( $_POST['action'], $this->action ) ){ |
|
80 | + if (!defined('DOING_AJAX') || !DOING_AJAX || !isset($_POST['action']) || false === strpos($_POST['action'], $this->action)) { |
|
81 | 81 | return $plugins; |
82 | 82 | } |
83 | 83 | |
84 | - foreach( $plugins as $key => $plugin ) { |
|
84 | + foreach ($plugins as $key => $plugin) { |
|
85 | 85 | |
86 | - if ( false !== strpos( $plugin, $this->plugin->definitions->slug ) ){ |
|
86 | + if (false !== strpos($plugin, $this->plugin->definitions->slug)) { |
|
87 | 87 | continue; |
88 | 88 | } |
89 | 89 | |
90 | - unset( $plugins[$key] ); |
|
90 | + unset($plugins[$key]); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | return $plugins; |
@@ -102,21 +102,21 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function handle_ajax() { |
104 | 104 | |
105 | - $action = $_REQUEST['todo']; |
|
106 | - $nonce = $_REQUEST['nonce']; |
|
105 | + $action = $_REQUEST['todo']; |
|
106 | + $nonce = $_REQUEST['nonce']; |
|
107 | 107 | |
108 | 108 | // Verify that we have a proper logged in user and it's the right person |
109 | - if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'handle-test-data' ) ){ |
|
109 | + if (empty($nonce) || !wp_verify_nonce($nonce, 'handle-test-data')) { |
|
110 | 110 | return; |
111 | 111 | } |
112 | 112 | |
113 | - if ( $action == 'delete' ){ |
|
113 | + if ($action == 'delete') { |
|
114 | 114 | |
115 | - $this->deletion_routing( $_REQUEST ); |
|
115 | + $this->deletion_routing($_REQUEST); |
|
116 | 116 | |
117 | - } elseif ( $action == 'create' ){ |
|
117 | + } elseif ($action == 'create') { |
|
118 | 118 | |
119 | - $this->creation_routing( $_REQUEST ); |
|
119 | + $this->creation_routing($_REQUEST); |
|
120 | 120 | |
121 | 121 | } |
122 | 122 | |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | * Choose which type of creation needs to be accomplished and route through |
130 | 130 | * the correct class. |
131 | 131 | */ |
132 | - private function creation_routing( $data ){ |
|
132 | + private function creation_routing($data) { |
|
133 | 133 | |
134 | - $type = 'DummyPress\Types\\' . ucwords( $data['type'] ); |
|
134 | + $type = 'DummyPress\Types\\' . ucwords($data['type']); |
|
135 | 135 | $object = new $type(); |
136 | - $return = $object->create_objects( $data['slug'], $data['connection'], true, 1 ); |
|
136 | + $return = $object->create_objects($data['slug'], $data['connection'], true, 1); |
|
137 | 137 | |
138 | - $clean = $this->reporting->create_report( $return ); |
|
138 | + $clean = $this->reporting->create_report($return); |
|
139 | 139 | |
140 | 140 | echo $clean; |
141 | 141 | |
@@ -146,21 +146,21 @@ discard block |
||
146 | 146 | * Choose which type of deletion needs to be accomplished and route through |
147 | 147 | * the correct method of Delete. |
148 | 148 | */ |
149 | - private function deletion_routing( $data ){ |
|
149 | + private function deletion_routing($data) { |
|
150 | 150 | |
151 | 151 | $delete_content = new Delete; |
152 | 152 | |
153 | - if ( $data['type'] == 'all' ){ |
|
153 | + if ($data['type'] == 'all') { |
|
154 | 154 | |
155 | 155 | $return = $delete_content->delete_all_test_data(); |
156 | 156 | |
157 | 157 | } else { |
158 | 158 | |
159 | - $return = $delete_content->delete_objects( $data ); |
|
159 | + $return = $delete_content->delete_objects($data); |
|
160 | 160 | |
161 | 161 | } |
162 | 162 | |
163 | - $clean = $this->reporting->create_report( $return ); |
|
163 | + $clean = $this->reporting->create_report($return); |
|
164 | 164 | |
165 | 165 | echo $clean; |
166 | 166 |
@@ -10,16 +10,16 @@ |
||
10 | 10 | * @subpackage Evans |
11 | 11 | * @author Old Town Media |
12 | 12 | */ |
13 | -class Reporting{ |
|
13 | +class Reporting { |
|
14 | 14 | |
15 | - public function create_report( $data ){ |
|
15 | + public function create_report($data) { |
|
16 | 16 | |
17 | - $cleaned = json_encode( $this->parse_data( $data ) ); |
|
17 | + $cleaned = json_encode($this->parse_data($data)); |
|
18 | 18 | return $cleaned; |
19 | 19 | |
20 | 20 | } |
21 | 21 | |
22 | - private function parse_data( $data ){ |
|
22 | + private function parse_data($data) { |
|
23 | 23 | |
24 | 24 | return $data; |
25 | 25 |
@@ -427,29 +427,29 @@ discard block |
||
427 | 427 | } |
428 | 428 | |
429 | 429 | // Download the file |
430 | - $tmp = \download_url( $url ); |
|
430 | + $tmp = \download_url( $url ); |
|
431 | 431 | |
432 | - preg_match( '/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches ); |
|
432 | + preg_match( '/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches ); |
|
433 | 433 | |
434 | - $file_array['name'] = basename( $matches[0] ); |
|
435 | - $file_array['tmp_name'] = $tmp; |
|
434 | + $file_array['name'] = basename( $matches[0] ); |
|
435 | + $file_array['tmp_name'] = $tmp; |
|
436 | 436 | |
437 | - // Check for download errors |
|
438 | - if ( is_wp_error( $tmp ) ) { |
|
439 | - unlink( $file_array[ 'tmp_name' ] ); |
|
440 | - error_log( $tmp->get_error_message() ); |
|
441 | - } |
|
437 | + // Check for download errors |
|
438 | + if ( is_wp_error( $tmp ) ) { |
|
439 | + unlink( $file_array[ 'tmp_name' ] ); |
|
440 | + error_log( $tmp->get_error_message() ); |
|
441 | + } |
|
442 | 442 | |
443 | 443 | // Pull the image into the media library |
444 | - $image_id = media_handle_sideload( $file_array, $post_id ); |
|
444 | + $image_id = media_handle_sideload( $file_array, $post_id ); |
|
445 | 445 | |
446 | - // Check for handle sideload errors. |
|
447 | - if ( is_wp_error( $image_id ) ) { |
|
448 | - unlink( $file_array['tmp_name'] ); |
|
449 | - error_log( $image_id->get_error_message() ); |
|
450 | - } |
|
446 | + // Check for handle sideload errors. |
|
447 | + if ( is_wp_error( $image_id ) ) { |
|
448 | + unlink( $file_array['tmp_name'] ); |
|
449 | + error_log( $image_id->get_error_message() ); |
|
450 | + } |
|
451 | 451 | |
452 | - return apply_filters( "tc_image_data", $image_id ); |
|
452 | + return apply_filters( "tc_image_data", $image_id ); |
|
453 | 453 | |
454 | 454 | } |
455 | 455 | |
@@ -472,9 +472,9 @@ discard block |
||
472 | 472 | |
473 | 473 | // If our cURL failed |
474 | 474 | if ( $curl_response === false ) { |
475 | - $info = curl_getinfo( $curl ); |
|
476 | - curl_close( $curl ); |
|
477 | - die( 'error occured during curl exec. Additional info: ' . var_export( $info ) ); |
|
475 | + $info = curl_getinfo( $curl ); |
|
476 | + curl_close( $curl ); |
|
477 | + die( 'error occured during curl exec. Additional info: ' . var_export( $info ) ); |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | curl_close( $curl ); |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | $char = "0123456789abcdefghijklmnopqrstuvwxyz"; |
621 | 621 | |
622 | 622 | $user_length = mt_rand( 5, 20 ); |
623 | - $domain_length = mt_rand( 7, 12 ); |
|
623 | + $domain_length = mt_rand( 7, 12 ); |
|
624 | 624 | |
625 | 625 | for ( $i = 1; $i <= $user_length; $i++ ){ |
626 | 626 | $user .= substr( $char, mt_rand( 0, strlen( $char ) ), 1 ); |
@@ -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 apply_filters( "tc_title_data", substr( $title, 0, -1 ) ); |
|
79 | + return apply_filters("tc_title_data", 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 | |
@@ -351,12 +351,12 @@ discard block |
||
351 | 351 | ); |
352 | 352 | |
353 | 353 | $used_keys = array(); |
354 | - for( $i = 1; $i < 7; $i++ ){ |
|
354 | + for ($i = 1; $i < 7; $i++) { |
|
355 | 355 | |
356 | 356 | // Pull a new random key and make sure we're not repeating any elements |
357 | - $key = rand( 0, 12 ); |
|
358 | - while( in_array( $key, $used_keys ) ){ |
|
359 | - $key = rand( 0, 12 ); |
|
357 | + $key = rand(0, 12); |
|
358 | + while (in_array($key, $used_keys)) { |
|
359 | + $key = rand(0, 12); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | $content .= $random_content_types[$key]; |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | $used_keys[] = $key; |
365 | 365 | } |
366 | 366 | |
367 | - return apply_filters( "tc_paragraphs_data", $content ); |
|
367 | + return apply_filters("tc_paragraphs_data", $content); |
|
368 | 368 | |
369 | 369 | } |
370 | 370 | |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | * |
377 | 377 | * @return string Plain text paragraphs. |
378 | 378 | */ |
379 | - public static function plain_text(){ |
|
379 | + public static function plain_text() { |
|
380 | 380 | |
381 | 381 | $paragraphs = array( |
382 | 382 | '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.', |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | '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.', |
392 | 392 | ); |
393 | 393 | |
394 | - return apply_filters( "tc_plain_text_data", $paragraphs[ rand( 0, 9 ) ] ); |
|
394 | + return apply_filters("tc_plain_text_data", $paragraphs[rand(0, 9)]); |
|
395 | 395 | |
396 | 396 | } |
397 | 397 | |
@@ -407,49 +407,49 @@ discard block |
||
407 | 407 | * @param int $post_id Post ID. |
408 | 408 | * @return mixed Attachment ID or WP Error. |
409 | 409 | */ |
410 | - public static function image( $post_id ){ |
|
410 | + public static function image($post_id) { |
|
411 | 411 | $file_array = array(); |
412 | 412 | |
413 | 413 | // Get the image from the API |
414 | 414 | $url = self::get_image_link(); |
415 | 415 | |
416 | 416 | // If the returned string is empty or it's not a string, try again. |
417 | - if ( empty( $url ) || !is_string( $url ) ){ |
|
417 | + if (empty($url) || !is_string($url)) { |
|
418 | 418 | |
419 | 419 | // Try again |
420 | 420 | $url = self::get_image_link(); |
421 | 421 | |
422 | 422 | // If it fails again, just give up |
423 | - if ( empty( $url ) || !is_string( $url ) ){ |
|
423 | + if (empty($url) || !is_string($url)) { |
|
424 | 424 | return; |
425 | 425 | } |
426 | 426 | |
427 | 427 | } |
428 | 428 | |
429 | 429 | // Download the file |
430 | - $tmp = \download_url( $url ); |
|
430 | + $tmp = \download_url($url); |
|
431 | 431 | |
432 | - preg_match( '/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches ); |
|
432 | + preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches); |
|
433 | 433 | |
434 | - $file_array['name'] = basename( $matches[0] ); |
|
434 | + $file_array['name'] = basename($matches[0]); |
|
435 | 435 | $file_array['tmp_name'] = $tmp; |
436 | 436 | |
437 | 437 | // Check for download errors |
438 | - if ( is_wp_error( $tmp ) ) { |
|
439 | - unlink( $file_array[ 'tmp_name' ] ); |
|
440 | - error_log( $tmp->get_error_message() ); |
|
438 | + if (is_wp_error($tmp)) { |
|
439 | + unlink($file_array['tmp_name']); |
|
440 | + error_log($tmp->get_error_message()); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | // Pull the image into the media library |
444 | - $image_id = media_handle_sideload( $file_array, $post_id ); |
|
444 | + $image_id = media_handle_sideload($file_array, $post_id); |
|
445 | 445 | |
446 | 446 | // Check for handle sideload errors. |
447 | - if ( is_wp_error( $image_id ) ) { |
|
448 | - unlink( $file_array['tmp_name'] ); |
|
449 | - error_log( $image_id->get_error_message() ); |
|
447 | + if (is_wp_error($image_id)) { |
|
448 | + unlink($file_array['tmp_name']); |
|
449 | + error_log($image_id->get_error_message()); |
|
450 | 450 | } |
451 | 451 | |
452 | - return apply_filters( "tc_image_data", $image_id ); |
|
452 | + return apply_filters("tc_image_data", $image_id); |
|
453 | 453 | |
454 | 454 | } |
455 | 455 | |
@@ -461,31 +461,31 @@ discard block |
||
461 | 461 | * |
462 | 462 | * @return string Image URL. |
463 | 463 | */ |
464 | - private static function get_image_link(){ |
|
464 | + private static function get_image_link() { |
|
465 | 465 | |
466 | 466 | // cURL an image API for a completely random photo |
467 | - $curl = curl_init( "http://www.splashbase.co/api/v1/images/random?images_only=true" ); |
|
467 | + $curl = curl_init("http://www.splashbase.co/api/v1/images/random?images_only=true"); |
|
468 | 468 | |
469 | - curl_setopt( $curl, CURLOPT_RETURNTRANSFER, TRUE ); |
|
469 | + curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); |
|
470 | 470 | |
471 | - $curl_response = curl_exec( $curl ); |
|
471 | + $curl_response = curl_exec($curl); |
|
472 | 472 | |
473 | 473 | // If our cURL failed |
474 | - if ( $curl_response === false ) { |
|
475 | - $info = curl_getinfo( $curl ); |
|
476 | - curl_close( $curl ); |
|
477 | - die( 'error occured during curl exec. Additional info: ' . var_export( $info ) ); |
|
474 | + if ($curl_response === false) { |
|
475 | + $info = curl_getinfo($curl); |
|
476 | + curl_close($curl); |
|
477 | + die('error occured during curl exec. Additional info: ' . var_export($info)); |
|
478 | 478 | } |
479 | 479 | |
480 | - curl_close( $curl ); |
|
480 | + curl_close($curl); |
|
481 | 481 | |
482 | 482 | // Decode the data |
483 | - $response = json_decode( $curl_response, true ); |
|
483 | + $response = json_decode($curl_response, true); |
|
484 | 484 | |
485 | 485 | // Check to make sure that the return contains a valid image extensions |
486 | 486 | preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $response['url'], $matches); |
487 | 487 | |
488 | - if ( !empty( $matches ) ){ |
|
488 | + if (!empty($matches)) { |
|
489 | 489 | return $response['url']; |
490 | 490 | } |
491 | 491 | |
@@ -500,12 +500,12 @@ discard block |
||
500 | 500 | * @param string $format PHP Date format. |
501 | 501 | * @return mixed Date in the format requested. |
502 | 502 | */ |
503 | - public static function date( $format ){ |
|
503 | + public static function date($format) { |
|
504 | 504 | |
505 | - $num_days = rand( 1, 60 ); |
|
506 | - $date = date( $format, strtotime( " +$num_days days" ) ); |
|
505 | + $num_days = rand(1, 60); |
|
506 | + $date = date($format, strtotime(" +$num_days days")); |
|
507 | 507 | |
508 | - return apply_filters( "tc_date_data", $date ); |
|
508 | + return apply_filters("tc_date_data", $date); |
|
509 | 509 | |
510 | 510 | } |
511 | 511 | |
@@ -517,19 +517,19 @@ discard block |
||
517 | 517 | * |
518 | 518 | * @return string Time string |
519 | 519 | */ |
520 | - public static function time(){ |
|
520 | + public static function time() { |
|
521 | 521 | |
522 | 522 | $times = array( |
523 | 523 | '8:00 am', |
524 | 524 | '5:00PM', |
525 | 525 | '13:00', |
526 | 526 | '2015', |
527 | - date( 'G:i', strtotime( " +".rand( 4, 24 )." hours" ) ), |
|
528 | - date( 'g:i', strtotime( " +".rand( 4, 24 )." hours" ) ), |
|
529 | - date( 'G:i A', strtotime( " +".rand( 4, 24 )." hours" ) ) |
|
527 | + date('G:i', strtotime(" +" . rand(4, 24) . " hours")), |
|
528 | + date('g:i', strtotime(" +" . rand(4, 24) . " hours")), |
|
529 | + date('G:i A', strtotime(" +" . rand(4, 24) . " hours")) |
|
530 | 530 | ); |
531 | 531 | |
532 | - return apply_filters( "tc_time_data", $times[ rand( 0, 6 ) ] ); |
|
532 | + return apply_filters("tc_time_data", $times[rand(0, 6)]); |
|
533 | 533 | |
534 | 534 | } |
535 | 535 | |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | * |
542 | 542 | * @return string Timezone |
543 | 543 | */ |
544 | - public static function timezone(){ |
|
544 | + public static function timezone() { |
|
545 | 545 | |
546 | 546 | $timezones = array( |
547 | 547 | 'America/Denver', |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | 'UTC' |
560 | 560 | ); |
561 | 561 | |
562 | - return apply_filters( "tc_timezone_data", $timezones[ rand( 0, 12 ) ] ); |
|
562 | + return apply_filters("tc_timezone_data", $timezones[rand(0, 12)]); |
|
563 | 563 | |
564 | 564 | } |
565 | 565 | |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | * |
573 | 573 | * @return string Phone #. |
574 | 574 | */ |
575 | - public static function phone(){ |
|
575 | + public static function phone() { |
|
576 | 576 | |
577 | 577 | $phone_numbers = array( |
578 | 578 | '7203893101', |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | '+43 780 0047112' |
589 | 589 | ); |
590 | 590 | |
591 | - return apply_filters( "tc_phone_data", $phone_numbers[ rand( 0, 10 ) ] ); |
|
591 | + return apply_filters("tc_phone_data", $phone_numbers[rand(0, 10)]); |
|
592 | 592 | |
593 | 593 | } |
594 | 594 | |
@@ -600,11 +600,11 @@ discard block |
||
600 | 600 | * |
601 | 601 | * @return string Email address. |
602 | 602 | */ |
603 | - public static function email( $superrandom = false ){ |
|
603 | + public static function email($superrandom = false) { |
|
604 | 604 | |
605 | 605 | // In certain situations we need to ensure that the email is never |
606 | 606 | // duplicated, like in creating new users. |
607 | - if ( $superrandom !== false ){ |
|
607 | + if ($superrandom !== false) { |
|
608 | 608 | $user = $domain = ''; |
609 | 609 | |
610 | 610 | $tlds = array( |
@@ -619,18 +619,18 @@ discard block |
||
619 | 619 | |
620 | 620 | $char = "0123456789abcdefghijklmnopqrstuvwxyz"; |
621 | 621 | |
622 | - $user_length = mt_rand( 5, 20 ); |
|
623 | - $domain_length = mt_rand( 7, 12 ); |
|
622 | + $user_length = mt_rand(5, 20); |
|
623 | + $domain_length = mt_rand(7, 12); |
|
624 | 624 | |
625 | - for ( $i = 1; $i <= $user_length; $i++ ){ |
|
626 | - $user .= substr( $char, mt_rand( 0, strlen( $char ) ), 1 ); |
|
625 | + for ($i = 1; $i <= $user_length; $i++) { |
|
626 | + $user .= substr($char, mt_rand(0, strlen($char)), 1); |
|
627 | 627 | } |
628 | 628 | |
629 | - for ( $i = 1; $i <= $domain_length; $i++ ){ |
|
630 | - $domain .= substr( $char, mt_rand( 0, strlen( $char ) ), 1 ); |
|
629 | + for ($i = 1; $i <= $domain_length; $i++) { |
|
630 | + $domain .= substr($char, mt_rand(0, strlen($char)), 1); |
|
631 | 631 | } |
632 | 632 | |
633 | - $tld = $tlds[ mt_rand( 0, ( sizeof( $tlds ) - 1 ) ) ]; |
|
633 | + $tld = $tlds[mt_rand(0, (sizeof($tlds) - 1))]; |
|
634 | 634 | |
635 | 635 | $email = $user . "@" . $domain . '.' . $tld; |
636 | 636 | |
@@ -647,12 +647,12 @@ discard block |
||
647 | 647 | '[email protected]' |
648 | 648 | ); |
649 | 649 | |
650 | - $email = $email_addresses[ rand( 0, 7 ) ]; |
|
650 | + $email = $email_addresses[rand(0, 7)]; |
|
651 | 651 | |
652 | 652 | } |
653 | 653 | |
654 | 654 | |
655 | - return apply_filters( "tc_email_data", $email ); |
|
655 | + return apply_filters("tc_email_data", $email); |
|
656 | 656 | |
657 | 657 | } |
658 | 658 | |
@@ -666,12 +666,12 @@ discard block |
||
666 | 666 | * |
667 | 667 | * @return string URL. |
668 | 668 | */ |
669 | - public static function link(){ |
|
669 | + public static function link() { |
|
670 | 670 | |
671 | 671 | $links = array( |
672 | 672 | 'http://google.com', |
673 | 673 | 'https://www.twitter.com', |
674 | - site_url( '/?iam=anextravariable' ), |
|
674 | + site_url('/?iam=anextravariable'), |
|
675 | 675 | 'github.com', |
676 | 676 | 'http://filebase.com', |
677 | 677 | 'www.oldtownmediainc.com', |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | 'https://www.eff.org' |
680 | 680 | ); |
681 | 681 | |
682 | - return apply_filters( "tc_link_data", $links[ rand( 0, 7 ) ] ); |
|
682 | + return apply_filters("tc_link_data", $links[rand(0, 7)]); |
|
683 | 683 | |
684 | 684 | } |
685 | 685 | |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | * |
691 | 691 | * @return string URL. |
692 | 692 | */ |
693 | - public static function oembed(){ |
|
693 | + public static function oembed() { |
|
694 | 694 | |
695 | 695 | $links = array( |
696 | 696 | 'https://www.youtube.com/watch?v=A85-YQsm6pY', |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | 'https://www.instagram.com/p/-eyLo0RMfX', |
702 | 702 | ); |
703 | 703 | |
704 | - return apply_filters( "tc_oembed_data", $links[ rand( 0, 5 ) ] ); |
|
704 | + return apply_filters("tc_oembed_data", $links[rand(0, 5)]); |
|
705 | 705 | |
706 | 706 | } |
707 | 707 | |
@@ -715,10 +715,10 @@ discard block |
||
715 | 715 | * @param string $type Video service to get link from |
716 | 716 | * @return string URL. |
717 | 717 | */ |
718 | - public static function video( $type ){ |
|
718 | + public static function video($type) { |
|
719 | 719 | |
720 | 720 | // Switch through our video types. Expecting to add more in the future |
721 | - switch( $type ){ |
|
721 | + switch ($type) { |
|
722 | 722 | |
723 | 723 | // YouTube videos |
724 | 724 | case 'youtube' : |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | |
760 | 760 | } |
761 | 761 | |
762 | - return apply_filters( "tc_video_data", $links[ rand( 0, 8 ) ] ); |
|
762 | + return apply_filters("tc_video_data", $links[rand(0, 8)]); |
|
763 | 763 | |
764 | 764 | } |
765 | 765 | |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | * |
771 | 771 | * @return array Randomly strung together name. |
772 | 772 | */ |
773 | - public static function name(){ |
|
773 | + public static function name() { |
|
774 | 774 | |
775 | 775 | $first_names = array( |
776 | 776 | 'Jacqui', |
@@ -819,11 +819,11 @@ discard block |
||
819 | 819 | ); |
820 | 820 | |
821 | 821 | $name = array( |
822 | - 'first' => $first_names[ rand( 0, 19 ) ], |
|
823 | - 'last' => $last_names[ rand( 0, 19 ) ] |
|
822 | + 'first' => $first_names[rand(0, 19)], |
|
823 | + 'last' => $last_names[rand(0, 19)] |
|
824 | 824 | ); |
825 | 825 | |
826 | - return apply_filters( "tc_name_data", $name ); |
|
826 | + return apply_filters("tc_name_data", $name); |
|
827 | 827 | |
828 | 828 | } |
829 | 829 |
@@ -130,8 +130,8 @@ |
||
130 | 130 | } else { |
131 | 131 | // We didn't get a reponse so print the notice out |
132 | 132 | echo '<div class="notice notice-error">'; |
133 | - 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.', 'dummybot' ).'</p>'; |
|
134 | - echo '</div>'; |
|
133 | + 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.', 'dummybot' ).'</p>'; |
|
134 | + echo '</div>'; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | } |
@@ -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,15 +45,15 @@ 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_filter( 'plugin_action_links_' . $this->definitions->basename , array( $this, 'add_settings_link' ) ); |
|
56 | - add_action( 'admin_notices', array( $this, 'internet_connected_admin_notice' ) ); |
|
54 | + add_action('admin_menu', array($this, 'add_menu_item')); |
|
55 | + add_filter('plugin_action_links_' . $this->definitions->basename, array($this, 'add_settings_link')); |
|
56 | + add_action('admin_notices', array($this, 'internet_connected_admin_notice')); |
|
57 | 57 | |
58 | 58 | } |
59 | 59 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @param Plugin $plugin Main plugin instance. |
65 | 65 | */ |
66 | - public function set_plugin( $plugin ) { |
|
66 | + public function set_plugin($plugin) { |
|
67 | 67 | |
68 | 68 | $this->plugin = $plugin; |
69 | 69 | return $this; |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | |
81 | 81 | $page = add_submenu_page( |
82 | 82 | 'tools.php', |
83 | - __( 'Create Dummy Content', 'dummybot' ), |
|
84 | - __( 'DummyBot', 'dummybot' ), |
|
83 | + __('Create Dummy Content', 'dummybot'), |
|
84 | + __('DummyBot', 'dummybot'), |
|
85 | 85 | 'manage_options', |
86 | 86 | 'create-test-data', |
87 | - array( $this, 'admin_page' ) |
|
87 | + array($this, 'admin_page') |
|
88 | 88 | ); |
89 | 89 | |
90 | - add_action( 'admin_print_styles-' . $page, array( $this, 'load_scripts' ) ); |
|
90 | + add_action('admin_print_styles-' . $page, array($this, 'load_scripts')); |
|
91 | 91 | |
92 | 92 | } |
93 | 93 | |
@@ -97,10 +97,10 @@ discard block |
||
97 | 97 | * @param array $links Existing links |
98 | 98 | * @return array Modified links |
99 | 99 | */ |
100 | - public function add_settings_link( $links ) { |
|
100 | + public function add_settings_link($links) { |
|
101 | 101 | |
102 | - $settings_link = '<a href="tools.php?page=create-test-data">' . __( 'Build Test Content', 'dummybot' ) . '</a>'; |
|
103 | - array_push( $links, $settings_link ); |
|
102 | + $settings_link = '<a href="tools.php?page=create-test-data">' . __('Build Test Content', 'dummybot') . '</a>'; |
|
103 | + array_push($links, $settings_link); |
|
104 | 104 | return $links; |
105 | 105 | |
106 | 106 | } |
@@ -113,24 +113,24 @@ discard block |
||
113 | 113 | * Internet, and the test fails displays a notice informing the user that |
114 | 114 | * images will not pull into test data. |
115 | 115 | */ |
116 | - public function internet_connected_admin_notice(){ |
|
116 | + public function internet_connected_admin_notice() { |
|
117 | 117 | |
118 | 118 | // Get the current admin screen & verify that we're on the right one |
119 | 119 | // before continuing. |
120 | 120 | $screen = get_current_screen(); |
121 | 121 | |
122 | - if ( $screen->base != 'tools_page_create-test-data' ){ |
|
122 | + if ($screen->base != 'tools_page_create-test-data') { |
|
123 | 123 | return; |
124 | 124 | } |
125 | 125 | |
126 | 126 | // Check the response |
127 | - if ( $this->connected ) { |
|
127 | + if ($this->connected) { |
|
128 | 128 | // We got a response so early return |
129 | 129 | return; |
130 | 130 | } else { |
131 | 131 | // We didn't get a reponse so print the notice out |
132 | 132 | echo '<div class="notice notice-error">'; |
133 | - 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.', 'dummybot' ).'</p>'; |
|
133 | + 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.', 'dummybot') . '</p>'; |
|
134 | 134 | echo '</div>'; |
135 | 135 | } |
136 | 136 | |
@@ -140,21 +140,21 @@ discard block |
||
140 | 140 | /** |
141 | 141 | * Load our script in the admin section and serve in data. |
142 | 142 | */ |
143 | - public function load_scripts(){ |
|
143 | + public function load_scripts() { |
|
144 | 144 | |
145 | - wp_enqueue_script( 'test-content-js', plugins_url( 'assets/admin.js' , dirname( __FILE__ ) ) ); |
|
146 | - wp_enqueue_style( 'test-content-css', plugins_url( 'assets/admin.css' , dirname( __FILE__ ) ) ); |
|
145 | + wp_enqueue_script('test-content-js', plugins_url('assets/admin.js', dirname(__FILE__))); |
|
146 | + wp_enqueue_style('test-content-css', plugins_url('assets/admin.css', dirname(__FILE__))); |
|
147 | 147 | |
148 | 148 | $data = array( |
149 | - 'nonce' => wp_create_nonce( 'handle-test-data' ), |
|
149 | + 'nonce' => wp_create_nonce('handle-test-data'), |
|
150 | 150 | 'strings' => array( |
151 | - 'createdStr' => __( 'Created', 'dummybot' ), |
|
152 | - 'deletedStr' => __( 'Deleting', 'dummybot' ), |
|
153 | - 'creatingStr' => __( 'Creating', 'dummybot' ), |
|
151 | + 'createdStr' => __('Created', 'dummybot'), |
|
152 | + 'deletedStr' => __('Deleting', 'dummybot'), |
|
153 | + 'creatingStr' => __('Creating', 'dummybot'), |
|
154 | 154 | ), |
155 | 155 | ); |
156 | 156 | |
157 | - wp_localize_script( 'test-content-js', 'test_content', $data ); |
|
157 | + wp_localize_script('test-content-js', 'test_content', $data); |
|
158 | 158 | |
159 | 159 | } |
160 | 160 | |
@@ -162,24 +162,24 @@ discard block |
||
162 | 162 | /** |
163 | 163 | * Print out our admin page to control test data. |
164 | 164 | */ |
165 | - public function admin_page(){ |
|
165 | + public function admin_page() { |
|
166 | 166 | echo '<div class="wrap" id="options_editor">' . "\n"; |
167 | 167 | |
168 | - echo '<h2>' . __( 'Create Test Data' , 'dummybot' ) . '</h2>' . "\n"; |
|
168 | + echo '<h2>' . __('Create Test Data', 'dummybot') . '</h2>' . "\n"; |
|
169 | 169 | |
170 | 170 | echo "<div class='nav-tab-wrapper'>"; |
171 | 171 | |
172 | - do_action( 'tc-admin-tabs', '' ); |
|
172 | + do_action('tc-admin-tabs', ''); |
|
173 | 173 | |
174 | 174 | echo "</div>"; |
175 | 175 | |
176 | 176 | echo ""; |
177 | 177 | |
178 | - do_action( 'tc-admin-sections', '' ); |
|
178 | + do_action('tc-admin-sections', ''); |
|
179 | 179 | |
180 | 180 | echo ""; |
181 | 181 | |
182 | - echo "<input type='hidden' id='connection-status' value='".$this->connected."'>"; |
|
182 | + echo "<input type='hidden' id='connection-status' value='" . $this->connected . "'>"; |
|
183 | 183 | |
184 | 184 | echo "<pre class='test-data-status-box' id='status-updates'></pre>"; |
185 | 185 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage Evans |
9 | 9 | * @author Old Town Media |
10 | 10 | */ |
11 | -class MetaboxValues{ |
|
11 | +class MetaboxValues { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Assigns the proper testing data to a custom metabox. |
@@ -22,61 +22,61 @@ discard block |
||
22 | 22 | * @param int $post_id Single post ID. |
23 | 23 | * @param array $cmb custom metabox array from CMB2. |
24 | 24 | */ |
25 | - public function get_values( $post_id, $cmb, $connected ){ |
|
25 | + public function get_values($post_id, $cmb, $connected) { |
|
26 | 26 | $value = ''; |
27 | 27 | |
28 | 28 | // First check that our post ID & cmb array aren't empty |
29 | - if ( empty( $cmb ) || empty( $post_id ) || ! is_user_logged_in() ){ |
|
29 | + if (empty($cmb) || empty($post_id) || !is_user_logged_in()) { |
|
30 | 30 | return; |
31 | 31 | } |
32 | 32 | |
33 | 33 | // Fetch the appropriate type of data and return |
34 | - switch( $cmb['type'] ){ |
|
34 | + switch ($cmb['type']) { |
|
35 | 35 | |
36 | 36 | case 'text': |
37 | 37 | case 'text_small': |
38 | 38 | case 'text_medium': |
39 | 39 | |
40 | - $value = $this->text( $cmb ); |
|
40 | + $value = $this->text($cmb); |
|
41 | 41 | |
42 | 42 | break; |
43 | 43 | |
44 | 44 | case 'text_url': |
45 | 45 | |
46 | - $value = $this->url( $cmb ); |
|
46 | + $value = $this->url($cmb); |
|
47 | 47 | |
48 | 48 | break; |
49 | 49 | |
50 | 50 | case 'text_email' : |
51 | 51 | case 'email': |
52 | 52 | |
53 | - $value = $this->email( $cmb ); |
|
53 | + $value = $this->email($cmb); |
|
54 | 54 | |
55 | 55 | break; |
56 | 56 | |
57 | 57 | case 'number' : |
58 | 58 | case 'text_money': |
59 | 59 | |
60 | - $value = $this->number( $cmb ); |
|
60 | + $value = $this->number($cmb); |
|
61 | 61 | |
62 | 62 | break; |
63 | 63 | |
64 | 64 | case 'text_time': |
65 | 65 | case 'time': |
66 | 66 | |
67 | - $value = $this->time( $cmb ); |
|
67 | + $value = $this->time($cmb); |
|
68 | 68 | |
69 | 69 | break; |
70 | 70 | |
71 | 71 | case 'select_timezone': |
72 | 72 | |
73 | - $value = $this->timezone( $cmb ); |
|
73 | + $value = $this->timezone($cmb); |
|
74 | 74 | |
75 | 75 | break; |
76 | 76 | |
77 | 77 | case 'text_date': |
78 | 78 | |
79 | - $value = $this->date( $cmb ); |
|
79 | + $value = $this->date($cmb); |
|
80 | 80 | |
81 | 81 | break; |
82 | 82 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | case 'date_unix': |
86 | 86 | case 'datetime_unix': |
87 | 87 | |
88 | - $value = $this->timestamp( $cmb ); |
|
88 | + $value = $this->timestamp($cmb); |
|
89 | 89 | |
90 | 90 | break; |
91 | 91 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | |
94 | 94 | case 'test_colorpicker': |
95 | 95 | |
96 | - $value = $this->color( $cmb ); |
|
96 | + $value = $this->color($cmb); |
|
97 | 97 | |
98 | 98 | break; |
99 | 99 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | case 'textarea_small': |
102 | 102 | case 'textarea_code': |
103 | 103 | |
104 | - $value = $this->textarea( $cmb ); |
|
104 | + $value = $this->textarea($cmb); |
|
105 | 105 | |
106 | 106 | break; |
107 | 107 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | case 'radio_inline': |
110 | 110 | case 'radio': |
111 | 111 | |
112 | - $value = $this->radio( $cmb ); |
|
112 | + $value = $this->radio($cmb); |
|
113 | 113 | |
114 | 114 | break; |
115 | 115 | |
@@ -119,30 +119,30 @@ discard block |
||
119 | 119 | |
120 | 120 | case 'checkbox': |
121 | 121 | |
122 | - if ( isset( $cmb['source'] ) && 'acf' === $cmb['source'] ){ |
|
123 | - $value = $this->multicheck( $cmb ); |
|
122 | + if (isset($cmb['source']) && 'acf' === $cmb['source']) { |
|
123 | + $value = $this->multicheck($cmb); |
|
124 | 124 | } else { |
125 | - $value = $this->checkbox( $cmb ); |
|
125 | + $value = $this->checkbox($cmb); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | break; |
129 | 129 | |
130 | 130 | case 'multicheck': |
131 | 131 | |
132 | - $value = $this->multicheck( $cmb ); |
|
132 | + $value = $this->multicheck($cmb); |
|
133 | 133 | |
134 | 134 | break; |
135 | 135 | |
136 | 136 | case 'wysiwyg': |
137 | 137 | |
138 | - $value = $this->wysiwyg( $cmb ); |
|
138 | + $value = $this->wysiwyg($cmb); |
|
139 | 139 | |
140 | 140 | break; |
141 | 141 | |
142 | 142 | case 'file': |
143 | 143 | case 'image': |
144 | 144 | |
145 | - $value = $this->file( $cmb, $post_id, $connected ); |
|
145 | + $value = $this->file($cmb, $post_id, $connected); |
|
146 | 146 | |
147 | 147 | break; |
148 | 148 | |
@@ -150,19 +150,19 @@ discard block |
||
150 | 150 | |
151 | 151 | case 'oembed': |
152 | 152 | |
153 | - $value = $this->oembed( $cmb ); |
|
153 | + $value = $this->oembed($cmb); |
|
154 | 154 | |
155 | 155 | break; |
156 | 156 | |
157 | 157 | } |
158 | 158 | |
159 | 159 | // Value must exist to attempt to insert |
160 | - if ( ! empty( $value ) && ! is_wp_error( $value ) ){ |
|
160 | + if (!empty($value) && !is_wp_error($value)) { |
|
161 | 161 | |
162 | - $this->update_meta( $post_id, $value, $cmb ); |
|
162 | + $this->update_meta($post_id, $value, $cmb); |
|
163 | 163 | |
164 | 164 | // If we're dealing with a WP Error object, just return the message for debugging |
165 | - } elseif ( is_wp_error( $value ) ){ |
|
165 | + } elseif (is_wp_error($value)) { |
|
166 | 166 | |
167 | 167 | return $value->get_error_message(); |
168 | 168 | |
@@ -179,27 +179,27 @@ discard block |
||
179 | 179 | * @param array $cmb Metabox data |
180 | 180 | * @return string cmb value |
181 | 181 | */ |
182 | - private function text( $cmb ){ |
|
182 | + private function text($cmb) { |
|
183 | 183 | |
184 | 184 | // If phone is in the id, fetch a phone # |
185 | - if ( stripos( $cmb['id'], 'phone' ) ){ |
|
185 | + if (stripos($cmb['id'], 'phone')) { |
|
186 | 186 | $value = TestContent::phone(); |
187 | 187 | |
188 | 188 | // If email is in the id, fetch an email address |
189 | - } elseif ( stripos( $cmb['id'], 'email' ) ){ |
|
189 | + } elseif (stripos($cmb['id'], 'email')) { |
|
190 | 190 | $value = TestContent::email(); |
191 | 191 | |
192 | 192 | // If time is in the id, fetch a time string |
193 | - } elseif ( stripos( $cmb['id'], 'time' ) ){ |
|
193 | + } elseif (stripos($cmb['id'], 'time')) { |
|
194 | 194 | $value = TestContent::time(); |
195 | 195 | |
196 | 196 | // Otherwise, just a random text string |
197 | 197 | } else { |
198 | - $value = TestContent::title( rand( 10, 50 ) ); |
|
198 | + $value = TestContent::title(rand(10, 50)); |
|
199 | 199 | } |
200 | 200 | |
201 | - if ( 'acf' === $cmb['source'] && !empty( $cmb['extras']->chars ) ){ |
|
202 | - $value = substr( $value, 0, $cmb['extras']->chars ); |
|
201 | + if ('acf' === $cmb['source'] && !empty($cmb['extras']->chars)) { |
|
202 | + $value = substr($value, 0, $cmb['extras']->chars); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | return $value; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * @param array $cmb Metabox data |
216 | 216 | * @return string cmb value |
217 | 217 | */ |
218 | - private function url( $cmb ){ |
|
218 | + private function url($cmb) { |
|
219 | 219 | |
220 | 220 | return TestContent::link(); |
221 | 221 | |
@@ -230,9 +230,9 @@ discard block |
||
230 | 230 | * @param array $cmb Metabox data |
231 | 231 | * @return string cmb value |
232 | 232 | */ |
233 | - private function email( $cmb ){ |
|
233 | + private function email($cmb) { |
|
234 | 234 | |
235 | - return TestContent::email();; |
|
235 | + return TestContent::email(); ; |
|
236 | 236 | |
237 | 237 | } |
238 | 238 | |
@@ -243,20 +243,20 @@ discard block |
||
243 | 243 | * @param array $cmb Metabox data |
244 | 244 | * @return int cmb value |
245 | 245 | */ |
246 | - private function number( $cmb ){ |
|
246 | + private function number($cmb) { |
|
247 | 247 | |
248 | 248 | $min = 1; |
249 | 249 | $max = 10000000; |
250 | 250 | |
251 | - if ( 'acf' == $cmb['source'] && !empty( $cmb['extras']->min ) ){ |
|
251 | + if ('acf' == $cmb['source'] && !empty($cmb['extras']->min)) { |
|
252 | 252 | $min = $cmb['extras']->min; |
253 | 253 | } |
254 | 254 | |
255 | - if ( 'acf' == $cmb['source'] && !empty( $cmb['extras']->max ) ){ |
|
255 | + if ('acf' == $cmb['source'] && !empty($cmb['extras']->max)) { |
|
256 | 256 | $max = $cmb['extras']->max; |
257 | 257 | } |
258 | 258 | |
259 | - return rand( $min, $max ); |
|
259 | + return rand($min, $max); |
|
260 | 260 | |
261 | 261 | } |
262 | 262 | |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * @param array $cmb Metabox data |
270 | 270 | * @return string cmb value |
271 | 271 | */ |
272 | - private function time( $cmb ){ |
|
272 | + private function time($cmb) { |
|
273 | 273 | |
274 | 274 | return TestContent::time(); |
275 | 275 | |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * @param array $cmb Metabox data |
285 | 285 | * @return string cmb value |
286 | 286 | */ |
287 | - private function timezone( $cmb ){ |
|
287 | + private function timezone($cmb) { |
|
288 | 288 | |
289 | 289 | return TestContent::timezone(); |
290 | 290 | |
@@ -299,9 +299,9 @@ discard block |
||
299 | 299 | * @param array $cmb Metabox data |
300 | 300 | * @return string cmb value |
301 | 301 | */ |
302 | - private function date( $cmb ){ |
|
302 | + private function date($cmb) { |
|
303 | 303 | |
304 | - return TestContent::date( 'm/d/Y' ); |
|
304 | + return TestContent::date('m/d/Y'); |
|
305 | 305 | |
306 | 306 | } |
307 | 307 | |
@@ -314,9 +314,9 @@ discard block |
||
314 | 314 | * @param array $cmb Metabox data |
315 | 315 | * @return string cmb value |
316 | 316 | */ |
317 | - private function timestamp( $cmb ){ |
|
317 | + private function timestamp($cmb) { |
|
318 | 318 | |
319 | - return TestContent::date( 'U' ); |
|
319 | + return TestContent::date('U'); |
|
320 | 320 | |
321 | 321 | } |
322 | 322 | |
@@ -327,9 +327,9 @@ discard block |
||
327 | 327 | * @param array $cmb Metabox data |
328 | 328 | * @return string cmb value |
329 | 329 | */ |
330 | - private function color( $cmb ){ |
|
330 | + private function color($cmb) { |
|
331 | 331 | |
332 | - return '#' . str_pad( dechex( mt_rand( 0, 0xFFFFFF ) ), 6, '0', STR_PAD_LEFT ); |
|
332 | + return '#' . str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT); |
|
333 | 333 | |
334 | 334 | } |
335 | 335 | |
@@ -342,12 +342,12 @@ discard block |
||
342 | 342 | * @param array $cmb Metabox data |
343 | 343 | * @return string cmb value |
344 | 344 | */ |
345 | - private function textarea( $cmb ){ |
|
345 | + private function textarea($cmb) { |
|
346 | 346 | |
347 | 347 | $value = TestContent::plain_text(); |
348 | 348 | |
349 | - if ( 'acf' == $cmb['source'] && !empty( $cmb['extras']->chars ) ){ |
|
350 | - $value = substr( $value, 0, $cmb['extras']->chars ); |
|
349 | + if ('acf' == $cmb['source'] && !empty($cmb['extras']->chars)) { |
|
350 | + $value = substr($value, 0, $cmb['extras']->chars); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | return $value; |
@@ -363,11 +363,11 @@ discard block |
||
363 | 363 | * @param array $cmb Metabox data |
364 | 364 | * @return string cmb value |
365 | 365 | */ |
366 | - private function radio( $cmb ){ |
|
366 | + private function radio($cmb) { |
|
367 | 367 | |
368 | 368 | // Grab a random item out of the array and return the key |
369 | - $new_val = array_slice( $cmb['options'], rand( 0, count( $cmb['options'] ) ), 1 ); |
|
370 | - $value = key( $new_val ); |
|
369 | + $new_val = array_slice($cmb['options'], rand(0, count($cmb['options'])), 1); |
|
370 | + $value = key($new_val); |
|
371 | 371 | |
372 | 372 | return $value; |
373 | 373 | |
@@ -382,11 +382,11 @@ discard block |
||
382 | 382 | * @param array $cmb Metabox data |
383 | 383 | * @return string cmb value |
384 | 384 | */ |
385 | - private function checkbox( $cmb ){ |
|
385 | + private function checkbox($cmb) { |
|
386 | 386 | $value = ''; |
387 | 387 | |
388 | 388 | // 50/50 odds of being turned on |
389 | - if ( rand( 0, 1 ) == 1 ){ |
|
389 | + if (rand(0, 1) == 1) { |
|
390 | 390 | $value = 'on'; |
391 | 391 | } |
392 | 392 | |
@@ -403,15 +403,15 @@ discard block |
||
403 | 403 | * @param array $cmb Metabox data |
404 | 404 | * @return array cmb value |
405 | 405 | */ |
406 | - private function multicheck( $cmb ){ |
|
406 | + private function multicheck($cmb) { |
|
407 | 407 | |
408 | 408 | $new_option = array(); |
409 | 409 | |
410 | 410 | // Loop through each of our options |
411 | - foreach ( $cmb['options'] as $key => $value ){ |
|
411 | + foreach ($cmb['options'] as $key => $value) { |
|
412 | 412 | |
413 | 413 | // 50/50 chance of being included |
414 | - if ( rand( 0, 1 ) ){ |
|
414 | + if (rand(0, 1)) { |
|
415 | 415 | $new_option[] = $key; |
416 | 416 | } |
417 | 417 | |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | * @param array $cmb Metabox data |
431 | 431 | * @return string cmb value |
432 | 432 | */ |
433 | - private function wysiwyg( $cmb ){ |
|
433 | + private function wysiwyg($cmb) { |
|
434 | 434 | |
435 | 435 | return TestContent::paragraphs(); |
436 | 436 | |
@@ -447,11 +447,11 @@ discard block |
||
447 | 447 | * @param bool $connected Whether we're connected to the Internets or not |
448 | 448 | * @return mixed string|object cmb value or WP_Error object |
449 | 449 | */ |
450 | - private function file( $cmb, $post_id, $connected ){ |
|
450 | + private function file($cmb, $post_id, $connected) { |
|
451 | 451 | $value = ''; |
452 | 452 | |
453 | - if ( true === $connected ){ |
|
454 | - $value = TestContent::image( $post_id ); |
|
453 | + if (true === $connected) { |
|
454 | + $value = TestContent::image($post_id); |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | return $value; |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | * @param array $cmb Metabox data |
468 | 468 | * @return string cmb value |
469 | 469 | */ |
470 | - private function oembed( $cmb ){ |
|
470 | + private function oembed($cmb) { |
|
471 | 471 | |
472 | 472 | return TestContent::oembed(); |
473 | 473 | |
@@ -485,25 +485,25 @@ discard block |
||
485 | 485 | * @param string $value Value to add into the database. |
486 | 486 | * @param array $cmb SMB data. |
487 | 487 | */ |
488 | - private function update_meta( $post_id, $value, $cmb ){ |
|
488 | + private function update_meta($post_id, $value, $cmb) { |
|
489 | 489 | |
490 | 490 | $type = $cmb['type']; |
491 | - $id = $cmb['id']; |
|
492 | - $value = apply_filters( "tc_{$type}_metabox", $value ); // Filter by metabox type |
|
493 | - $value = apply_filters( "tc_{$id}_metabox", $value ); // Filter by metabox ID |
|
491 | + $id = $cmb['id']; |
|
492 | + $value = apply_filters("tc_{$type}_metabox", $value); // Filter by metabox type |
|
493 | + $value = apply_filters("tc_{$id}_metabox", $value); // Filter by metabox ID |
|
494 | 494 | |
495 | 495 | // Files must be treated separately - they use the attachment ID |
496 | 496 | // & url of media for separate cmb values. (only in cmb1 & cmb2 though) |
497 | - if ( 'file'!== $cmb['type'] || ( 'file' === $cmb['type'] && 'cmb_hm' === $cmb['source'] ) ){ |
|
498 | - add_post_meta( $post_id, $cmb['id'], $value, true ); |
|
497 | + if ('file' !== $cmb['type'] || ('file' === $cmb['type'] && 'cmb_hm' === $cmb['source'])) { |
|
498 | + add_post_meta($post_id, $cmb['id'], $value, true); |
|
499 | 499 | } else { |
500 | - add_post_meta( $post_id, $cmb['id'].'_id', $value, true ); |
|
501 | - add_post_meta( $post_id, $cmb['id'], wp_get_attachment_url( $value ), true ); |
|
500 | + add_post_meta($post_id, $cmb['id'] . '_id', $value, true); |
|
501 | + add_post_meta($post_id, $cmb['id'], wp_get_attachment_url($value), true); |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | // Add extra, redundant meta. Because, why not have two rows for the price of one? |
505 | - if ( isset( $cmb['source'] ) && 'acf' === $cmb['source'] ){ |
|
506 | - add_post_meta( $post_id, '_' . $cmb['id'], $cmb['key'], true ); |
|
505 | + if (isset($cmb['source']) && 'acf' === $cmb['source']) { |
|
506 | + add_post_meta($post_id, '_' . $cmb['id'], $cmb['key'], true); |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | } |