@@ -10,261 +10,261 @@ |
||
10 | 10 | defined( 'ABSPATH' ) || exit; |
11 | 11 | |
12 | 12 | return array( |
13 | - 'BD' => '+880', |
|
14 | - 'BE' => '+32', |
|
15 | - 'BF' => '+226', |
|
16 | - 'BG' => '+359', |
|
17 | - 'BA' => '+387', |
|
18 | - 'BB' => '+1246', |
|
19 | - 'WF' => '+681', |
|
20 | - 'BL' => '+590', |
|
21 | - 'BM' => '+1441', |
|
22 | - 'BN' => '+673', |
|
23 | - 'BO' => '+591', |
|
24 | - 'BH' => '+973', |
|
25 | - 'BI' => '+257', |
|
26 | - 'BJ' => '+229', |
|
27 | - 'BT' => '+975', |
|
28 | - 'JM' => '+1876', |
|
29 | - 'BV' => '', |
|
30 | - 'BW' => '+267', |
|
31 | - 'WS' => '+685', |
|
32 | - 'BQ' => '+599', |
|
33 | - 'BR' => '+55', |
|
34 | - 'BS' => '+1242', |
|
35 | - 'JE' => '+441534', |
|
36 | - 'BY' => '+375', |
|
37 | - 'BZ' => '+501', |
|
38 | - 'RU' => '+7', |
|
39 | - 'RW' => '+250', |
|
40 | - 'RS' => '+381', |
|
41 | - 'TL' => '+670', |
|
42 | - 'RE' => '+262', |
|
43 | - 'TM' => '+993', |
|
44 | - 'TJ' => '+992', |
|
45 | - 'RO' => '+40', |
|
46 | - 'TK' => '+690', |
|
47 | - 'GW' => '+245', |
|
48 | - 'GU' => '+1671', |
|
49 | - 'GT' => '+502', |
|
50 | - 'GS' => '', |
|
51 | - 'GR' => '+30', |
|
52 | - 'GQ' => '+240', |
|
53 | - 'GP' => '+590', |
|
54 | - 'JP' => '+81', |
|
55 | - 'GY' => '+592', |
|
56 | - 'GG' => '+441481', |
|
57 | - 'GF' => '+594', |
|
58 | - 'GE' => '+995', |
|
59 | - 'GD' => '+1473', |
|
60 | - 'GB' => '+44', |
|
61 | - 'GA' => '+241', |
|
62 | - 'SV' => '+503', |
|
63 | - 'GN' => '+224', |
|
64 | - 'GM' => '+220', |
|
65 | - 'GL' => '+299', |
|
66 | - 'GI' => '+350', |
|
67 | - 'GH' => '+233', |
|
68 | - 'OM' => '+968', |
|
69 | - 'TN' => '+216', |
|
70 | - 'JO' => '+962', |
|
71 | - 'HR' => '+385', |
|
72 | - 'HT' => '+509', |
|
73 | - 'HU' => '+36', |
|
74 | - 'HK' => '+852', |
|
75 | - 'HN' => '+504', |
|
76 | - 'HM' => '', |
|
77 | - 'VE' => '+58', |
|
78 | - 'PR' => array( |
|
79 | - '+1787', |
|
80 | - '+1939', |
|
81 | - ), |
|
82 | - 'PS' => '+970', |
|
83 | - 'PW' => '+680', |
|
84 | - 'PT' => '+351', |
|
85 | - 'SJ' => '+47', |
|
86 | - 'PY' => '+595', |
|
87 | - 'IQ' => '+964', |
|
88 | - 'PA' => '+507', |
|
89 | - 'PF' => '+689', |
|
90 | - 'PG' => '+675', |
|
91 | - 'PE' => '+51', |
|
92 | - 'PK' => '+92', |
|
93 | - 'PH' => '+63', |
|
94 | - 'PN' => '+870', |
|
95 | - 'PL' => '+48', |
|
96 | - 'PM' => '+508', |
|
97 | - 'ZM' => '+260', |
|
98 | - 'EH' => '+212', |
|
99 | - 'EE' => '+372', |
|
100 | - 'EG' => '+20', |
|
101 | - 'ZA' => '+27', |
|
102 | - 'EC' => '+593', |
|
103 | - 'IT' => '+39', |
|
104 | - 'VN' => '+84', |
|
105 | - 'SB' => '+677', |
|
106 | - 'ET' => '+251', |
|
107 | - 'SO' => '+252', |
|
108 | - 'ZW' => '+263', |
|
109 | - 'SA' => '+966', |
|
110 | - 'ES' => '+34', |
|
111 | - 'ER' => '+291', |
|
112 | - 'ME' => '+382', |
|
113 | - 'MD' => '+373', |
|
114 | - 'MG' => '+261', |
|
115 | - 'MF' => '+590', |
|
116 | - 'MA' => '+212', |
|
117 | - 'MC' => '+377', |
|
118 | - 'UZ' => '+998', |
|
119 | - 'MM' => '+95', |
|
120 | - 'ML' => '+223', |
|
121 | - 'MO' => '+853', |
|
122 | - 'MN' => '+976', |
|
123 | - 'MH' => '+692', |
|
124 | - 'MK' => '+389', |
|
125 | - 'MU' => '+230', |
|
126 | - 'MT' => '+356', |
|
127 | - 'MW' => '+265', |
|
128 | - 'MV' => '+960', |
|
129 | - 'MQ' => '+596', |
|
130 | - 'MP' => '+1670', |
|
131 | - 'MS' => '+1664', |
|
132 | - 'MR' => '+222', |
|
133 | - 'IM' => '+441624', |
|
134 | - 'UG' => '+256', |
|
135 | - 'TZ' => '+255', |
|
136 | - 'MY' => '+60', |
|
137 | - 'MX' => '+52', |
|
138 | - 'IL' => '+972', |
|
139 | - 'FR' => '+33', |
|
140 | - 'IO' => '+246', |
|
141 | - 'SH' => '+290', |
|
142 | - 'FI' => '+358', |
|
143 | - 'FJ' => '+679', |
|
144 | - 'FK' => '+500', |
|
145 | - 'FM' => '+691', |
|
146 | - 'FO' => '+298', |
|
147 | - 'NI' => '+505', |
|
148 | - 'NL' => '+31', |
|
149 | - 'NO' => '+47', |
|
150 | - 'NA' => '+264', |
|
151 | - 'VU' => '+678', |
|
152 | - 'NC' => '+687', |
|
153 | - 'NE' => '+227', |
|
154 | - 'NF' => '+672', |
|
155 | - 'NG' => '+234', |
|
156 | - 'NZ' => '+64', |
|
157 | - 'NP' => '+977', |
|
158 | - 'NR' => '+674', |
|
159 | - 'NU' => '+683', |
|
160 | - 'CK' => '+682', |
|
161 | - 'XK' => '', |
|
162 | - 'CI' => '+225', |
|
163 | - 'CH' => '+41', |
|
164 | - 'CO' => '+57', |
|
165 | - 'CN' => '+86', |
|
166 | - 'CM' => '+237', |
|
167 | - 'CL' => '+56', |
|
168 | - 'CC' => '+61', |
|
169 | - 'CA' => '+1', |
|
170 | - 'CG' => '+242', |
|
171 | - 'CF' => '+236', |
|
172 | - 'CD' => '+243', |
|
173 | - 'CZ' => '+420', |
|
174 | - 'CY' => '+357', |
|
175 | - 'CX' => '+61', |
|
176 | - 'CR' => '+506', |
|
177 | - 'CW' => '+599', |
|
178 | - 'CV' => '+238', |
|
179 | - 'CU' => '+53', |
|
180 | - 'SZ' => '+268', |
|
181 | - 'SY' => '+963', |
|
182 | - 'SX' => '+599', |
|
183 | - 'KG' => '+996', |
|
184 | - 'KE' => '+254', |
|
185 | - 'SS' => '+211', |
|
186 | - 'SR' => '+597', |
|
187 | - 'KI' => '+686', |
|
188 | - 'KH' => '+855', |
|
189 | - 'KN' => '+1869', |
|
190 | - 'KM' => '+269', |
|
191 | - 'ST' => '+239', |
|
192 | - 'SK' => '+421', |
|
193 | - 'KR' => '+82', |
|
194 | - 'SI' => '+386', |
|
195 | - 'KP' => '+850', |
|
196 | - 'KW' => '+965', |
|
197 | - 'SN' => '+221', |
|
198 | - 'SM' => '+378', |
|
199 | - 'SL' => '+232', |
|
200 | - 'SC' => '+248', |
|
201 | - 'KZ' => '+7', |
|
202 | - 'KY' => '+1345', |
|
203 | - 'SG' => '+65', |
|
204 | - 'SE' => '+46', |
|
205 | - 'SD' => '+249', |
|
206 | - 'DO' => array( |
|
207 | - '+1809', |
|
208 | - '+1829', |
|
209 | - '+1849', |
|
210 | - ), |
|
211 | - 'DM' => '+1767', |
|
212 | - 'DJ' => '+253', |
|
213 | - 'DK' => '+45', |
|
214 | - 'VG' => '+1284', |
|
215 | - 'DE' => '+49', |
|
216 | - 'YE' => '+967', |
|
217 | - 'DZ' => '+213', |
|
218 | - 'US' => '+1', |
|
219 | - 'UY' => '+598', |
|
220 | - 'YT' => '+262', |
|
221 | - 'UM' => '+1', |
|
222 | - 'LB' => '+961', |
|
223 | - 'LC' => '+1758', |
|
224 | - 'LA' => '+856', |
|
225 | - 'TV' => '+688', |
|
226 | - 'TW' => '+886', |
|
227 | - 'TT' => '+1868', |
|
228 | - 'TR' => '+90', |
|
229 | - 'LK' => '+94', |
|
230 | - 'LI' => '+423', |
|
231 | - 'LV' => '+371', |
|
232 | - 'TO' => '+676', |
|
233 | - 'LT' => '+370', |
|
234 | - 'LU' => '+352', |
|
235 | - 'LR' => '+231', |
|
236 | - 'LS' => '+266', |
|
237 | - 'TH' => '+66', |
|
238 | - 'TF' => '', |
|
239 | - 'TG' => '+228', |
|
240 | - 'TD' => '+235', |
|
241 | - 'TC' => '+1649', |
|
242 | - 'LY' => '+218', |
|
243 | - 'VA' => '+379', |
|
244 | - 'VC' => '+1784', |
|
245 | - 'AE' => '+971', |
|
246 | - 'AD' => '+376', |
|
247 | - 'AG' => '+1268', |
|
248 | - 'AF' => '+93', |
|
249 | - 'AI' => '+1264', |
|
250 | - 'VI' => '+1340', |
|
251 | - 'IS' => '+354', |
|
252 | - 'IR' => '+98', |
|
253 | - 'AM' => '+374', |
|
254 | - 'AL' => '+355', |
|
255 | - 'AO' => '+244', |
|
256 | - 'AQ' => '', |
|
257 | - 'AS' => '+1684', |
|
258 | - 'AR' => '+54', |
|
259 | - 'AU' => '+61', |
|
260 | - 'AT' => '+43', |
|
261 | - 'AW' => '+297', |
|
262 | - 'IN' => '+91', |
|
263 | - 'AX' => '+35818', |
|
264 | - 'AZ' => '+994', |
|
265 | - 'IE' => '+353', |
|
266 | - 'ID' => '+62', |
|
267 | - 'UA' => '+380', |
|
268 | - 'QA' => '+974', |
|
269 | - 'MZ' => '+258', |
|
13 | + 'BD' => '+880', |
|
14 | + 'BE' => '+32', |
|
15 | + 'BF' => '+226', |
|
16 | + 'BG' => '+359', |
|
17 | + 'BA' => '+387', |
|
18 | + 'BB' => '+1246', |
|
19 | + 'WF' => '+681', |
|
20 | + 'BL' => '+590', |
|
21 | + 'BM' => '+1441', |
|
22 | + 'BN' => '+673', |
|
23 | + 'BO' => '+591', |
|
24 | + 'BH' => '+973', |
|
25 | + 'BI' => '+257', |
|
26 | + 'BJ' => '+229', |
|
27 | + 'BT' => '+975', |
|
28 | + 'JM' => '+1876', |
|
29 | + 'BV' => '', |
|
30 | + 'BW' => '+267', |
|
31 | + 'WS' => '+685', |
|
32 | + 'BQ' => '+599', |
|
33 | + 'BR' => '+55', |
|
34 | + 'BS' => '+1242', |
|
35 | + 'JE' => '+441534', |
|
36 | + 'BY' => '+375', |
|
37 | + 'BZ' => '+501', |
|
38 | + 'RU' => '+7', |
|
39 | + 'RW' => '+250', |
|
40 | + 'RS' => '+381', |
|
41 | + 'TL' => '+670', |
|
42 | + 'RE' => '+262', |
|
43 | + 'TM' => '+993', |
|
44 | + 'TJ' => '+992', |
|
45 | + 'RO' => '+40', |
|
46 | + 'TK' => '+690', |
|
47 | + 'GW' => '+245', |
|
48 | + 'GU' => '+1671', |
|
49 | + 'GT' => '+502', |
|
50 | + 'GS' => '', |
|
51 | + 'GR' => '+30', |
|
52 | + 'GQ' => '+240', |
|
53 | + 'GP' => '+590', |
|
54 | + 'JP' => '+81', |
|
55 | + 'GY' => '+592', |
|
56 | + 'GG' => '+441481', |
|
57 | + 'GF' => '+594', |
|
58 | + 'GE' => '+995', |
|
59 | + 'GD' => '+1473', |
|
60 | + 'GB' => '+44', |
|
61 | + 'GA' => '+241', |
|
62 | + 'SV' => '+503', |
|
63 | + 'GN' => '+224', |
|
64 | + 'GM' => '+220', |
|
65 | + 'GL' => '+299', |
|
66 | + 'GI' => '+350', |
|
67 | + 'GH' => '+233', |
|
68 | + 'OM' => '+968', |
|
69 | + 'TN' => '+216', |
|
70 | + 'JO' => '+962', |
|
71 | + 'HR' => '+385', |
|
72 | + 'HT' => '+509', |
|
73 | + 'HU' => '+36', |
|
74 | + 'HK' => '+852', |
|
75 | + 'HN' => '+504', |
|
76 | + 'HM' => '', |
|
77 | + 'VE' => '+58', |
|
78 | + 'PR' => array( |
|
79 | + '+1787', |
|
80 | + '+1939', |
|
81 | + ), |
|
82 | + 'PS' => '+970', |
|
83 | + 'PW' => '+680', |
|
84 | + 'PT' => '+351', |
|
85 | + 'SJ' => '+47', |
|
86 | + 'PY' => '+595', |
|
87 | + 'IQ' => '+964', |
|
88 | + 'PA' => '+507', |
|
89 | + 'PF' => '+689', |
|
90 | + 'PG' => '+675', |
|
91 | + 'PE' => '+51', |
|
92 | + 'PK' => '+92', |
|
93 | + 'PH' => '+63', |
|
94 | + 'PN' => '+870', |
|
95 | + 'PL' => '+48', |
|
96 | + 'PM' => '+508', |
|
97 | + 'ZM' => '+260', |
|
98 | + 'EH' => '+212', |
|
99 | + 'EE' => '+372', |
|
100 | + 'EG' => '+20', |
|
101 | + 'ZA' => '+27', |
|
102 | + 'EC' => '+593', |
|
103 | + 'IT' => '+39', |
|
104 | + 'VN' => '+84', |
|
105 | + 'SB' => '+677', |
|
106 | + 'ET' => '+251', |
|
107 | + 'SO' => '+252', |
|
108 | + 'ZW' => '+263', |
|
109 | + 'SA' => '+966', |
|
110 | + 'ES' => '+34', |
|
111 | + 'ER' => '+291', |
|
112 | + 'ME' => '+382', |
|
113 | + 'MD' => '+373', |
|
114 | + 'MG' => '+261', |
|
115 | + 'MF' => '+590', |
|
116 | + 'MA' => '+212', |
|
117 | + 'MC' => '+377', |
|
118 | + 'UZ' => '+998', |
|
119 | + 'MM' => '+95', |
|
120 | + 'ML' => '+223', |
|
121 | + 'MO' => '+853', |
|
122 | + 'MN' => '+976', |
|
123 | + 'MH' => '+692', |
|
124 | + 'MK' => '+389', |
|
125 | + 'MU' => '+230', |
|
126 | + 'MT' => '+356', |
|
127 | + 'MW' => '+265', |
|
128 | + 'MV' => '+960', |
|
129 | + 'MQ' => '+596', |
|
130 | + 'MP' => '+1670', |
|
131 | + 'MS' => '+1664', |
|
132 | + 'MR' => '+222', |
|
133 | + 'IM' => '+441624', |
|
134 | + 'UG' => '+256', |
|
135 | + 'TZ' => '+255', |
|
136 | + 'MY' => '+60', |
|
137 | + 'MX' => '+52', |
|
138 | + 'IL' => '+972', |
|
139 | + 'FR' => '+33', |
|
140 | + 'IO' => '+246', |
|
141 | + 'SH' => '+290', |
|
142 | + 'FI' => '+358', |
|
143 | + 'FJ' => '+679', |
|
144 | + 'FK' => '+500', |
|
145 | + 'FM' => '+691', |
|
146 | + 'FO' => '+298', |
|
147 | + 'NI' => '+505', |
|
148 | + 'NL' => '+31', |
|
149 | + 'NO' => '+47', |
|
150 | + 'NA' => '+264', |
|
151 | + 'VU' => '+678', |
|
152 | + 'NC' => '+687', |
|
153 | + 'NE' => '+227', |
|
154 | + 'NF' => '+672', |
|
155 | + 'NG' => '+234', |
|
156 | + 'NZ' => '+64', |
|
157 | + 'NP' => '+977', |
|
158 | + 'NR' => '+674', |
|
159 | + 'NU' => '+683', |
|
160 | + 'CK' => '+682', |
|
161 | + 'XK' => '', |
|
162 | + 'CI' => '+225', |
|
163 | + 'CH' => '+41', |
|
164 | + 'CO' => '+57', |
|
165 | + 'CN' => '+86', |
|
166 | + 'CM' => '+237', |
|
167 | + 'CL' => '+56', |
|
168 | + 'CC' => '+61', |
|
169 | + 'CA' => '+1', |
|
170 | + 'CG' => '+242', |
|
171 | + 'CF' => '+236', |
|
172 | + 'CD' => '+243', |
|
173 | + 'CZ' => '+420', |
|
174 | + 'CY' => '+357', |
|
175 | + 'CX' => '+61', |
|
176 | + 'CR' => '+506', |
|
177 | + 'CW' => '+599', |
|
178 | + 'CV' => '+238', |
|
179 | + 'CU' => '+53', |
|
180 | + 'SZ' => '+268', |
|
181 | + 'SY' => '+963', |
|
182 | + 'SX' => '+599', |
|
183 | + 'KG' => '+996', |
|
184 | + 'KE' => '+254', |
|
185 | + 'SS' => '+211', |
|
186 | + 'SR' => '+597', |
|
187 | + 'KI' => '+686', |
|
188 | + 'KH' => '+855', |
|
189 | + 'KN' => '+1869', |
|
190 | + 'KM' => '+269', |
|
191 | + 'ST' => '+239', |
|
192 | + 'SK' => '+421', |
|
193 | + 'KR' => '+82', |
|
194 | + 'SI' => '+386', |
|
195 | + 'KP' => '+850', |
|
196 | + 'KW' => '+965', |
|
197 | + 'SN' => '+221', |
|
198 | + 'SM' => '+378', |
|
199 | + 'SL' => '+232', |
|
200 | + 'SC' => '+248', |
|
201 | + 'KZ' => '+7', |
|
202 | + 'KY' => '+1345', |
|
203 | + 'SG' => '+65', |
|
204 | + 'SE' => '+46', |
|
205 | + 'SD' => '+249', |
|
206 | + 'DO' => array( |
|
207 | + '+1809', |
|
208 | + '+1829', |
|
209 | + '+1849', |
|
210 | + ), |
|
211 | + 'DM' => '+1767', |
|
212 | + 'DJ' => '+253', |
|
213 | + 'DK' => '+45', |
|
214 | + 'VG' => '+1284', |
|
215 | + 'DE' => '+49', |
|
216 | + 'YE' => '+967', |
|
217 | + 'DZ' => '+213', |
|
218 | + 'US' => '+1', |
|
219 | + 'UY' => '+598', |
|
220 | + 'YT' => '+262', |
|
221 | + 'UM' => '+1', |
|
222 | + 'LB' => '+961', |
|
223 | + 'LC' => '+1758', |
|
224 | + 'LA' => '+856', |
|
225 | + 'TV' => '+688', |
|
226 | + 'TW' => '+886', |
|
227 | + 'TT' => '+1868', |
|
228 | + 'TR' => '+90', |
|
229 | + 'LK' => '+94', |
|
230 | + 'LI' => '+423', |
|
231 | + 'LV' => '+371', |
|
232 | + 'TO' => '+676', |
|
233 | + 'LT' => '+370', |
|
234 | + 'LU' => '+352', |
|
235 | + 'LR' => '+231', |
|
236 | + 'LS' => '+266', |
|
237 | + 'TH' => '+66', |
|
238 | + 'TF' => '', |
|
239 | + 'TG' => '+228', |
|
240 | + 'TD' => '+235', |
|
241 | + 'TC' => '+1649', |
|
242 | + 'LY' => '+218', |
|
243 | + 'VA' => '+379', |
|
244 | + 'VC' => '+1784', |
|
245 | + 'AE' => '+971', |
|
246 | + 'AD' => '+376', |
|
247 | + 'AG' => '+1268', |
|
248 | + 'AF' => '+93', |
|
249 | + 'AI' => '+1264', |
|
250 | + 'VI' => '+1340', |
|
251 | + 'IS' => '+354', |
|
252 | + 'IR' => '+98', |
|
253 | + 'AM' => '+374', |
|
254 | + 'AL' => '+355', |
|
255 | + 'AO' => '+244', |
|
256 | + 'AQ' => '', |
|
257 | + 'AS' => '+1684', |
|
258 | + 'AR' => '+54', |
|
259 | + 'AU' => '+61', |
|
260 | + 'AT' => '+43', |
|
261 | + 'AW' => '+297', |
|
262 | + 'IN' => '+91', |
|
263 | + 'AX' => '+35818', |
|
264 | + 'AZ' => '+994', |
|
265 | + 'IE' => '+353', |
|
266 | + 'ID' => '+62', |
|
267 | + 'UA' => '+380', |
|
268 | + 'QA' => '+974', |
|
269 | + 'MZ' => '+258', |
|
270 | 270 | ); |
@@ -38,29 +38,29 @@ discard block |
||
38 | 38 | 'advanced' => false |
39 | 39 | ), |
40 | 40 | 'items' => array( |
41 | - 'title' => __( 'Items to buy', 'invoicing' ), |
|
42 | - 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2 ', 'invoicing' ), |
|
43 | - 'type' => 'text', |
|
44 | - 'desc_tip' => true, |
|
45 | - 'default' => '', |
|
46 | - 'placeholder' => __('Items to buy','invoicing'), |
|
47 | - 'advanced' => false |
|
41 | + 'title' => __( 'Items to buy', 'invoicing' ), |
|
42 | + 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2 ', 'invoicing' ), |
|
43 | + 'type' => 'text', |
|
44 | + 'desc_tip' => true, |
|
45 | + 'default' => '', |
|
46 | + 'placeholder' => __('Items to buy','invoicing'), |
|
47 | + 'advanced' => false |
|
48 | 48 | ), |
49 | 49 | 'label' => array( |
50 | - 'title' => __( 'Button Label', 'invoicing' ), |
|
51 | - 'desc' => __( 'Enter button label. Default "Buy Now".', 'invoicing' ), |
|
52 | - 'type' => 'text', |
|
53 | - 'desc_tip' => true, |
|
54 | - 'default' => __( 'Buy Now', 'invoicing' ), |
|
55 | - 'advanced' => false |
|
50 | + 'title' => __( 'Button Label', 'invoicing' ), |
|
51 | + 'desc' => __( 'Enter button label. Default "Buy Now".', 'invoicing' ), |
|
52 | + 'type' => 'text', |
|
53 | + 'desc_tip' => true, |
|
54 | + 'default' => __( 'Buy Now', 'invoicing' ), |
|
55 | + 'advanced' => false |
|
56 | 56 | ), |
57 | 57 | 'post_id' => array( |
58 | - 'title' => __( 'Post ID', 'invoicing' ), |
|
59 | - 'desc' => __( 'Enter related post ID. This is for 3rd party add ons and not mandatory field.', 'invoicing' ), |
|
60 | - 'type' => 'number', |
|
61 | - 'desc_tip' => true, |
|
62 | - 'default' => '', |
|
63 | - 'advanced' => true |
|
58 | + 'title' => __( 'Post ID', 'invoicing' ), |
|
59 | + 'desc' => __( 'Enter related post ID. This is for 3rd party add ons and not mandatory field.', 'invoicing' ), |
|
60 | + 'type' => 'number', |
|
61 | + 'desc_tip' => true, |
|
62 | + 'default' => '', |
|
63 | + 'advanced' => true |
|
64 | 64 | ), |
65 | 65 | ) |
66 | 66 | |
@@ -70,43 +70,43 @@ discard block |
||
70 | 70 | parent::__construct( $options ); |
71 | 71 | } |
72 | 72 | |
73 | - /** |
|
74 | - * The Super block output function. |
|
75 | - * |
|
76 | - * @param array $args |
|
77 | - * @param array $widget_args |
|
78 | - * @param string $content |
|
79 | - * |
|
80 | - * @return string |
|
81 | - */ |
|
73 | + /** |
|
74 | + * The Super block output function. |
|
75 | + * |
|
76 | + * @param array $args |
|
77 | + * @param array $widget_args |
|
78 | + * @param string $content |
|
79 | + * |
|
80 | + * @return string |
|
81 | + */ |
|
82 | 82 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
83 | 83 | |
84 | - $defaults = array( |
|
85 | - 'items' => '', // should be used like: item_id|quantity,item_id|quantity,item_id|quantity |
|
86 | - 'label' => __( 'Buy Now', 'invoicing' ), // the button title |
|
87 | - 'post_id' => '', // any related post_id |
|
88 | - ); |
|
84 | + $defaults = array( |
|
85 | + 'items' => '', // should be used like: item_id|quantity,item_id|quantity,item_id|quantity |
|
86 | + 'label' => __( 'Buy Now', 'invoicing' ), // the button title |
|
87 | + 'post_id' => '', // any related post_id |
|
88 | + ); |
|
89 | 89 | |
90 | - /** |
|
91 | - * Parse incoming $args into an array and merge it with $defaults |
|
92 | - */ |
|
93 | - $args = wp_parse_args( $args, $defaults ); |
|
90 | + /** |
|
91 | + * Parse incoming $args into an array and merge it with $defaults |
|
92 | + */ |
|
93 | + $args = wp_parse_args( $args, $defaults ); |
|
94 | 94 | |
95 | - $html = '<div class="wpi-buy-button-wrapper wpi-g">'; |
|
95 | + $html = '<div class="wpi-buy-button-wrapper wpi-g">'; |
|
96 | 96 | |
97 | - if ( empty( $args['items'] ) ) { |
|
98 | - $html .= __( 'No items selected', 'invoicing' ); |
|
99 | - } else { |
|
100 | - $post_id = isset( $args['post_id'] ) && is_numeric( $args['post_id'] ) ? sanitize_text_field( $args['post_id'] ) : 0; |
|
101 | - $label = isset( $args['label'] ) ? sanitize_text_field( $args['label'] ) : __( 'Buy Now', 'invoicing' ); |
|
102 | - $items = esc_attr( $args['items'] ); |
|
103 | - $html .= "<button class='button button-primary wpi-buy-button' type='button' onclick=\"wpi_buy(this, '$items','$post_id');\">$label</button>"; |
|
104 | - } |
|
97 | + if ( empty( $args['items'] ) ) { |
|
98 | + $html .= __( 'No items selected', 'invoicing' ); |
|
99 | + } else { |
|
100 | + $post_id = isset( $args['post_id'] ) && is_numeric( $args['post_id'] ) ? sanitize_text_field( $args['post_id'] ) : 0; |
|
101 | + $label = isset( $args['label'] ) ? sanitize_text_field( $args['label'] ) : __( 'Buy Now', 'invoicing' ); |
|
102 | + $items = esc_attr( $args['items'] ); |
|
103 | + $html .= "<button class='button button-primary wpi-buy-button' type='button' onclick=\"wpi_buy(this, '$items','$post_id');\">$label</button>"; |
|
104 | + } |
|
105 | 105 | |
106 | - $html .= wp_nonce_field( 'wpinv_buy_items', 'wpinv_buy_nonce', true, false ); |
|
107 | - $html .= '</div>'; |
|
106 | + $html .= wp_nonce_field( 'wpinv_buy_items', 'wpinv_buy_nonce', true, false ); |
|
107 | + $html .= '</div>'; |
|
108 | 108 | |
109 | - return $html; |
|
109 | + return $html; |
|
110 | 110 | |
111 | 111 | } |
112 | 112 |
@@ -1,271 +1,271 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if ( ! defined( 'ABSPATH' ) ) { |
4 | - exit; |
|
4 | + exit; |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | if ( ! class_exists( "AyeCode_Connect_Helper" ) ) { |
8 | - /** |
|
9 | - * Allow the quick setup and connection of our AyeCode Connect plugin. |
|
10 | - * |
|
11 | - * Class AyeCode_Connect_Helper |
|
12 | - */ |
|
13 | - class AyeCode_Connect_Helper { |
|
14 | - |
|
15 | - // Hold the version number |
|
16 | - var $version = "1.0.3"; |
|
17 | - |
|
18 | - // Hold the default strings. |
|
19 | - var $strings = array(); |
|
20 | - |
|
21 | - // Hold the default pages. |
|
22 | - var $pages = array(); |
|
23 | - |
|
24 | - /** |
|
25 | - * The constructor. |
|
26 | - * |
|
27 | - * AyeCode_Connect_Helper constructor. |
|
28 | - * |
|
29 | - * @param array $strings |
|
30 | - * @param array $pages |
|
31 | - */ |
|
32 | - public function __construct( $strings = array(), $pages = array() ) { |
|
33 | - |
|
34 | - // Only fire if not localhost and the current user has the right permissions. |
|
35 | - if ( ! $this->is_localhost() && current_user_can( 'manage_options' ) ) { |
|
36 | - |
|
37 | - |
|
38 | - // set default strings |
|
39 | - $default_strings = array( |
|
40 | - 'connect_title' => __( "Thanks for choosing an AyeCode Product!" ), |
|
41 | - 'connect_external' => __( "Please confirm you wish to connect your site?" ), |
|
42 | - 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s" ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>" ), |
|
43 | - 'connect_button' => __( "Connect Site" ), |
|
44 | - 'connecting_button' => __( "Connecting..." ), |
|
45 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost." ), |
|
46 | - 'error' => __( "Something went wrong, please refresh and try again." ), |
|
47 | - ); |
|
48 | - $this->strings = array_merge( $default_strings, $strings ); |
|
49 | - |
|
50 | - |
|
51 | - // set default pages |
|
52 | - $default_pages = array(); |
|
53 | - $this->pages = array_merge( $default_pages, $pages ); |
|
54 | - |
|
55 | - // maybe show connect site notice |
|
56 | - add_action( 'admin_notices', array( $this, 'ayecode_connect_install_notice' ) ); |
|
57 | - |
|
58 | - // add ajax action if not already added |
|
59 | - if ( ! has_action( 'wp_ajax_ayecode_connect_helper' ) ) { |
|
60 | - add_action( 'wp_ajax_ayecode_connect_helper', array( $this, 'ayecode_connect_install' ) ); |
|
61 | - } |
|
62 | - } |
|
63 | - |
|
64 | - // add ajax action if not already added |
|
65 | - if ( ! has_action( 'wp_ajax_nopriv_ayecode_connect_helper_installed' ) ) { |
|
66 | - add_action( 'wp_ajax_nopriv_ayecode_connect_helper_installed', array( $this, 'ayecode_connect_helper_installed' ) ); |
|
67 | - } |
|
68 | - |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * Give a way to check we can connect via a external redirect. |
|
73 | - */ |
|
74 | - public function ayecode_connect_helper_installed(){ |
|
75 | - $active = array( |
|
76 | - 'gd' => defined('GEODIRECTORY_VERSION') && version_compare(GEODIRECTORY_VERSION,'2.0.0.79','>') ? 1 : 0, |
|
77 | - 'uwp' => defined('USERSWP_VERSION') && version_compare(USERSWP_VERSION,'1.2.1.5','>') ? 1 : 0, |
|
78 | - 'wpi' => defined('WPINV_VERSION') && version_compare(WPINV_VERSION,'1.0.14','>') ? 1 : 0, |
|
79 | - ); |
|
80 | - wp_send_json_success( $active ); |
|
81 | - wp_die(); |
|
82 | - } |
|
83 | - |
|
84 | - /** |
|
85 | - * Get slug from path |
|
86 | - * |
|
87 | - * @param string $key |
|
88 | - * |
|
89 | - * @return string |
|
90 | - */ |
|
91 | - private function format_plugin_slug( $key ) { |
|
92 | - $slug = explode( '/', $key ); |
|
93 | - $slug = explode( '.', end( $slug ) ); |
|
94 | - |
|
95 | - return $slug[0]; |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * Install and activate the AyeCode Connect Plugin |
|
100 | - */ |
|
101 | - public function ayecode_connect_install() { |
|
102 | - |
|
103 | - // bail if localhost |
|
104 | - if ( $this->is_localhost() ) { |
|
105 | - wp_send_json_error( $this->strings['error_localhost'] ); |
|
106 | - } |
|
107 | - |
|
108 | - // Explicitly clear the event. |
|
109 | - wp_clear_scheduled_hook( 'geodir_plugin_background_installer', func_get_args() ); |
|
110 | - |
|
111 | - $success = true; |
|
112 | - $plugin_slug = "ayecode-connect"; |
|
113 | - if ( ! empty( $plugin_slug ) ) { |
|
114 | - require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
|
115 | - require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); |
|
116 | - require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); |
|
117 | - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
118 | - |
|
119 | - WP_Filesystem(); |
|
120 | - |
|
121 | - $skin = new Automatic_Upgrader_Skin; |
|
122 | - $upgrader = new WP_Upgrader( $skin ); |
|
123 | - $installed_plugins = array_map( array( $this, 'format_plugin_slug' ), array_keys( get_plugins() ) ); |
|
124 | - $plugin_slug = $plugin_slug; |
|
125 | - $plugin = $plugin_slug . '/' . $plugin_slug . '.php'; |
|
126 | - $installed = false; |
|
127 | - $activate = false; |
|
128 | - |
|
129 | - // See if the plugin is installed already |
|
130 | - if ( in_array( $plugin_slug, $installed_plugins ) ) { |
|
131 | - $installed = true; |
|
132 | - $activate = ! is_plugin_active( $plugin ); |
|
133 | - } |
|
134 | - |
|
135 | - // Install this thing! |
|
136 | - if ( ! $installed ) { |
|
137 | - |
|
138 | - // Suppress feedback |
|
139 | - ob_start(); |
|
140 | - |
|
141 | - try { |
|
142 | - $plugin_information = plugins_api( 'plugin_information', array( |
|
143 | - 'slug' => $plugin_slug, |
|
144 | - 'fields' => array( |
|
145 | - 'short_description' => false, |
|
146 | - 'sections' => false, |
|
147 | - 'requires' => false, |
|
148 | - 'rating' => false, |
|
149 | - 'ratings' => false, |
|
150 | - 'downloaded' => false, |
|
151 | - 'last_updated' => false, |
|
152 | - 'added' => false, |
|
153 | - 'tags' => false, |
|
154 | - 'homepage' => false, |
|
155 | - 'donate_link' => false, |
|
156 | - 'author_profile' => false, |
|
157 | - 'author' => false, |
|
158 | - ), |
|
159 | - ) ); |
|
160 | - |
|
161 | - if ( is_wp_error( $plugin_information ) ) { |
|
162 | - throw new Exception( $plugin_information->get_error_message() ); |
|
163 | - } |
|
164 | - |
|
165 | - $package = $plugin_information->download_link; |
|
166 | - $download = $upgrader->download_package( $package ); |
|
167 | - |
|
168 | - if ( is_wp_error( $download ) ) { |
|
169 | - throw new Exception( $download->get_error_message() ); |
|
170 | - } |
|
171 | - |
|
172 | - $working_dir = $upgrader->unpack_package( $download, true ); |
|
173 | - |
|
174 | - if ( is_wp_error( $working_dir ) ) { |
|
175 | - throw new Exception( $working_dir->get_error_message() ); |
|
176 | - } |
|
177 | - |
|
178 | - $result = $upgrader->install_package( array( |
|
179 | - 'source' => $working_dir, |
|
180 | - 'destination' => WP_PLUGIN_DIR, |
|
181 | - 'clear_destination' => false, |
|
182 | - 'abort_if_destination_exists' => false, |
|
183 | - 'clear_working' => true, |
|
184 | - 'hook_extra' => array( |
|
185 | - 'type' => 'plugin', |
|
186 | - 'action' => 'install', |
|
187 | - ), |
|
188 | - ) ); |
|
189 | - |
|
190 | - if ( is_wp_error( $result ) ) { |
|
191 | - throw new Exception( $result->get_error_message() ); |
|
192 | - } |
|
193 | - |
|
194 | - $activate = true; |
|
195 | - |
|
196 | - } catch ( Exception $e ) { |
|
197 | - $success = false; |
|
198 | - } |
|
199 | - |
|
200 | - // Discard feedback |
|
201 | - ob_end_clean(); |
|
202 | - } |
|
203 | - |
|
204 | - wp_clean_plugins_cache(); |
|
205 | - |
|
206 | - // Activate this thing |
|
207 | - if ( $activate ) { |
|
208 | - try { |
|
209 | - $result = activate_plugin( $plugin ); |
|
210 | - |
|
211 | - if ( is_wp_error( $result ) ) { |
|
212 | - $success = false; |
|
213 | - } else { |
|
214 | - $success = true; |
|
215 | - } |
|
216 | - } catch ( Exception $e ) { |
|
217 | - $success = false; |
|
218 | - } |
|
219 | - } |
|
220 | - } |
|
221 | - |
|
222 | - if ( $success && function_exists( 'ayecode_connect_args' ) ) { |
|
223 | - ayecode_connect();// init |
|
224 | - $args = ayecode_connect_args(); |
|
225 | - $client = new AyeCode_Connect( $args ); |
|
226 | - $redirect_to = ! empty( $_POST['redirect_to'] ) ? esc_url_raw( $_POST['redirect_to'] ) : ''; |
|
227 | - $redirect = $client->build_connect_url( $redirect_to ); |
|
228 | - wp_send_json_success( array( 'connect_url' => $redirect ) ); |
|
229 | - } else { |
|
230 | - wp_send_json_error( $this->strings['error_localhost'] ); |
|
231 | - } |
|
232 | - wp_die(); |
|
233 | - } |
|
234 | - |
|
235 | - /** |
|
236 | - * Check if maybe localhost. |
|
237 | - * |
|
238 | - * @return bool |
|
239 | - */ |
|
240 | - public function is_localhost() { |
|
241 | - $localhost = false; |
|
242 | - |
|
243 | - $host = isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : ''; |
|
244 | - $localhost_domains = array( |
|
245 | - 'localhost', |
|
246 | - 'localhost.localdomain', |
|
247 | - '127.0.0.1', |
|
248 | - '::1' |
|
249 | - ); |
|
250 | - |
|
251 | - if ( in_array( $host, $localhost_domains ) ) { |
|
252 | - $localhost = true; |
|
253 | - } |
|
254 | - |
|
255 | - return $localhost; |
|
256 | - } |
|
257 | - |
|
258 | - /** |
|
259 | - * Show notice to connect site. |
|
260 | - */ |
|
261 | - public function ayecode_connect_install_notice() { |
|
262 | - if ( $this->maybe_show() ) { |
|
263 | - $connect_title_string = $this->strings['connect_title']; |
|
264 | - $connect_external_string = $this->strings['connect_external']; |
|
265 | - $connect_string = $this->strings['connect']; |
|
266 | - $connect_button_string = $this->strings['connect_button']; |
|
267 | - $connecting_button_string = $this->strings['connecting_button']; |
|
268 | - ?> |
|
8 | + /** |
|
9 | + * Allow the quick setup and connection of our AyeCode Connect plugin. |
|
10 | + * |
|
11 | + * Class AyeCode_Connect_Helper |
|
12 | + */ |
|
13 | + class AyeCode_Connect_Helper { |
|
14 | + |
|
15 | + // Hold the version number |
|
16 | + var $version = "1.0.3"; |
|
17 | + |
|
18 | + // Hold the default strings. |
|
19 | + var $strings = array(); |
|
20 | + |
|
21 | + // Hold the default pages. |
|
22 | + var $pages = array(); |
|
23 | + |
|
24 | + /** |
|
25 | + * The constructor. |
|
26 | + * |
|
27 | + * AyeCode_Connect_Helper constructor. |
|
28 | + * |
|
29 | + * @param array $strings |
|
30 | + * @param array $pages |
|
31 | + */ |
|
32 | + public function __construct( $strings = array(), $pages = array() ) { |
|
33 | + |
|
34 | + // Only fire if not localhost and the current user has the right permissions. |
|
35 | + if ( ! $this->is_localhost() && current_user_can( 'manage_options' ) ) { |
|
36 | + |
|
37 | + |
|
38 | + // set default strings |
|
39 | + $default_strings = array( |
|
40 | + 'connect_title' => __( "Thanks for choosing an AyeCode Product!" ), |
|
41 | + 'connect_external' => __( "Please confirm you wish to connect your site?" ), |
|
42 | + 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s" ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>" ), |
|
43 | + 'connect_button' => __( "Connect Site" ), |
|
44 | + 'connecting_button' => __( "Connecting..." ), |
|
45 | + 'error_localhost' => __( "This service will only work with a live domain, not a localhost." ), |
|
46 | + 'error' => __( "Something went wrong, please refresh and try again." ), |
|
47 | + ); |
|
48 | + $this->strings = array_merge( $default_strings, $strings ); |
|
49 | + |
|
50 | + |
|
51 | + // set default pages |
|
52 | + $default_pages = array(); |
|
53 | + $this->pages = array_merge( $default_pages, $pages ); |
|
54 | + |
|
55 | + // maybe show connect site notice |
|
56 | + add_action( 'admin_notices', array( $this, 'ayecode_connect_install_notice' ) ); |
|
57 | + |
|
58 | + // add ajax action if not already added |
|
59 | + if ( ! has_action( 'wp_ajax_ayecode_connect_helper' ) ) { |
|
60 | + add_action( 'wp_ajax_ayecode_connect_helper', array( $this, 'ayecode_connect_install' ) ); |
|
61 | + } |
|
62 | + } |
|
63 | + |
|
64 | + // add ajax action if not already added |
|
65 | + if ( ! has_action( 'wp_ajax_nopriv_ayecode_connect_helper_installed' ) ) { |
|
66 | + add_action( 'wp_ajax_nopriv_ayecode_connect_helper_installed', array( $this, 'ayecode_connect_helper_installed' ) ); |
|
67 | + } |
|
68 | + |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * Give a way to check we can connect via a external redirect. |
|
73 | + */ |
|
74 | + public function ayecode_connect_helper_installed(){ |
|
75 | + $active = array( |
|
76 | + 'gd' => defined('GEODIRECTORY_VERSION') && version_compare(GEODIRECTORY_VERSION,'2.0.0.79','>') ? 1 : 0, |
|
77 | + 'uwp' => defined('USERSWP_VERSION') && version_compare(USERSWP_VERSION,'1.2.1.5','>') ? 1 : 0, |
|
78 | + 'wpi' => defined('WPINV_VERSION') && version_compare(WPINV_VERSION,'1.0.14','>') ? 1 : 0, |
|
79 | + ); |
|
80 | + wp_send_json_success( $active ); |
|
81 | + wp_die(); |
|
82 | + } |
|
83 | + |
|
84 | + /** |
|
85 | + * Get slug from path |
|
86 | + * |
|
87 | + * @param string $key |
|
88 | + * |
|
89 | + * @return string |
|
90 | + */ |
|
91 | + private function format_plugin_slug( $key ) { |
|
92 | + $slug = explode( '/', $key ); |
|
93 | + $slug = explode( '.', end( $slug ) ); |
|
94 | + |
|
95 | + return $slug[0]; |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * Install and activate the AyeCode Connect Plugin |
|
100 | + */ |
|
101 | + public function ayecode_connect_install() { |
|
102 | + |
|
103 | + // bail if localhost |
|
104 | + if ( $this->is_localhost() ) { |
|
105 | + wp_send_json_error( $this->strings['error_localhost'] ); |
|
106 | + } |
|
107 | + |
|
108 | + // Explicitly clear the event. |
|
109 | + wp_clear_scheduled_hook( 'geodir_plugin_background_installer', func_get_args() ); |
|
110 | + |
|
111 | + $success = true; |
|
112 | + $plugin_slug = "ayecode-connect"; |
|
113 | + if ( ! empty( $plugin_slug ) ) { |
|
114 | + require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
|
115 | + require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); |
|
116 | + require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); |
|
117 | + require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
118 | + |
|
119 | + WP_Filesystem(); |
|
120 | + |
|
121 | + $skin = new Automatic_Upgrader_Skin; |
|
122 | + $upgrader = new WP_Upgrader( $skin ); |
|
123 | + $installed_plugins = array_map( array( $this, 'format_plugin_slug' ), array_keys( get_plugins() ) ); |
|
124 | + $plugin_slug = $plugin_slug; |
|
125 | + $plugin = $plugin_slug . '/' . $plugin_slug . '.php'; |
|
126 | + $installed = false; |
|
127 | + $activate = false; |
|
128 | + |
|
129 | + // See if the plugin is installed already |
|
130 | + if ( in_array( $plugin_slug, $installed_plugins ) ) { |
|
131 | + $installed = true; |
|
132 | + $activate = ! is_plugin_active( $plugin ); |
|
133 | + } |
|
134 | + |
|
135 | + // Install this thing! |
|
136 | + if ( ! $installed ) { |
|
137 | + |
|
138 | + // Suppress feedback |
|
139 | + ob_start(); |
|
140 | + |
|
141 | + try { |
|
142 | + $plugin_information = plugins_api( 'plugin_information', array( |
|
143 | + 'slug' => $plugin_slug, |
|
144 | + 'fields' => array( |
|
145 | + 'short_description' => false, |
|
146 | + 'sections' => false, |
|
147 | + 'requires' => false, |
|
148 | + 'rating' => false, |
|
149 | + 'ratings' => false, |
|
150 | + 'downloaded' => false, |
|
151 | + 'last_updated' => false, |
|
152 | + 'added' => false, |
|
153 | + 'tags' => false, |
|
154 | + 'homepage' => false, |
|
155 | + 'donate_link' => false, |
|
156 | + 'author_profile' => false, |
|
157 | + 'author' => false, |
|
158 | + ), |
|
159 | + ) ); |
|
160 | + |
|
161 | + if ( is_wp_error( $plugin_information ) ) { |
|
162 | + throw new Exception( $plugin_information->get_error_message() ); |
|
163 | + } |
|
164 | + |
|
165 | + $package = $plugin_information->download_link; |
|
166 | + $download = $upgrader->download_package( $package ); |
|
167 | + |
|
168 | + if ( is_wp_error( $download ) ) { |
|
169 | + throw new Exception( $download->get_error_message() ); |
|
170 | + } |
|
171 | + |
|
172 | + $working_dir = $upgrader->unpack_package( $download, true ); |
|
173 | + |
|
174 | + if ( is_wp_error( $working_dir ) ) { |
|
175 | + throw new Exception( $working_dir->get_error_message() ); |
|
176 | + } |
|
177 | + |
|
178 | + $result = $upgrader->install_package( array( |
|
179 | + 'source' => $working_dir, |
|
180 | + 'destination' => WP_PLUGIN_DIR, |
|
181 | + 'clear_destination' => false, |
|
182 | + 'abort_if_destination_exists' => false, |
|
183 | + 'clear_working' => true, |
|
184 | + 'hook_extra' => array( |
|
185 | + 'type' => 'plugin', |
|
186 | + 'action' => 'install', |
|
187 | + ), |
|
188 | + ) ); |
|
189 | + |
|
190 | + if ( is_wp_error( $result ) ) { |
|
191 | + throw new Exception( $result->get_error_message() ); |
|
192 | + } |
|
193 | + |
|
194 | + $activate = true; |
|
195 | + |
|
196 | + } catch ( Exception $e ) { |
|
197 | + $success = false; |
|
198 | + } |
|
199 | + |
|
200 | + // Discard feedback |
|
201 | + ob_end_clean(); |
|
202 | + } |
|
203 | + |
|
204 | + wp_clean_plugins_cache(); |
|
205 | + |
|
206 | + // Activate this thing |
|
207 | + if ( $activate ) { |
|
208 | + try { |
|
209 | + $result = activate_plugin( $plugin ); |
|
210 | + |
|
211 | + if ( is_wp_error( $result ) ) { |
|
212 | + $success = false; |
|
213 | + } else { |
|
214 | + $success = true; |
|
215 | + } |
|
216 | + } catch ( Exception $e ) { |
|
217 | + $success = false; |
|
218 | + } |
|
219 | + } |
|
220 | + } |
|
221 | + |
|
222 | + if ( $success && function_exists( 'ayecode_connect_args' ) ) { |
|
223 | + ayecode_connect();// init |
|
224 | + $args = ayecode_connect_args(); |
|
225 | + $client = new AyeCode_Connect( $args ); |
|
226 | + $redirect_to = ! empty( $_POST['redirect_to'] ) ? esc_url_raw( $_POST['redirect_to'] ) : ''; |
|
227 | + $redirect = $client->build_connect_url( $redirect_to ); |
|
228 | + wp_send_json_success( array( 'connect_url' => $redirect ) ); |
|
229 | + } else { |
|
230 | + wp_send_json_error( $this->strings['error_localhost'] ); |
|
231 | + } |
|
232 | + wp_die(); |
|
233 | + } |
|
234 | + |
|
235 | + /** |
|
236 | + * Check if maybe localhost. |
|
237 | + * |
|
238 | + * @return bool |
|
239 | + */ |
|
240 | + public function is_localhost() { |
|
241 | + $localhost = false; |
|
242 | + |
|
243 | + $host = isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : ''; |
|
244 | + $localhost_domains = array( |
|
245 | + 'localhost', |
|
246 | + 'localhost.localdomain', |
|
247 | + '127.0.0.1', |
|
248 | + '::1' |
|
249 | + ); |
|
250 | + |
|
251 | + if ( in_array( $host, $localhost_domains ) ) { |
|
252 | + $localhost = true; |
|
253 | + } |
|
254 | + |
|
255 | + return $localhost; |
|
256 | + } |
|
257 | + |
|
258 | + /** |
|
259 | + * Show notice to connect site. |
|
260 | + */ |
|
261 | + public function ayecode_connect_install_notice() { |
|
262 | + if ( $this->maybe_show() ) { |
|
263 | + $connect_title_string = $this->strings['connect_title']; |
|
264 | + $connect_external_string = $this->strings['connect_external']; |
|
265 | + $connect_string = $this->strings['connect']; |
|
266 | + $connect_button_string = $this->strings['connect_button']; |
|
267 | + $connecting_button_string = $this->strings['connecting_button']; |
|
268 | + ?> |
|
269 | 269 | <div class="notice notice-info acch-notice"> |
270 | 270 | <span class="acch-float-left"> |
271 | 271 | <svg width="61px" height="61px" viewBox="0 0 61 61" version="1.1" |
@@ -304,8 +304,8 @@ discard block |
||
304 | 304 | <h3 class="acch-title"><?php echo esc_attr( $connect_title_string ); ?></h3> |
305 | 305 | <p> |
306 | 306 | <?php |
307 | - echo $connect_string; |
|
308 | - ?> |
|
307 | + echo $connect_string; |
|
308 | + ?> |
|
309 | 309 | </p> |
310 | 310 | </span> |
311 | 311 | |
@@ -318,9 +318,9 @@ discard block |
||
318 | 318 | </div> |
319 | 319 | |
320 | 320 | <?php |
321 | - // only include the popup HTML if needed. |
|
322 | - if ( ! empty( $_REQUEST['external-connect-request'] ) ) { |
|
323 | - ?> |
|
321 | + // only include the popup HTML if needed. |
|
322 | + if ( ! empty( $_REQUEST['external-connect-request'] ) ) { |
|
323 | + ?> |
|
324 | 324 | <div id="ayecode-connect-helper-external-confirm" style="display:none;"> |
325 | 325 | <div class="noticex notice-info acch-notice" style="border: none;"> |
326 | 326 | <span class="acch-float-left"> |
@@ -369,23 +369,23 @@ discard block |
||
369 | 369 | </div> |
370 | 370 | </div> |
371 | 371 | <?php |
372 | - } |
|
373 | - |
|
374 | - // add required scripts |
|
375 | - $this->script(); |
|
376 | - } |
|
377 | - } |
|
378 | - |
|
379 | - /** |
|
380 | - * Get the JS Script. |
|
381 | - */ |
|
382 | - public function script() { |
|
383 | - |
|
384 | - // add thickbox if external request is requested |
|
385 | - if ( ! empty( $_REQUEST['external-connect-request'] ) ) { |
|
386 | - add_thickbox(); |
|
387 | - } |
|
388 | - ?> |
|
372 | + } |
|
373 | + |
|
374 | + // add required scripts |
|
375 | + $this->script(); |
|
376 | + } |
|
377 | + } |
|
378 | + |
|
379 | + /** |
|
380 | + * Get the JS Script. |
|
381 | + */ |
|
382 | + public function script() { |
|
383 | + |
|
384 | + // add thickbox if external request is requested |
|
385 | + if ( ! empty( $_REQUEST['external-connect-request'] ) ) { |
|
386 | + add_thickbox(); |
|
387 | + } |
|
388 | + ?> |
|
389 | 389 | <style> |
390 | 390 | .acch-title { |
391 | 391 | margin: 0; |
@@ -454,43 +454,43 @@ discard block |
||
454 | 454 | |
455 | 455 | |
456 | 456 | <?php |
457 | - // add thickbox if external request is requested |
|
458 | - if(! empty( $_REQUEST['external-connect-request'] )) { |
|
459 | - ?> |
|
457 | + // add thickbox if external request is requested |
|
458 | + if(! empty( $_REQUEST['external-connect-request'] )) { |
|
459 | + ?> |
|
460 | 460 | jQuery(function () { |
461 | 461 | setTimeout(function () { |
462 | 462 | tb_show("AyeCode Connect", "?TB_inline?width=300&height=80&inlineId=ayecode-connect-helper-external-confirm"); |
463 | 463 | }, 200); |
464 | 464 | }); |
465 | 465 | <?php |
466 | - } |
|
467 | - ?> |
|
466 | + } |
|
467 | + ?> |
|
468 | 468 | |
469 | 469 | </script> |
470 | 470 | <?php |
471 | - } |
|
472 | - |
|
473 | - /** |
|
474 | - * Decide what pages to show on. |
|
475 | - * |
|
476 | - * @return bool |
|
477 | - */ |
|
478 | - public function maybe_show() { |
|
479 | - $show = false; |
|
480 | - |
|
481 | - // check if on a page set to show |
|
482 | - if ( isset( $_REQUEST['page'] ) && in_array( $_REQUEST['page'], $this->pages ) ) { |
|
483 | - |
|
484 | - // check if not active and connected |
|
485 | - if ( ! defined( 'AYECODE_CONNECT_VERSION' ) || ! get_option( 'ayecode_connect_blog_token' ) ) { |
|
486 | - $show = true; |
|
487 | - } |
|
471 | + } |
|
472 | + |
|
473 | + /** |
|
474 | + * Decide what pages to show on. |
|
475 | + * |
|
476 | + * @return bool |
|
477 | + */ |
|
478 | + public function maybe_show() { |
|
479 | + $show = false; |
|
480 | + |
|
481 | + // check if on a page set to show |
|
482 | + if ( isset( $_REQUEST['page'] ) && in_array( $_REQUEST['page'], $this->pages ) ) { |
|
483 | + |
|
484 | + // check if not active and connected |
|
485 | + if ( ! defined( 'AYECODE_CONNECT_VERSION' ) || ! get_option( 'ayecode_connect_blog_token' ) ) { |
|
486 | + $show = true; |
|
487 | + } |
|
488 | 488 | |
489 | - } |
|
489 | + } |
|
490 | 490 | |
491 | - return $show; |
|
492 | - } |
|
491 | + return $show; |
|
492 | + } |
|
493 | 493 | |
494 | - } |
|
494 | + } |
|
495 | 495 | |
496 | 496 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * |
7 | 7 | */ |
8 | 8 | if ( ! defined( 'ABSPATH' ) ) { |
9 | - exit; |
|
9 | + exit; |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | /** |
@@ -15,71 +15,71 @@ discard block |
||
15 | 15 | class WPInv_Admin_Addons extends Ayecode_Addons { |
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * Get the extensions page tabs. |
|
20 | - * |
|
21 | - * @return array of tabs. |
|
22 | - */ |
|
23 | - public function get_tabs(){ |
|
24 | - $tabs = array( |
|
25 | - 'addons' => __("Addons", "invoicing"), |
|
18 | + /** |
|
19 | + * Get the extensions page tabs. |
|
20 | + * |
|
21 | + * @return array of tabs. |
|
22 | + */ |
|
23 | + public function get_tabs(){ |
|
24 | + $tabs = array( |
|
25 | + 'addons' => __("Addons", "invoicing"), |
|
26 | 26 | 'gateways' => __("Payment Gateways", "invoicing"), |
27 | 27 | 'recommended_plugins' => __("Recommended plugins", "invoicing"), |
28 | 28 | 'membership' => __("Membership", "invoicing"), |
29 | - ); |
|
30 | - |
|
31 | - return $tabs; |
|
32 | - } |
|
33 | - |
|
34 | - /** |
|
35 | - * Get section content for the addons screen. |
|
36 | - * |
|
37 | - * @param string $section_id |
|
38 | - * |
|
39 | - * @return array |
|
40 | - */ |
|
41 | - public function get_section_data( $section_id ) { |
|
42 | - $section = self::get_tab( $section_id ); |
|
43 | - $api_url = "https://wpinvoicing.com/edd-api/v2/products/"; |
|
44 | - $section_data = new stdClass(); |
|
45 | - |
|
46 | - if($section_id=='recommended_plugins'){ |
|
47 | - $section_data->products = self::get_recommend_wp_plugins_edd_formatted(); |
|
48 | - } |
|
49 | - elseif ( ! empty( $section ) ) { |
|
50 | - if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing |
|
51 | - //if ( 1==1) { |
|
52 | - |
|
53 | - $query_args = array( 'category' => $section_id, 'number' => 100); |
|
54 | - $query_args = apply_filters('wpeu_edd_api_query_args',$query_args,$api_url,$section_id); |
|
55 | - |
|
56 | - $raw_section = wp_safe_remote_get( esc_url_raw( add_query_arg($query_args ,$api_url) ), array( 'user-agent' => 'Invoicing Addons Page','timeout' => 15, ) ); |
|
57 | - |
|
58 | - if ( ! is_wp_error( $raw_section ) ) { |
|
59 | - $section_data = json_decode( wp_remote_retrieve_body( $raw_section ) ); |
|
60 | - |
|
61 | - if ( ! empty( $section_data->products ) ) { |
|
62 | - set_transient( 'wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS ); |
|
63 | - } |
|
64 | - } |
|
65 | - } |
|
66 | - } |
|
67 | - |
|
68 | - $products = isset($section_data->products) ? $section_data->products : ''; |
|
69 | - |
|
70 | - return apply_filters( 'wpi_addons_section_data', $products, $section_id ); |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * Outputs a button. |
|
75 | - *ccc |
|
76 | - * @param string $url |
|
77 | - * @param string $text |
|
78 | - * @param string $theme |
|
79 | - * @param string $plugin |
|
80 | - */ |
|
81 | - public function output_button( $addon ) { |
|
82 | - $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
29 | + ); |
|
30 | + |
|
31 | + return $tabs; |
|
32 | + } |
|
33 | + |
|
34 | + /** |
|
35 | + * Get section content for the addons screen. |
|
36 | + * |
|
37 | + * @param string $section_id |
|
38 | + * |
|
39 | + * @return array |
|
40 | + */ |
|
41 | + public function get_section_data( $section_id ) { |
|
42 | + $section = self::get_tab( $section_id ); |
|
43 | + $api_url = "https://wpinvoicing.com/edd-api/v2/products/"; |
|
44 | + $section_data = new stdClass(); |
|
45 | + |
|
46 | + if($section_id=='recommended_plugins'){ |
|
47 | + $section_data->products = self::get_recommend_wp_plugins_edd_formatted(); |
|
48 | + } |
|
49 | + elseif ( ! empty( $section ) ) { |
|
50 | + if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing |
|
51 | + //if ( 1==1) { |
|
52 | + |
|
53 | + $query_args = array( 'category' => $section_id, 'number' => 100); |
|
54 | + $query_args = apply_filters('wpeu_edd_api_query_args',$query_args,$api_url,$section_id); |
|
55 | + |
|
56 | + $raw_section = wp_safe_remote_get( esc_url_raw( add_query_arg($query_args ,$api_url) ), array( 'user-agent' => 'Invoicing Addons Page','timeout' => 15, ) ); |
|
57 | + |
|
58 | + if ( ! is_wp_error( $raw_section ) ) { |
|
59 | + $section_data = json_decode( wp_remote_retrieve_body( $raw_section ) ); |
|
60 | + |
|
61 | + if ( ! empty( $section_data->products ) ) { |
|
62 | + set_transient( 'wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS ); |
|
63 | + } |
|
64 | + } |
|
65 | + } |
|
66 | + } |
|
67 | + |
|
68 | + $products = isset($section_data->products) ? $section_data->products : ''; |
|
69 | + |
|
70 | + return apply_filters( 'wpi_addons_section_data', $products, $section_id ); |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * Outputs a button. |
|
75 | + *ccc |
|
76 | + * @param string $url |
|
77 | + * @param string $text |
|
78 | + * @param string $theme |
|
79 | + * @param string $plugin |
|
80 | + */ |
|
81 | + public function output_button( $addon ) { |
|
82 | + $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
83 | 83 | // $button_text = __('Free','invoicing'); |
84 | 84 | // $licensing = false; |
85 | 85 | // $installed = false; |
@@ -91,123 +91,123 @@ discard block |
||
91 | 91 | // $install_status = 'get'; |
92 | 92 | // $onclick = ''; |
93 | 93 | |
94 | - $wp_org_themes = array('supreme-directory','directory-starter'); |
|
95 | - |
|
96 | - $button_args = array( |
|
97 | - 'type' => ($current_tab == 'addons' || $current_tab =='gateways') ? 'addons' : $current_tab, |
|
98 | - 'id' => isset($addon->info->id) ? absint($addon->info->id) : '', |
|
99 | - 'title' => isset($addon->info->title) ? $addon->info->title : '', |
|
100 | - 'button_text' => __('Free','invoicing'), |
|
101 | - 'price_text' => __('Free','invoicing'), |
|
102 | - 'link' => isset($addon->info->link) ? $addon->info->link : '', // link to product |
|
103 | - 'url' => isset($addon->info->link) ? $addon->info->link : '', // button url |
|
104 | - 'class' => 'button-primary', |
|
105 | - 'install_status' => 'get', |
|
106 | - 'installed' => false, |
|
107 | - 'price' => '', |
|
108 | - 'licensing' => isset($addon->licensing->enabled) && $addon->licensing->enabled ? true : false, |
|
109 | - 'license' => isset($addon->licensing->license) && $addon->licensing->license ? $addon->licensing->license : '', |
|
110 | - 'onclick' => '', |
|
111 | - 'slug' => isset($addon->info->slug) ? $addon->info->slug : '', |
|
112 | - 'active' => false, |
|
113 | - 'file' => '', |
|
114 | - 'update_url' => '', |
|
115 | - ); |
|
116 | - |
|
117 | - if( ($current_tab == 'addons' || $current_tab =='gateways') && isset($addon->info->id) && $addon->info->id){ |
|
118 | - include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
|
119 | - if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
|
120 | - $status = self::install_plugin_install_status($addon); |
|
121 | - $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
|
122 | - if(isset($status['status'])){$button_args['install_status'] = $status['status'];} |
|
123 | - $button_args['update_url'] = "https://wpinvoicing.com"; |
|
124 | - }elseif($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) { |
|
125 | - if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
|
126 | - $button_args['installed'] = self::is_theme_installed($addon); |
|
127 | - if(!in_array($button_args['slug'],$wp_org_themes)){ |
|
128 | - $button_args['update_url'] = "https://wpinvoicing.com"; |
|
129 | - } |
|
130 | - }elseif($current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug){ |
|
131 | - include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
|
132 | - $status = install_plugin_install_status(array("slug"=>$button_args['slug'],"version"=>"")); |
|
133 | - $button_args['install_status'] = isset($status['status']) ? $status['status'] : 'install'; |
|
134 | - $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
|
135 | - } |
|
136 | - |
|
137 | - // set price |
|
138 | - if(isset($addon->pricing) && !empty($addon->pricing)){ |
|
139 | - if(is_object($addon->pricing)){ |
|
140 | - $prices = (Array)$addon->pricing; |
|
141 | - $button_args['price'] = reset($prices); |
|
142 | - }elseif(isset($addon->pricing)){ |
|
143 | - $button_args['price'] = $addon->pricing; |
|
144 | - } |
|
145 | - } |
|
146 | - |
|
147 | - // set price text |
|
148 | - if( $button_args['price'] && $button_args['price'] != '0.00' ){ |
|
149 | - $button_args['price_text'] = sprintf( __('From: $%d', 'invoicing'), $button_args['price']); |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - // set if installed |
|
154 | - if(in_array($button_args['install_status'], array('installed','latest_installed','update_available','newer_installed'))){ |
|
155 | - $button_args['installed'] = true; |
|
156 | - } |
|
94 | + $wp_org_themes = array('supreme-directory','directory-starter'); |
|
95 | + |
|
96 | + $button_args = array( |
|
97 | + 'type' => ($current_tab == 'addons' || $current_tab =='gateways') ? 'addons' : $current_tab, |
|
98 | + 'id' => isset($addon->info->id) ? absint($addon->info->id) : '', |
|
99 | + 'title' => isset($addon->info->title) ? $addon->info->title : '', |
|
100 | + 'button_text' => __('Free','invoicing'), |
|
101 | + 'price_text' => __('Free','invoicing'), |
|
102 | + 'link' => isset($addon->info->link) ? $addon->info->link : '', // link to product |
|
103 | + 'url' => isset($addon->info->link) ? $addon->info->link : '', // button url |
|
104 | + 'class' => 'button-primary', |
|
105 | + 'install_status' => 'get', |
|
106 | + 'installed' => false, |
|
107 | + 'price' => '', |
|
108 | + 'licensing' => isset($addon->licensing->enabled) && $addon->licensing->enabled ? true : false, |
|
109 | + 'license' => isset($addon->licensing->license) && $addon->licensing->license ? $addon->licensing->license : '', |
|
110 | + 'onclick' => '', |
|
111 | + 'slug' => isset($addon->info->slug) ? $addon->info->slug : '', |
|
112 | + 'active' => false, |
|
113 | + 'file' => '', |
|
114 | + 'update_url' => '', |
|
115 | + ); |
|
116 | + |
|
117 | + if( ($current_tab == 'addons' || $current_tab =='gateways') && isset($addon->info->id) && $addon->info->id){ |
|
118 | + include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
|
119 | + if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
|
120 | + $status = self::install_plugin_install_status($addon); |
|
121 | + $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
|
122 | + if(isset($status['status'])){$button_args['install_status'] = $status['status'];} |
|
123 | + $button_args['update_url'] = "https://wpinvoicing.com"; |
|
124 | + }elseif($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) { |
|
125 | + if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
|
126 | + $button_args['installed'] = self::is_theme_installed($addon); |
|
127 | + if(!in_array($button_args['slug'],$wp_org_themes)){ |
|
128 | + $button_args['update_url'] = "https://wpinvoicing.com"; |
|
129 | + } |
|
130 | + }elseif($current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug){ |
|
131 | + include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
|
132 | + $status = install_plugin_install_status(array("slug"=>$button_args['slug'],"version"=>"")); |
|
133 | + $button_args['install_status'] = isset($status['status']) ? $status['status'] : 'install'; |
|
134 | + $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
|
135 | + } |
|
136 | + |
|
137 | + // set price |
|
138 | + if(isset($addon->pricing) && !empty($addon->pricing)){ |
|
139 | + if(is_object($addon->pricing)){ |
|
140 | + $prices = (Array)$addon->pricing; |
|
141 | + $button_args['price'] = reset($prices); |
|
142 | + }elseif(isset($addon->pricing)){ |
|
143 | + $button_args['price'] = $addon->pricing; |
|
144 | + } |
|
145 | + } |
|
146 | + |
|
147 | + // set price text |
|
148 | + if( $button_args['price'] && $button_args['price'] != '0.00' ){ |
|
149 | + $button_args['price_text'] = sprintf( __('From: $%d', 'invoicing'), $button_args['price']); |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + // set if installed |
|
154 | + if(in_array($button_args['install_status'], array('installed','latest_installed','update_available','newer_installed'))){ |
|
155 | + $button_args['installed'] = true; |
|
156 | + } |
|
157 | 157 | |
158 | 158 | // print_r($button_args); |
159 | - // set if active |
|
160 | - if($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')){ |
|
161 | - if($button_args['type'] != 'themes'){ |
|
162 | - $button_args['active'] = is_plugin_active($button_args['file']); |
|
163 | - }else{ |
|
164 | - $button_args['active'] = self::is_theme_active($addon); |
|
165 | - } |
|
166 | - } |
|
167 | - |
|
168 | - // set button text and class |
|
169 | - if($button_args['active']){ |
|
170 | - $button_args['button_text'] = __('Active','invoicing'); |
|
171 | - $button_args['class'] = ' button-secondary disabled '; |
|
172 | - }elseif($button_args['installed']){ |
|
173 | - $button_args['button_text'] = __('Activate','invoicing'); |
|
174 | - |
|
175 | - if($button_args['type'] != 'themes'){ |
|
176 | - if ( current_user_can( 'manage_options' ) ) { |
|
177 | - $button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin='.$button_args['file']), 'activate-plugin_' . $button_args['file']); |
|
178 | - }else{ |
|
179 | - $button_args['url'] = '#'; |
|
180 | - } |
|
181 | - }else{ |
|
182 | - if ( current_user_can( 'switch_themes' ) ) { |
|
183 | - $button_args['url'] = self::get_theme_activation_url($addon); |
|
184 | - }else{ |
|
185 | - $button_args['url'] = '#'; |
|
186 | - } |
|
187 | - } |
|
188 | - |
|
189 | - }else{ |
|
190 | - if($button_args['type'] == 'recommended_plugins'){ |
|
191 | - $button_args['button_text'] = __('Install','invoicing'); |
|
192 | - }else{ |
|
193 | - $button_args['button_text'] = __('Get it','invoicing'); |
|
194 | - |
|
195 | - /*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){ |
|
159 | + // set if active |
|
160 | + if($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')){ |
|
161 | + if($button_args['type'] != 'themes'){ |
|
162 | + $button_args['active'] = is_plugin_active($button_args['file']); |
|
163 | + }else{ |
|
164 | + $button_args['active'] = self::is_theme_active($addon); |
|
165 | + } |
|
166 | + } |
|
167 | + |
|
168 | + // set button text and class |
|
169 | + if($button_args['active']){ |
|
170 | + $button_args['button_text'] = __('Active','invoicing'); |
|
171 | + $button_args['class'] = ' button-secondary disabled '; |
|
172 | + }elseif($button_args['installed']){ |
|
173 | + $button_args['button_text'] = __('Activate','invoicing'); |
|
174 | + |
|
175 | + if($button_args['type'] != 'themes'){ |
|
176 | + if ( current_user_can( 'manage_options' ) ) { |
|
177 | + $button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin='.$button_args['file']), 'activate-plugin_' . $button_args['file']); |
|
178 | + }else{ |
|
179 | + $button_args['url'] = '#'; |
|
180 | + } |
|
181 | + }else{ |
|
182 | + if ( current_user_can( 'switch_themes' ) ) { |
|
183 | + $button_args['url'] = self::get_theme_activation_url($addon); |
|
184 | + }else{ |
|
185 | + $button_args['url'] = '#'; |
|
186 | + } |
|
187 | + } |
|
188 | + |
|
189 | + }else{ |
|
190 | + if($button_args['type'] == 'recommended_plugins'){ |
|
191 | + $button_args['button_text'] = __('Install','invoicing'); |
|
192 | + }else{ |
|
193 | + $button_args['button_text'] = __('Get it','invoicing'); |
|
194 | + |
|
195 | + /*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){ |
|
196 | 196 | $button_args['button_text'] = __('Install','invoicing'); |
197 | 197 | $button_args['url'] = self::get_theme_install_url($button_args['slug']); |
198 | 198 | $button_args['onclick'] = 'gd_set_button_installing(this);'; |
199 | 199 | }*/ |
200 | 200 | |
201 | - } |
|
202 | - } |
|
201 | + } |
|
202 | + } |
|
203 | 203 | |
204 | 204 | |
205 | - // filter the button arguments |
|
206 | - $button_args = apply_filters('edd_api_button_args',$button_args); |
|
205 | + // filter the button arguments |
|
206 | + $button_args = apply_filters('edd_api_button_args',$button_args); |
|
207 | 207 | // print_r($button_args); |
208 | - // set price text |
|
209 | - if(isset($button_args['price_text'])){ |
|
210 | - ?> |
|
208 | + // set price text |
|
209 | + if(isset($button_args['price_text'])){ |
|
210 | + ?> |
|
211 | 211 | <a |
212 | 212 | target="_blank" |
213 | 213 | class="addons-price-text" |
@@ -215,15 +215,15 @@ discard block |
||
215 | 215 | <?php echo esc_html( $button_args['price_text'] ); ?> |
216 | 216 | </a> |
217 | 217 | <?php |
218 | - } |
|
218 | + } |
|
219 | 219 | |
220 | 220 | |
221 | - $target = ''; |
|
222 | - if ( ! empty( $button_args['url'] ) ) { |
|
223 | - $target = strpos($button_args['url'], get_site_url()) !== false ? '' : ' target="_blank" '; |
|
224 | - } |
|
221 | + $target = ''; |
|
222 | + if ( ! empty( $button_args['url'] ) ) { |
|
223 | + $target = strpos($button_args['url'], get_site_url()) !== false ? '' : ' target="_blank" '; |
|
224 | + } |
|
225 | 225 | |
226 | - ?> |
|
226 | + ?> |
|
227 | 227 | <a |
228 | 228 | data-licence="<?php echo esc_attr($button_args['license']);?>" |
229 | 229 | data-licensing="<?php echo $button_args['licensing'] ? 1 : 0;?>" |
@@ -246,33 +246,33 @@ discard block |
||
246 | 246 | <?php |
247 | 247 | |
248 | 248 | |
249 | - } |
|
250 | - |
|
251 | - |
|
252 | - /** |
|
253 | - * Handles output of the addons page in admin. |
|
254 | - */ |
|
255 | - public function output() { |
|
256 | - $tabs = self::get_tabs(); |
|
257 | - $sections = self::get_sections(); |
|
258 | - $theme = wp_get_theme(); |
|
259 | - $section_keys = array_keys( $sections ); |
|
260 | - $current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys ); |
|
261 | - $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
262 | - include_once( WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php' ); |
|
263 | - } |
|
264 | - |
|
265 | - /** |
|
266 | - * A list of recommended wp.org plugins. |
|
267 | - * @return array |
|
268 | - */ |
|
269 | - public function get_recommend_wp_plugins(){ |
|
270 | - $plugins = array( |
|
249 | + } |
|
250 | + |
|
251 | + |
|
252 | + /** |
|
253 | + * Handles output of the addons page in admin. |
|
254 | + */ |
|
255 | + public function output() { |
|
256 | + $tabs = self::get_tabs(); |
|
257 | + $sections = self::get_sections(); |
|
258 | + $theme = wp_get_theme(); |
|
259 | + $section_keys = array_keys( $sections ); |
|
260 | + $current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys ); |
|
261 | + $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
262 | + include_once( WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php' ); |
|
263 | + } |
|
264 | + |
|
265 | + /** |
|
266 | + * A list of recommended wp.org plugins. |
|
267 | + * @return array |
|
268 | + */ |
|
269 | + public function get_recommend_wp_plugins(){ |
|
270 | + $plugins = array( |
|
271 | 271 | 'invoicing-quotes' => array( |
272 | 272 | 'url' => 'https://wordpress.org/plugins/invoicing-quotes/', |
273 | 273 | 'slug' => 'invoicing-quotes', |
274 | - 'name' => 'Quotes', |
|
275 | - 'thumbnail' => 'https://ps.w.org/invoicing-quotes/assets/banner-772x250.jpg', |
|
274 | + 'name' => 'Quotes', |
|
275 | + 'thumbnail' => 'https://ps.w.org/invoicing-quotes/assets/banner-772x250.jpg', |
|
276 | 276 | 'desc' => __('Allows you to create quotes, send them to clients and convert them to Invoices when accepted by the customer.','invoicing'), |
277 | 277 | ), |
278 | 278 | 'geodirectory' => array( |
@@ -287,8 +287,8 @@ discard block |
||
287 | 287 | 'name' => 'UsersWP', |
288 | 288 | 'desc' => __('Allow frontend user login and registration as well as have slick profile pages.','invoicing'), |
289 | 289 | ), |
290 | - ); |
|
290 | + ); |
|
291 | 291 | |
292 | - return $plugins; |
|
293 | - } |
|
292 | + return $plugins; |
|
293 | + } |
|
294 | 294 | } |
@@ -3,102 +3,102 @@ discard block |
||
3 | 3 | class SD_Hello_World 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' => 'fas fa-globe-americas', |
|
17 | - // Dash icon name for the block: https://developer.wordpress.org/resource/dashicons/#arrow-right |
|
18 | - // OR font-awesome 5 class name: fas fa-globe-americas |
|
19 | - 'block-category' => 'widgets', |
|
20 | - // the category for the block, 'common', 'formatting', 'layout', 'widgets', 'embed'. |
|
21 | - 'block-keywords' => "['hello','world']", |
|
22 | - // used in the block search, MAX 3 |
|
23 | - 'block-output' => array( // the block visual output elements as an array |
|
24 | - array( |
|
25 | - 'element' => 'p', |
|
26 | - 'title' => __( 'Placeholder', 'hello-world' ), |
|
27 | - 'class' => '[%className%]', |
|
28 | - 'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%] |
|
29 | - ) |
|
30 | - ), |
|
31 | - 'block-wrap' => '', // You can specify the type of element to wrap the block `div` or `span` etc.. Or blank for no wrap at all. |
|
32 | - 'class_name' => __CLASS__, |
|
33 | - // The calling class name |
|
34 | - 'base_id' => 'hello_world', |
|
35 | - // this is used as the widget id and the shortcode id. |
|
36 | - 'name' => __( 'Hello World', 'hello-world' ), |
|
37 | - // the name of the widget/block |
|
38 | - 'widget_ops' => array( |
|
39 | - 'classname' => 'hello-world-class', |
|
40 | - // widget class |
|
41 | - 'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world' ), |
|
42 | - // widget description |
|
43 | - ), |
|
44 | - 'no_wrap' => true, // This will prevent the widget being wrapped in the containing widget class div. |
|
45 | - 'arguments' => array( // these are the arguments that will be used in the widget, shortcode and block settings. |
|
46 | - 'after_text' => array( // this is the input name='' |
|
47 | - 'title' => __( 'Text after hello:', 'hello-world' ), |
|
48 | - // input title |
|
49 | - 'desc' => __( 'This is the text that will appear after `Hello:`.', 'hello-world' ), |
|
50 | - // input description |
|
51 | - 'type' => 'text', |
|
52 | - // the type of input, test, select, checkbox etc. |
|
53 | - 'placeholder' => 'World', |
|
54 | - // the input placeholder text. |
|
55 | - 'desc_tip' => true, |
|
56 | - // if the input should show the widget description text as a tooltip. |
|
57 | - 'default' => 'World', |
|
58 | - // the input default value. |
|
59 | - 'advanced' => false |
|
60 | - // not yet implemented |
|
61 | - ), |
|
62 | - ) |
|
63 | - ); |
|
64 | - |
|
65 | - parent::__construct( $options ); |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * This is the output function for the widget, shortcode and block (front end). |
|
71 | - * |
|
72 | - * @param array $args The arguments values. |
|
73 | - * @param array $widget_args The widget arguments when used. |
|
74 | - * @param string $content The shortcode content argument |
|
75 | - * |
|
76 | - * @return string |
|
77 | - */ |
|
78 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
79 | - |
|
80 | - /** |
|
81 | - * @var string $after_text |
|
82 | - * @var string $another_input This is added by filter below. |
|
83 | - */ |
|
84 | - extract( $args, EXTR_SKIP ); |
|
85 | - |
|
86 | - /* |
|
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' => 'fas fa-globe-americas', |
|
17 | + // Dash icon name for the block: https://developer.wordpress.org/resource/dashicons/#arrow-right |
|
18 | + // OR font-awesome 5 class name: fas fa-globe-americas |
|
19 | + 'block-category' => 'widgets', |
|
20 | + // the category for the block, 'common', 'formatting', 'layout', 'widgets', 'embed'. |
|
21 | + 'block-keywords' => "['hello','world']", |
|
22 | + // used in the block search, MAX 3 |
|
23 | + 'block-output' => array( // the block visual output elements as an array |
|
24 | + array( |
|
25 | + 'element' => 'p', |
|
26 | + 'title' => __( 'Placeholder', 'hello-world' ), |
|
27 | + 'class' => '[%className%]', |
|
28 | + 'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%] |
|
29 | + ) |
|
30 | + ), |
|
31 | + 'block-wrap' => '', // You can specify the type of element to wrap the block `div` or `span` etc.. Or blank for no wrap at all. |
|
32 | + 'class_name' => __CLASS__, |
|
33 | + // The calling class name |
|
34 | + 'base_id' => 'hello_world', |
|
35 | + // this is used as the widget id and the shortcode id. |
|
36 | + 'name' => __( 'Hello World', 'hello-world' ), |
|
37 | + // the name of the widget/block |
|
38 | + 'widget_ops' => array( |
|
39 | + 'classname' => 'hello-world-class', |
|
40 | + // widget class |
|
41 | + 'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world' ), |
|
42 | + // widget description |
|
43 | + ), |
|
44 | + 'no_wrap' => true, // This will prevent the widget being wrapped in the containing widget class div. |
|
45 | + 'arguments' => array( // these are the arguments that will be used in the widget, shortcode and block settings. |
|
46 | + 'after_text' => array( // this is the input name='' |
|
47 | + 'title' => __( 'Text after hello:', 'hello-world' ), |
|
48 | + // input title |
|
49 | + 'desc' => __( 'This is the text that will appear after `Hello:`.', 'hello-world' ), |
|
50 | + // input description |
|
51 | + 'type' => 'text', |
|
52 | + // the type of input, test, select, checkbox etc. |
|
53 | + 'placeholder' => 'World', |
|
54 | + // the input placeholder text. |
|
55 | + 'desc_tip' => true, |
|
56 | + // if the input should show the widget description text as a tooltip. |
|
57 | + 'default' => 'World', |
|
58 | + // the input default value. |
|
59 | + 'advanced' => false |
|
60 | + // not yet implemented |
|
61 | + ), |
|
62 | + ) |
|
63 | + ); |
|
64 | + |
|
65 | + parent::__construct( $options ); |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * This is the output function for the widget, shortcode and block (front end). |
|
71 | + * |
|
72 | + * @param array $args The arguments values. |
|
73 | + * @param array $widget_args The widget arguments when used. |
|
74 | + * @param string $content The shortcode content argument |
|
75 | + * |
|
76 | + * @return string |
|
77 | + */ |
|
78 | + public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
79 | + |
|
80 | + /** |
|
81 | + * @var string $after_text |
|
82 | + * @var string $another_input This is added by filter below. |
|
83 | + */ |
|
84 | + extract( $args, EXTR_SKIP ); |
|
85 | + |
|
86 | + /* |
|
87 | 87 | * This value is added by filter so might not exist if filter is removed so we check. |
88 | 88 | */ |
89 | - if ( ! isset( $another_input ) ) { |
|
90 | - $another_input = ''; |
|
91 | - } |
|
89 | + if ( ! isset( $another_input ) ) { |
|
90 | + $another_input = ''; |
|
91 | + } |
|
92 | 92 | |
93 | - return "Hello: " . $after_text . "" . $another_input; |
|
93 | + return "Hello: " . $after_text . "" . $another_input; |
|
94 | 94 | |
95 | - } |
|
95 | + } |
|
96 | 96 | |
97 | 97 | } |
98 | 98 | |
99 | 99 | // register it. |
100 | 100 | add_action( 'widgets_init', function () { |
101 | - register_widget( 'SD_Hello_World' ); |
|
101 | + register_widget( 'SD_Hello_World' ); |
|
102 | 102 | } ); |
103 | 103 | |
104 | 104 | |
@@ -111,26 +111,26 @@ discard block |
||
111 | 111 | */ |
112 | 112 | function _my_extra_arguments( $options ) { |
113 | 113 | |
114 | - /* |
|
114 | + /* |
|
115 | 115 | * Add a new input option. |
116 | 116 | */ |
117 | - $options['arguments']['another_input'] = array( |
|
118 | - 'name' => 'another_input', // this is the input name='' |
|
119 | - 'title' => __( 'Another input:', 'hello-world' ), // input title |
|
120 | - 'desc' => __( 'This is an input added via filter.', 'hello-world' ), // input description |
|
121 | - 'type' => 'text', // the type of input, test, select, checkbox etc. |
|
122 | - 'placeholder' => 'Placeholder text', // the input placeholder text. |
|
123 | - 'desc_tip' => true, // if the input should show the widget description text as a tooltip. |
|
124 | - 'default' => '', // the input default value. |
|
125 | - 'advanced' => false // not yet implemented |
|
126 | - ); |
|
127 | - |
|
128 | - /* |
|
117 | + $options['arguments']['another_input'] = array( |
|
118 | + 'name' => 'another_input', // this is the input name='' |
|
119 | + 'title' => __( 'Another input:', 'hello-world' ), // input title |
|
120 | + 'desc' => __( 'This is an input added via filter.', 'hello-world' ), // input description |
|
121 | + 'type' => 'text', // the type of input, test, select, checkbox etc. |
|
122 | + 'placeholder' => 'Placeholder text', // the input placeholder text. |
|
123 | + 'desc_tip' => true, // if the input should show the widget description text as a tooltip. |
|
124 | + 'default' => '', // the input default value. |
|
125 | + 'advanced' => false // not yet implemented |
|
126 | + ); |
|
127 | + |
|
128 | + /* |
|
129 | 129 | * Output the new option in the block output also. |
130 | 130 | */ |
131 | - $options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]";; |
|
131 | + $options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]";; |
|
132 | 132 | |
133 | - return $options; |
|
133 | + return $options; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | //add_filter( 'wp_super_duper_options_hello_world', '_my_extra_arguments' ); |
137 | 137 | \ No newline at end of file |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if ( ! defined( 'ABSPATH' ) ) { |
4 | - exit; // Exit if accessed directly |
|
4 | + exit; // Exit if accessed directly |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | /** |
@@ -11,81 +11,81 @@ discard block |
||
11 | 11 | */ |
12 | 12 | class AUI_Component_Alert { |
13 | 13 | |
14 | - /** |
|
15 | - * Build the component. |
|
16 | - * |
|
17 | - * @param array $args |
|
18 | - * |
|
19 | - * @return string The rendered component. |
|
20 | - */ |
|
21 | - public static function get($args = array()){ |
|
22 | - $defaults = array( |
|
23 | - 'type' => 'info', |
|
24 | - 'class' => '', |
|
25 | - 'icon' => '', |
|
26 | - 'heading' => '', |
|
27 | - 'content' => '', |
|
28 | - 'footer' => '', |
|
29 | - 'dismissible'=> false, |
|
30 | - 'data' => '', |
|
31 | - ); |
|
14 | + /** |
|
15 | + * Build the component. |
|
16 | + * |
|
17 | + * @param array $args |
|
18 | + * |
|
19 | + * @return string The rendered component. |
|
20 | + */ |
|
21 | + public static function get($args = array()){ |
|
22 | + $defaults = array( |
|
23 | + 'type' => 'info', |
|
24 | + 'class' => '', |
|
25 | + 'icon' => '', |
|
26 | + 'heading' => '', |
|
27 | + 'content' => '', |
|
28 | + 'footer' => '', |
|
29 | + 'dismissible'=> false, |
|
30 | + 'data' => '', |
|
31 | + ); |
|
32 | 32 | |
33 | - /** |
|
34 | - * Parse incoming $args into an array and merge it with $defaults |
|
35 | - */ |
|
36 | - $args = wp_parse_args( $args, $defaults ); |
|
37 | - $output = ''; |
|
38 | - if ( ! empty( $args['content'] ) ) { |
|
39 | - $type = sanitize_html_class( $args['type'] ); |
|
40 | - if($type=='error'){$type='danger';} |
|
41 | - $icon = !empty($args['icon']) ? "<i class='".esc_attr($args['icon'])."'></i>" : ''; |
|
33 | + /** |
|
34 | + * Parse incoming $args into an array and merge it with $defaults |
|
35 | + */ |
|
36 | + $args = wp_parse_args( $args, $defaults ); |
|
37 | + $output = ''; |
|
38 | + if ( ! empty( $args['content'] ) ) { |
|
39 | + $type = sanitize_html_class( $args['type'] ); |
|
40 | + if($type=='error'){$type='danger';} |
|
41 | + $icon = !empty($args['icon']) ? "<i class='".esc_attr($args['icon'])."'></i>" : ''; |
|
42 | 42 | |
43 | - // set default icon |
|
44 | - if(!$icon && $args['icon']!==false && $type){ |
|
45 | - if($type=='danger'){$icon = '<i class="fas fa-exclamation-circle"></i>';} |
|
46 | - elseif($type=='warning'){$icon = '<i class="fas fa-exclamation-triangle"></i>';} |
|
47 | - elseif($type=='success'){$icon = '<i class="fas fa-check-circle"></i>';} |
|
48 | - elseif($type=='info'){$icon = '<i class="fas fa-info-circle"></i>';} |
|
49 | - } |
|
43 | + // set default icon |
|
44 | + if(!$icon && $args['icon']!==false && $type){ |
|
45 | + if($type=='danger'){$icon = '<i class="fas fa-exclamation-circle"></i>';} |
|
46 | + elseif($type=='warning'){$icon = '<i class="fas fa-exclamation-triangle"></i>';} |
|
47 | + elseif($type=='success'){$icon = '<i class="fas fa-check-circle"></i>';} |
|
48 | + elseif($type=='info'){$icon = '<i class="fas fa-info-circle"></i>';} |
|
49 | + } |
|
50 | 50 | |
51 | - $data = ''; |
|
52 | - $class = !empty($args['class']) ? esc_attr($args['class']) : ''; |
|
53 | - if($args['dismissible']){$class .= " alert-dismissible fade show";} |
|
51 | + $data = ''; |
|
52 | + $class = !empty($args['class']) ? esc_attr($args['class']) : ''; |
|
53 | + if($args['dismissible']){$class .= " alert-dismissible fade show";} |
|
54 | 54 | |
55 | - // open |
|
56 | - $output .= '<div class="alert alert-' . $type . ' '.$class.'" role="alert" '.$data.'>'; |
|
55 | + // open |
|
56 | + $output .= '<div class="alert alert-' . $type . ' '.$class.'" role="alert" '.$data.'>'; |
|
57 | 57 | |
58 | - // heading |
|
59 | - if ( ! empty( $args['heading'] ) ) { |
|
60 | - $output .= '<h4 class="alert-heading">' . $args['heading'] . '</h4>'; |
|
61 | - } |
|
58 | + // heading |
|
59 | + if ( ! empty( $args['heading'] ) ) { |
|
60 | + $output .= '<h4 class="alert-heading">' . $args['heading'] . '</h4>'; |
|
61 | + } |
|
62 | 62 | |
63 | - // icon |
|
64 | - if ( ! empty( $icon) ) { |
|
65 | - $output .= $icon." "; |
|
66 | - } |
|
63 | + // icon |
|
64 | + if ( ! empty( $icon) ) { |
|
65 | + $output .= $icon." "; |
|
66 | + } |
|
67 | 67 | |
68 | - // content |
|
69 | - $output .= $args['content']; |
|
68 | + // content |
|
69 | + $output .= $args['content']; |
|
70 | 70 | |
71 | - // dismissible |
|
72 | - if($args['dismissible']){ |
|
73 | - $output .= '<button type="button" class="close" data-dismiss="alert" aria-label="Close">'; |
|
74 | - $output .= '<span aria-hidden="true">×</span>'; |
|
75 | - $output .= '</button>'; |
|
76 | - } |
|
71 | + // dismissible |
|
72 | + if($args['dismissible']){ |
|
73 | + $output .= '<button type="button" class="close" data-dismiss="alert" aria-label="Close">'; |
|
74 | + $output .= '<span aria-hidden="true">×</span>'; |
|
75 | + $output .= '</button>'; |
|
76 | + } |
|
77 | 77 | |
78 | - // footer |
|
79 | - if ( ! empty( $args['footer'] ) ) { |
|
80 | - $output .= '<hr>'; |
|
81 | - $output .= '<p class="mb-0">' . $args['footer'] . '</p>'; |
|
82 | - } |
|
78 | + // footer |
|
79 | + if ( ! empty( $args['footer'] ) ) { |
|
80 | + $output .= '<hr>'; |
|
81 | + $output .= '<p class="mb-0">' . $args['footer'] . '</p>'; |
|
82 | + } |
|
83 | 83 | |
84 | - // close |
|
85 | - $output .= '</div>'; |
|
86 | - } |
|
84 | + // close |
|
85 | + $output .= '</div>'; |
|
86 | + } |
|
87 | 87 | |
88 | - return $output; |
|
89 | - } |
|
88 | + return $output; |
|
89 | + } |
|
90 | 90 | |
91 | 91 | } |
92 | 92 | \ No newline at end of file |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if ( ! defined( 'ABSPATH' ) ) { |
4 | - exit; // Exit if accessed directly |
|
4 | + exit; // Exit if accessed directly |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | /** |
@@ -11,62 +11,62 @@ discard block |
||
11 | 11 | */ |
12 | 12 | class AUI_Component_Dropdown { |
13 | 13 | |
14 | - /** |
|
15 | - * Build the component. |
|
16 | - * |
|
17 | - * @param array $args |
|
18 | - * |
|
19 | - * @return string The rendered component. |
|
20 | - */ |
|
21 | - public static function get($args = array()){ |
|
22 | - $defaults = array( |
|
23 | - 'type' => 'button', |
|
24 | - 'href' => '#', |
|
25 | - 'class' => 'btn btn-primary dropdown-toggle', |
|
26 | - 'wrapper_class' => '', |
|
27 | - 'dropdown_menu_class' => '', |
|
28 | - 'id' => '', |
|
29 | - 'title' => '', |
|
30 | - 'value' => '', |
|
31 | - 'content' => '', |
|
32 | - 'icon' => '', |
|
33 | - 'hover_content' => '', |
|
34 | - 'hover_icon' => '', |
|
35 | - 'data-toggle' => 'dropdown', |
|
36 | - 'aria-haspopup' => 'true', |
|
37 | - 'aria-expanded' => 'false', |
|
38 | - 'dropdown_menu' => '', // unescaped html menu (non-preferred way) |
|
39 | - 'dropdown_items' => array(), // array of AUI calls |
|
14 | + /** |
|
15 | + * Build the component. |
|
16 | + * |
|
17 | + * @param array $args |
|
18 | + * |
|
19 | + * @return string The rendered component. |
|
20 | + */ |
|
21 | + public static function get($args = array()){ |
|
22 | + $defaults = array( |
|
23 | + 'type' => 'button', |
|
24 | + 'href' => '#', |
|
25 | + 'class' => 'btn btn-primary dropdown-toggle', |
|
26 | + 'wrapper_class' => '', |
|
27 | + 'dropdown_menu_class' => '', |
|
28 | + 'id' => '', |
|
29 | + 'title' => '', |
|
30 | + 'value' => '', |
|
31 | + 'content' => '', |
|
32 | + 'icon' => '', |
|
33 | + 'hover_content' => '', |
|
34 | + 'hover_icon' => '', |
|
35 | + 'data-toggle' => 'dropdown', |
|
36 | + 'aria-haspopup' => 'true', |
|
37 | + 'aria-expanded' => 'false', |
|
38 | + 'dropdown_menu' => '', // unescaped html menu (non-preferred way) |
|
39 | + 'dropdown_items' => array(), // array of AUI calls |
|
40 | 40 | |
41 | - ); |
|
41 | + ); |
|
42 | 42 | |
43 | - /** |
|
44 | - * Parse incoming $args into an array and merge it with $defaults |
|
45 | - */ |
|
46 | - $args = wp_parse_args( $args, $defaults ); |
|
47 | - $output = ''; |
|
48 | - if ( ! empty( $args['type'] ) ) { |
|
49 | - // wrapper open |
|
50 | - $output .= '<div class="dropdown '.AUI_Component_Helper::esc_classes($args['wrapper_class']).'">'; |
|
43 | + /** |
|
44 | + * Parse incoming $args into an array and merge it with $defaults |
|
45 | + */ |
|
46 | + $args = wp_parse_args( $args, $defaults ); |
|
47 | + $output = ''; |
|
48 | + if ( ! empty( $args['type'] ) ) { |
|
49 | + // wrapper open |
|
50 | + $output .= '<div class="dropdown '.AUI_Component_Helper::esc_classes($args['wrapper_class']).'">'; |
|
51 | 51 | |
52 | - // button part |
|
53 | - $output .= aui()->button($args); |
|
52 | + // button part |
|
53 | + $output .= aui()->button($args); |
|
54 | 54 | |
55 | - // dropdown-menu |
|
56 | - if(!empty($args['dropdown_menu'])){ |
|
57 | - $output .= $args['dropdown_menu']; |
|
58 | - }elseif(!empty($args['dropdown_items'])){ |
|
59 | - $output .= '<div class="dropdown-menu '.AUI_Component_Helper::esc_classes($args['dropdown_menu_class']).'" aria-labelledby="'.sanitize_html_class($args['id']).'">'; |
|
60 | - $output .= aui()->render($args['dropdown_items']); |
|
61 | - $output .= '</div>'; |
|
62 | - } |
|
55 | + // dropdown-menu |
|
56 | + if(!empty($args['dropdown_menu'])){ |
|
57 | + $output .= $args['dropdown_menu']; |
|
58 | + }elseif(!empty($args['dropdown_items'])){ |
|
59 | + $output .= '<div class="dropdown-menu '.AUI_Component_Helper::esc_classes($args['dropdown_menu_class']).'" aria-labelledby="'.sanitize_html_class($args['id']).'">'; |
|
60 | + $output .= aui()->render($args['dropdown_items']); |
|
61 | + $output .= '</div>'; |
|
62 | + } |
|
63 | 63 | |
64 | - // wrapper close |
|
65 | - $output .= '</div>'; |
|
64 | + // wrapper close |
|
65 | + $output .= '</div>'; |
|
66 | 66 | |
67 | - } |
|
67 | + } |
|
68 | 68 | |
69 | - return $output; |
|
70 | - } |
|
69 | + return $output; |
|
70 | + } |
|
71 | 71 | |
72 | 72 | } |
73 | 73 | \ No newline at end of file |
@@ -16,132 +16,132 @@ |
||
16 | 16 | |
17 | 17 | // If this file is called directly, abort. |
18 | 18 | if ( ! defined( 'WPINC' ) ) { |
19 | - die; |
|
19 | + die; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | class AyeCode_UI_Plugin { |
23 | 23 | |
24 | - /** |
|
25 | - * AUI Plugin constructor. |
|
26 | - * |
|
27 | - * @since 1.0.0 |
|
28 | - */ |
|
29 | - public function __construct() { |
|
30 | - |
|
31 | - // load AUI |
|
32 | - require_once( dirname( __FILE__ ) . '/ayecode-ui-loader.php' ); |
|
33 | - |
|
34 | - // Maybe show example page |
|
35 | - add_action( 'template_redirect', array( $this,'maybe_show_examples' ) ); |
|
36 | - } |
|
37 | - |
|
38 | - public function maybe_show_examples(){ |
|
39 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
40 | - echo "<head>"; |
|
41 | - wp_head(); |
|
42 | - echo "</head>"; |
|
43 | - echo "<body>"; |
|
44 | - echo $this->get_examples(); |
|
45 | - echo "</body>"; |
|
46 | - exit; |
|
47 | - } |
|
48 | - } |
|
49 | - |
|
50 | - public function get_examples(){ |
|
51 | - $output = ''; |
|
52 | - |
|
53 | - |
|
54 | - // open form |
|
55 | - $output .= "<form class='p-5 m-5 border rounded'>"; |
|
56 | - |
|
57 | - // input example |
|
58 | - $output .= aui()->input(array( |
|
59 | - 'type' => 'text', |
|
60 | - 'id' => 'text-example', |
|
61 | - 'name' => 'text-example', |
|
62 | - 'placeholder' => 'text placeholder', |
|
63 | - 'title' => 'Text input example', |
|
64 | - 'value' => '', |
|
65 | - 'required' => false, |
|
66 | - 'help_text' => 'help text', |
|
67 | - 'label' => 'Text input example label' |
|
68 | - )); |
|
69 | - |
|
70 | - // input example |
|
71 | - $output .= aui()->input(array( |
|
72 | - 'type' => 'url', |
|
73 | - 'id' => 'text-example2', |
|
74 | - 'name' => 'text-example', |
|
75 | - 'placeholder' => 'url placeholder', |
|
76 | - 'title' => 'Text input example', |
|
77 | - 'value' => '', |
|
78 | - 'required' => false, |
|
79 | - 'help_text' => 'help text', |
|
80 | - 'label' => 'Text input example label' |
|
81 | - )); |
|
82 | - |
|
83 | - // checkbox example |
|
84 | - $output .= aui()->input(array( |
|
85 | - 'type' => 'checkbox', |
|
86 | - 'id' => 'checkbox-example', |
|
87 | - 'name' => 'checkbox-example', |
|
88 | - 'placeholder' => 'checkbox-example', |
|
89 | - 'title' => 'Checkbox example', |
|
90 | - 'value' => '1', |
|
91 | - 'checked' => true, |
|
92 | - 'required' => false, |
|
93 | - 'help_text' => 'help text', |
|
94 | - 'label' => 'Checkbox checked' |
|
95 | - )); |
|
96 | - |
|
97 | - // checkbox example |
|
98 | - $output .= aui()->input(array( |
|
99 | - 'type' => 'checkbox', |
|
100 | - 'id' => 'checkbox-example2', |
|
101 | - 'name' => 'checkbox-example2', |
|
102 | - 'placeholder' => 'checkbox-example', |
|
103 | - 'title' => 'Checkbox example', |
|
104 | - 'value' => '1', |
|
105 | - 'checked' => false, |
|
106 | - 'required' => false, |
|
107 | - 'help_text' => 'help text', |
|
108 | - 'label' => 'Checkbox un-checked' |
|
109 | - )); |
|
110 | - |
|
111 | - // switch example |
|
112 | - $output .= aui()->input(array( |
|
113 | - 'type' => 'checkbox', |
|
114 | - 'id' => 'switch-example', |
|
115 | - 'name' => 'switch-example', |
|
116 | - 'placeholder' => 'checkbox-example', |
|
117 | - 'title' => 'Switch example', |
|
118 | - 'value' => '1', |
|
119 | - 'checked' => true, |
|
120 | - 'switch' => true, |
|
121 | - 'required' => false, |
|
122 | - 'help_text' => 'help text', |
|
123 | - 'label' => 'Switch on' |
|
124 | - )); |
|
125 | - |
|
126 | - // switch example |
|
127 | - $output .= aui()->input(array( |
|
128 | - 'type' => 'checkbox', |
|
129 | - 'id' => 'switch-example2', |
|
130 | - 'name' => 'switch-example2', |
|
131 | - 'placeholder' => 'checkbox-example', |
|
132 | - 'title' => 'Switch example', |
|
133 | - 'value' => '1', |
|
134 | - 'checked' => false, |
|
135 | - 'switch' => true, |
|
136 | - 'required' => false, |
|
137 | - 'help_text' => 'help text', |
|
138 | - 'label' => 'Switch off' |
|
139 | - )); |
|
140 | - |
|
141 | - // close form |
|
142 | - $output .= "</form>"; |
|
143 | - |
|
144 | - return $output; |
|
145 | - } |
|
24 | + /** |
|
25 | + * AUI Plugin constructor. |
|
26 | + * |
|
27 | + * @since 1.0.0 |
|
28 | + */ |
|
29 | + public function __construct() { |
|
30 | + |
|
31 | + // load AUI |
|
32 | + require_once( dirname( __FILE__ ) . '/ayecode-ui-loader.php' ); |
|
33 | + |
|
34 | + // Maybe show example page |
|
35 | + add_action( 'template_redirect', array( $this,'maybe_show_examples' ) ); |
|
36 | + } |
|
37 | + |
|
38 | + public function maybe_show_examples(){ |
|
39 | + if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
40 | + echo "<head>"; |
|
41 | + wp_head(); |
|
42 | + echo "</head>"; |
|
43 | + echo "<body>"; |
|
44 | + echo $this->get_examples(); |
|
45 | + echo "</body>"; |
|
46 | + exit; |
|
47 | + } |
|
48 | + } |
|
49 | + |
|
50 | + public function get_examples(){ |
|
51 | + $output = ''; |
|
52 | + |
|
53 | + |
|
54 | + // open form |
|
55 | + $output .= "<form class='p-5 m-5 border rounded'>"; |
|
56 | + |
|
57 | + // input example |
|
58 | + $output .= aui()->input(array( |
|
59 | + 'type' => 'text', |
|
60 | + 'id' => 'text-example', |
|
61 | + 'name' => 'text-example', |
|
62 | + 'placeholder' => 'text placeholder', |
|
63 | + 'title' => 'Text input example', |
|
64 | + 'value' => '', |
|
65 | + 'required' => false, |
|
66 | + 'help_text' => 'help text', |
|
67 | + 'label' => 'Text input example label' |
|
68 | + )); |
|
69 | + |
|
70 | + // input example |
|
71 | + $output .= aui()->input(array( |
|
72 | + 'type' => 'url', |
|
73 | + 'id' => 'text-example2', |
|
74 | + 'name' => 'text-example', |
|
75 | + 'placeholder' => 'url placeholder', |
|
76 | + 'title' => 'Text input example', |
|
77 | + 'value' => '', |
|
78 | + 'required' => false, |
|
79 | + 'help_text' => 'help text', |
|
80 | + 'label' => 'Text input example label' |
|
81 | + )); |
|
82 | + |
|
83 | + // checkbox example |
|
84 | + $output .= aui()->input(array( |
|
85 | + 'type' => 'checkbox', |
|
86 | + 'id' => 'checkbox-example', |
|
87 | + 'name' => 'checkbox-example', |
|
88 | + 'placeholder' => 'checkbox-example', |
|
89 | + 'title' => 'Checkbox example', |
|
90 | + 'value' => '1', |
|
91 | + 'checked' => true, |
|
92 | + 'required' => false, |
|
93 | + 'help_text' => 'help text', |
|
94 | + 'label' => 'Checkbox checked' |
|
95 | + )); |
|
96 | + |
|
97 | + // checkbox example |
|
98 | + $output .= aui()->input(array( |
|
99 | + 'type' => 'checkbox', |
|
100 | + 'id' => 'checkbox-example2', |
|
101 | + 'name' => 'checkbox-example2', |
|
102 | + 'placeholder' => 'checkbox-example', |
|
103 | + 'title' => 'Checkbox example', |
|
104 | + 'value' => '1', |
|
105 | + 'checked' => false, |
|
106 | + 'required' => false, |
|
107 | + 'help_text' => 'help text', |
|
108 | + 'label' => 'Checkbox un-checked' |
|
109 | + )); |
|
110 | + |
|
111 | + // switch example |
|
112 | + $output .= aui()->input(array( |
|
113 | + 'type' => 'checkbox', |
|
114 | + 'id' => 'switch-example', |
|
115 | + 'name' => 'switch-example', |
|
116 | + 'placeholder' => 'checkbox-example', |
|
117 | + 'title' => 'Switch example', |
|
118 | + 'value' => '1', |
|
119 | + 'checked' => true, |
|
120 | + 'switch' => true, |
|
121 | + 'required' => false, |
|
122 | + 'help_text' => 'help text', |
|
123 | + 'label' => 'Switch on' |
|
124 | + )); |
|
125 | + |
|
126 | + // switch example |
|
127 | + $output .= aui()->input(array( |
|
128 | + 'type' => 'checkbox', |
|
129 | + 'id' => 'switch-example2', |
|
130 | + 'name' => 'switch-example2', |
|
131 | + 'placeholder' => 'checkbox-example', |
|
132 | + 'title' => 'Switch example', |
|
133 | + 'value' => '1', |
|
134 | + 'checked' => false, |
|
135 | + 'switch' => true, |
|
136 | + 'required' => false, |
|
137 | + 'help_text' => 'help text', |
|
138 | + 'label' => 'Switch off' |
|
139 | + )); |
|
140 | + |
|
141 | + // close form |
|
142 | + $output .= "</form>"; |
|
143 | + |
|
144 | + return $output; |
|
145 | + } |
|
146 | 146 | } |
147 | 147 | new AyeCode_UI_Plugin(); |
148 | 148 | \ No newline at end of file |
@@ -5,106 +5,106 @@ discard block |
||
5 | 5 | */ |
6 | 6 | |
7 | 7 | if ( ! defined( 'ABSPATH' ) ) { |
8 | - exit; // Exit if accessed directly |
|
8 | + exit; // Exit if accessed directly |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | if ( ! class_exists( 'GetPaid_Admin_Profile', false ) ) : |
12 | 12 | |
13 | - /** |
|
14 | - * GetPaid_Admin_Profile Class. |
|
15 | - */ |
|
16 | - class GetPaid_Admin_Profile { |
|
17 | - |
|
18 | - /** |
|
19 | - * Hook in tabs. |
|
20 | - */ |
|
21 | - public function __construct() { |
|
22 | - add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
23 | - add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
24 | - |
|
25 | - add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) ); |
|
26 | - add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) ); |
|
27 | - } |
|
28 | - |
|
29 | - /** |
|
30 | - * Get Address Fields for the edit user pages. |
|
31 | - * |
|
32 | - * @return array Fields to display which are filtered through invoicing_customer_meta_fields before being returned |
|
33 | - */ |
|
34 | - public function get_customer_meta_fields() { |
|
35 | - |
|
36 | - $show_fields = apply_filters( |
|
37 | - 'getpaid_customer_meta_fields', |
|
38 | - array( |
|
39 | - 'billing' => array( |
|
40 | - 'title' => __( 'Billing Details (GetPaid)', 'invoicing' ), |
|
41 | - 'fields' => array( |
|
42 | - '_wpinv_first_name' => array( |
|
43 | - 'label' => __( 'First name', 'invoicing' ), |
|
44 | - 'description' => '', |
|
45 | - ), |
|
46 | - '_wpinv_last_name' => array( |
|
47 | - 'label' => __( 'Last name', 'invoicing' ), |
|
48 | - 'description' => '', |
|
49 | - ), |
|
50 | - '_wpinv_company' => array( |
|
51 | - 'label' => __( 'Company', 'invoicing' ), |
|
52 | - 'description' => '', |
|
53 | - ), |
|
54 | - '_wpinv_address' => array( |
|
55 | - 'label' => __( 'Address', 'invoicing' ), |
|
56 | - 'description' => '', |
|
57 | - ), |
|
58 | - '_wpinv_city' => array( |
|
59 | - 'label' => __( 'City', 'invoicing' ), |
|
60 | - 'description' => '', |
|
61 | - ), |
|
62 | - '_wpinv_zip' => array( |
|
63 | - 'label' => __( 'Postcode / ZIP', 'invoicing' ), |
|
64 | - 'description' => '', |
|
65 | - ), |
|
66 | - '_wpinv_country' => array( |
|
67 | - 'label' => __( 'Country / Region', 'invoicing' ), |
|
68 | - 'description' => '', |
|
69 | - 'class' => 'getpaid_js_field-country', |
|
70 | - 'type' => 'select', |
|
71 | - 'options' => array( '' => __( 'Select a country / region…', 'invoicing' ) ) + wpinv_get_country_list(), |
|
72 | - ), |
|
73 | - '_wpinv_state' => array( |
|
74 | - 'label' => __( 'State / County', 'invoicing' ), |
|
75 | - 'description' => __( 'State / County or state code', 'invoicing' ), |
|
76 | - 'class' => 'getpaid_js_field-state regular-text', |
|
77 | - ), |
|
78 | - '_wpinv_phone' => array( |
|
79 | - 'label' => __( 'Phone', 'invoicing' ), |
|
80 | - 'description' => '', |
|
81 | - ), |
|
82 | - '_wpinv_vat_number' => array( |
|
83 | - 'label' => __( 'VAT Number', 'invoicing' ), |
|
84 | - 'description' => '', |
|
85 | - ), |
|
86 | - ), |
|
87 | - ), |
|
88 | - ) |
|
89 | - ); |
|
90 | - return $show_fields; |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * Show Address Fields on edit user pages. |
|
95 | - * |
|
96 | - * @param WP_User $user |
|
97 | - */ |
|
98 | - public function add_customer_meta_fields( $user ) { |
|
99 | - |
|
100 | - if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) { |
|
101 | - return; |
|
102 | - } |
|
103 | - |
|
104 | - $show_fields = $this->get_customer_meta_fields(); |
|
105 | - |
|
106 | - foreach ( $show_fields as $fieldset_key => $fieldset ) : |
|
107 | - ?> |
|
13 | + /** |
|
14 | + * GetPaid_Admin_Profile Class. |
|
15 | + */ |
|
16 | + class GetPaid_Admin_Profile { |
|
17 | + |
|
18 | + /** |
|
19 | + * Hook in tabs. |
|
20 | + */ |
|
21 | + public function __construct() { |
|
22 | + add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
23 | + add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
24 | + |
|
25 | + add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) ); |
|
26 | + add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) ); |
|
27 | + } |
|
28 | + |
|
29 | + /** |
|
30 | + * Get Address Fields for the edit user pages. |
|
31 | + * |
|
32 | + * @return array Fields to display which are filtered through invoicing_customer_meta_fields before being returned |
|
33 | + */ |
|
34 | + public function get_customer_meta_fields() { |
|
35 | + |
|
36 | + $show_fields = apply_filters( |
|
37 | + 'getpaid_customer_meta_fields', |
|
38 | + array( |
|
39 | + 'billing' => array( |
|
40 | + 'title' => __( 'Billing Details (GetPaid)', 'invoicing' ), |
|
41 | + 'fields' => array( |
|
42 | + '_wpinv_first_name' => array( |
|
43 | + 'label' => __( 'First name', 'invoicing' ), |
|
44 | + 'description' => '', |
|
45 | + ), |
|
46 | + '_wpinv_last_name' => array( |
|
47 | + 'label' => __( 'Last name', 'invoicing' ), |
|
48 | + 'description' => '', |
|
49 | + ), |
|
50 | + '_wpinv_company' => array( |
|
51 | + 'label' => __( 'Company', 'invoicing' ), |
|
52 | + 'description' => '', |
|
53 | + ), |
|
54 | + '_wpinv_address' => array( |
|
55 | + 'label' => __( 'Address', 'invoicing' ), |
|
56 | + 'description' => '', |
|
57 | + ), |
|
58 | + '_wpinv_city' => array( |
|
59 | + 'label' => __( 'City', 'invoicing' ), |
|
60 | + 'description' => '', |
|
61 | + ), |
|
62 | + '_wpinv_zip' => array( |
|
63 | + 'label' => __( 'Postcode / ZIP', 'invoicing' ), |
|
64 | + 'description' => '', |
|
65 | + ), |
|
66 | + '_wpinv_country' => array( |
|
67 | + 'label' => __( 'Country / Region', 'invoicing' ), |
|
68 | + 'description' => '', |
|
69 | + 'class' => 'getpaid_js_field-country', |
|
70 | + 'type' => 'select', |
|
71 | + 'options' => array( '' => __( 'Select a country / region…', 'invoicing' ) ) + wpinv_get_country_list(), |
|
72 | + ), |
|
73 | + '_wpinv_state' => array( |
|
74 | + 'label' => __( 'State / County', 'invoicing' ), |
|
75 | + 'description' => __( 'State / County or state code', 'invoicing' ), |
|
76 | + 'class' => 'getpaid_js_field-state regular-text', |
|
77 | + ), |
|
78 | + '_wpinv_phone' => array( |
|
79 | + 'label' => __( 'Phone', 'invoicing' ), |
|
80 | + 'description' => '', |
|
81 | + ), |
|
82 | + '_wpinv_vat_number' => array( |
|
83 | + 'label' => __( 'VAT Number', 'invoicing' ), |
|
84 | + 'description' => '', |
|
85 | + ), |
|
86 | + ), |
|
87 | + ), |
|
88 | + ) |
|
89 | + ); |
|
90 | + return $show_fields; |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * Show Address Fields on edit user pages. |
|
95 | + * |
|
96 | + * @param WP_User $user |
|
97 | + */ |
|
98 | + public function add_customer_meta_fields( $user ) { |
|
99 | + |
|
100 | + if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) { |
|
101 | + return; |
|
102 | + } |
|
103 | + |
|
104 | + $show_fields = $this->get_customer_meta_fields(); |
|
105 | + |
|
106 | + foreach ( $show_fields as $fieldset_key => $fieldset ) : |
|
107 | + ?> |
|
108 | 108 | <h2><?php echo $fieldset['title']; ?></h2> |
109 | 109 | <table class="form-table" id="<?php echo esc_attr( 'getpaid-fieldset-' . $fieldset_key ); ?>"> |
110 | 110 | <?php foreach ( $fieldset['fields'] as $key => $field ) : ?> |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | <?php if ( ! empty( $field['type'] ) && 'select' === $field['type'] ) : ?> |
117 | 117 | <select name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" class="<?php echo esc_attr( $field['class'] ); ?> wpi_select2" style="width: 25em;"> |
118 | 118 | <?php |
119 | - $selected = esc_attr( get_user_meta( $user->ID, $key, true ) ); |
|
120 | - foreach ( $field['options'] as $option_key => $option_value ) : |
|
121 | - ?> |
|
119 | + $selected = esc_attr( get_user_meta( $user->ID, $key, true ) ); |
|
120 | + foreach ( $field['options'] as $option_key => $option_value ) : |
|
121 | + ?> |
|
122 | 122 | <option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $selected, $option_key, true ); ?>><?php echo esc_html( $option_value ); ?></option> |
123 | 123 | <?php endforeach; ?> |
124 | 124 | </select> |
@@ -133,52 +133,52 @@ discard block |
||
133 | 133 | <?php endforeach; ?> |
134 | 134 | </table> |
135 | 135 | <?php |
136 | - endforeach; |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * Save Address Fields on edit user pages. |
|
141 | - * |
|
142 | - * @param int $user_id User ID of the user being saved |
|
143 | - */ |
|
144 | - public function save_customer_meta_fields( $user_id ) { |
|
145 | - if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) { |
|
146 | - return; |
|
147 | - } |
|
148 | - |
|
149 | - $save_fields = $this->get_customer_meta_fields(); |
|
150 | - |
|
151 | - foreach ( $save_fields as $fieldset ) { |
|
152 | - |
|
153 | - foreach ( $fieldset['fields'] as $key => $field ) { |
|
154 | - |
|
155 | - if ( isset( $field['type'] ) && 'checkbox' === $field['type'] ) { |
|
156 | - update_user_meta( $user_id, $key, isset( $_POST[ $key ] ) ); |
|
157 | - } elseif ( isset( $_POST[ $key ] ) ) { |
|
158 | - update_user_meta( $user_id, $key, wpinv_clean( $_POST[ $key ] ) ); |
|
159 | - } |
|
160 | - } |
|
161 | - } |
|
162 | - } |
|
163 | - |
|
164 | - /** |
|
165 | - * Get user meta for a given key, with fallbacks to core user info for pre-existing fields. |
|
166 | - * |
|
167 | - * @since 3.1.0 |
|
168 | - * @param int $user_id User ID of the user being edited |
|
169 | - * @param string $key Key for user meta field |
|
170 | - * @return string |
|
171 | - */ |
|
172 | - protected function get_user_meta( $user_id, $key ) { |
|
173 | - $value = get_user_meta( $user_id, $key, true ); |
|
174 | - $existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' ); |
|
175 | - if ( ! $value && in_array( $key, $existing_fields ) ) { |
|
176 | - $value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true ); |
|
177 | - } |
|
178 | - |
|
179 | - return $value; |
|
180 | - } |
|
181 | - } |
|
136 | + endforeach; |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * Save Address Fields on edit user pages. |
|
141 | + * |
|
142 | + * @param int $user_id User ID of the user being saved |
|
143 | + */ |
|
144 | + public function save_customer_meta_fields( $user_id ) { |
|
145 | + if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) { |
|
146 | + return; |
|
147 | + } |
|
148 | + |
|
149 | + $save_fields = $this->get_customer_meta_fields(); |
|
150 | + |
|
151 | + foreach ( $save_fields as $fieldset ) { |
|
152 | + |
|
153 | + foreach ( $fieldset['fields'] as $key => $field ) { |
|
154 | + |
|
155 | + if ( isset( $field['type'] ) && 'checkbox' === $field['type'] ) { |
|
156 | + update_user_meta( $user_id, $key, isset( $_POST[ $key ] ) ); |
|
157 | + } elseif ( isset( $_POST[ $key ] ) ) { |
|
158 | + update_user_meta( $user_id, $key, wpinv_clean( $_POST[ $key ] ) ); |
|
159 | + } |
|
160 | + } |
|
161 | + } |
|
162 | + } |
|
163 | + |
|
164 | + /** |
|
165 | + * Get user meta for a given key, with fallbacks to core user info for pre-existing fields. |
|
166 | + * |
|
167 | + * @since 3.1.0 |
|
168 | + * @param int $user_id User ID of the user being edited |
|
169 | + * @param string $key Key for user meta field |
|
170 | + * @return string |
|
171 | + */ |
|
172 | + protected function get_user_meta( $user_id, $key ) { |
|
173 | + $value = get_user_meta( $user_id, $key, true ); |
|
174 | + $existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' ); |
|
175 | + if ( ! $value && in_array( $key, $existing_fields ) ) { |
|
176 | + $value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true ); |
|
177 | + } |
|
178 | + |
|
179 | + return $value; |
|
180 | + } |
|
181 | + } |
|
182 | 182 | |
183 | 183 | endif; |
184 | 184 |