@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @subpackage Test Content |
10 | 10 | * @author Old Town Media |
11 | 11 | */ |
12 | -abstract class Type{ |
|
12 | +abstract class Type { |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * type |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * Registers the type with the rest of the plugin |
35 | 35 | */ |
36 | - public function register_type(){ |
|
36 | + public function register_type() { |
|
37 | 37 | |
38 | 38 | add_filter( 'tc-types', array( $this, 'set_type' ) ); |
39 | 39 | |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | * @param array $types Original types array |
47 | 47 | * @return array Modified types array with our current type |
48 | 48 | */ |
49 | - public function set_type( $types ){ |
|
49 | + public function set_type( $types ) { |
|
50 | 50 | |
51 | - $types[] = $this->type; |
|
51 | + $types[ ] = $this->type; |
|
52 | 52 | return $types; |
53 | 53 | |
54 | 54 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @subpackage Test Content |
10 | 10 | * @author Old Town Media |
11 | 11 | */ |
12 | -abstract class Type{ |
|
12 | +abstract class Type { |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * type |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * Registers the type with the rest of the plugin |
35 | 35 | */ |
36 | - public function register_type(){ |
|
36 | + public function register_type() { |
|
37 | 37 | |
38 | 38 | add_filter( 'tc-types', array( $this, 'set_type' ) ); |
39 | 39 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param array $types Original types array |
47 | 47 | * @return array Modified types array with our current type |
48 | 48 | */ |
49 | - public function set_type( $types ){ |
|
49 | + public function set_type( $types ) { |
|
50 | 50 | |
51 | 51 | $types[] = $this->type; |
52 | 52 | return $types; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @subpackage Test Content |
11 | 11 | * @author Old Town Media |
12 | 12 | */ |
13 | -abstract class View{ |
|
13 | +abstract class View { |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * title |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @see tab, view |
46 | 46 | */ |
47 | - public function register_view(){ |
|
47 | + public function register_view() { |
|
48 | 48 | |
49 | 49 | add_action( 'tc-admin-tabs', array( $this, 'tab' ), $this->priority ); |
50 | 50 | add_action( 'tc-admin-sections', array( $this, 'view' ), $this->priority ); |
@@ -58,10 +58,10 @@ discard block |
||
58 | 58 | * Each view has a tab and tab navigation - this function compiles our |
59 | 59 | * navigation tab. Rarely extended. |
60 | 60 | */ |
61 | - public function tab(){ |
|
61 | + public function tab() { |
|
62 | 62 | $html = ""; |
63 | 63 | |
64 | - $html .= "<a class='nav-tab' data-type='".sanitize_title( $this->title )."' href='javascript:void(0)'>"; |
|
64 | + $html .= "<a class='nav-tab' data-type='" . sanitize_title( $this->title ) . "' href='javascript:void(0)'>"; |
|
65 | 65 | $html .= $this->title; |
66 | 66 | $html .= "</a>"; |
67 | 67 | |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @see actions_section, options_section |
80 | 80 | */ |
81 | - public function view(){ |
|
81 | + public function view() { |
|
82 | 82 | $html = ''; |
83 | 83 | |
84 | - $html .= "<section class='test-content-tab' data-type='".sanitize_title( $this->title )."'>"; |
|
84 | + $html .= "<section class='test-content-tab' data-type='" . sanitize_title( $this->title ) . "'>"; |
|
85 | 85 | $html .= $this->actions_section(); |
86 | 86 | $html .= $this->options_section(); |
87 | 87 | $html .= "</section>"; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @return string HTML content. |
100 | 100 | */ |
101 | - protected function actions_section(){ |
|
101 | + protected function actions_section() { |
|
102 | 102 | $html = ''; |
103 | 103 | return $html; |
104 | 104 | } |
@@ -115,13 +115,13 @@ discard block |
||
115 | 115 | * @param string $html Existing HTML content. |
116 | 116 | * @return string HTML section content. |
117 | 117 | */ |
118 | - protected function options_section( $html = '' ){ |
|
118 | + protected function options_section( $html = '' ) { |
|
119 | 119 | $html .= "<hr>"; |
120 | 120 | |
121 | 121 | $html .= "<div class='test-data-cpt'>"; |
122 | 122 | $html .= "<h3>"; |
123 | - $html .= "<span class='label'>".__( 'Quantity', 'dummybot' )."</span>"; |
|
124 | - $html .= "<input type='number' value='0' class='quantity-adjustment' for='".$this->type."' > "; |
|
123 | + $html .= "<span class='label'>" . __( 'Quantity', 'dummybot' ) . "</span>"; |
|
124 | + $html .= "<input type='number' value='0' class='quantity-adjustment' for='" . $this->type . "' > "; |
|
125 | 125 | $html .= "</h3>"; |
126 | 126 | $html .= "</div>"; |
127 | 127 | |
@@ -139,12 +139,12 @@ discard block |
||
139 | 139 | * @param string $text Text to display in the button. |
140 | 140 | * @return string HTML. |
141 | 141 | */ |
142 | - protected function build_button( $action, $slug, $text ){ |
|
142 | + protected function build_button( $action, $slug, $text ) { |
|
143 | 143 | $html = $dashicon = ''; |
144 | 144 | |
145 | - if ( $action == 'create' ){ |
|
145 | + if ( $action == 'create' ) { |
|
146 | 146 | $dashicon = 'dashicons-plus'; |
147 | - } elseif ( $action == 'delete' ){ |
|
147 | + } elseif ( $action == 'delete' ) { |
|
148 | 148 | $dashicon = 'dashicons-trash'; |
149 | 149 | } |
150 | 150 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @subpackage Test Content |
11 | 11 | * @author Old Town Media |
12 | 12 | */ |
13 | -abstract class View{ |
|
13 | +abstract class View { |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * title |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @see tab, view |
46 | 46 | */ |
47 | - public function register_view(){ |
|
47 | + public function register_view() { |
|
48 | 48 | |
49 | 49 | add_action( 'tc-admin-tabs', array( $this, 'tab' ), $this->priority ); |
50 | 50 | add_action( 'tc-admin-sections', array( $this, 'view' ), $this->priority ); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * Each view has a tab and tab navigation - this function compiles our |
59 | 59 | * navigation tab. Rarely extended. |
60 | 60 | */ |
61 | - public function tab(){ |
|
61 | + public function tab() { |
|
62 | 62 | $html = ""; |
63 | 63 | |
64 | 64 | $html .= "<a class='nav-tab' data-type='".sanitize_title( $this->title )."' href='javascript:void(0)'>"; |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @see actions_section, options_section |
80 | 80 | */ |
81 | - public function view(){ |
|
81 | + public function view() { |
|
82 | 82 | $html = ''; |
83 | 83 | |
84 | 84 | $html .= "<section class='test-content-tab' data-type='".sanitize_title( $this->title )."'>"; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @return string HTML content. |
100 | 100 | */ |
101 | - protected function actions_section(){ |
|
101 | + protected function actions_section() { |
|
102 | 102 | $html = ''; |
103 | 103 | return $html; |
104 | 104 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @param string $html Existing HTML content. |
116 | 116 | * @return string HTML section content. |
117 | 117 | */ |
118 | - protected function options_section( $html = '' ){ |
|
118 | + protected function options_section( $html = '' ) { |
|
119 | 119 | $html .= "<hr>"; |
120 | 120 | |
121 | 121 | $html .= "<div class='test-data-cpt'>"; |
@@ -139,12 +139,12 @@ discard block |
||
139 | 139 | * @param string $text Text to display in the button. |
140 | 140 | * @return string HTML. |
141 | 141 | */ |
142 | - protected function build_button( $action, $slug, $text ){ |
|
142 | + protected function build_button( $action, $slug, $text ) { |
|
143 | 143 | $html = $dashicon = ''; |
144 | 144 | |
145 | - if ( $action == 'create' ){ |
|
145 | + if ( $action == 'create' ) { |
|
146 | 146 | $dashicon = 'dashicons-plus'; |
147 | - } elseif ( $action == 'delete' ){ |
|
147 | + } elseif ( $action == 'delete' ) { |
|
148 | 148 | $dashicon = 'dashicons-trash'; |
149 | 149 | } |
150 | 150 |
@@ -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,12 +39,12 @@ 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' ) ); |
|
47 | + add_action( "wp_ajax_{$this->action}", array( $this, 'handle_ajax' ) ); |
|
48 | 48 | add_filter( 'option_active_plugins', array( $this, 'ajax_exclude_plugins' ) ); |
49 | 49 | |
50 | 50 | } |
@@ -77,17 +77,17 @@ discard block |
||
77 | 77 | */ |
78 | 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,19 +102,19 @@ 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 | 115 | $this->deletion_routing( $_REQUEST ); |
116 | 116 | |
117 | - } elseif ( $action == 'create' ){ |
|
117 | + } elseif ( $action == 'create' ) { |
|
118 | 118 | |
119 | 119 | $this->creation_routing( $_REQUEST ); |
120 | 120 | |
@@ -129,11 +129,11 @@ 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 | 138 | $clean = $this->reporting->create_report( $return ); |
139 | 139 | |
@@ -146,11 +146,11 @@ 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 |
@@ -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,7 +39,7 @@ 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'; |
@@ -77,13 +77,13 @@ discard block |
||
77 | 77 | */ |
78 | 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 | 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 | |
@@ -106,15 +106,15 @@ discard block |
||
106 | 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 | 115 | $this->deletion_routing( $_REQUEST ); |
116 | 116 | |
117 | - } elseif ( $action == 'create' ){ |
|
117 | + } elseif ( $action == 'create' ) { |
|
118 | 118 | |
119 | 119 | $this->creation_routing( $_REQUEST ); |
120 | 120 | |
@@ -129,7 +129,7 @@ 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 | 134 | $type = 'DummyPress\Types\\' . ucwords( $data['type'] ); |
135 | 135 | $object = new $type(); |
@@ -146,11 +146,11 @@ 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 |
@@ -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 | 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 |
@@ -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 | 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 |
@@ -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,16 +22,16 @@ 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': |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | |
121 | 121 | case 'checkbox': |
122 | 122 | |
123 | - if ( isset( $cmb['source'] ) && 'acf' === $cmb['source'] ){ |
|
123 | + if ( isset( $cmb[ 'source' ] ) && 'acf' === $cmb[ 'source' ] ) { |
|
124 | 124 | $value = $this->multicheck( $cmb ); |
125 | 125 | } else { |
126 | 126 | $value = $this->checkbox( $cmb ); |
@@ -158,12 +158,12 @@ discard block |
||
158 | 158 | } |
159 | 159 | |
160 | 160 | // Value must exist to attempt to insert |
161 | - if ( ! empty( $value ) && ! is_wp_error( $value ) ){ |
|
161 | + if ( ! empty( $value ) && ! is_wp_error( $value ) ) { |
|
162 | 162 | |
163 | 163 | $this->update_meta( $post_id, $value, $cmb ); |
164 | 164 | |
165 | 165 | // If we're dealing with a WP Error object, just return the message for debugging |
166 | - } elseif ( is_wp_error( $value ) ){ |
|
166 | + } elseif ( is_wp_error( $value ) ) { |
|
167 | 167 | |
168 | 168 | return $value->get_error_message(); |
169 | 169 | |
@@ -180,22 +180,22 @@ discard block |
||
180 | 180 | * @param array $cmb Metabox data |
181 | 181 | * @return string cmb value |
182 | 182 | */ |
183 | - private function text( $cmb ){ |
|
183 | + private function text( $cmb ) { |
|
184 | 184 | |
185 | 185 | // If phone is in the id, fetch a phone # |
186 | - if ( stripos( $cmb['id'], 'phone' ) ){ |
|
186 | + if ( stripos( $cmb[ 'id' ], 'phone' ) ) { |
|
187 | 187 | $value = TestContent::phone(); |
188 | 188 | |
189 | 189 | // If email is in the id, fetch an email address |
190 | - } elseif ( stripos( $cmb['id'], 'email' ) ){ |
|
190 | + } elseif ( stripos( $cmb[ 'id' ], 'email' ) ) { |
|
191 | 191 | $value = TestContent::email(); |
192 | 192 | |
193 | 193 | // If time is in the id, fetch a time string |
194 | - } elseif ( stripos( $cmb['id'], 'time' ) ){ |
|
194 | + } elseif ( stripos( $cmb[ 'id' ], 'time' ) ) { |
|
195 | 195 | $value = TestContent::time(); |
196 | 196 | |
197 | 197 | // If company|organization is in the ID, fetch a company name |
198 | - } elseif ( stripos( $cmb['id'], 'company' ) || stripos( $cmb['id'], 'organization' ) ){ |
|
198 | + } elseif ( stripos( $cmb[ 'id' ], 'company' ) || stripos( $cmb[ 'id' ], 'organization' ) ) { |
|
199 | 199 | $value = TestContent::organization(); |
200 | 200 | |
201 | 201 | // Otherwise, just a random text string |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | $value = TestContent::title( rand( 10, 50 ) ); |
204 | 204 | } |
205 | 205 | |
206 | - if ( 'acf' === $cmb['source'] && !empty( $cmb['extras']->chars ) ){ |
|
207 | - $value = substr( $value, 0, $cmb['extras']->chars ); |
|
206 | + if ( 'acf' === $cmb[ 'source' ] && ! empty( $cmb[ 'extras' ]->chars ) ) { |
|
207 | + $value = substr( $value, 0, $cmb[ 'extras' ]->chars ); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | return $value; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @param array $cmb Metabox data |
221 | 221 | * @return string cmb value |
222 | 222 | */ |
223 | - private function url( $cmb ){ |
|
223 | + private function url( $cmb ) { |
|
224 | 224 | |
225 | 225 | return TestContent::link(); |
226 | 226 | |
@@ -235,9 +235,9 @@ discard block |
||
235 | 235 | * @param array $cmb Metabox data |
236 | 236 | * @return string cmb value |
237 | 237 | */ |
238 | - private function email( $cmb ){ |
|
238 | + private function email( $cmb ) { |
|
239 | 239 | |
240 | - return TestContent::email();; |
|
240 | + return TestContent::email(); ; |
|
241 | 241 | |
242 | 242 | } |
243 | 243 | |
@@ -248,17 +248,17 @@ discard block |
||
248 | 248 | * @param array $cmb Metabox data |
249 | 249 | * @return int cmb value |
250 | 250 | */ |
251 | - private function number( $cmb ){ |
|
251 | + private function number( $cmb ) { |
|
252 | 252 | |
253 | 253 | $min = 1; |
254 | 254 | $max = 10000000; |
255 | 255 | |
256 | - if ( 'acf' == $cmb['source'] && !empty( $cmb['extras']->min ) ){ |
|
257 | - $min = $cmb['extras']->min; |
|
256 | + if ( 'acf' == $cmb[ 'source' ] && ! empty( $cmb[ 'extras' ]->min ) ) { |
|
257 | + $min = $cmb[ 'extras' ]->min; |
|
258 | 258 | } |
259 | 259 | |
260 | - if ( 'acf' == $cmb['source'] && !empty( $cmb['extras']->max ) ){ |
|
261 | - $max = $cmb['extras']->max; |
|
260 | + if ( 'acf' == $cmb[ 'source' ] && ! empty( $cmb[ 'extras' ]->max ) ) { |
|
261 | + $max = $cmb[ 'extras' ]->max; |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | return rand( $min, $max ); |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | * @param array $cmb Metabox data |
275 | 275 | * @return string cmb value |
276 | 276 | */ |
277 | - private function time( $cmb ){ |
|
277 | + private function time( $cmb ) { |
|
278 | 278 | |
279 | 279 | return TestContent::time(); |
280 | 280 | |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | * @param array $cmb Metabox data |
290 | 290 | * @return string cmb value |
291 | 291 | */ |
292 | - private function timezone( $cmb ){ |
|
292 | + private function timezone( $cmb ) { |
|
293 | 293 | |
294 | 294 | return TestContent::timezone(); |
295 | 295 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | * @param array $cmb Metabox data |
305 | 305 | * @return string cmb value |
306 | 306 | */ |
307 | - private function date( $cmb ){ |
|
307 | + private function date( $cmb ) { |
|
308 | 308 | |
309 | 309 | return TestContent::date( 'm/d/Y' ); |
310 | 310 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @param array $cmb Metabox data |
320 | 320 | * @return string cmb value |
321 | 321 | */ |
322 | - private function timestamp( $cmb ){ |
|
322 | + private function timestamp( $cmb ) { |
|
323 | 323 | |
324 | 324 | return TestContent::date( 'U' ); |
325 | 325 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * @param array $cmb Metabox data |
333 | 333 | * @return string cmb value |
334 | 334 | */ |
335 | - private function color( $cmb ){ |
|
335 | + private function color( $cmb ) { |
|
336 | 336 | |
337 | 337 | return '#' . str_pad( dechex( mt_rand( 0, 0xFFFFFF ) ), 6, '0', STR_PAD_LEFT ); |
338 | 338 | |
@@ -347,12 +347,12 @@ discard block |
||
347 | 347 | * @param array $cmb Metabox data |
348 | 348 | * @return string cmb value |
349 | 349 | */ |
350 | - private function textarea( $cmb ){ |
|
350 | + private function textarea( $cmb ) { |
|
351 | 351 | |
352 | 352 | $value = TestContent::plain_text(); |
353 | 353 | |
354 | - if ( 'acf' == $cmb['source'] && !empty( $cmb['extras']->chars ) ){ |
|
355 | - $value = substr( $value, 0, $cmb['extras']->chars ); |
|
354 | + if ( 'acf' == $cmb[ 'source' ] && ! empty( $cmb[ 'extras' ]->chars ) ) { |
|
355 | + $value = substr( $value, 0, $cmb[ 'extras' ]->chars ); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | return $value; |
@@ -368,10 +368,10 @@ discard block |
||
368 | 368 | * @param array $cmb Metabox data |
369 | 369 | * @return string cmb value |
370 | 370 | */ |
371 | - private function radio( $cmb ){ |
|
371 | + private function radio( $cmb ) { |
|
372 | 372 | |
373 | 373 | // Grab a random item out of the array and return the key |
374 | - $new_val = array_slice( $cmb['options'], rand( 0, count( $cmb['options'] ) ), 1 ); |
|
374 | + $new_val = array_slice( $cmb[ 'options' ], rand( 0, count( $cmb[ 'options' ] ) ), 1 ); |
|
375 | 375 | $value = key( $new_val ); |
376 | 376 | |
377 | 377 | return $value; |
@@ -387,11 +387,11 @@ discard block |
||
387 | 387 | * @param array $cmb Metabox data |
388 | 388 | * @return string cmb value |
389 | 389 | */ |
390 | - private function checkbox( $cmb ){ |
|
390 | + private function checkbox( $cmb ) { |
|
391 | 391 | $value = ''; |
392 | 392 | |
393 | 393 | // 50/50 odds of being turned on |
394 | - if ( rand( 0, 1 ) == 1 ){ |
|
394 | + if ( rand( 0, 1 ) == 1 ) { |
|
395 | 395 | $value = 'on'; |
396 | 396 | } |
397 | 397 | |
@@ -408,16 +408,16 @@ discard block |
||
408 | 408 | * @param array $cmb Metabox data |
409 | 409 | * @return array cmb value |
410 | 410 | */ |
411 | - private function multicheck( $cmb ){ |
|
411 | + private function multicheck( $cmb ) { |
|
412 | 412 | |
413 | 413 | $new_option = array(); |
414 | 414 | |
415 | 415 | // Loop through each of our options |
416 | - foreach ( $cmb['options'] as $key => $value ){ |
|
416 | + foreach ( $cmb[ 'options' ] as $key => $value ) { |
|
417 | 417 | |
418 | 418 | // 50/50 chance of being included |
419 | - if ( rand( 0, 1 ) ){ |
|
420 | - $new_option[] = $key; |
|
419 | + if ( rand( 0, 1 ) ) { |
|
420 | + $new_option[ ] = $key; |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | } |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | * @param array $cmb Metabox data |
436 | 436 | * @return string cmb value |
437 | 437 | */ |
438 | - private function wysiwyg( $cmb ){ |
|
438 | + private function wysiwyg( $cmb ) { |
|
439 | 439 | |
440 | 440 | return TestContent::paragraphs(); |
441 | 441 | |
@@ -452,10 +452,10 @@ discard block |
||
452 | 452 | * @param bool $connected Whether we're connected to the Internets or not |
453 | 453 | * @return mixed string|object cmb value or WP_Error object |
454 | 454 | */ |
455 | - private function file( $cmb, $post_id, $connected ){ |
|
455 | + private function file( $cmb, $post_id, $connected ) { |
|
456 | 456 | $value = ''; |
457 | 457 | |
458 | - if ( true === $connected ){ |
|
458 | + if ( true === $connected ) { |
|
459 | 459 | $value = TestContent::image( $post_id ); |
460 | 460 | } |
461 | 461 | |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | * @param array $cmb Metabox data |
473 | 473 | * @return string cmb value |
474 | 474 | */ |
475 | - private function oembed( $cmb ){ |
|
475 | + private function oembed( $cmb ) { |
|
476 | 476 | |
477 | 477 | return TestContent::oembed(); |
478 | 478 | |
@@ -490,25 +490,25 @@ discard block |
||
490 | 490 | * @param string $value Value to add into the database. |
491 | 491 | * @param array $cmb SMB data. |
492 | 492 | */ |
493 | - private function update_meta( $post_id, $value, $cmb ){ |
|
493 | + private function update_meta( $post_id, $value, $cmb ) { |
|
494 | 494 | |
495 | - $type = $cmb['type']; |
|
496 | - $id = $cmb['id']; |
|
497 | - $value = apply_filters( "tc_{$type}_metabox", $value ); // Filter by metabox type |
|
495 | + $type = $cmb[ 'type' ]; |
|
496 | + $id = $cmb[ 'id' ]; |
|
497 | + $value = apply_filters( "tc_{$type}_metabox", $value ); // Filter by metabox type |
|
498 | 498 | $value = apply_filters( "tc_{$id}_metabox", $value ); // Filter by metabox ID |
499 | 499 | |
500 | 500 | // Files must be treated separately - they use the attachment ID |
501 | 501 | // & url of media for separate cmb values. (only in cmb1 & cmb2 though) |
502 | - if ( 'file'!== $cmb['type'] || ( 'file' === $cmb['type'] && 'cmb_hm' === $cmb['source'] ) ){ |
|
503 | - add_post_meta( $post_id, $cmb['id'], $value, true ); |
|
502 | + if ( 'file' !== $cmb[ 'type' ] || ( 'file' === $cmb[ 'type' ] && 'cmb_hm' === $cmb[ 'source' ] ) ) { |
|
503 | + add_post_meta( $post_id, $cmb[ 'id' ], $value, true ); |
|
504 | 504 | } else { |
505 | - add_post_meta( $post_id, $cmb['id'].'_id', $value, true ); |
|
506 | - add_post_meta( $post_id, $cmb['id'], wp_get_attachment_url( $value ), true ); |
|
505 | + add_post_meta( $post_id, $cmb[ 'id' ] . '_id', $value, true ); |
|
506 | + add_post_meta( $post_id, $cmb[ 'id' ], wp_get_attachment_url( $value ), true ); |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | // Add extra, redundant meta. Because, why not have two rows for the price of one? |
510 | - if ( isset( $cmb['source'] ) && 'acf' === $cmb['source'] ){ |
|
511 | - add_post_meta( $post_id, '_' . $cmb['id'], $cmb['key'], true ); |
|
510 | + if ( isset( $cmb[ 'source' ] ) && 'acf' === $cmb[ 'source' ] ) { |
|
511 | + add_post_meta( $post_id, '_' . $cmb[ 'id' ], $cmb[ 'key' ], true ); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | } |
@@ -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,16 +22,16 @@ 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': |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | |
121 | 121 | case 'checkbox': |
122 | 122 | |
123 | - if ( isset( $cmb['source'] ) && 'acf' === $cmb['source'] ){ |
|
123 | + if ( isset( $cmb['source'] ) && 'acf' === $cmb['source'] ) { |
|
124 | 124 | $value = $this->multicheck( $cmb ); |
125 | 125 | } else { |
126 | 126 | $value = $this->checkbox( $cmb ); |
@@ -158,12 +158,12 @@ discard block |
||
158 | 158 | } |
159 | 159 | |
160 | 160 | // Value must exist to attempt to insert |
161 | - if ( ! empty( $value ) && ! is_wp_error( $value ) ){ |
|
161 | + if ( ! empty( $value ) && ! is_wp_error( $value ) ) { |
|
162 | 162 | |
163 | 163 | $this->update_meta( $post_id, $value, $cmb ); |
164 | 164 | |
165 | 165 | // If we're dealing with a WP Error object, just return the message for debugging |
166 | - } elseif ( is_wp_error( $value ) ){ |
|
166 | + } elseif ( is_wp_error( $value ) ) { |
|
167 | 167 | |
168 | 168 | return $value->get_error_message(); |
169 | 169 | |
@@ -180,22 +180,22 @@ discard block |
||
180 | 180 | * @param array $cmb Metabox data |
181 | 181 | * @return string cmb value |
182 | 182 | */ |
183 | - private function text( $cmb ){ |
|
183 | + private function text( $cmb ) { |
|
184 | 184 | |
185 | 185 | // If phone is in the id, fetch a phone # |
186 | - if ( stripos( $cmb['id'], 'phone' ) ){ |
|
186 | + if ( stripos( $cmb['id'], 'phone' ) ) { |
|
187 | 187 | $value = TestContent::phone(); |
188 | 188 | |
189 | 189 | // If email is in the id, fetch an email address |
190 | - } elseif ( stripos( $cmb['id'], 'email' ) ){ |
|
190 | + } elseif ( stripos( $cmb['id'], 'email' ) ) { |
|
191 | 191 | $value = TestContent::email(); |
192 | 192 | |
193 | 193 | // If time is in the id, fetch a time string |
194 | - } elseif ( stripos( $cmb['id'], 'time' ) ){ |
|
194 | + } elseif ( stripos( $cmb['id'], 'time' ) ) { |
|
195 | 195 | $value = TestContent::time(); |
196 | 196 | |
197 | 197 | // If company|organization is in the ID, fetch a company name |
198 | - } elseif ( stripos( $cmb['id'], 'company' ) || stripos( $cmb['id'], 'organization' ) ){ |
|
198 | + } elseif ( stripos( $cmb['id'], 'company' ) || stripos( $cmb['id'], 'organization' ) ) { |
|
199 | 199 | $value = TestContent::organization(); |
200 | 200 | |
201 | 201 | // Otherwise, just a random text string |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | $value = TestContent::title( rand( 10, 50 ) ); |
204 | 204 | } |
205 | 205 | |
206 | - if ( 'acf' === $cmb['source'] && !empty( $cmb['extras']->chars ) ){ |
|
206 | + if ( 'acf' === $cmb['source'] && !empty( $cmb['extras']->chars ) ) { |
|
207 | 207 | $value = substr( $value, 0, $cmb['extras']->chars ); |
208 | 208 | } |
209 | 209 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @param array $cmb Metabox data |
221 | 221 | * @return string cmb value |
222 | 222 | */ |
223 | - private function url( $cmb ){ |
|
223 | + private function url( $cmb ) { |
|
224 | 224 | |
225 | 225 | return TestContent::link(); |
226 | 226 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * @param array $cmb Metabox data |
236 | 236 | * @return string cmb value |
237 | 237 | */ |
238 | - private function email( $cmb ){ |
|
238 | + private function email( $cmb ) { |
|
239 | 239 | |
240 | 240 | return TestContent::email();; |
241 | 241 | |
@@ -248,16 +248,16 @@ discard block |
||
248 | 248 | * @param array $cmb Metabox data |
249 | 249 | * @return int cmb value |
250 | 250 | */ |
251 | - private function number( $cmb ){ |
|
251 | + private function number( $cmb ) { |
|
252 | 252 | |
253 | 253 | $min = 1; |
254 | 254 | $max = 10000000; |
255 | 255 | |
256 | - if ( 'acf' == $cmb['source'] && !empty( $cmb['extras']->min ) ){ |
|
256 | + if ( 'acf' == $cmb['source'] && !empty( $cmb['extras']->min ) ) { |
|
257 | 257 | $min = $cmb['extras']->min; |
258 | 258 | } |
259 | 259 | |
260 | - if ( 'acf' == $cmb['source'] && !empty( $cmb['extras']->max ) ){ |
|
260 | + if ( 'acf' == $cmb['source'] && !empty( $cmb['extras']->max ) ) { |
|
261 | 261 | $max = $cmb['extras']->max; |
262 | 262 | } |
263 | 263 | |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | * @param array $cmb Metabox data |
275 | 275 | * @return string cmb value |
276 | 276 | */ |
277 | - private function time( $cmb ){ |
|
277 | + private function time( $cmb ) { |
|
278 | 278 | |
279 | 279 | return TestContent::time(); |
280 | 280 | |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | * @param array $cmb Metabox data |
290 | 290 | * @return string cmb value |
291 | 291 | */ |
292 | - private function timezone( $cmb ){ |
|
292 | + private function timezone( $cmb ) { |
|
293 | 293 | |
294 | 294 | return TestContent::timezone(); |
295 | 295 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | * @param array $cmb Metabox data |
305 | 305 | * @return string cmb value |
306 | 306 | */ |
307 | - private function date( $cmb ){ |
|
307 | + private function date( $cmb ) { |
|
308 | 308 | |
309 | 309 | return TestContent::date( 'm/d/Y' ); |
310 | 310 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @param array $cmb Metabox data |
320 | 320 | * @return string cmb value |
321 | 321 | */ |
322 | - private function timestamp( $cmb ){ |
|
322 | + private function timestamp( $cmb ) { |
|
323 | 323 | |
324 | 324 | return TestContent::date( 'U' ); |
325 | 325 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * @param array $cmb Metabox data |
333 | 333 | * @return string cmb value |
334 | 334 | */ |
335 | - private function color( $cmb ){ |
|
335 | + private function color( $cmb ) { |
|
336 | 336 | |
337 | 337 | return '#' . str_pad( dechex( mt_rand( 0, 0xFFFFFF ) ), 6, '0', STR_PAD_LEFT ); |
338 | 338 | |
@@ -347,11 +347,11 @@ discard block |
||
347 | 347 | * @param array $cmb Metabox data |
348 | 348 | * @return string cmb value |
349 | 349 | */ |
350 | - private function textarea( $cmb ){ |
|
350 | + private function textarea( $cmb ) { |
|
351 | 351 | |
352 | 352 | $value = TestContent::plain_text(); |
353 | 353 | |
354 | - if ( 'acf' == $cmb['source'] && !empty( $cmb['extras']->chars ) ){ |
|
354 | + if ( 'acf' == $cmb['source'] && !empty( $cmb['extras']->chars ) ) { |
|
355 | 355 | $value = substr( $value, 0, $cmb['extras']->chars ); |
356 | 356 | } |
357 | 357 | |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * @param array $cmb Metabox data |
369 | 369 | * @return string cmb value |
370 | 370 | */ |
371 | - private function radio( $cmb ){ |
|
371 | + private function radio( $cmb ) { |
|
372 | 372 | |
373 | 373 | // Grab a random item out of the array and return the key |
374 | 374 | $new_val = array_slice( $cmb['options'], rand( 0, count( $cmb['options'] ) ), 1 ); |
@@ -387,11 +387,11 @@ discard block |
||
387 | 387 | * @param array $cmb Metabox data |
388 | 388 | * @return string cmb value |
389 | 389 | */ |
390 | - private function checkbox( $cmb ){ |
|
390 | + private function checkbox( $cmb ) { |
|
391 | 391 | $value = ''; |
392 | 392 | |
393 | 393 | // 50/50 odds of being turned on |
394 | - if ( rand( 0, 1 ) == 1 ){ |
|
394 | + if ( rand( 0, 1 ) == 1 ) { |
|
395 | 395 | $value = 'on'; |
396 | 396 | } |
397 | 397 | |
@@ -408,15 +408,15 @@ discard block |
||
408 | 408 | * @param array $cmb Metabox data |
409 | 409 | * @return array cmb value |
410 | 410 | */ |
411 | - private function multicheck( $cmb ){ |
|
411 | + private function multicheck( $cmb ) { |
|
412 | 412 | |
413 | 413 | $new_option = array(); |
414 | 414 | |
415 | 415 | // Loop through each of our options |
416 | - foreach ( $cmb['options'] as $key => $value ){ |
|
416 | + foreach ( $cmb['options'] as $key => $value ) { |
|
417 | 417 | |
418 | 418 | // 50/50 chance of being included |
419 | - if ( rand( 0, 1 ) ){ |
|
419 | + if ( rand( 0, 1 ) ) { |
|
420 | 420 | $new_option[] = $key; |
421 | 421 | } |
422 | 422 | |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | * @param array $cmb Metabox data |
436 | 436 | * @return string cmb value |
437 | 437 | */ |
438 | - private function wysiwyg( $cmb ){ |
|
438 | + private function wysiwyg( $cmb ) { |
|
439 | 439 | |
440 | 440 | return TestContent::paragraphs(); |
441 | 441 | |
@@ -452,10 +452,10 @@ discard block |
||
452 | 452 | * @param bool $connected Whether we're connected to the Internets or not |
453 | 453 | * @return mixed string|object cmb value or WP_Error object |
454 | 454 | */ |
455 | - private function file( $cmb, $post_id, $connected ){ |
|
455 | + private function file( $cmb, $post_id, $connected ) { |
|
456 | 456 | $value = ''; |
457 | 457 | |
458 | - if ( true === $connected ){ |
|
458 | + if ( true === $connected ) { |
|
459 | 459 | $value = TestContent::image( $post_id ); |
460 | 460 | } |
461 | 461 | |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | * @param array $cmb Metabox data |
473 | 473 | * @return string cmb value |
474 | 474 | */ |
475 | - private function oembed( $cmb ){ |
|
475 | + private function oembed( $cmb ) { |
|
476 | 476 | |
477 | 477 | return TestContent::oembed(); |
478 | 478 | |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | * @param string $value Value to add into the database. |
491 | 491 | * @param array $cmb SMB data. |
492 | 492 | */ |
493 | - private function update_meta( $post_id, $value, $cmb ){ |
|
493 | + private function update_meta( $post_id, $value, $cmb ) { |
|
494 | 494 | |
495 | 495 | $type = $cmb['type']; |
496 | 496 | $id = $cmb['id']; |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | |
500 | 500 | // Files must be treated separately - they use the attachment ID |
501 | 501 | // & url of media for separate cmb values. (only in cmb1 & cmb2 though) |
502 | - if ( 'file'!== $cmb['type'] || ( 'file' === $cmb['type'] && 'cmb_hm' === $cmb['source'] ) ){ |
|
502 | + if ( 'file'!== $cmb['type'] || ( 'file' === $cmb['type'] && 'cmb_hm' === $cmb['source'] ) ) { |
|
503 | 503 | add_post_meta( $post_id, $cmb['id'], $value, true ); |
504 | 504 | } else { |
505 | 505 | add_post_meta( $post_id, $cmb['id'].'_id', $value, true ); |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | } |
508 | 508 | |
509 | 509 | // Add extra, redundant meta. Because, why not have two rows for the price of one? |
510 | - if ( isset( $cmb['source'] ) && 'acf' === $cmb['source'] ){ |
|
510 | + if ( isset( $cmb['source'] ) && 'acf' === $cmb['source'] ) { |
|
511 | 511 | add_post_meta( $post_id, '_' . $cmb['id'], $cmb['key'], true ); |
512 | 512 | } |
513 | 513 |
@@ -9,25 +9,25 @@ 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 | 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 | 32 | $class = 'DummyPress\Types\\' . ucwords( $type ); |
33 | 33 | $object = new $class(); |
@@ -53,19 +53,19 @@ 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'] ); |
|
68 | - $slug = $data['slug']; |
|
67 | + $type = 'DummyPress\Types\\' . ucwords( $data[ 'type' ] ); |
|
68 | + $slug = $data[ 'slug' ]; |
|
69 | 69 | |
70 | 70 | $object = new $type(); |
71 | 71 | |
@@ -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 |
@@ -9,25 +9,25 @@ 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 | 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 | 32 | $class = 'DummyPress\Types\\' . ucwords( $type ); |
33 | 33 | $object = new $class(); |
@@ -53,14 +53,14 @@ 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 | |
@@ -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 |
@@ -10,13 +10,13 @@ discard block |
||
10 | 10 | * @subpackage Test Content |
11 | 11 | * @author Old Town Media |
12 | 12 | */ |
13 | -class Various extends Abs\View{ |
|
13 | +class Various extends Abs\View { |
|
14 | 14 | |
15 | - public function __construct(){ |
|
15 | + public function __construct() { |
|
16 | 16 | |
17 | 17 | $this->title = __( 'Various', 'dummybot' ); |
18 | 18 | $this->type = 'all'; |
19 | - $this->priority = 10; |
|
19 | + $this->priority = 10; |
|
20 | 20 | |
21 | 21 | } |
22 | 22 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return string HTML content. |
30 | 30 | */ |
31 | - protected function actions_section(){ |
|
31 | + protected function actions_section() { |
|
32 | 32 | $html = ''; |
33 | 33 | |
34 | 34 | $html .= "<div class='test-data-cpt'>"; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param string $html Existing HTML content. |
55 | 55 | * @return string HTML section content. |
56 | 56 | */ |
57 | - protected function options_section( $html = '' ){ |
|
57 | + protected function options_section( $html = '' ) { |
|
58 | 58 | return $html; |
59 | 59 | } |
60 | 60 |
@@ -10,9 +10,9 @@ discard block |
||
10 | 10 | * @subpackage Test Content |
11 | 11 | * @author Old Town Media |
12 | 12 | */ |
13 | -class Various extends Abs\View{ |
|
13 | +class Various extends Abs\View { |
|
14 | 14 | |
15 | - public function __construct(){ |
|
15 | + public function __construct() { |
|
16 | 16 | |
17 | 17 | $this->title = __( 'Various', 'dummybot' ); |
18 | 18 | $this->type = 'all'; |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return string HTML content. |
30 | 30 | */ |
31 | - protected function actions_section(){ |
|
31 | + protected function actions_section() { |
|
32 | 32 | $html = ''; |
33 | 33 | |
34 | 34 | $html .= "<div class='test-data-cpt'>"; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param string $html Existing HTML content. |
55 | 55 | * @return string HTML section content. |
56 | 56 | */ |
57 | - protected function options_section( $html = '' ){ |
|
57 | + protected function options_section( $html = '' ) { |
|
58 | 58 | return $html; |
59 | 59 | } |
60 | 60 |
@@ -10,13 +10,13 @@ discard block |
||
10 | 10 | * @subpackage Test Content |
11 | 11 | * @author Old Town Media |
12 | 12 | */ |
13 | -class Posts extends Abs\View{ |
|
13 | +class Posts extends Abs\View { |
|
14 | 14 | |
15 | - public function __construct(){ |
|
15 | + public function __construct() { |
|
16 | 16 | |
17 | 17 | $this->title = __( 'Posts', 'dummybot' ); |
18 | 18 | $this->type = 'post'; |
19 | - $this->priority = 1; |
|
19 | + $this->priority = 1; |
|
20 | 20 | |
21 | 21 | } |
22 | 22 | |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @return string HTML content. |
29 | 29 | */ |
30 | - protected function actions_section(){ |
|
30 | + protected function actions_section() { |
|
31 | 31 | $html = ''; |
32 | 32 | |
33 | 33 | // Loop through every post type available on the site |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | ); |
41 | 41 | |
42 | 42 | // Skip banned cpts |
43 | - if ( in_array( $post_type->name, $skipped_cpts ) ){ |
|
43 | + if ( in_array( $post_type->name, $skipped_cpts ) ) { |
|
44 | 44 | continue; |
45 | 45 | } |
46 | 46 |
@@ -10,9 +10,9 @@ discard block |
||
10 | 10 | * @subpackage Test Content |
11 | 11 | * @author Old Town Media |
12 | 12 | */ |
13 | -class Posts extends Abs\View{ |
|
13 | +class Posts extends Abs\View { |
|
14 | 14 | |
15 | - public function __construct(){ |
|
15 | + public function __construct() { |
|
16 | 16 | |
17 | 17 | $this->title = __( 'Posts', 'dummybot' ); |
18 | 18 | $this->type = 'post'; |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @return string HTML content. |
29 | 29 | */ |
30 | - protected function actions_section(){ |
|
30 | + protected function actions_section() { |
|
31 | 31 | $html = ''; |
32 | 32 | |
33 | 33 | // Loop through every post type available on the site |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | ); |
41 | 41 | |
42 | 42 | // Skip banned cpts |
43 | - if ( in_array( $post_type->name, $skipped_cpts ) ){ |
|
43 | + if ( in_array( $post_type->name, $skipped_cpts ) ) { |
|
44 | 44 | continue; |
45 | 45 | } |
46 | 46 |
@@ -10,13 +10,13 @@ discard block |
||
10 | 10 | * @subpackage Test Content |
11 | 11 | * @author Old Town Media |
12 | 12 | */ |
13 | -class Terms extends Abs\View{ |
|
13 | +class Terms extends Abs\View { |
|
14 | 14 | |
15 | - public function __construct(){ |
|
15 | + public function __construct() { |
|
16 | 16 | |
17 | 17 | $this->title = __( 'Terms', 'dummybot' ); |
18 | 18 | $this->type = 'term'; |
19 | - $this->priority = 2; |
|
19 | + $this->priority = 2; |
|
20 | 20 | |
21 | 21 | } |
22 | 22 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return string HTML content. |
30 | 30 | */ |
31 | - protected function actions_section(){ |
|
31 | + protected function actions_section() { |
|
32 | 32 | $html = ''; |
33 | 33 | |
34 | 34 | $taxonomies = get_taxonomies(); |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | foreach ( $taxonomies as $tax ) : |
37 | 37 | |
38 | 38 | $skipped_taxonomies = array( |
39 | - 'post_format', // We shouldn't be making random post format classes |
|
40 | - 'product_shipping_class', // These aren't used visually and are therefore skipped |
|
41 | - 'nav_menu', // Menus are handled seperately of taxonomies |
|
39 | + 'post_format', // We shouldn't be making random post format classes |
|
40 | + 'product_shipping_class', // These aren't used visually and are therefore skipped |
|
41 | + 'nav_menu', // Menus are handled seperately of taxonomies |
|
42 | 42 | ); |
43 | 43 | |
44 | 44 | // Skip banned taxonomies |
45 | - if ( in_array( $tax, $skipped_taxonomies ) ){ |
|
45 | + if ( in_array( $tax, $skipped_taxonomies ) ) { |
|
46 | 46 | continue; |
47 | 47 | } |
48 | 48 | |
@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | |
53 | 53 | $html .= "<h3>"; |
54 | 54 | |
55 | - $html .= "<span class='label'>".$taxonomy->labels->name."</span>"; |
|
55 | + $html .= "<span class='label'>" . $taxonomy->labels->name . "</span>"; |
|
56 | 56 | |
57 | - $html .= $this->build_button( 'create', $tax, __( 'Create', 'dummybot' )." ".$taxonomy->labels->name ); |
|
58 | - $html .= $this->build_button( 'delete', $tax, __( 'Delete', 'dummybot' )." ".$taxonomy->labels->name ); |
|
57 | + $html .= $this->build_button( 'create', $tax, __( 'Create', 'dummybot' ) . " " . $taxonomy->labels->name ); |
|
58 | + $html .= $this->build_button( 'delete', $tax, __( 'Delete', 'dummybot' ) . " " . $taxonomy->labels->name ); |
|
59 | 59 | |
60 | 60 | $html .= "</h3>"; |
61 | 61 |
@@ -10,9 +10,9 @@ discard block |
||
10 | 10 | * @subpackage Test Content |
11 | 11 | * @author Old Town Media |
12 | 12 | */ |
13 | -class Terms extends Abs\View{ |
|
13 | +class Terms extends Abs\View { |
|
14 | 14 | |
15 | - public function __construct(){ |
|
15 | + public function __construct() { |
|
16 | 16 | |
17 | 17 | $this->title = __( 'Terms', 'dummybot' ); |
18 | 18 | $this->type = 'term'; |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return string HTML content. |
30 | 30 | */ |
31 | - protected function actions_section(){ |
|
31 | + protected function actions_section() { |
|
32 | 32 | $html = ''; |
33 | 33 | |
34 | 34 | $taxonomies = get_taxonomies(); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | ); |
43 | 43 | |
44 | 44 | // Skip banned taxonomies |
45 | - if ( in_array( $tax, $skipped_taxonomies ) ){ |
|
45 | + if ( in_array( $tax, $skipped_taxonomies ) ) { |
|
46 | 46 | continue; |
47 | 47 | } |
48 | 48 |