@@ -5,237 +5,237 @@ |
||
5 | 5 | |
6 | 6 | abstract class Wpinv_DB { |
7 | 7 | |
8 | - /** |
|
9 | - * The name of our database table |
|
10 | - * |
|
11 | - * @access public |
|
12 | - * @since 1.0.0 |
|
13 | - */ |
|
14 | - public $table_name; |
|
15 | - |
|
16 | - /** |
|
17 | - * The version of our database table |
|
18 | - * |
|
19 | - * @access public |
|
20 | - * @since 1.0.0 |
|
21 | - */ |
|
22 | - public $version; |
|
23 | - |
|
24 | - /** |
|
25 | - * The name of the primary column |
|
26 | - * |
|
27 | - * @access public |
|
28 | - * @since 1.0.0 |
|
29 | - */ |
|
30 | - public $primary_key; |
|
31 | - |
|
32 | - /** |
|
33 | - * Get things started |
|
34 | - * |
|
35 | - * @access public |
|
36 | - * @since 1.0.0 |
|
37 | - */ |
|
38 | - public function __construct() {} |
|
39 | - |
|
40 | - /** |
|
41 | - * Whitelist of columns |
|
42 | - * |
|
43 | - * @access public |
|
44 | - * @since 1.0.0 |
|
45 | - * @return array |
|
46 | - */ |
|
47 | - public function get_columns() { |
|
48 | - return array(); |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * Default column values |
|
53 | - * |
|
54 | - * @access public |
|
55 | - * @since 1.0.0 |
|
56 | - * @return array |
|
57 | - */ |
|
58 | - public function get_column_defaults() { |
|
59 | - return array(); |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * Retrieve a row by the primary key |
|
64 | - * |
|
65 | - * @access public |
|
66 | - * @since 1.0.0 |
|
67 | - * @return object |
|
68 | - */ |
|
69 | - public function get( $row_id ) { |
|
70 | - global $wpdb; |
|
71 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * Retrieve a row by a specific column / value |
|
76 | - * |
|
77 | - * @access public |
|
78 | - * @since 1.0.0 |
|
79 | - * @return object |
|
80 | - */ |
|
81 | - public function get_by( $column, $row_id ) { |
|
82 | - global $wpdb; |
|
83 | - $column = esc_sql( $column ); |
|
84 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) ); |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * Retrieve a specific column's value by the primary key |
|
89 | - * |
|
90 | - * @access public |
|
91 | - * @since 1.0.0 |
|
92 | - * @return string |
|
93 | - */ |
|
94 | - public function get_column( $column, $row_id ) { |
|
95 | - global $wpdb; |
|
96 | - $column = esc_sql( $column ); |
|
97 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * Retrieve a specific column's value by the the specified column / value |
|
102 | - * |
|
103 | - * @access public |
|
104 | - * @since 1.0.0 |
|
105 | - * @return string |
|
106 | - */ |
|
107 | - public function get_column_by( $column, $column_where, $column_value ) { |
|
108 | - global $wpdb; |
|
109 | - $column_where = esc_sql( $column_where ); |
|
110 | - $column = esc_sql( $column ); |
|
111 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) ); |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * Insert a new row |
|
116 | - * |
|
117 | - * @access public |
|
118 | - * @since 1.0.0 |
|
119 | - * @return int |
|
120 | - */ |
|
121 | - public function insert( $data, $type = '' ) { |
|
122 | - global $wpdb; |
|
123 | - |
|
124 | - // Set default values |
|
125 | - $data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
126 | - |
|
127 | - do_action( 'wpinv_pre_insert_' . $type, $data ); |
|
128 | - |
|
129 | - // Initialise column format array |
|
130 | - $column_formats = $this->get_columns(); |
|
131 | - |
|
132 | - // Force fields to lower case |
|
133 | - $data = array_change_key_case( $data ); |
|
134 | - |
|
135 | - // White list columns |
|
136 | - $data = array_intersect_key( $data, $column_formats ); |
|
137 | - |
|
138 | - // Reorder $column_formats to match the order of columns given in $data |
|
139 | - $data_keys = array_keys( $data ); |
|
140 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
141 | - |
|
142 | - $wpdb->insert( $this->table_name, $data, $column_formats ); |
|
143 | - $wpdb_insert_id = $wpdb->insert_id; |
|
144 | - |
|
145 | - do_action( 'wpinv_post_insert_' . $type, $wpdb_insert_id, $data ); |
|
146 | - |
|
147 | - return $wpdb_insert_id; |
|
148 | - } |
|
149 | - |
|
150 | - /** |
|
151 | - * Update a row |
|
152 | - * |
|
153 | - * @access public |
|
154 | - * @since 1.0.0 |
|
155 | - * @return bool |
|
156 | - */ |
|
157 | - public function update( $row_id, $data = array(), $where = '' ) { |
|
158 | - |
|
159 | - global $wpdb; |
|
160 | - |
|
161 | - // Row ID must be positive integer |
|
162 | - $row_id = absint( $row_id ); |
|
163 | - |
|
164 | - if( empty( $row_id ) ) { |
|
165 | - return false; |
|
166 | - } |
|
167 | - |
|
168 | - if( empty( $where ) ) { |
|
169 | - $where = $this->primary_key; |
|
170 | - } |
|
171 | - |
|
172 | - // Initialise column format array |
|
173 | - $column_formats = $this->get_columns(); |
|
174 | - |
|
175 | - // Force fields to lower case |
|
176 | - $data = array_change_key_case( $data ); |
|
177 | - |
|
178 | - // White list columns |
|
179 | - $data = array_intersect_key( $data, $column_formats ); |
|
180 | - |
|
181 | - // Reorder $column_formats to match the order of columns given in $data |
|
182 | - $data_keys = array_keys( $data ); |
|
183 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
184 | - |
|
185 | - if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) { |
|
186 | - return false; |
|
187 | - } |
|
188 | - |
|
189 | - return true; |
|
190 | - } |
|
191 | - |
|
192 | - /** |
|
193 | - * Delete a row identified by the primary key |
|
194 | - * |
|
195 | - * @access public |
|
196 | - * @since 1.0.0 |
|
197 | - * @return bool |
|
198 | - */ |
|
199 | - public function delete( $row_id = 0 ) { |
|
200 | - |
|
201 | - global $wpdb; |
|
202 | - |
|
203 | - // Row ID must be positive integer |
|
204 | - $row_id = absint( $row_id ); |
|
205 | - |
|
206 | - if( empty( $row_id ) ) { |
|
207 | - return false; |
|
208 | - } |
|
209 | - |
|
210 | - if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) { |
|
211 | - return false; |
|
212 | - } |
|
213 | - |
|
214 | - return true; |
|
215 | - } |
|
216 | - |
|
217 | - /** |
|
218 | - * Check if the given table exists |
|
219 | - * |
|
220 | - * @since 2.4 |
|
221 | - * @param string $table The table name |
|
222 | - * @return bool If the table name exists |
|
223 | - */ |
|
224 | - public function table_exists( $table ) { |
|
225 | - global $wpdb; |
|
226 | - $table = sanitize_text_field( $table ); |
|
227 | - |
|
228 | - return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table; |
|
229 | - } |
|
230 | - |
|
231 | - /** |
|
232 | - * Check if the table was ever installed |
|
233 | - * |
|
234 | - * @since 2.4 |
|
235 | - * @return bool Returns if the customers table was installed and upgrade routine run |
|
236 | - */ |
|
237 | - public function installed() { |
|
238 | - return $this->table_exists( $this->table_name ); |
|
239 | - } |
|
8 | + /** |
|
9 | + * The name of our database table |
|
10 | + * |
|
11 | + * @access public |
|
12 | + * @since 1.0.0 |
|
13 | + */ |
|
14 | + public $table_name; |
|
15 | + |
|
16 | + /** |
|
17 | + * The version of our database table |
|
18 | + * |
|
19 | + * @access public |
|
20 | + * @since 1.0.0 |
|
21 | + */ |
|
22 | + public $version; |
|
23 | + |
|
24 | + /** |
|
25 | + * The name of the primary column |
|
26 | + * |
|
27 | + * @access public |
|
28 | + * @since 1.0.0 |
|
29 | + */ |
|
30 | + public $primary_key; |
|
31 | + |
|
32 | + /** |
|
33 | + * Get things started |
|
34 | + * |
|
35 | + * @access public |
|
36 | + * @since 1.0.0 |
|
37 | + */ |
|
38 | + public function __construct() {} |
|
39 | + |
|
40 | + /** |
|
41 | + * Whitelist of columns |
|
42 | + * |
|
43 | + * @access public |
|
44 | + * @since 1.0.0 |
|
45 | + * @return array |
|
46 | + */ |
|
47 | + public function get_columns() { |
|
48 | + return array(); |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * Default column values |
|
53 | + * |
|
54 | + * @access public |
|
55 | + * @since 1.0.0 |
|
56 | + * @return array |
|
57 | + */ |
|
58 | + public function get_column_defaults() { |
|
59 | + return array(); |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * Retrieve a row by the primary key |
|
64 | + * |
|
65 | + * @access public |
|
66 | + * @since 1.0.0 |
|
67 | + * @return object |
|
68 | + */ |
|
69 | + public function get( $row_id ) { |
|
70 | + global $wpdb; |
|
71 | + return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * Retrieve a row by a specific column / value |
|
76 | + * |
|
77 | + * @access public |
|
78 | + * @since 1.0.0 |
|
79 | + * @return object |
|
80 | + */ |
|
81 | + public function get_by( $column, $row_id ) { |
|
82 | + global $wpdb; |
|
83 | + $column = esc_sql( $column ); |
|
84 | + return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) ); |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * Retrieve a specific column's value by the primary key |
|
89 | + * |
|
90 | + * @access public |
|
91 | + * @since 1.0.0 |
|
92 | + * @return string |
|
93 | + */ |
|
94 | + public function get_column( $column, $row_id ) { |
|
95 | + global $wpdb; |
|
96 | + $column = esc_sql( $column ); |
|
97 | + return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * Retrieve a specific column's value by the the specified column / value |
|
102 | + * |
|
103 | + * @access public |
|
104 | + * @since 1.0.0 |
|
105 | + * @return string |
|
106 | + */ |
|
107 | + public function get_column_by( $column, $column_where, $column_value ) { |
|
108 | + global $wpdb; |
|
109 | + $column_where = esc_sql( $column_where ); |
|
110 | + $column = esc_sql( $column ); |
|
111 | + return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) ); |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * Insert a new row |
|
116 | + * |
|
117 | + * @access public |
|
118 | + * @since 1.0.0 |
|
119 | + * @return int |
|
120 | + */ |
|
121 | + public function insert( $data, $type = '' ) { |
|
122 | + global $wpdb; |
|
123 | + |
|
124 | + // Set default values |
|
125 | + $data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
126 | + |
|
127 | + do_action( 'wpinv_pre_insert_' . $type, $data ); |
|
128 | + |
|
129 | + // Initialise column format array |
|
130 | + $column_formats = $this->get_columns(); |
|
131 | + |
|
132 | + // Force fields to lower case |
|
133 | + $data = array_change_key_case( $data ); |
|
134 | + |
|
135 | + // White list columns |
|
136 | + $data = array_intersect_key( $data, $column_formats ); |
|
137 | + |
|
138 | + // Reorder $column_formats to match the order of columns given in $data |
|
139 | + $data_keys = array_keys( $data ); |
|
140 | + $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
141 | + |
|
142 | + $wpdb->insert( $this->table_name, $data, $column_formats ); |
|
143 | + $wpdb_insert_id = $wpdb->insert_id; |
|
144 | + |
|
145 | + do_action( 'wpinv_post_insert_' . $type, $wpdb_insert_id, $data ); |
|
146 | + |
|
147 | + return $wpdb_insert_id; |
|
148 | + } |
|
149 | + |
|
150 | + /** |
|
151 | + * Update a row |
|
152 | + * |
|
153 | + * @access public |
|
154 | + * @since 1.0.0 |
|
155 | + * @return bool |
|
156 | + */ |
|
157 | + public function update( $row_id, $data = array(), $where = '' ) { |
|
158 | + |
|
159 | + global $wpdb; |
|
160 | + |
|
161 | + // Row ID must be positive integer |
|
162 | + $row_id = absint( $row_id ); |
|
163 | + |
|
164 | + if( empty( $row_id ) ) { |
|
165 | + return false; |
|
166 | + } |
|
167 | + |
|
168 | + if( empty( $where ) ) { |
|
169 | + $where = $this->primary_key; |
|
170 | + } |
|
171 | + |
|
172 | + // Initialise column format array |
|
173 | + $column_formats = $this->get_columns(); |
|
174 | + |
|
175 | + // Force fields to lower case |
|
176 | + $data = array_change_key_case( $data ); |
|
177 | + |
|
178 | + // White list columns |
|
179 | + $data = array_intersect_key( $data, $column_formats ); |
|
180 | + |
|
181 | + // Reorder $column_formats to match the order of columns given in $data |
|
182 | + $data_keys = array_keys( $data ); |
|
183 | + $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
184 | + |
|
185 | + if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) { |
|
186 | + return false; |
|
187 | + } |
|
188 | + |
|
189 | + return true; |
|
190 | + } |
|
191 | + |
|
192 | + /** |
|
193 | + * Delete a row identified by the primary key |
|
194 | + * |
|
195 | + * @access public |
|
196 | + * @since 1.0.0 |
|
197 | + * @return bool |
|
198 | + */ |
|
199 | + public function delete( $row_id = 0 ) { |
|
200 | + |
|
201 | + global $wpdb; |
|
202 | + |
|
203 | + // Row ID must be positive integer |
|
204 | + $row_id = absint( $row_id ); |
|
205 | + |
|
206 | + if( empty( $row_id ) ) { |
|
207 | + return false; |
|
208 | + } |
|
209 | + |
|
210 | + if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) { |
|
211 | + return false; |
|
212 | + } |
|
213 | + |
|
214 | + return true; |
|
215 | + } |
|
216 | + |
|
217 | + /** |
|
218 | + * Check if the given table exists |
|
219 | + * |
|
220 | + * @since 2.4 |
|
221 | + * @param string $table The table name |
|
222 | + * @return bool If the table name exists |
|
223 | + */ |
|
224 | + public function table_exists( $table ) { |
|
225 | + global $wpdb; |
|
226 | + $table = sanitize_text_field( $table ); |
|
227 | + |
|
228 | + return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table; |
|
229 | + } |
|
230 | + |
|
231 | + /** |
|
232 | + * Check if the table was ever installed |
|
233 | + * |
|
234 | + * @since 2.4 |
|
235 | + * @return bool Returns if the customers table was installed and upgrade routine run |
|
236 | + */ |
|
237 | + public function installed() { |
|
238 | + return $this->table_exists( $this->table_name ); |
|
239 | + } |
|
240 | 240 | |
241 | 241 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Exit if accessed directly |
4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
4 | +if (!defined('ABSPATH')) exit; |
|
5 | 5 | |
6 | 6 | abstract class Wpinv_DB { |
7 | 7 | |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | * @since 1.0.0 |
67 | 67 | * @return object |
68 | 68 | */ |
69 | - public function get( $row_id ) { |
|
69 | + public function get($row_id) { |
|
70 | 70 | global $wpdb; |
71 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
71 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | * @since 1.0.0 |
79 | 79 | * @return object |
80 | 80 | */ |
81 | - public function get_by( $column, $row_id ) { |
|
81 | + public function get_by($column, $row_id) { |
|
82 | 82 | global $wpdb; |
83 | - $column = esc_sql( $column ); |
|
84 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) ); |
|
83 | + $column = esc_sql($column); |
|
84 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id)); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | * @since 1.0.0 |
92 | 92 | * @return string |
93 | 93 | */ |
94 | - public function get_column( $column, $row_id ) { |
|
94 | + public function get_column($column, $row_id) { |
|
95 | 95 | global $wpdb; |
96 | - $column = esc_sql( $column ); |
|
97 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
96 | + $column = esc_sql($column); |
|
97 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | * @since 1.0.0 |
105 | 105 | * @return string |
106 | 106 | */ |
107 | - public function get_column_by( $column, $column_where, $column_value ) { |
|
107 | + public function get_column_by($column, $column_where, $column_value) { |
|
108 | 108 | global $wpdb; |
109 | - $column_where = esc_sql( $column_where ); |
|
110 | - $column = esc_sql( $column ); |
|
111 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) ); |
|
109 | + $column_where = esc_sql($column_where); |
|
110 | + $column = esc_sql($column); |
|
111 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value)); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -118,31 +118,31 @@ discard block |
||
118 | 118 | * @since 1.0.0 |
119 | 119 | * @return int |
120 | 120 | */ |
121 | - public function insert( $data, $type = '' ) { |
|
121 | + public function insert($data, $type = '') { |
|
122 | 122 | global $wpdb; |
123 | 123 | |
124 | 124 | // Set default values |
125 | - $data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
125 | + $data = wp_parse_args($data, $this->get_column_defaults()); |
|
126 | 126 | |
127 | - do_action( 'wpinv_pre_insert_' . $type, $data ); |
|
127 | + do_action('wpinv_pre_insert_' . $type, $data); |
|
128 | 128 | |
129 | 129 | // Initialise column format array |
130 | 130 | $column_formats = $this->get_columns(); |
131 | 131 | |
132 | 132 | // Force fields to lower case |
133 | - $data = array_change_key_case( $data ); |
|
133 | + $data = array_change_key_case($data); |
|
134 | 134 | |
135 | 135 | // White list columns |
136 | - $data = array_intersect_key( $data, $column_formats ); |
|
136 | + $data = array_intersect_key($data, $column_formats); |
|
137 | 137 | |
138 | 138 | // Reorder $column_formats to match the order of columns given in $data |
139 | - $data_keys = array_keys( $data ); |
|
140 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
139 | + $data_keys = array_keys($data); |
|
140 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
141 | 141 | |
142 | - $wpdb->insert( $this->table_name, $data, $column_formats ); |
|
142 | + $wpdb->insert($this->table_name, $data, $column_formats); |
|
143 | 143 | $wpdb_insert_id = $wpdb->insert_id; |
144 | 144 | |
145 | - do_action( 'wpinv_post_insert_' . $type, $wpdb_insert_id, $data ); |
|
145 | + do_action('wpinv_post_insert_' . $type, $wpdb_insert_id, $data); |
|
146 | 146 | |
147 | 147 | return $wpdb_insert_id; |
148 | 148 | } |
@@ -154,18 +154,18 @@ discard block |
||
154 | 154 | * @since 1.0.0 |
155 | 155 | * @return bool |
156 | 156 | */ |
157 | - public function update( $row_id, $data = array(), $where = '' ) { |
|
157 | + public function update($row_id, $data = array(), $where = '') { |
|
158 | 158 | |
159 | 159 | global $wpdb; |
160 | 160 | |
161 | 161 | // Row ID must be positive integer |
162 | - $row_id = absint( $row_id ); |
|
162 | + $row_id = absint($row_id); |
|
163 | 163 | |
164 | - if( empty( $row_id ) ) { |
|
164 | + if (empty($row_id)) { |
|
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | |
168 | - if( empty( $where ) ) { |
|
168 | + if (empty($where)) { |
|
169 | 169 | $where = $this->primary_key; |
170 | 170 | } |
171 | 171 | |
@@ -173,16 +173,16 @@ discard block |
||
173 | 173 | $column_formats = $this->get_columns(); |
174 | 174 | |
175 | 175 | // Force fields to lower case |
176 | - $data = array_change_key_case( $data ); |
|
176 | + $data = array_change_key_case($data); |
|
177 | 177 | |
178 | 178 | // White list columns |
179 | - $data = array_intersect_key( $data, $column_formats ); |
|
179 | + $data = array_intersect_key($data, $column_formats); |
|
180 | 180 | |
181 | 181 | // Reorder $column_formats to match the order of columns given in $data |
182 | - $data_keys = array_keys( $data ); |
|
183 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
182 | + $data_keys = array_keys($data); |
|
183 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
184 | 184 | |
185 | - if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) { |
|
185 | + if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) { |
|
186 | 186 | return false; |
187 | 187 | } |
188 | 188 | |
@@ -196,18 +196,18 @@ discard block |
||
196 | 196 | * @since 1.0.0 |
197 | 197 | * @return bool |
198 | 198 | */ |
199 | - public function delete( $row_id = 0 ) { |
|
199 | + public function delete($row_id = 0) { |
|
200 | 200 | |
201 | 201 | global $wpdb; |
202 | 202 | |
203 | 203 | // Row ID must be positive integer |
204 | - $row_id = absint( $row_id ); |
|
204 | + $row_id = absint($row_id); |
|
205 | 205 | |
206 | - if( empty( $row_id ) ) { |
|
206 | + if (empty($row_id)) { |
|
207 | 207 | return false; |
208 | 208 | } |
209 | 209 | |
210 | - if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) { |
|
210 | + if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) { |
|
211 | 211 | return false; |
212 | 212 | } |
213 | 213 | |
@@ -221,11 +221,11 @@ discard block |
||
221 | 221 | * @param string $table The table name |
222 | 222 | * @return bool If the table name exists |
223 | 223 | */ |
224 | - public function table_exists( $table ) { |
|
224 | + public function table_exists($table) { |
|
225 | 225 | global $wpdb; |
226 | - $table = sanitize_text_field( $table ); |
|
226 | + $table = sanitize_text_field($table); |
|
227 | 227 | |
228 | - return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table; |
|
228 | + return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table; |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * @return bool Returns if the customers table was installed and upgrade routine run |
236 | 236 | */ |
237 | 237 | public function installed() { |
238 | - return $this->table_exists( $this->table_name ); |
|
238 | + return $this->table_exists($this->table_name); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | } |
@@ -1,7 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Exit if accessed directly |
4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
4 | +if ( ! defined( 'ABSPATH' ) ) { |
|
5 | + exit; |
|
6 | +} |
|
5 | 7 | |
6 | 8 | abstract class Wpinv_DB { |
7 | 9 |
@@ -1,6 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly |
3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
3 | +if ( ! defined( 'ABSPATH' ) ) { |
|
4 | + exit; |
|
5 | +} |
|
4 | 6 | |
5 | 7 | function wpinv_get_users_invoices( $user = 0, $number = 20, $pagination = false, $status = 'publish', $orderby = 'ID', $order = 'DESC' ) { |
6 | 8 | if ( empty( $user ) ) { |
@@ -159,11 +159,11 @@ discard block |
||
159 | 159 | */ |
160 | 160 | function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) { |
161 | 161 | |
162 | - if ( current_user_can( 'manage_options' ) ) { |
|
163 | - return 'manage_options'; |
|
164 | - }; |
|
162 | + if ( current_user_can( 'manage_options' ) ) { |
|
163 | + return 'manage_options'; |
|
164 | + }; |
|
165 | 165 | |
166 | - return $capalibilty; |
|
166 | + return $capalibilty; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -185,10 +185,10 @@ discard block |
||
185 | 185 | function wpinv_create_user( $email ) { |
186 | 186 | |
187 | 187 | // Prepare user values. |
188 | - $args = array( |
|
189 | - 'user_login' => wpinv_generate_user_name( $email ), |
|
190 | - 'user_pass' => wp_generate_password(), |
|
191 | - 'user_email' => $email, |
|
188 | + $args = array( |
|
189 | + 'user_login' => wpinv_generate_user_name( $email ), |
|
190 | + 'user_pass' => wp_generate_password(), |
|
191 | + 'user_email' => $email, |
|
192 | 192 | 'role' => 'subscriber', |
193 | 193 | ); |
194 | 194 | |
@@ -205,20 +205,20 @@ discard block |
||
205 | 205 | function wpinv_generate_user_name( $prefix = '' ) { |
206 | 206 | |
207 | 207 | // If prefix is an email, retrieve the part before the email. |
208 | - $prefix = strtok( $prefix, '@' ); |
|
208 | + $prefix = strtok( $prefix, '@' ); |
|
209 | 209 | |
210 | - // Trim to 4 characters max. |
|
211 | - $prefix = sanitize_user( $prefix ); |
|
210 | + // Trim to 4 characters max. |
|
211 | + $prefix = sanitize_user( $prefix ); |
|
212 | 212 | |
213 | - $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
214 | - if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
215 | - $prefix = 'gtp'; |
|
216 | - } |
|
213 | + $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
214 | + if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
215 | + $prefix = 'gtp'; |
|
216 | + } |
|
217 | 217 | |
218 | - $username = $prefix . '_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
219 | - if ( username_exists( $username ) ) { |
|
220 | - return wpinv_generate_user_name( $username ); |
|
221 | - } |
|
218 | + $username = $prefix . '_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
219 | + if ( username_exists( $username ) ) { |
|
220 | + return wpinv_generate_user_name( $username ); |
|
221 | + } |
|
222 | 222 | |
223 | 223 | return $username; |
224 | 224 | } |
@@ -1,22 +1,22 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly |
3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
3 | +if (!defined('ABSPATH')) exit; |
|
4 | 4 | |
5 | -function wpinv_get_users_invoices( $user = 0, $number = 20, $pagination = false, $status = 'publish', $orderby = 'ID', $order = 'DESC' ) { |
|
6 | - if ( empty( $user ) ) { |
|
5 | +function wpinv_get_users_invoices($user = 0, $number = 20, $pagination = false, $status = 'publish', $orderby = 'ID', $order = 'DESC') { |
|
6 | + if (empty($user)) { |
|
7 | 7 | $user = get_current_user_id(); |
8 | 8 | } |
9 | 9 | |
10 | - if ( empty( $user ) ) { |
|
10 | + if (empty($user)) { |
|
11 | 11 | return false; |
12 | 12 | } |
13 | 13 | |
14 | - $args = apply_filters( 'wpinv_get_users_invoices_args', array( 'user' => $user, 'limit' => $number, 'status' => $status, 'paginate' => $pagination, 'orderby' => $orderby, 'order' => $order ) ); |
|
14 | + $args = apply_filters('wpinv_get_users_invoices_args', array('user' => $user, 'limit' => $number, 'status' => $status, 'paginate' => $pagination, 'orderby' => $orderby, 'order' => $order)); |
|
15 | 15 | |
16 | - return wpinv_get_invoices( $args ); |
|
16 | + return wpinv_get_invoices($args); |
|
17 | 17 | } |
18 | 18 | |
19 | -function wpinv_dropdown_users( $args = '' ) { |
|
19 | +function wpinv_dropdown_users($args = '') { |
|
20 | 20 | $defaults = array( |
21 | 21 | 'show_option_all' => '', 'show_option_none' => '', 'hide_if_only_one_author' => '', |
22 | 22 | 'orderby' => 'display_name', 'order' => 'ASC', |
@@ -27,18 +27,18 @@ discard block |
||
27 | 27 | 'option_none_value' => -1 |
28 | 28 | ); |
29 | 29 | |
30 | - $defaults['selected'] = is_author() ? get_query_var( 'author' ) : 0; |
|
30 | + $defaults['selected'] = is_author() ? get_query_var('author') : 0; |
|
31 | 31 | |
32 | - $r = wp_parse_args( $args, $defaults ); |
|
32 | + $r = wp_parse_args($args, $defaults); |
|
33 | 33 | |
34 | - $query_args = wp_array_slice_assoc( $r, array( 'blog_id', 'include', 'exclude', 'orderby', 'order', 'who' ) ); |
|
34 | + $query_args = wp_array_slice_assoc($r, array('blog_id', 'include', 'exclude', 'orderby', 'order', 'who')); |
|
35 | 35 | |
36 | - $fields = array( 'ID', 'user_login', 'user_email' ); |
|
36 | + $fields = array('ID', 'user_login', 'user_email'); |
|
37 | 37 | |
38 | - $show = ! empty( $r['show'] ) ? $r['show'] : 'display_name'; |
|
39 | - if ( 'display_name_with_login' === $show ) { |
|
38 | + $show = !empty($r['show']) ? $r['show'] : 'display_name'; |
|
39 | + if ('display_name_with_login' === $show) { |
|
40 | 40 | $fields[] = 'display_name'; |
41 | - } else if ( 'display_name_with_email' === $show ) { |
|
41 | + } else if ('display_name_with_email' === $show) { |
|
42 | 42 | $fields[] = 'display_name'; |
43 | 43 | } else { |
44 | 44 | $fields[] = $show; |
@@ -50,99 +50,99 @@ discard block |
||
50 | 50 | $show_option_none = $r['show_option_none']; |
51 | 51 | $option_none_value = $r['option_none_value']; |
52 | 52 | |
53 | - $query_args = apply_filters( 'wpinv_dropdown_users_args', $query_args, $r ); |
|
53 | + $query_args = apply_filters('wpinv_dropdown_users_args', $query_args, $r); |
|
54 | 54 | |
55 | - $users = get_users( $query_args ); |
|
55 | + $users = get_users($query_args); |
|
56 | 56 | |
57 | 57 | $output = ''; |
58 | - if ( ! empty( $users ) && ( empty( $r['hide_if_only_one_author'] ) || count( $users ) > 1 ) ) { |
|
59 | - $name = esc_attr( $r['name'] ); |
|
60 | - if ( $r['multi'] && ! $r['id'] ) { |
|
58 | + if (!empty($users) && (empty($r['hide_if_only_one_author']) || count($users) > 1)) { |
|
59 | + $name = esc_attr($r['name']); |
|
60 | + if ($r['multi'] && !$r['id']) { |
|
61 | 61 | $id = ''; |
62 | 62 | } else { |
63 | - $id = $r['id'] ? " id='" . esc_attr( $r['id'] ) . "'" : " id='$name'"; |
|
63 | + $id = $r['id'] ? " id='" . esc_attr($r['id']) . "'" : " id='$name'"; |
|
64 | 64 | } |
65 | 65 | $output = "<select name='{$name}'{$id} class='" . $r['class'] . "'>\n"; |
66 | 66 | |
67 | - if ( $show_option_all ) { |
|
67 | + if ($show_option_all) { |
|
68 | 68 | $output .= "\t<option value='0'>$show_option_all</option>\n"; |
69 | 69 | } |
70 | 70 | |
71 | - if ( $show_option_none ) { |
|
72 | - $_selected = selected( $option_none_value, $r['selected'], false ); |
|
73 | - $output .= "\t<option value='" . esc_attr( $option_none_value ) . "'$_selected>$show_option_none</option>\n"; |
|
71 | + if ($show_option_none) { |
|
72 | + $_selected = selected($option_none_value, $r['selected'], false); |
|
73 | + $output .= "\t<option value='" . esc_attr($option_none_value) . "'$_selected>$show_option_none</option>\n"; |
|
74 | 74 | } |
75 | 75 | |
76 | - if ( $r['include_selected'] && ( $r['selected'] > 0 ) ) { |
|
76 | + if ($r['include_selected'] && ($r['selected'] > 0)) { |
|
77 | 77 | $found_selected = false; |
78 | 78 | $r['selected'] = (int) $r['selected']; |
79 | - foreach ( (array) $users as $user ) { |
|
79 | + foreach ((array) $users as $user) { |
|
80 | 80 | $user->ID = (int) $user->ID; |
81 | - if ( $user->ID === $r['selected'] ) { |
|
81 | + if ($user->ID === $r['selected']) { |
|
82 | 82 | $found_selected = true; |
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | - if ( ! $found_selected ) { |
|
87 | - $users[] = get_userdata( $r['selected'] ); |
|
86 | + if (!$found_selected) { |
|
87 | + $users[] = get_userdata($r['selected']); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
91 | - foreach ( (array) $users as $user ) { |
|
92 | - if ( 'display_name_with_login' === $show ) { |
|
91 | + foreach ((array) $users as $user) { |
|
92 | + if ('display_name_with_login' === $show) { |
|
93 | 93 | /* translators: 1: display name, 2: user_login */ |
94 | - $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown' ), $user->display_name, $user->user_login ); |
|
95 | - } elseif ( 'display_name_with_email' === $show ) { |
|
94 | + $display = sprintf(_x('%1$s (%2$s)', 'user dropdown'), $user->display_name, $user->user_login); |
|
95 | + } elseif ('display_name_with_email' === $show) { |
|
96 | 96 | /* translators: 1: display name, 2: user_email */ |
97 | - if ( $user->display_name == $user->user_email ) { |
|
97 | + if ($user->display_name == $user->user_email) { |
|
98 | 98 | $display = $user->display_name; |
99 | 99 | } else { |
100 | - $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown' ), $user->display_name, $user->user_email ); |
|
100 | + $display = sprintf(_x('%1$s (%2$s)', 'user dropdown'), $user->display_name, $user->user_email); |
|
101 | 101 | } |
102 | - } elseif ( ! empty( $user->$show ) ) { |
|
102 | + } elseif (!empty($user->$show)) { |
|
103 | 103 | $display = $user->$show; |
104 | 104 | } else { |
105 | 105 | $display = '(' . $user->user_login . ')'; |
106 | 106 | } |
107 | 107 | |
108 | - $_selected = selected( $user->ID, $r['selected'], false ); |
|
109 | - $output .= "\t<option value='$user->ID'$_selected>" . esc_html( $display ) . "</option>\n"; |
|
108 | + $_selected = selected($user->ID, $r['selected'], false); |
|
109 | + $output .= "\t<option value='$user->ID'$_selected>" . esc_html($display) . "</option>\n"; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | $output .= "</select>"; |
113 | 113 | } |
114 | 114 | |
115 | - $html = apply_filters( 'wpinv_dropdown_users', $output ); |
|
115 | + $html = apply_filters('wpinv_dropdown_users', $output); |
|
116 | 116 | |
117 | - if ( $r['echo'] ) { |
|
117 | + if ($r['echo']) { |
|
118 | 118 | echo $html; |
119 | 119 | } |
120 | 120 | return $html; |
121 | 121 | } |
122 | 122 | |
123 | -function wpinv_guest_redirect( $redirect_to, $user_id = 0 ) { |
|
124 | - if ( (int)wpinv_get_option( 'guest_checkout' ) && $user_id > 0 ) { |
|
125 | - wpinv_login_user( $user_id ); |
|
123 | +function wpinv_guest_redirect($redirect_to, $user_id = 0) { |
|
124 | + if ((int) wpinv_get_option('guest_checkout') && $user_id > 0) { |
|
125 | + wpinv_login_user($user_id); |
|
126 | 126 | } else { |
127 | - $redirect_to = wp_login_url( $redirect_to ); |
|
127 | + $redirect_to = wp_login_url($redirect_to); |
|
128 | 128 | } |
129 | 129 | |
130 | - $redirect_to = apply_filters( 'wpinv_invoice_link_guest_redirect', $redirect_to, $user_id ); |
|
130 | + $redirect_to = apply_filters('wpinv_invoice_link_guest_redirect', $redirect_to, $user_id); |
|
131 | 131 | |
132 | - wp_redirect( $redirect_to ); |
|
132 | + wp_redirect($redirect_to); |
|
133 | 133 | } |
134 | 134 | |
135 | -function wpinv_login_user( $user_id ) { |
|
136 | - if ( is_user_logged_in() ) { |
|
135 | +function wpinv_login_user($user_id) { |
|
136 | + if (is_user_logged_in()) { |
|
137 | 137 | return true; |
138 | 138 | } |
139 | 139 | |
140 | - $user = get_user_by( 'id', $user_id ); |
|
140 | + $user = get_user_by('id', $user_id); |
|
141 | 141 | |
142 | - if ( !empty( $user ) && !is_wp_error( $user ) && !empty( $user->user_login ) ) { |
|
143 | - wp_set_current_user( $user_id, $user->user_login ); |
|
144 | - wp_set_auth_cookie( $user_id ); |
|
145 | - do_action( 'wp_login', $user->user_login ); |
|
142 | + if (!empty($user) && !is_wp_error($user) && !empty($user->user_login)) { |
|
143 | + wp_set_current_user($user_id, $user->user_login); |
|
144 | + wp_set_auth_cookie($user_id); |
|
145 | + do_action('wp_login', $user->user_login); |
|
146 | 146 | |
147 | 147 | return true; |
148 | 148 | } |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | * @return string capability to check against |
158 | 158 | * @param string $capalibilty Optional. The alternative capability to check against. |
159 | 159 | */ |
160 | -function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) { |
|
160 | +function wpinv_get_capability($capalibilty = 'manage_invoicing') { |
|
161 | 161 | |
162 | - if ( current_user_can( 'manage_options' ) ) { |
|
162 | + if (current_user_can('manage_options')) { |
|
163 | 163 | return 'manage_options'; |
164 | 164 | }; |
165 | 165 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @return bool |
174 | 174 | */ |
175 | 175 | function wpinv_current_user_can_manage_invoicing() { |
176 | - return current_user_can( wpinv_get_capability() ); |
|
176 | + return current_user_can(wpinv_get_capability()); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
@@ -182,17 +182,17 @@ discard block |
||
182 | 182 | * @since 1.0.19 |
183 | 183 | * @return int|WP_Error |
184 | 184 | */ |
185 | -function wpinv_create_user( $email ) { |
|
185 | +function wpinv_create_user($email) { |
|
186 | 186 | |
187 | 187 | // Prepare user values. |
188 | 188 | $args = array( |
189 | - 'user_login' => wpinv_generate_user_name( $email ), |
|
189 | + 'user_login' => wpinv_generate_user_name($email), |
|
190 | 190 | 'user_pass' => wp_generate_password(), |
191 | 191 | 'user_email' => $email, |
192 | 192 | 'role' => 'subscriber', |
193 | 193 | ); |
194 | 194 | |
195 | - return wp_insert_user( $args ); |
|
195 | + return wp_insert_user($args); |
|
196 | 196 | |
197 | 197 | } |
198 | 198 | |
@@ -202,22 +202,22 @@ discard block |
||
202 | 202 | * @since 1.0.19 |
203 | 203 | * @return bool|WP_User |
204 | 204 | */ |
205 | -function wpinv_generate_user_name( $prefix = '' ) { |
|
205 | +function wpinv_generate_user_name($prefix = '') { |
|
206 | 206 | |
207 | 207 | // If prefix is an email, retrieve the part before the email. |
208 | - $prefix = strtok( $prefix, '@' ); |
|
208 | + $prefix = strtok($prefix, '@'); |
|
209 | 209 | |
210 | 210 | // Trim to 4 characters max. |
211 | - $prefix = sanitize_user( $prefix ); |
|
211 | + $prefix = sanitize_user($prefix); |
|
212 | 212 | |
213 | - $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
214 | - if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
213 | + $illegal_logins = (array) apply_filters('illegal_user_logins', array()); |
|
214 | + if (empty($prefix) || in_array(strtolower($prefix), array_map('strtolower', $illegal_logins), true)) { |
|
215 | 215 | $prefix = 'gtp'; |
216 | 216 | } |
217 | 217 | |
218 | - $username = $prefix . '_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
219 | - if ( username_exists( $username ) ) { |
|
220 | - return wpinv_generate_user_name( $username ); |
|
218 | + $username = $prefix . '_' . zeroise(wp_rand(0, 9999), 4); |
|
219 | + if (username_exists($username)) { |
|
220 | + return wpinv_generate_user_name($username); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | return $username; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; // Exit if accessed directly |
4 | 4 | } |
5 | 5 | |
@@ -14,18 +14,18 @@ discard block |
||
14 | 14 | * Hook in methods. |
15 | 15 | */ |
16 | 16 | public static function init() { |
17 | - add_action( 'init', array( __CLASS__, 'init_hooks' ), 0 ); |
|
18 | - add_action( 'admin_notices', array( __CLASS__, 'notices' ) ); |
|
17 | + add_action('init', array(__CLASS__, 'init_hooks'), 0); |
|
18 | + add_action('admin_notices', array(__CLASS__, 'notices')); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | public static function init_hooks() { |
22 | - if ( false === ( $page_uris = get_transient( 'wpinv_cache_excluded_uris' ) ) ) { |
|
23 | - $checkout_page = wpinv_get_option( 'checkout_page', '' ); |
|
24 | - $success_page = wpinv_get_option( 'success_page', '' ); |
|
25 | - $failure_page = wpinv_get_option( 'failure_page', '' ); |
|
26 | - $history_page = wpinv_get_option( 'invoice_history_page', '' ); |
|
27 | - $subscr_page = wpinv_get_option( 'invoice_subscription_page', '' ); |
|
28 | - if ( empty( $checkout_page ) || empty( $success_page ) || empty( $failure_page ) || empty( $history_page ) || empty( $subscr_page ) ) { |
|
22 | + if (false === ($page_uris = get_transient('wpinv_cache_excluded_uris'))) { |
|
23 | + $checkout_page = wpinv_get_option('checkout_page', ''); |
|
24 | + $success_page = wpinv_get_option('success_page', ''); |
|
25 | + $failure_page = wpinv_get_option('failure_page', ''); |
|
26 | + $history_page = wpinv_get_option('invoice_history_page', ''); |
|
27 | + $subscr_page = wpinv_get_option('invoice_subscription_page', ''); |
|
28 | + if (empty($checkout_page) || empty($success_page) || empty($failure_page) || empty($history_page) || empty($subscr_page)) { |
|
29 | 29 | return; |
30 | 30 | } |
31 | 31 | |
@@ -39,34 +39,34 @@ discard block |
||
39 | 39 | $page_uris[] = 'p=' . $subscr_page; |
40 | 40 | |
41 | 41 | // Exclude permalinks |
42 | - $checkout_page = get_post( $checkout_page ); |
|
43 | - $success_page = get_post( $success_page ); |
|
44 | - $failure_page = get_post( $failure_page ); |
|
45 | - $history_page = get_post( $history_page ); |
|
46 | - $subscr_page = get_post( $subscr_page ); |
|
42 | + $checkout_page = get_post($checkout_page); |
|
43 | + $success_page = get_post($success_page); |
|
44 | + $failure_page = get_post($failure_page); |
|
45 | + $history_page = get_post($history_page); |
|
46 | + $subscr_page = get_post($subscr_page); |
|
47 | 47 | |
48 | - if ( ! is_null( $checkout_page ) ) { |
|
48 | + if (!is_null($checkout_page)) { |
|
49 | 49 | $page_uris[] = '/' . $checkout_page->post_name; |
50 | 50 | } |
51 | - if ( ! is_null( $success_page ) ) { |
|
51 | + if (!is_null($success_page)) { |
|
52 | 52 | $page_uris[] = '/' . $success_page->post_name; |
53 | 53 | } |
54 | - if ( ! is_null( $failure_page ) ) { |
|
54 | + if (!is_null($failure_page)) { |
|
55 | 55 | $page_uris[] = '/' . $failure_page->post_name; |
56 | 56 | } |
57 | - if ( ! is_null( $history_page ) ) { |
|
57 | + if (!is_null($history_page)) { |
|
58 | 58 | $page_uris[] = '/' . $history_page->post_name; |
59 | 59 | } |
60 | - if ( ! is_null( $subscr_page ) ) { |
|
60 | + if (!is_null($subscr_page)) { |
|
61 | 61 | $page_uris[] = '/' . $subscr_page->post_name; |
62 | 62 | } |
63 | 63 | |
64 | - set_transient( 'wpinv_cache_excluded_uris', $page_uris ); |
|
64 | + set_transient('wpinv_cache_excluded_uris', $page_uris); |
|
65 | 65 | } |
66 | 66 | |
67 | - if ( is_array( $page_uris ) ) { |
|
68 | - foreach( $page_uris as $uri ) { |
|
69 | - if ( strstr( $_SERVER['REQUEST_URI'], $uri ) ) { |
|
67 | + if (is_array($page_uris)) { |
|
68 | + foreach ($page_uris as $uri) { |
|
69 | + if (strstr($_SERVER['REQUEST_URI'], $uri)) { |
|
70 | 70 | self::nocache(); |
71 | 71 | break; |
72 | 72 | } |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | * @access private |
80 | 80 | */ |
81 | 81 | private static function nocache() { |
82 | - if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
|
83 | - define( "DONOTCACHEPAGE", true ); |
|
82 | + if (!defined('DONOTCACHEPAGE')) { |
|
83 | + define("DONOTCACHEPAGE", true); |
|
84 | 84 | } |
85 | - if ( ! defined( 'DONOTCACHEOBJECT' ) ) { |
|
86 | - define( "DONOTCACHEOBJECT", true ); |
|
85 | + if (!defined('DONOTCACHEOBJECT')) { |
|
86 | + define("DONOTCACHEOBJECT", true); |
|
87 | 87 | } |
88 | - if ( ! defined( 'DONOTCACHEDB' ) ) { |
|
89 | - define( "DONOTCACHEDB", true ); |
|
88 | + if (!defined('DONOTCACHEDB')) { |
|
89 | + define("DONOTCACHEDB", true); |
|
90 | 90 | } |
91 | 91 | nocache_headers(); |
92 | 92 | } |
@@ -95,18 +95,18 @@ discard block |
||
95 | 95 | * notices function. |
96 | 96 | */ |
97 | 97 | public static function notices() { |
98 | - if ( ! function_exists( 'w3tc_pgcache_flush' ) || ! function_exists( 'w3_instance' ) ) { |
|
98 | + if (!function_exists('w3tc_pgcache_flush') || !function_exists('w3_instance')) { |
|
99 | 99 | return; |
100 | 100 | } |
101 | 101 | |
102 | - $config = w3_instance( 'W3_Config' ); |
|
103 | - $enabled = $config->get_integer( 'dbcache.enabled' ); |
|
104 | - $settings = array_map( 'trim', $config->get_array( 'dbcache.reject.sql' ) ); |
|
102 | + $config = w3_instance('W3_Config'); |
|
103 | + $enabled = $config->get_integer('dbcache.enabled'); |
|
104 | + $settings = array_map('trim', $config->get_array('dbcache.reject.sql')); |
|
105 | 105 | |
106 | - if ( $enabled && ! in_array( '_wp_session_', $settings ) ) { |
|
106 | + if ($enabled && !in_array('_wp_session_', $settings)) { |
|
107 | 107 | ?> |
108 | 108 | <div class="error"> |
109 | - <p><?php printf( __( 'In order for <strong>database caching</strong> to work with Invoicing you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'invoicing' ), '<code>_wp_session_</code>', admin_url( 'admin.php?page=w3tc_dbcache' ) ); ?></p> |
|
109 | + <p><?php printf(__('In order for <strong>database caching</strong> to work with Invoicing you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'invoicing'), '<code>_wp_session_</code>', admin_url('admin.php?page=w3tc_dbcache')); ?></p> |
|
110 | 110 | </div> |
111 | 111 | <?php |
112 | 112 | } |
@@ -79,7 +79,7 @@ |
||
79 | 79 | |
80 | 80 | if(empty($count)){ |
81 | 81 | $output .= __('No Invoice(s)','invoicing'); |
82 | - }else{ |
|
82 | + } else{ |
|
83 | 83 | $link_url = admin_url( "edit.php?post_type=wpi_invoice&author=".absint($user_id) ); |
84 | 84 | $link_text = sprintf( __('Invoices ( %d )', 'invoicing'), $count ); |
85 | 85 | $output .= "<a href='$link_url' >$link_text</a>"; |
@@ -7,15 +7,15 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | class WPInv_Admin_Users { |
15 | 15 | private static $instance; |
16 | 16 | |
17 | 17 | public static function run() { |
18 | - if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Admin_Users ) ) { |
|
18 | + if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Admin_Users)) { |
|
19 | 19 | self::$instance = new WPInv_Admin_Users; |
20 | 20 | } |
21 | 21 | |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | } |
24 | 24 | |
25 | 25 | public function __construct() { |
26 | - add_filter( 'manage_users_columns', array( $this, 'wpinv_add_user_column') ); |
|
27 | - add_filter( 'manage_users_custom_column', array( $this, 'wpinv_user_column_content') , 10, 3 ); |
|
26 | + add_filter('manage_users_columns', array($this, 'wpinv_add_user_column')); |
|
27 | + add_filter('manage_users_custom_column', array($this, 'wpinv_user_column_content'), 10, 3); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @return mixed |
36 | 36 | */ |
37 | - public function wpinv_add_user_column( $column ) { |
|
38 | - $column['wpinvoicing'] = __('Invoicing','invoicing'); |
|
37 | + public function wpinv_add_user_column($column) { |
|
38 | + $column['wpinvoicing'] = __('Invoicing', 'invoicing'); |
|
39 | 39 | return $column; |
40 | 40 | } |
41 | 41 | |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return string |
50 | 50 | */ |
51 | - function wpinv_user_column_content( $val, $column_name, $user_id ) { |
|
51 | + function wpinv_user_column_content($val, $column_name, $user_id) { |
|
52 | 52 | switch ($column_name) { |
53 | 53 | case 'wpinvoicing' : |
54 | - return $this->get_user_invoices( $user_id ); |
|
54 | + return $this->get_user_invoices($user_id); |
|
55 | 55 | break; |
56 | 56 | default: |
57 | 57 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @return string |
67 | 67 | */ |
68 | - public function get_user_invoices($user_id){ |
|
68 | + public function get_user_invoices($user_id) { |
|
69 | 69 | $output = ''; |
70 | 70 | $wp_query_args = array( |
71 | 71 | 'post_type' => 'wpi_invoice', |
@@ -77,14 +77,14 @@ discard block |
||
77 | 77 | |
78 | 78 | $wp_query_args = apply_filters('wpinv_get_user_invoices_args', $wp_query_args, $user_id); |
79 | 79 | |
80 | - $invoices = new WP_Query( $wp_query_args ); |
|
81 | - $count = absint( $invoices->found_posts ); |
|
80 | + $invoices = new WP_Query($wp_query_args); |
|
81 | + $count = absint($invoices->found_posts); |
|
82 | 82 | |
83 | - if(empty($count)){ |
|
84 | - $output .= __('No Invoice(s)','invoicing'); |
|
85 | - }else{ |
|
86 | - $link_url = admin_url( "edit.php?post_type=wpi_invoice&author=".absint($user_id) ); |
|
87 | - $link_text = sprintf( __('Invoices ( %d )', 'invoicing'), $count ); |
|
83 | + if (empty($count)) { |
|
84 | + $output .= __('No Invoice(s)', 'invoicing'); |
|
85 | + } else { |
|
86 | + $link_url = admin_url("edit.php?post_type=wpi_invoice&author=" . absint($user_id)); |
|
87 | + $link_text = sprintf(__('Invoices ( %d )', 'invoicing'), $count); |
|
88 | 88 | $output .= "<a href='$link_url' >$link_text</a>"; |
89 | 89 | } |
90 | 90 |
@@ -15,12 +15,12 @@ |
||
15 | 15 | */ |
16 | 16 | |
17 | 17 | if ( ! defined( 'ABSPATH' ) ) { |
18 | - exit; |
|
18 | + exit; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | if ( ! class_exists( 'WP_Super_Duper' ) ) { |
22 | - // include the class if needed |
|
23 | - include_once( dirname( __FILE__ ) . "/wp-super-duper.php" ); |
|
22 | + // include the class if needed |
|
23 | + include_once( dirname( __FILE__ ) . "/wp-super-duper.php" ); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /* |
@@ -14,21 +14,21 @@ |
||
14 | 14 | * Tested up to: 5.3 |
15 | 15 | */ |
16 | 16 | |
17 | -if ( ! defined( 'ABSPATH' ) ) { |
|
17 | +if (!defined('ABSPATH')) { |
|
18 | 18 | exit; |
19 | 19 | } |
20 | 20 | |
21 | -if ( ! class_exists( 'WP_Super_Duper' ) ) { |
|
21 | +if (!class_exists('WP_Super_Duper')) { |
|
22 | 22 | // include the class if needed |
23 | - include_once( dirname( __FILE__ ) . "/wp-super-duper.php" ); |
|
23 | + include_once(dirname(__FILE__) . "/wp-super-duper.php"); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /* |
27 | 27 | * Hello world example. |
28 | 28 | */ |
29 | -include_once( dirname( __FILE__ ) . "/hello-world.php" ); |
|
29 | +include_once(dirname(__FILE__) . "/hello-world.php"); |
|
30 | 30 | |
31 | 31 | /* |
32 | 32 | * Map example. |
33 | 33 | */ |
34 | -include_once( dirname( __FILE__ ) . "/map.php" ); |
|
34 | +include_once(dirname(__FILE__) . "/map.php"); |
@@ -3,241 +3,241 @@ |
||
3 | 3 | class SD_Map extends WP_Super_Duper { |
4 | 4 | |
5 | 5 | |
6 | - public $arguments; |
|
7 | - |
|
8 | - /** |
|
9 | - * Sets up the widgets name etc |
|
10 | - */ |
|
11 | - public function __construct() { |
|
12 | - |
|
13 | - $options = array( |
|
14 | - 'textdomain' => 'super-duper', |
|
15 | - // textdomain of the plugin/theme (used to prefix the Gutenberg block) |
|
16 | - 'block-icon' => 'admin-site', |
|
17 | - // Dash icon name for the block: https://developer.wordpress.org/resource/dashicons/#arrow-right |
|
18 | - 'block-category' => 'widgets', |
|
19 | - // the category for the block, 'common', 'formatting', 'layout', 'widgets', 'embed'. |
|
20 | - 'block-keywords' => "['map','super','google']", |
|
21 | - // used in the block search, MAX 3 |
|
22 | - 'block-output' => array( // the block visual output elements as an array |
|
23 | - array( |
|
24 | - 'element' => 'p', |
|
25 | - 'content' => __('A Google API key is required to use this block, we recommend installing our plugin which makes it easy and sets it globally, or you can set a key in the block settings sidebar: ','super-duper'), |
|
26 | - //'element_require' => '"1"=='.get_option( 'rgmk_google_map_api_key', '"0"') ? '"0"' : '"1"', |
|
27 | - 'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""', |
|
28 | - ), |
|
29 | - array( |
|
30 | - 'element' => 'a', |
|
31 | - 'content' => __('API KEY for Google Maps','super-duper'), |
|
32 | - 'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""', |
|
33 | - 'href' => 'https://wordpress.org/plugins/api-key-for-google-maps/', |
|
34 | - ), |
|
35 | - array( |
|
36 | - 'element' => 'img', |
|
37 | - 'class' => '[%className%]', |
|
38 | - //'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%] |
|
39 | - 'element_require' => '[%type%]=="image"', |
|
40 | - 'src' => get_option( 'rgmk_google_map_api_key', false) ? "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=".get_option( 'rgmk_google_map_api_key') : "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=[%api_key%]" |
|
41 | - ), |
|
42 | - array( |
|
43 | - 'element' => 'div', |
|
44 | - 'class' => 'sd-map-iframe-cover', |
|
45 | - 'style' => '{overflow:"hidden", position:"relative"}', |
|
46 | - array( |
|
47 | - 'element' => 'iframe', |
|
48 | - 'title' => __( 'Placeholderx', 'super-duper' ), |
|
49 | - 'class' => '[%className%]', |
|
50 | - 'width' => '[%width%]', |
|
51 | - 'height' => '[%height%]', |
|
52 | - 'frameborder' => '0', |
|
53 | - 'allowfullscreen' => 'true', |
|
54 | - 'style' => '{border:0}', |
|
55 | - 'element_require' => '[%type%]!="image"', |
|
56 | - 'src' => get_option( 'rgmk_google_map_api_key', false) ? "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=".get_option( 'rgmk_google_map_api_key') : "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=[%api_key%]" |
|
57 | - ), |
|
58 | - ), |
|
59 | - array( |
|
60 | - 'element' => 'style', |
|
61 | - 'content' => '.sd-map-iframe-cover:hover:before {background: #4a4a4a88; content: "'.__("Click here, Settings are in the block settings sidebar","super-duper").'";} .sd-map-iframe-cover:before{cursor: pointer; content: ""; width: 100%; height: 100%; position: absolute; top: 0; bottom: 0;padding-top: 33%; text-align: center; color: #fff; font-size: 20px; font-weight: bold;}', |
|
62 | - 'element_require' => '[%type%]!="image"', |
|
63 | - ), |
|
64 | - ), |
|
65 | - 'class_name' => __CLASS__, |
|
66 | - // The calling class name |
|
67 | - 'base_id' => 'sd_map', |
|
68 | - // this is used as the widget id and the shortcode id. |
|
69 | - 'name' => __( 'Map', 'super-duper' ), |
|
70 | - // the name of the widget/block |
|
71 | - 'widget_ops' => array( |
|
72 | - 'classname' => 'sd-map-class', |
|
73 | - // widget class |
|
74 | - 'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world' ), |
|
75 | - // widget description |
|
76 | - ), |
|
77 | - 'arguments' => array( // these are the arguments that will be used in the widget, shortcode and block settings. |
|
78 | - 'type' => array( |
|
79 | - 'title' => __('Map Type:', 'geodirectory'), |
|
80 | - 'desc' => __('Select the map type to use.', 'geodirectory'), |
|
81 | - 'type' => 'select', |
|
82 | - 'options' => array( |
|
83 | - "image" => __('Static Image', 'geodirectory'), |
|
84 | - "place" => __('Place', 'geodirectory'), |
|
6 | + public $arguments; |
|
7 | + |
|
8 | + /** |
|
9 | + * Sets up the widgets name etc |
|
10 | + */ |
|
11 | + public function __construct() { |
|
12 | + |
|
13 | + $options = array( |
|
14 | + 'textdomain' => 'super-duper', |
|
15 | + // textdomain of the plugin/theme (used to prefix the Gutenberg block) |
|
16 | + 'block-icon' => 'admin-site', |
|
17 | + // Dash icon name for the block: https://developer.wordpress.org/resource/dashicons/#arrow-right |
|
18 | + 'block-category' => 'widgets', |
|
19 | + // the category for the block, 'common', 'formatting', 'layout', 'widgets', 'embed'. |
|
20 | + 'block-keywords' => "['map','super','google']", |
|
21 | + // used in the block search, MAX 3 |
|
22 | + 'block-output' => array( // the block visual output elements as an array |
|
23 | + array( |
|
24 | + 'element' => 'p', |
|
25 | + 'content' => __('A Google API key is required to use this block, we recommend installing our plugin which makes it easy and sets it globally, or you can set a key in the block settings sidebar: ','super-duper'), |
|
26 | + //'element_require' => '"1"=='.get_option( 'rgmk_google_map_api_key', '"0"') ? '"0"' : '"1"', |
|
27 | + 'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""', |
|
28 | + ), |
|
29 | + array( |
|
30 | + 'element' => 'a', |
|
31 | + 'content' => __('API KEY for Google Maps','super-duper'), |
|
32 | + 'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""', |
|
33 | + 'href' => 'https://wordpress.org/plugins/api-key-for-google-maps/', |
|
34 | + ), |
|
35 | + array( |
|
36 | + 'element' => 'img', |
|
37 | + 'class' => '[%className%]', |
|
38 | + //'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%] |
|
39 | + 'element_require' => '[%type%]=="image"', |
|
40 | + 'src' => get_option( 'rgmk_google_map_api_key', false) ? "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=".get_option( 'rgmk_google_map_api_key') : "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=[%api_key%]" |
|
41 | + ), |
|
42 | + array( |
|
43 | + 'element' => 'div', |
|
44 | + 'class' => 'sd-map-iframe-cover', |
|
45 | + 'style' => '{overflow:"hidden", position:"relative"}', |
|
46 | + array( |
|
47 | + 'element' => 'iframe', |
|
48 | + 'title' => __( 'Placeholderx', 'super-duper' ), |
|
49 | + 'class' => '[%className%]', |
|
50 | + 'width' => '[%width%]', |
|
51 | + 'height' => '[%height%]', |
|
52 | + 'frameborder' => '0', |
|
53 | + 'allowfullscreen' => 'true', |
|
54 | + 'style' => '{border:0}', |
|
55 | + 'element_require' => '[%type%]!="image"', |
|
56 | + 'src' => get_option( 'rgmk_google_map_api_key', false) ? "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=".get_option( 'rgmk_google_map_api_key') : "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=[%api_key%]" |
|
57 | + ), |
|
58 | + ), |
|
59 | + array( |
|
60 | + 'element' => 'style', |
|
61 | + 'content' => '.sd-map-iframe-cover:hover:before {background: #4a4a4a88; content: "'.__("Click here, Settings are in the block settings sidebar","super-duper").'";} .sd-map-iframe-cover:before{cursor: pointer; content: ""; width: 100%; height: 100%; position: absolute; top: 0; bottom: 0;padding-top: 33%; text-align: center; color: #fff; font-size: 20px; font-weight: bold;}', |
|
62 | + 'element_require' => '[%type%]!="image"', |
|
63 | + ), |
|
64 | + ), |
|
65 | + 'class_name' => __CLASS__, |
|
66 | + // The calling class name |
|
67 | + 'base_id' => 'sd_map', |
|
68 | + // this is used as the widget id and the shortcode id. |
|
69 | + 'name' => __( 'Map', 'super-duper' ), |
|
70 | + // the name of the widget/block |
|
71 | + 'widget_ops' => array( |
|
72 | + 'classname' => 'sd-map-class', |
|
73 | + // widget class |
|
74 | + 'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world' ), |
|
75 | + // widget description |
|
76 | + ), |
|
77 | + 'arguments' => array( // these are the arguments that will be used in the widget, shortcode and block settings. |
|
78 | + 'type' => array( |
|
79 | + 'title' => __('Map Type:', 'geodirectory'), |
|
80 | + 'desc' => __('Select the map type to use.', 'geodirectory'), |
|
81 | + 'type' => 'select', |
|
82 | + 'options' => array( |
|
83 | + "image" => __('Static Image', 'geodirectory'), |
|
84 | + "place" => __('Place', 'geodirectory'), |
|
85 | 85 | // "directions" => __('Directions', 'geodirectory'), |
86 | 86 | // "search" => __('Search', 'geodirectory'), |
87 | 87 | // "view" => __('View', 'geodirectory'), |
88 | 88 | // "streetview" => __('Streetview', 'geodirectory'), |
89 | - ), |
|
90 | - 'default' => 'image', |
|
91 | - 'desc_tip' => true, |
|
92 | - 'advanced' => false |
|
93 | - ), |
|
94 | - 'location' => array( |
|
95 | - 'type' => 'text', |
|
96 | - 'title' => __( 'Location:', 'geodirectory' ), |
|
97 | - 'desc' => __( 'Enter the location to show on the map, place, city, zip code or GPS.', 'geodirectory' ), |
|
98 | - 'placeholder' => 'Place, city, zip code or GPS', |
|
99 | - 'desc_tip' => true, |
|
100 | - 'default' => 'Ireland', |
|
101 | - 'advanced' => false |
|
102 | - ), |
|
103 | - 'static_width' => array( |
|
104 | - 'type' => 'number', |
|
105 | - 'title' => __( 'Width:', 'geodirectory' ), |
|
106 | - 'desc' => __( 'This is the width of the map, for static maps you can only use px values.', 'geodirectory' ), |
|
107 | - 'placeholder' => '600', |
|
108 | - 'desc_tip' => true, |
|
109 | - 'default' => '600', |
|
110 | - 'custom_attributes' => array( |
|
111 | - 'max' => '2000', |
|
112 | - 'min' => '100', |
|
113 | - ), |
|
114 | - 'element_require' => '[%type%]=="image"', |
|
115 | - 'advanced' => false |
|
116 | - ), |
|
117 | - 'static_height' => array( |
|
118 | - 'type' => 'number', |
|
119 | - 'title' => __( 'Height:', 'geodirectory' ), |
|
120 | - 'desc' => __( 'This is the height of the map, for static maps you can only use px values.', 'geodirectory' ), |
|
121 | - 'placeholder' => '400', |
|
122 | - 'desc_tip' => true, |
|
123 | - 'default' => '400', |
|
124 | - 'custom_attributes' => array( |
|
125 | - 'max' => '2000', |
|
126 | - 'min' => '100', |
|
127 | - 'required' => 'required', |
|
128 | - ), |
|
129 | - 'element_require' => '[%type%]=="image"', |
|
130 | - 'advanced' => false |
|
131 | - ), |
|
132 | - 'width' => array( |
|
133 | - 'type' => 'text', |
|
134 | - 'title' => __( 'Width:', 'geodirectory' ), |
|
135 | - 'desc' => __( 'This is the width of the map, you can use % or px here.', 'geodirectory' ), |
|
136 | - 'placeholder' => '100%', |
|
137 | - 'desc_tip' => true, |
|
138 | - 'default' => '100%', |
|
139 | - 'element_require' => '[%type%]!="image"', |
|
140 | - 'advanced' => false |
|
141 | - ), |
|
142 | - 'height' => array( |
|
143 | - 'type' => 'text', |
|
144 | - 'title' => __( 'Height:', 'geodirectory' ), |
|
145 | - 'desc' => __( 'This is the height of the map, you can use %, px or vh here.', 'geodirectory' ), |
|
146 | - 'placeholder' => '425px', |
|
147 | - 'desc_tip' => true, |
|
148 | - 'default' => '425px', |
|
149 | - 'element_require' => '[%type%]!="image"', |
|
150 | - 'advanced' => false |
|
151 | - ), |
|
152 | - 'maptype' => array( |
|
153 | - 'type' => 'select', |
|
154 | - 'title' => __( 'Mapview:', 'geodirectory' ), |
|
155 | - 'desc' => __( 'This is the type of map view that will be used by default.', 'geodirectory' ), |
|
156 | - 'options' => array( |
|
157 | - "roadmap" => __( 'Road Map', 'geodirectory' ), |
|
158 | - "satellite" => __( 'Satellite Map', 'geodirectory' ), |
|
89 | + ), |
|
90 | + 'default' => 'image', |
|
91 | + 'desc_tip' => true, |
|
92 | + 'advanced' => false |
|
93 | + ), |
|
94 | + 'location' => array( |
|
95 | + 'type' => 'text', |
|
96 | + 'title' => __( 'Location:', 'geodirectory' ), |
|
97 | + 'desc' => __( 'Enter the location to show on the map, place, city, zip code or GPS.', 'geodirectory' ), |
|
98 | + 'placeholder' => 'Place, city, zip code or GPS', |
|
99 | + 'desc_tip' => true, |
|
100 | + 'default' => 'Ireland', |
|
101 | + 'advanced' => false |
|
102 | + ), |
|
103 | + 'static_width' => array( |
|
104 | + 'type' => 'number', |
|
105 | + 'title' => __( 'Width:', 'geodirectory' ), |
|
106 | + 'desc' => __( 'This is the width of the map, for static maps you can only use px values.', 'geodirectory' ), |
|
107 | + 'placeholder' => '600', |
|
108 | + 'desc_tip' => true, |
|
109 | + 'default' => '600', |
|
110 | + 'custom_attributes' => array( |
|
111 | + 'max' => '2000', |
|
112 | + 'min' => '100', |
|
113 | + ), |
|
114 | + 'element_require' => '[%type%]=="image"', |
|
115 | + 'advanced' => false |
|
116 | + ), |
|
117 | + 'static_height' => array( |
|
118 | + 'type' => 'number', |
|
119 | + 'title' => __( 'Height:', 'geodirectory' ), |
|
120 | + 'desc' => __( 'This is the height of the map, for static maps you can only use px values.', 'geodirectory' ), |
|
121 | + 'placeholder' => '400', |
|
122 | + 'desc_tip' => true, |
|
123 | + 'default' => '400', |
|
124 | + 'custom_attributes' => array( |
|
125 | + 'max' => '2000', |
|
126 | + 'min' => '100', |
|
127 | + 'required' => 'required', |
|
128 | + ), |
|
129 | + 'element_require' => '[%type%]=="image"', |
|
130 | + 'advanced' => false |
|
131 | + ), |
|
132 | + 'width' => array( |
|
133 | + 'type' => 'text', |
|
134 | + 'title' => __( 'Width:', 'geodirectory' ), |
|
135 | + 'desc' => __( 'This is the width of the map, you can use % or px here.', 'geodirectory' ), |
|
136 | + 'placeholder' => '100%', |
|
137 | + 'desc_tip' => true, |
|
138 | + 'default' => '100%', |
|
139 | + 'element_require' => '[%type%]!="image"', |
|
140 | + 'advanced' => false |
|
141 | + ), |
|
142 | + 'height' => array( |
|
143 | + 'type' => 'text', |
|
144 | + 'title' => __( 'Height:', 'geodirectory' ), |
|
145 | + 'desc' => __( 'This is the height of the map, you can use %, px or vh here.', 'geodirectory' ), |
|
146 | + 'placeholder' => '425px', |
|
147 | + 'desc_tip' => true, |
|
148 | + 'default' => '425px', |
|
149 | + 'element_require' => '[%type%]!="image"', |
|
150 | + 'advanced' => false |
|
151 | + ), |
|
152 | + 'maptype' => array( |
|
153 | + 'type' => 'select', |
|
154 | + 'title' => __( 'Mapview:', 'geodirectory' ), |
|
155 | + 'desc' => __( 'This is the type of map view that will be used by default.', 'geodirectory' ), |
|
156 | + 'options' => array( |
|
157 | + "roadmap" => __( 'Road Map', 'geodirectory' ), |
|
158 | + "satellite" => __( 'Satellite Map', 'geodirectory' ), |
|
159 | 159 | // "hybrid" => __( 'Hybrid Map', 'geodirectory' ), |
160 | 160 | // "terrain" => __( 'Terrain Map', 'geodirectory' ), |
161 | - ), |
|
162 | - 'desc_tip' => true, |
|
163 | - 'default' => 'roadmap', |
|
164 | - 'advanced' => true |
|
165 | - ), |
|
166 | - 'zoom' => array( |
|
167 | - 'type' => 'select', |
|
168 | - 'title' => __( 'Zoom level:', 'geodirectory' ), |
|
169 | - 'desc' => __( 'This is the zoom level of the map, `auto` is recommended.', 'geodirectory' ), |
|
170 | - 'options' => range( 1, 19 ), |
|
171 | - 'placeholder' => '', |
|
172 | - 'desc_tip' => true, |
|
173 | - 'default' => '7', |
|
174 | - 'advanced' => true |
|
175 | - ), |
|
176 | - 'api_key' => array( |
|
177 | - 'type' => 'text', |
|
178 | - 'title' => __( 'Api Key:', 'geodirectory' ), |
|
179 | - 'desc' => __( 'This is the height of the map, you can use %, px or vh here.', 'geodirectory' ), |
|
180 | - 'placeholder' => '', |
|
181 | - 'desc_tip' => true, |
|
182 | - 'default' => '', |
|
183 | - 'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1', |
|
184 | - 'advanced' => false |
|
185 | - ), |
|
186 | - ) |
|
187 | - ); |
|
188 | - |
|
189 | - parent::__construct( $options ); |
|
190 | - } |
|
191 | - |
|
192 | - |
|
193 | - /** |
|
194 | - * This is the output function for the widget, shortcode and block (front end). |
|
195 | - * |
|
196 | - * @param array $args The arguments values. |
|
197 | - * @param array $widget_args The widget arguments when used. |
|
198 | - * @param string $content The shortcode content argument |
|
199 | - * |
|
200 | - * @return string |
|
201 | - */ |
|
202 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
203 | - |
|
204 | - // options |
|
205 | - $defaults = array( |
|
206 | - 'type' => 'image', // image, place |
|
207 | - 'location' => 'Ireland', |
|
208 | - 'static_width' => '600', |
|
209 | - 'static_height' => '400', |
|
210 | - 'width'=> '100%', |
|
211 | - 'height'=> '425px', |
|
212 | - 'maptype' => 'roadmap', |
|
213 | - 'zoom' => '7', |
|
214 | - 'api_key' => 'AIzaSyBK3ZcmK0ljxl5agNyJNQh_G24Thq1btuE', |
|
215 | - ); |
|
216 | - |
|
217 | - /** |
|
218 | - * Parse incoming $args into an array and merge it with $defaults |
|
219 | - */ |
|
220 | - $args = wp_parse_args($args, $defaults ); |
|
221 | - |
|
222 | - $output = ''; |
|
223 | - |
|
224 | - |
|
225 | - // check if we have a global API key |
|
226 | - $args['api_key'] = get_option( 'rgmk_google_map_api_key', false ) ? get_option( 'rgmk_google_map_api_key' ) : $args['api_key']; |
|
227 | - |
|
228 | - if($args['type']=='image'){ |
|
229 | - $output .= "<img src='https://maps.googleapis.com/maps/api/staticmap?center=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&size=".esc_attr($args['static_width'])."x".esc_attr($args['static_height'])."&key=".esc_attr($args['api_key'])."' />"; |
|
230 | - }else{ |
|
231 | - $output .= "<iframe width='".esc_attr($args['width'])."' height='".esc_attr($args['height'])."' frameborder='0' allowfullscreen style='border:0;' src='https://www.google.com/maps/embed/v1/".esc_attr($args['type'])."?q=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&key=".esc_attr($args['api_key'])."' ></iframe> "; |
|
232 | - } |
|
233 | - |
|
234 | - return $output; |
|
235 | - |
|
236 | - } |
|
161 | + ), |
|
162 | + 'desc_tip' => true, |
|
163 | + 'default' => 'roadmap', |
|
164 | + 'advanced' => true |
|
165 | + ), |
|
166 | + 'zoom' => array( |
|
167 | + 'type' => 'select', |
|
168 | + 'title' => __( 'Zoom level:', 'geodirectory' ), |
|
169 | + 'desc' => __( 'This is the zoom level of the map, `auto` is recommended.', 'geodirectory' ), |
|
170 | + 'options' => range( 1, 19 ), |
|
171 | + 'placeholder' => '', |
|
172 | + 'desc_tip' => true, |
|
173 | + 'default' => '7', |
|
174 | + 'advanced' => true |
|
175 | + ), |
|
176 | + 'api_key' => array( |
|
177 | + 'type' => 'text', |
|
178 | + 'title' => __( 'Api Key:', 'geodirectory' ), |
|
179 | + 'desc' => __( 'This is the height of the map, you can use %, px or vh here.', 'geodirectory' ), |
|
180 | + 'placeholder' => '', |
|
181 | + 'desc_tip' => true, |
|
182 | + 'default' => '', |
|
183 | + 'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1', |
|
184 | + 'advanced' => false |
|
185 | + ), |
|
186 | + ) |
|
187 | + ); |
|
188 | + |
|
189 | + parent::__construct( $options ); |
|
190 | + } |
|
191 | + |
|
192 | + |
|
193 | + /** |
|
194 | + * This is the output function for the widget, shortcode and block (front end). |
|
195 | + * |
|
196 | + * @param array $args The arguments values. |
|
197 | + * @param array $widget_args The widget arguments when used. |
|
198 | + * @param string $content The shortcode content argument |
|
199 | + * |
|
200 | + * @return string |
|
201 | + */ |
|
202 | + public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
203 | + |
|
204 | + // options |
|
205 | + $defaults = array( |
|
206 | + 'type' => 'image', // image, place |
|
207 | + 'location' => 'Ireland', |
|
208 | + 'static_width' => '600', |
|
209 | + 'static_height' => '400', |
|
210 | + 'width'=> '100%', |
|
211 | + 'height'=> '425px', |
|
212 | + 'maptype' => 'roadmap', |
|
213 | + 'zoom' => '7', |
|
214 | + 'api_key' => 'AIzaSyBK3ZcmK0ljxl5agNyJNQh_G24Thq1btuE', |
|
215 | + ); |
|
216 | + |
|
217 | + /** |
|
218 | + * Parse incoming $args into an array and merge it with $defaults |
|
219 | + */ |
|
220 | + $args = wp_parse_args($args, $defaults ); |
|
221 | + |
|
222 | + $output = ''; |
|
223 | + |
|
224 | + |
|
225 | + // check if we have a global API key |
|
226 | + $args['api_key'] = get_option( 'rgmk_google_map_api_key', false ) ? get_option( 'rgmk_google_map_api_key' ) : $args['api_key']; |
|
227 | + |
|
228 | + if($args['type']=='image'){ |
|
229 | + $output .= "<img src='https://maps.googleapis.com/maps/api/staticmap?center=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&size=".esc_attr($args['static_width'])."x".esc_attr($args['static_height'])."&key=".esc_attr($args['api_key'])."' />"; |
|
230 | + }else{ |
|
231 | + $output .= "<iframe width='".esc_attr($args['width'])."' height='".esc_attr($args['height'])."' frameborder='0' allowfullscreen style='border:0;' src='https://www.google.com/maps/embed/v1/".esc_attr($args['type'])."?q=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&key=".esc_attr($args['api_key'])."' ></iframe> "; |
|
232 | + } |
|
233 | + |
|
234 | + return $output; |
|
235 | + |
|
236 | + } |
|
237 | 237 | |
238 | 238 | } |
239 | 239 | |
240 | 240 | // register it. |
241 | 241 | add_action( 'widgets_init', function () { |
242 | - register_widget( 'SD_Map' ); |
|
242 | + register_widget( 'SD_Map' ); |
|
243 | 243 | } ); |
@@ -22,14 +22,14 @@ discard block |
||
22 | 22 | 'block-output' => array( // the block visual output elements as an array |
23 | 23 | array( |
24 | 24 | 'element' => 'p', |
25 | - 'content' => __('A Google API key is required to use this block, we recommend installing our plugin which makes it easy and sets it globally, or you can set a key in the block settings sidebar: ','super-duper'), |
|
25 | + 'content' => __('A Google API key is required to use this block, we recommend installing our plugin which makes it easy and sets it globally, or you can set a key in the block settings sidebar: ', 'super-duper'), |
|
26 | 26 | //'element_require' => '"1"=='.get_option( 'rgmk_google_map_api_key', '"0"') ? '"0"' : '"1"', |
27 | - 'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""', |
|
27 | + 'element_require' => get_option('rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""', |
|
28 | 28 | ), |
29 | 29 | array( |
30 | 30 | 'element' => 'a', |
31 | - 'content' => __('API KEY for Google Maps','super-duper'), |
|
32 | - 'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""', |
|
31 | + 'content' => __('API KEY for Google Maps', 'super-duper'), |
|
32 | + 'element_require' => get_option('rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""', |
|
33 | 33 | 'href' => 'https://wordpress.org/plugins/api-key-for-google-maps/', |
34 | 34 | ), |
35 | 35 | array( |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | 'class' => '[%className%]', |
38 | 38 | //'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%] |
39 | 39 | 'element_require' => '[%type%]=="image"', |
40 | - 'src' => get_option( 'rgmk_google_map_api_key', false) ? "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=".get_option( 'rgmk_google_map_api_key') : "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=[%api_key%]" |
|
40 | + 'src' => get_option('rgmk_google_map_api_key', false) ? "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=" . get_option('rgmk_google_map_api_key') : "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=[%api_key%]" |
|
41 | 41 | ), |
42 | 42 | array( |
43 | 43 | 'element' => 'div', |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | 'style' => '{overflow:"hidden", position:"relative"}', |
46 | 46 | array( |
47 | 47 | 'element' => 'iframe', |
48 | - 'title' => __( 'Placeholderx', 'super-duper' ), |
|
48 | + 'title' => __('Placeholderx', 'super-duper'), |
|
49 | 49 | 'class' => '[%className%]', |
50 | 50 | 'width' => '[%width%]', |
51 | 51 | 'height' => '[%height%]', |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | 'allowfullscreen' => 'true', |
54 | 54 | 'style' => '{border:0}', |
55 | 55 | 'element_require' => '[%type%]!="image"', |
56 | - 'src' => get_option( 'rgmk_google_map_api_key', false) ? "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=".get_option( 'rgmk_google_map_api_key') : "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=[%api_key%]" |
|
56 | + 'src' => get_option('rgmk_google_map_api_key', false) ? "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=" . get_option('rgmk_google_map_api_key') : "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=[%api_key%]" |
|
57 | 57 | ), |
58 | 58 | ), |
59 | 59 | array( |
60 | 60 | 'element' => 'style', |
61 | - 'content' => '.sd-map-iframe-cover:hover:before {background: #4a4a4a88; content: "'.__("Click here, Settings are in the block settings sidebar","super-duper").'";} .sd-map-iframe-cover:before{cursor: pointer; content: ""; width: 100%; height: 100%; position: absolute; top: 0; bottom: 0;padding-top: 33%; text-align: center; color: #fff; font-size: 20px; font-weight: bold;}', |
|
61 | + 'content' => '.sd-map-iframe-cover:hover:before {background: #4a4a4a88; content: "' . __("Click here, Settings are in the block settings sidebar", "super-duper") . '";} .sd-map-iframe-cover:before{cursor: pointer; content: ""; width: 100%; height: 100%; position: absolute; top: 0; bottom: 0;padding-top: 33%; text-align: center; color: #fff; font-size: 20px; font-weight: bold;}', |
|
62 | 62 | 'element_require' => '[%type%]!="image"', |
63 | 63 | ), |
64 | 64 | ), |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | // The calling class name |
67 | 67 | 'base_id' => 'sd_map', |
68 | 68 | // this is used as the widget id and the shortcode id. |
69 | - 'name' => __( 'Map', 'super-duper' ), |
|
69 | + 'name' => __('Map', 'super-duper'), |
|
70 | 70 | // the name of the widget/block |
71 | 71 | 'widget_ops' => array( |
72 | 72 | 'classname' => 'sd-map-class', |
73 | 73 | // widget class |
74 | - 'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world' ), |
|
74 | + 'description' => esc_html__('This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world'), |
|
75 | 75 | // widget description |
76 | 76 | ), |
77 | 77 | 'arguments' => array( // these are the arguments that will be used in the widget, shortcode and block settings. |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | ), |
94 | 94 | 'location' => array( |
95 | 95 | 'type' => 'text', |
96 | - 'title' => __( 'Location:', 'geodirectory' ), |
|
97 | - 'desc' => __( 'Enter the location to show on the map, place, city, zip code or GPS.', 'geodirectory' ), |
|
96 | + 'title' => __('Location:', 'geodirectory'), |
|
97 | + 'desc' => __('Enter the location to show on the map, place, city, zip code or GPS.', 'geodirectory'), |
|
98 | 98 | 'placeholder' => 'Place, city, zip code or GPS', |
99 | 99 | 'desc_tip' => true, |
100 | 100 | 'default' => 'Ireland', |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | ), |
103 | 103 | 'static_width' => array( |
104 | 104 | 'type' => 'number', |
105 | - 'title' => __( 'Width:', 'geodirectory' ), |
|
106 | - 'desc' => __( 'This is the width of the map, for static maps you can only use px values.', 'geodirectory' ), |
|
105 | + 'title' => __('Width:', 'geodirectory'), |
|
106 | + 'desc' => __('This is the width of the map, for static maps you can only use px values.', 'geodirectory'), |
|
107 | 107 | 'placeholder' => '600', |
108 | 108 | 'desc_tip' => true, |
109 | 109 | 'default' => '600', |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | ), |
117 | 117 | 'static_height' => array( |
118 | 118 | 'type' => 'number', |
119 | - 'title' => __( 'Height:', 'geodirectory' ), |
|
120 | - 'desc' => __( 'This is the height of the map, for static maps you can only use px values.', 'geodirectory' ), |
|
119 | + 'title' => __('Height:', 'geodirectory'), |
|
120 | + 'desc' => __('This is the height of the map, for static maps you can only use px values.', 'geodirectory'), |
|
121 | 121 | 'placeholder' => '400', |
122 | 122 | 'desc_tip' => true, |
123 | 123 | 'default' => '400', |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | ), |
132 | 132 | 'width' => array( |
133 | 133 | 'type' => 'text', |
134 | - 'title' => __( 'Width:', 'geodirectory' ), |
|
135 | - 'desc' => __( 'This is the width of the map, you can use % or px here.', 'geodirectory' ), |
|
134 | + 'title' => __('Width:', 'geodirectory'), |
|
135 | + 'desc' => __('This is the width of the map, you can use % or px here.', 'geodirectory'), |
|
136 | 136 | 'placeholder' => '100%', |
137 | 137 | 'desc_tip' => true, |
138 | 138 | 'default' => '100%', |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | ), |
142 | 142 | 'height' => array( |
143 | 143 | 'type' => 'text', |
144 | - 'title' => __( 'Height:', 'geodirectory' ), |
|
145 | - 'desc' => __( 'This is the height of the map, you can use %, px or vh here.', 'geodirectory' ), |
|
144 | + 'title' => __('Height:', 'geodirectory'), |
|
145 | + 'desc' => __('This is the height of the map, you can use %, px or vh here.', 'geodirectory'), |
|
146 | 146 | 'placeholder' => '425px', |
147 | 147 | 'desc_tip' => true, |
148 | 148 | 'default' => '425px', |
@@ -151,11 +151,11 @@ discard block |
||
151 | 151 | ), |
152 | 152 | 'maptype' => array( |
153 | 153 | 'type' => 'select', |
154 | - 'title' => __( 'Mapview:', 'geodirectory' ), |
|
155 | - 'desc' => __( 'This is the type of map view that will be used by default.', 'geodirectory' ), |
|
154 | + 'title' => __('Mapview:', 'geodirectory'), |
|
155 | + 'desc' => __('This is the type of map view that will be used by default.', 'geodirectory'), |
|
156 | 156 | 'options' => array( |
157 | - "roadmap" => __( 'Road Map', 'geodirectory' ), |
|
158 | - "satellite" => __( 'Satellite Map', 'geodirectory' ), |
|
157 | + "roadmap" => __('Road Map', 'geodirectory'), |
|
158 | + "satellite" => __('Satellite Map', 'geodirectory'), |
|
159 | 159 | // "hybrid" => __( 'Hybrid Map', 'geodirectory' ), |
160 | 160 | // "terrain" => __( 'Terrain Map', 'geodirectory' ), |
161 | 161 | ), |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | ), |
166 | 166 | 'zoom' => array( |
167 | 167 | 'type' => 'select', |
168 | - 'title' => __( 'Zoom level:', 'geodirectory' ), |
|
169 | - 'desc' => __( 'This is the zoom level of the map, `auto` is recommended.', 'geodirectory' ), |
|
170 | - 'options' => range( 1, 19 ), |
|
168 | + 'title' => __('Zoom level:', 'geodirectory'), |
|
169 | + 'desc' => __('This is the zoom level of the map, `auto` is recommended.', 'geodirectory'), |
|
170 | + 'options' => range(1, 19), |
|
171 | 171 | 'placeholder' => '', |
172 | 172 | 'desc_tip' => true, |
173 | 173 | 'default' => '7', |
@@ -175,18 +175,18 @@ discard block |
||
175 | 175 | ), |
176 | 176 | 'api_key' => array( |
177 | 177 | 'type' => 'text', |
178 | - 'title' => __( 'Api Key:', 'geodirectory' ), |
|
179 | - 'desc' => __( 'This is the height of the map, you can use %, px or vh here.', 'geodirectory' ), |
|
178 | + 'title' => __('Api Key:', 'geodirectory'), |
|
179 | + 'desc' => __('This is the height of the map, you can use %, px or vh here.', 'geodirectory'), |
|
180 | 180 | 'placeholder' => '', |
181 | 181 | 'desc_tip' => true, |
182 | 182 | 'default' => '', |
183 | - 'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1', |
|
183 | + 'element_require' => get_option('rgmk_google_map_api_key', false) ? '1==0' : '1==1', |
|
184 | 184 | 'advanced' => false |
185 | 185 | ), |
186 | 186 | ) |
187 | 187 | ); |
188 | 188 | |
189 | - parent::__construct( $options ); |
|
189 | + parent::__construct($options); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * |
200 | 200 | * @return string |
201 | 201 | */ |
202 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
202 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
203 | 203 | |
204 | 204 | // options |
205 | 205 | $defaults = array( |
@@ -217,18 +217,18 @@ discard block |
||
217 | 217 | /** |
218 | 218 | * Parse incoming $args into an array and merge it with $defaults |
219 | 219 | */ |
220 | - $args = wp_parse_args($args, $defaults ); |
|
220 | + $args = wp_parse_args($args, $defaults); |
|
221 | 221 | |
222 | 222 | $output = ''; |
223 | 223 | |
224 | 224 | |
225 | 225 | // check if we have a global API key |
226 | - $args['api_key'] = get_option( 'rgmk_google_map_api_key', false ) ? get_option( 'rgmk_google_map_api_key' ) : $args['api_key']; |
|
226 | + $args['api_key'] = get_option('rgmk_google_map_api_key', false) ? get_option('rgmk_google_map_api_key') : $args['api_key']; |
|
227 | 227 | |
228 | - if($args['type']=='image'){ |
|
229 | - $output .= "<img src='https://maps.googleapis.com/maps/api/staticmap?center=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&size=".esc_attr($args['static_width'])."x".esc_attr($args['static_height'])."&key=".esc_attr($args['api_key'])."' />"; |
|
230 | - }else{ |
|
231 | - $output .= "<iframe width='".esc_attr($args['width'])."' height='".esc_attr($args['height'])."' frameborder='0' allowfullscreen style='border:0;' src='https://www.google.com/maps/embed/v1/".esc_attr($args['type'])."?q=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&key=".esc_attr($args['api_key'])."' ></iframe> "; |
|
228 | + if ($args['type'] == 'image') { |
|
229 | + $output .= "<img src='https://maps.googleapis.com/maps/api/staticmap?center=" . esc_attr($args['location']) . "&maptype=" . esc_attr($args['maptype']) . "&zoom=" . esc_attr($args['zoom']) . "&size=" . esc_attr($args['static_width']) . "x" . esc_attr($args['static_height']) . "&key=" . esc_attr($args['api_key']) . "' />"; |
|
230 | + } else { |
|
231 | + $output .= "<iframe width='" . esc_attr($args['width']) . "' height='" . esc_attr($args['height']) . "' frameborder='0' allowfullscreen style='border:0;' src='https://www.google.com/maps/embed/v1/" . esc_attr($args['type']) . "?q=" . esc_attr($args['location']) . "&maptype=" . esc_attr($args['maptype']) . "&zoom=" . esc_attr($args['zoom']) . "&key=" . esc_attr($args['api_key']) . "' ></iframe> "; |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | return $output; |
@@ -238,6 +238,6 @@ discard block |
||
238 | 238 | } |
239 | 239 | |
240 | 240 | // register it. |
241 | -add_action( 'widgets_init', function () { |
|
242 | - register_widget( 'SD_Map' ); |
|
241 | +add_action('widgets_init', function() { |
|
242 | + register_widget('SD_Map'); |
|
243 | 243 | } ); |
@@ -227,7 +227,7 @@ |
||
227 | 227 | |
228 | 228 | if($args['type']=='image'){ |
229 | 229 | $output .= "<img src='https://maps.googleapis.com/maps/api/staticmap?center=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&size=".esc_attr($args['static_width'])."x".esc_attr($args['static_height'])."&key=".esc_attr($args['api_key'])."' />"; |
230 | - }else{ |
|
230 | + } else{ |
|
231 | 231 | $output .= "<iframe width='".esc_attr($args['width'])."' height='".esc_attr($args['height'])."' frameborder='0' allowfullscreen style='border:0;' src='https://www.google.com/maps/embed/v1/".esc_attr($args['type'])."?q=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&key=".esc_attr($args['api_key'])."' ></iframe> "; |
232 | 232 | } |
233 | 233 |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | |
6 | 6 | class OxidInstaller extends BaseInstaller |
7 | 7 | { |
8 | - const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/'; |
|
8 | + const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/'; |
|
9 | 9 | |
10 | 10 | protected $locations = array( |
11 | 11 | 'module' => 'modules/{$name}/', |
@@ -13,47 +13,47 @@ discard block |
||
13 | 13 | 'out' => 'out/{$name}/', |
14 | 14 | ); |
15 | 15 | |
16 | - /** |
|
17 | - * getInstallPath |
|
18 | - * |
|
19 | - * @param PackageInterface $package |
|
20 | - * @param string $frameworkType |
|
21 | - * @return void |
|
22 | - */ |
|
23 | - public function getInstallPath(PackageInterface $package, $frameworkType = '') |
|
24 | - { |
|
25 | - $installPath = parent::getInstallPath($package, $frameworkType); |
|
26 | - $type = $this->package->getType(); |
|
27 | - if ($type === 'oxid-module') { |
|
28 | - $this->prepareVendorDirectory($installPath); |
|
29 | - } |
|
30 | - return $installPath; |
|
31 | - } |
|
16 | + /** |
|
17 | + * getInstallPath |
|
18 | + * |
|
19 | + * @param PackageInterface $package |
|
20 | + * @param string $frameworkType |
|
21 | + * @return void |
|
22 | + */ |
|
23 | + public function getInstallPath(PackageInterface $package, $frameworkType = '') |
|
24 | + { |
|
25 | + $installPath = parent::getInstallPath($package, $frameworkType); |
|
26 | + $type = $this->package->getType(); |
|
27 | + if ($type === 'oxid-module') { |
|
28 | + $this->prepareVendorDirectory($installPath); |
|
29 | + } |
|
30 | + return $installPath; |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * prepareVendorDirectory |
|
35 | - * |
|
36 | - * Makes sure there is a vendormetadata.php file inside |
|
37 | - * the vendor folder if there is a vendor folder. |
|
38 | - * |
|
39 | - * @param string $installPath |
|
40 | - * @return void |
|
41 | - */ |
|
42 | - protected function prepareVendorDirectory($installPath) |
|
43 | - { |
|
44 | - $matches = ''; |
|
45 | - $hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches); |
|
46 | - if (!$hasVendorDirectory) { |
|
47 | - return; |
|
48 | - } |
|
33 | + /** |
|
34 | + * prepareVendorDirectory |
|
35 | + * |
|
36 | + * Makes sure there is a vendormetadata.php file inside |
|
37 | + * the vendor folder if there is a vendor folder. |
|
38 | + * |
|
39 | + * @param string $installPath |
|
40 | + * @return void |
|
41 | + */ |
|
42 | + protected function prepareVendorDirectory($installPath) |
|
43 | + { |
|
44 | + $matches = ''; |
|
45 | + $hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches); |
|
46 | + if (!$hasVendorDirectory) { |
|
47 | + return; |
|
48 | + } |
|
49 | 49 | |
50 | - $vendorDirectory = $matches['vendor']; |
|
51 | - $vendorPath = getcwd() . '/modules/' . $vendorDirectory; |
|
52 | - if (!file_exists($vendorPath)) { |
|
53 | - mkdir($vendorPath, 0755, true); |
|
54 | - } |
|
50 | + $vendorDirectory = $matches['vendor']; |
|
51 | + $vendorPath = getcwd() . '/modules/' . $vendorDirectory; |
|
52 | + if (!file_exists($vendorPath)) { |
|
53 | + mkdir($vendorPath, 0755, true); |
|
54 | + } |
|
55 | 55 | |
56 | - $vendorMetaDataPath = $vendorPath . '/vendormetadata.php'; |
|
57 | - touch($vendorMetaDataPath); |
|
58 | - } |
|
56 | + $vendorMetaDataPath = $vendorPath . '/vendormetadata.php'; |
|
57 | + touch($vendorMetaDataPath); |
|
58 | + } |
|
59 | 59 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | $restrictedWords = implode('|', array_keys($this->locations)); |
21 | 21 | |
22 | 22 | $vars['name'] = strtolower($vars['name']); |
23 | - $vars['name'] = preg_replace('/^(?:grav-)?(?:(?:'.$restrictedWords.')-)?(.*?)(?:-(?:'.$restrictedWords.'))?$/ui', |
|
23 | + $vars['name'] = preg_replace('/^(?:grav-)?(?:(?:' . $restrictedWords . ')-)?(.*?)(?:-(?:' . $restrictedWords . '))?$/ui', |
|
24 | 24 | '$1', |
25 | 25 | $vars['name'] |
26 | 26 | ); |
@@ -3,8 +3,8 @@ |
||
3 | 3 | |
4 | 4 | class ClanCatsFrameworkInstaller extends BaseInstaller |
5 | 5 | { |
6 | - protected $locations = array( |
|
7 | - 'ship' => 'CCF/orbit/{$name}/', |
|
8 | - 'theme' => 'CCF/app/themes/{$name}/', |
|
9 | - ); |
|
6 | + protected $locations = array( |
|
7 | + 'ship' => 'CCF/orbit/{$name}/', |
|
8 | + 'theme' => 'CCF/app/themes/{$name}/', |
|
9 | + ); |
|
10 | 10 | } |
11 | 11 | \ No newline at end of file |