WP-UserOnline - Version 2.86

Version Description

  • FIXED: Notices in Widget Constructor for WordPress 4.3
Download this release

Release Info

Developer GamerZ
Plugin Icon WP-UserOnline
Version 2.86
Comparing to
See all releases

Code changes from version 2.85 to 2.86

lang/wp-useronline-de_DE.mo CHANGED
Binary file
lang/wp-useronline-de_DE.po CHANGED
@@ -1,447 +1,359 @@
1
  msgid ""
2
  msgstr ""
3
- "Project-Id-Version: WP-UserOnline 2.40\n"
4
  "Report-Msgid-Bugs-To: \n"
5
  "POT-Creation-Date: 2008-12-12 01:08+0800\n"
6
- "PO-Revision-Date: 2008-12-12 01:08+0800\n"
7
  "Last-Translator: Lester Chan <lesterchan@gmail.com>\n"
8
  "Language-Team: Martin Sebald <martin@sebald.com>\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
 
 
 
12
  "X-Poedit-Country: GERMANY\n"
13
- "X-Poedit-KeywordsList: __;_e\n"
 
14
  "X-Poedit-Basepath: .\n"
15
- "X-Poedit-Language: German\n"
16
  "X-Poedit-SearchPath-0: .\n"
 
17
 
18
- #: useronline-options.php:63
19
- msgid "Useronline Timeout"
20
- msgstr "UserOnline Timeout"
21
-
22
- #: useronline-options.php:64
23
- msgid "Useronline Bots"
24
- msgstr "UserOnline Bots"
25
-
26
- #: useronline-options.php:65
27
- msgid "Useronline URL"
28
- msgstr "UserOnline URL"
29
-
30
- #: useronline-options.php:66
31
- msgid "Useronline Naming Conventions"
32
- msgstr "UserOnline Namenskonventionen"
33
-
34
- #: useronline-options.php:67
35
- msgid "User(s) Online Template"
36
- msgstr "Besucher online Template"
37
-
38
- #: useronline-options.php:68
39
- msgid "User(s) Browsing Site Template"
40
- msgstr "Surfende Besucher auf Webauftritt Template"
41
-
42
- #: useronline-options.php:69
43
- msgid "User(s) Browsing Page Template"
44
- msgstr "Surfende Besucher auf Seite Template"
45
-
46
- #: useronline-options.php:74
47
- msgid "Updated"
48
- msgstr "aktualisiert"
49
-
50
- #: useronline-options.php:79
51
- msgid "No Useronline Option Updated"
52
- msgstr "Keine UserOnline Option aktualisiert"
53
-
54
- #: useronline-options.php:85
55
- #: useronline-options.php:380
56
- msgid "UNINSTALL WP-UserOnline"
57
- msgstr "WP-UserOnline DEINSTALLIEREN"
58
-
59
- #: useronline-options.php:92
60
- #, php-format
61
- msgid "Table '%s' has been deleted."
62
- msgstr "Tabelle '%s' wurde gel&ouml;scht."
63
-
64
- #: useronline-options.php:101
65
- #, php-format
66
- msgid "Setting Key '%s' has been deleted."
67
- msgstr "Setting Key '%s' wurde gel&ouml;scht."
68
-
69
- #: useronline-options.php:105
70
- #, php-format
71
- msgid "Error deleting Setting Key '%s'."
72
- msgstr "Fehler beim L&ouml;schen von Setting Key '%s'."
73
-
74
- #: useronline-options.php:127
75
- #: useronline-options.php:338
76
- msgid "Uninstall WP-UserOnline"
77
- msgstr "WP-UserOnline deinstallieren"
78
-
79
- #: useronline-options.php:128
80
- #, php-format
81
- msgid "<a href=\"%s\">Click Here</a> To Finish The Uninstallation And WP-UserOnline Will Be Deactivated Automatically."
82
- msgstr "<a href=\"%s\">Hier klicken</a> um die Deinstallation abzuschlie&szlig;en und WP-UserOnline automatisch zu deaktivieren."
83
-
84
- #: useronline-options.php:153
85
- #: wp-useronline.php:914
86
  msgid "Online"
87
  msgstr "online"
88
 
89
- #: useronline-options.php:160
90
- #: wp-useronline.php:913
91
  msgid "1 User"
92
  msgstr "1 Besucher"
93
 
94
- #: useronline-options.php:161
95
- #: wp-useronline.php:913
96
- msgid "%USERONLINE_COUNT% Users"
97
- msgstr "%USERONLINE_COUNT% Besucher"
98
-
99
- #: useronline-options.php:162
100
- #: wp-useronline.php:913
101
  msgid "1 Member"
102
  msgstr "1 Mitglied"
103
 
104
- #: useronline-options.php:163
105
- #: wp-useronline.php:913
106
- msgid "%USERONLINE_COUNT% Members"
107
- msgstr "%USERONLINE_COUNT% Mitglieder"
108
-
109
- #: useronline-options.php:164
110
- #: wp-useronline.php:913
111
  msgid "1 Guest"
112
  msgstr "1 Gast"
113
 
114
- #: useronline-options.php:165
115
- #: wp-useronline.php:913
116
- msgid "%USERONLINE_COUNT% Guests"
117
- msgstr "%USERONLINE_COUNT% G&auml;ste"
118
-
119
- #: useronline-options.php:166
120
- #: wp-useronline.php:913
121
  msgid "1 Bot"
122
  msgstr "1 Bot"
123
 
124
- #: useronline-options.php:167
125
- #: wp-useronline.php:913
126
- msgid "%USERONLINE_COUNT% Bots"
127
- msgstr "%USERONLINE_COUNT% Bots"
128
-
129
- #: useronline-options.php:170
130
- #: useronline-options.php:171
131
- #: useronline-options.php:172
132
- #: useronline-options.php:176
133
- #: useronline-options.php:177
134
- #: useronline-options.php:178
135
- #: wp-useronline.php:915
136
- #: wp-useronline.php:916
137
  msgid ","
138
- msgstr ""
139
 
140
- #: useronline-options.php:179
141
- #: wp-useronline.php:916
142
  msgid "Browsing This Page."
143
  msgstr "surfen auf dieser Seite."
144
 
145
- #: useronline-options.php:186
146
- #: useronline-options.php:187
147
- msgid "Useronline Options"
148
- msgstr "UserOnline Optionen"
149
-
150
- #: useronline-options.php:190
151
  msgid "Time Out"
152
  msgstr "Timeout"
153
 
154
- #: useronline-options.php:192
155
- msgid "How long till it will remove the user from the database (In seconds)."
156
- msgstr "Zeit nach der Besucher aus der Datenbank entfernt werden sollen (in Sekunden)."
157
-
158
- #: useronline-options.php:196
159
  msgid "UserOnline URL"
160
  msgstr "UserOnline URL"
161
 
162
- #: useronline-options.php:198
163
- msgid "URL To UserOnline Page (leave blank if you do not want to link it to the UserOnline Page)<br />Example: http://www.yoursite.com/blogs/useronline/<br />Example: http://www.yoursite.com/blogs/?page_id=2"
164
- msgstr "URL zur UserOnline Seite (leer lassen wenn nicht zur UserOnline Seite verlinkt werden soll)<br />Beispiel: http://www.deineseite.de/blog/useronline/<br />Beispiel: http://www.deineseite.de/blog/?page_id=2"
165
-
166
- #: useronline-options.php:202
167
- msgid "Bots Name/User Agent"
168
- msgstr "Bot Name / User Agent"
169
-
170
- #: useronline-options.php:204
171
- msgid "Here are a list of bots and their partial browser agents.<br />On the left column will be the <strong>Bot's Name</strong> and on the right column will be their <strong>Partial Browser Agent</strong>.<br />Start each entry on a new line."
172
- msgstr "Hier die Liste der Bots mit ihren partiellen User Agents.<br />In der linken Spalte den <strong>Bot Namen</strong> eintragen, in der rechten Spalte ihren <strong>partiellen User Agent</strong> eintragen.<br />F&uuml;r jeden Eintrag eine neue Zeile beginnen."
173
-
174
- #: useronline-options.php:212
175
  msgid "Naming Conventions:"
176
  msgstr "Namenskonventionen:"
177
 
178
- #: useronline-options.php:213
179
- #: useronline-options.php:254
180
- #: useronline-options.php:266
181
- #: useronline-options.php:298
182
  msgid "Allowed Variables:"
183
  msgstr "Erlaubte Variablen:"
184
 
185
- #: useronline-options.php:215
186
- #: useronline-options.php:259
187
- #: useronline-options.php:274
188
- #: useronline-options.php:306
189
  msgid "Restore Default Template"
190
  msgstr "Zur&uuml;cksetzen auf Grundeinstellungen"
191
 
192
- #: useronline-options.php:221
 
193
  msgid "Singular Form"
194
  msgstr "Singular"
195
 
196
- #: useronline-options.php:222
 
197
  msgid "Plural Form"
198
  msgstr "Plural"
199
 
200
- #: useronline-options.php:249
 
201
  msgid "Useronline Templates"
202
  msgstr "UserOnline Templates"
203
 
204
- #: useronline-options.php:253
 
205
  msgid "User(s) Online:"
206
  msgstr "Besucher online:"
207
 
208
- #: useronline-options.php:265
 
209
  msgid "User(s) Browsing Site:"
210
  msgstr "Surfende Besucher auf Webauftritt:"
211
 
212
- #: useronline-options.php:280
213
- #: useronline-options.php:312
214
  msgid "Member Names Separator"
215
  msgstr "Mitglieder Trennzeichen"
216
 
217
- #: useronline-options.php:281
218
- #: useronline-options.php:313
219
  msgid "Guests Separator"
220
  msgstr "G&auml;ste Trennzeichen"
221
 
222
- #: useronline-options.php:282
223
- #: useronline-options.php:314
224
  msgid "Bots Separator"
225
  msgstr "Bots Trennzeichen"
226
 
227
- #: useronline-options.php:297
 
228
  msgid "User(s) Browsing Page:"
229
  msgstr "Surfende Besucher auf Seite:"
230
 
231
- #: useronline-options.php:329
 
232
  msgid "Save Changes"
233
- msgstr ""
234
-
235
- #: useronline-options.php:340
236
- msgid "Deactivating WP-UserOnline plugin does not remove any data that may have been created, such as the useronline options. To completely remove this plugin, you can uninstall it here."
237
- msgstr "Durch die Deaktivierung des WP-UserOnline Plugins werden keinerlei Daten, die eventuell erzeugt wurden, entfernt, wie beispielsweise die UserOnline Optionen. Um das Plugin vollst&auml;ig zu entfernen kann es hier deinstalliert werden."
238
-
239
- #: useronline-options.php:343
240
- msgid "WARNING:"
241
- msgstr "WARNUNG:"
242
-
243
- #: useronline-options.php:344
244
- msgid "Once uninstalled, this cannot be undone. You should use a Database Backup plugin of WordPress to back up all the data first."
245
- msgstr "Einmal deinstalliert kann dies nicht mehr r&uuml;ckg&auml;ngig gemacht werden. Vor der Deinstallation wird eine Datensicherung empfohlen!"
246
-
247
- #: useronline-options.php:347
248
- msgid "The following WordPress Options/Tables will be DELETED:"
249
- msgstr "Die folgenden WordPress Optionen/Tabellen werden GEL&Ouml;SCHT:"
250
-
251
- #: useronline-options.php:352
252
- msgid "WordPress Options"
253
- msgstr "WordPress Optionen"
254
 
255
- #: useronline-options.php:353
256
- msgid "WordPress Tables"
257
- msgstr "WordPress Tabellen"
258
-
259
- #: useronline-options.php:379
260
- #: wp-useronline-widget.php:73
261
  msgid "Yes"
262
  msgstr "Ja"
263
 
264
- #: useronline-options.php:380
265
- msgid ""
266
- "You Are About To Uninstall WP-UserOnline From WordPress.\\n"
267
- "This Action Is Not Reversible.\\n"
268
- "\\n"
269
- " Choose [Cancel] To Stop, [OK] To Uninstall."
270
- msgstr ""
271
- "Sie sind dabei, WP-UserOnline aus WordPress zu deinstallieren.\\n"
272
- "Diese Aktion ist nicht r&uuml;ckg&auml;ngig zu machen.\\n"
273
- "\\n"
274
- " [Abbrechen] ausw&uuml;hlen um zu stoppen, [OK] um zu deinstallieren."
275
-
276
- #: wp-useronline-widget.php:62
277
  msgid "UserOnline"
278
  msgstr "UserOnline"
279
 
280
- #: wp-useronline-widget.php:69
281
- msgid "Widget Title"
282
- msgstr "Widget Titel"
283
-
284
- #: wp-useronline-widget.php:70
285
- msgid "Display Users Browsing Site Under Users Online Count?"
286
- msgstr "Besucher, die auf dem Webauftritt surfen, unter dem Onlinez&auml;hler anzeigen?"
287
-
288
- #: wp-useronline-widget.php:75
289
  msgid "No"
290
  msgstr "Nein"
291
 
292
- #: wp-useronline.php:58
293
- #: wp-useronline.php:844
294
- #: wp-useronline.php:846
295
- #: wp-useronline.php:856
296
  msgid "WP-UserOnline"
297
  msgstr "WP-UserOnline"
298
 
299
- #: wp-useronline.php:61
300
- msgid "Useronline"
301
- msgstr "UserOnline"
302
-
303
- #: wp-useronline.php:126
304
- msgid "guest"
305
- msgstr "Gast"
306
-
307
- #: wp-useronline.php:132
308
- #: wp-useronline.php:707
309
  msgid "Guest"
310
  msgstr "Gast"
311
 
312
- #: wp-useronline.php:147
313
- msgid "Blog Archive"
314
- msgstr "Blogarchiv"
315
-
316
- #: wp-useronline.php:228
317
- #: wp-useronline.php:259
318
- #: wp-useronline.php:742
319
- #: wp-useronline.php:744
320
- #: wp-useronline.php:762
321
- #: wp-useronline.php:764
322
- #: wp-useronline.php:777
323
  #, php-format
 
324
  msgid "%s @ %s"
325
  msgstr "%s, %s"
326
 
327
- #: wp-useronline.php:396
328
- msgid "No User Is Browsing This Site"
329
- msgstr "Kein Besucher surft auf diesem Webauftritt"
330
-
331
- #: wp-useronline.php:538
332
- msgid "No User Is Browsing This Page"
333
- msgstr "Kein Besucher surft auf dieser Seite"
334
-
335
- #: wp-useronline.php:609
336
  #, fuzzy
 
337
  msgid "Users Online Now"
338
  msgstr "Besucher online:"
339
 
340
- #: wp-useronline.php:621
341
- #, php-format
342
- msgid "There is <strong><a href=\"%s\">%s user</a></strong> online now."
343
- msgstr ""
344
-
345
- #: wp-useronline.php:623
346
- #, php-format
347
- msgid "There are a total of <strong><a href=\"%s\">%s users</a></strong> online now."
348
- msgstr ""
349
-
350
- #: wp-useronline.php:628
351
- #: wp-useronline.php:729
352
  #, php-format
 
353
  msgid "Most users ever online were <strong>%s</strong>, on <strong>%s</strong>"
354
- msgstr ""
355
-
356
- #: wp-useronline.php:692
357
- msgid "User"
358
- msgstr "Besucher"
359
-
360
- #: wp-useronline.php:694
361
- msgid "Users"
362
- msgstr "Besucher"
363
-
364
- #: wp-useronline.php:699
365
- msgid "Member"
366
- msgstr "Mitglied"
367
-
368
- #: wp-useronline.php:701
369
- msgid "Members"
370
- msgstr "Mitglieder"
371
-
372
- #: wp-useronline.php:709
373
- msgid "Guests"
374
- msgstr "G&auml;ste"
375
-
376
- #: wp-useronline.php:714
377
- msgid "Bot"
378
- msgstr "Bot"
379
 
380
- #: wp-useronline.php:716
381
- msgid "Bots"
382
- msgstr "Bots"
383
-
384
- #: wp-useronline.php:725
385
- #, php-format
386
- msgid "There is <strong>%s</strong> online now: <strong>%s</strong>, <strong>%s</strong> and <strong>%s</strong>."
387
- msgstr ""
388
-
389
- #: wp-useronline.php:727
390
- #, php-format
391
- msgid "There are a total of <strong>%s</strong> online now: <strong>%s</strong>, <strong>%s</strong> and <strong>%s</strong>."
392
- msgstr ""
393
-
394
- #: wp-useronline.php:732
395
- #: wp-useronline.php:752
396
- #: wp-useronline.php:772
397
  msgid "Online Now"
398
  msgstr "jetzt online"
399
 
400
- #: wp-useronline.php:739
401
- #: wp-useronline.php:759
402
  msgid "referral"
403
  msgstr "Referrer"
404
 
405
- #: wp-useronline.php:742
406
- #: wp-useronline.php:744
407
- #: wp-useronline.php:762
408
- #: wp-useronline.php:764
409
- #: wp-useronline.php:777
410
  msgid "on"
411
  msgstr "am"
412
 
413
- #: wp-useronline.php:742
414
- #: wp-useronline.php:744
415
- #: wp-useronline.php:762
416
- #: wp-useronline.php:764
417
- #: wp-useronline.php:777
418
  msgid "url"
419
  msgstr "URL"
420
 
421
- #: wp-useronline.php:784
422
- msgid "No One Is Online Now"
423
- msgstr "Momentan ist niemand online"
 
 
 
 
 
 
 
 
 
424
 
425
- #: wp-useronline.php:860
426
- msgid "On"
427
- msgstr "am"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
428
 
429
- #~ msgid "user(s) online now."
430
- #~ msgstr "Benutzer momentan online."
431
- #~ msgid "Most users ever online was"
432
- #~ msgstr "Der Rekord von gleichzeitigen Besuchern liegt bei"
433
- #~ msgid "Update Options"
434
- #~ msgstr "Optionen speichern"
435
- #~ msgid "Cancel"
436
- #~ msgstr "Abbrechen"
437
- #~ msgid "There is"
438
- #~ msgstr "Es gibt"
439
- #~ msgid "There are a total of"
440
- #~ msgstr "Insgesamt sind momentan"
441
- #~ msgid "online now"
442
- #~ msgstr "online"
443
- #~ msgid "and"
444
- #~ msgstr "und"
445
- #~ msgid "Most users ever online were"
446
- #~ msgstr "Der Rekord von gleichzeitigen Besuchern liegt bei"
 
 
 
 
 
 
 
 
 
 
 
 
447
 
1
  msgid ""
2
  msgstr ""
3
+ "Project-Id-Version: WP-UserOnline v2.85\n"
4
  "Report-Msgid-Bugs-To: \n"
5
  "POT-Creation-Date: 2008-12-12 01:08+0800\n"
6
+ "PO-Revision-Date: 2015-05-05 12:53:55+0000\n"
7
  "Last-Translator: Lester Chan <lesterchan@gmail.com>\n"
8
  "Language-Team: Martin Sebald <martin@sebald.com>\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
13
+ "X-Generator: CSL v1.x\n"
14
+ "X-Poedit-Language: German\n"
15
  "X-Poedit-Country: GERMANY\n"
16
+ "X-Poedit-SourceCharset: utf-8\n"
17
+ "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n"
18
  "X-Poedit-Basepath: .\n"
19
+ "X-Poedit-Bookmarks: \n"
20
  "X-Poedit-SearchPath-0: .\n"
21
+ "X-Textdomain-Support: yes"
22
 
23
+ #: wp-useronline.php:57
24
+ #@ wp-useronline
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  msgid "Online"
26
  msgstr "online"
27
 
28
+ #: wp-useronline.php:46
29
+ #@ wp-useronline
30
  msgid "1 User"
31
  msgstr "1 Besucher"
32
 
33
+ #: wp-useronline.php:48
34
+ #@ wp-useronline
 
 
 
 
 
35
  msgid "1 Member"
36
  msgstr "1 Mitglied"
37
 
38
+ #: wp-useronline.php:50
39
+ #@ wp-useronline
 
 
 
 
 
40
  msgid "1 Guest"
41
  msgstr "1 Gast"
42
 
43
+ #: wp-useronline.php:52
44
+ #@ wp-useronline
 
 
 
 
 
45
  msgid "1 Bot"
46
  msgstr "1 Bot"
47
 
48
+ #: wp-useronline.php:61
49
+ #: wp-useronline.php:62
50
+ #: wp-useronline.php:63
51
+ #: wp-useronline.php:70
52
+ #: wp-useronline.php:71
53
+ #: wp-useronline.php:72
54
+ #@ wp-useronline
 
 
 
 
 
 
55
  msgid ","
56
+ msgstr ","
57
 
58
+ #: wp-useronline.php:74
59
+ #@ wp-useronline
60
  msgid "Browsing This Page."
61
  msgstr "surfen auf dieser Seite."
62
 
63
+ #: admin.php:113
64
+ #@ wp-useronline
 
 
 
 
65
  msgid "Time Out"
66
  msgstr "Timeout"
67
 
68
+ #: admin.php:121
69
+ #@ wp-useronline
 
 
 
70
  msgid "UserOnline URL"
71
  msgstr "UserOnline URL"
72
 
73
+ #: admin.php:187
74
+ #@ wp-useronline
 
 
 
 
 
 
 
 
 
 
 
75
  msgid "Naming Conventions:"
76
  msgstr "Namenskonventionen:"
77
 
78
+ #: admin.php:188
79
+ #: admin.php:228
80
+ #: admin.php:250
81
+ #@ wp-useronline
82
  msgid "Allowed Variables:"
83
  msgstr "Erlaubte Variablen:"
84
 
85
+ #: admin.php:233
86
+ #: admin.php:258
87
+ #@ wp-useronline
 
88
  msgid "Restore Default Template"
89
  msgstr "Zur&uuml;cksetzen auf Grundeinstellungen"
90
 
91
+ #: admin.php:196
92
+ #@ wp-useronline
93
  msgid "Singular Form"
94
  msgstr "Singular"
95
 
96
+ #: admin.php:197
97
+ #@ wp-useronline
98
  msgid "Plural Form"
99
  msgstr "Plural"
100
 
101
+ #: admin.php:151
102
+ #@ wp-useronline
103
  msgid "Useronline Templates"
104
  msgstr "UserOnline Templates"
105
 
106
+ #: admin.php:227
107
+ #@ wp-useronline
108
  msgid "User(s) Online:"
109
  msgstr "Besucher online:"
110
 
111
+ #: admin.php:163
112
+ #@ wp-useronline
113
  msgid "User(s) Browsing Site:"
114
  msgstr "Surfende Besucher auf Webauftritt:"
115
 
116
+ #: admin.php:264
117
+ #@ wp-useronline
118
  msgid "Member Names Separator"
119
  msgstr "Mitglieder Trennzeichen"
120
 
121
+ #: admin.php:265
122
+ #@ wp-useronline
123
  msgid "Guests Separator"
124
  msgstr "G&auml;ste Trennzeichen"
125
 
126
+ #: admin.php:266
127
+ #@ wp-useronline
128
  msgid "Bots Separator"
129
  msgstr "Bots Trennzeichen"
130
 
131
+ #: admin.php:164
132
+ #@ wp-useronline
133
  msgid "User(s) Browsing Page:"
134
  msgstr "Surfende Besucher auf Seite:"
135
 
136
+ #: admin.php:177
137
+ #@ wp-useronline
138
  msgid "Save Changes"
139
+ msgstr "Änderungen übernehmen"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
 
141
+ #: admin.php:131
142
+ #@ wp-useronline
 
 
 
 
143
  msgid "Yes"
144
  msgstr "Ja"
145
 
146
+ #: admin.php:56
147
+ #: widget.php:6
148
+ #: widget.php:49
149
+ #@ wp-useronline
 
 
 
 
 
 
 
 
 
150
  msgid "UserOnline"
151
  msgstr "UserOnline"
152
 
153
+ #: admin.php:131
154
+ #@ wp-useronline
 
 
 
 
 
 
 
155
  msgid "No"
156
  msgstr "Nein"
157
 
158
+ #: admin.php:10
159
+ #: wp-stats.php:14
160
+ #: wp-stats.php:31
161
+ #@ wp-useronline
162
  msgid "WP-UserOnline"
163
  msgstr "WP-UserOnline"
164
 
165
+ #: core.php:120
166
+ #@ wp-useronline
 
 
 
 
 
 
 
 
167
  msgid "Guest"
168
  msgstr "Gast"
169
 
170
+ #: template-tags.php:250
171
+ #: template-tags.php:252
 
 
 
 
 
 
 
 
 
172
  #, php-format
173
+ #@ wp-useronline
174
  msgid "%s @ %s"
175
  msgstr "%s, %s"
176
 
177
+ #: admin.php:9
 
 
 
 
 
 
 
 
178
  #, fuzzy
179
+ #@ wp-useronline
180
  msgid "Users Online Now"
181
  msgstr "Besucher online:"
182
 
183
+ #: template-tags.php:272
 
 
 
 
 
 
 
 
 
 
 
184
  #, php-format
185
+ #@ wp-useronline
186
  msgid "Most users ever online were <strong>%s</strong>, on <strong>%s</strong>"
187
+ msgstr "Es waren mit <strong>%s</strong> Benutzer am <strong>%s</strong> die meisten online."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
 
189
+ #: template-tags.php:205
190
+ #@ wp-useronline
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
  msgid "Online Now"
192
  msgstr "jetzt online"
193
 
194
+ #: template-tags.php:194
195
+ #@ wp-useronline
196
  msgid "referral"
197
  msgstr "Referrer"
198
 
199
+ #: template-tags.php:192
200
+ #@ wp-useronline
 
 
 
201
  msgid "on"
202
  msgstr "am"
203
 
204
+ #: template-tags.php:193
205
+ #@ wp-useronline
 
 
 
206
  msgid "url"
207
  msgstr "URL"
208
 
209
+ #: admin.php:27
210
+ #, php-format
211
+ #@ wp-useronline
212
+ msgid "There is <strong><a href='%s'>%s user</a></strong> online now."
213
+ msgid_plural "There are a total of <strong><a href='%s'>%s users</a></strong> online now."
214
+ msgstr[0] "Es ist jetzt <strong><a href='%s'>%s Benutzer</a></strong> online"
215
+ msgstr[1] "Es sind jetzt insgesamt <strong><a href='%s'>%s Benutzer</a></strong> online."
216
+
217
+ #: admin.php:55
218
+ #@ wp-useronline
219
+ msgid "UserOnline Options"
220
+ msgstr "UserOnline Optionen"
221
 
222
+ #: admin.php:116
223
+ #@ wp-useronline
224
+ msgid "How long until it will remove the user from the database (in seconds)."
225
+ msgstr "Wie lange, bis der Benutzer von der Datenbank entfernt wird (in Sekunden)."
226
+
227
+ #: admin.php:124
228
+ #@ wp-useronline
229
+ msgid "URL To UserOnline Page<br />Example: http://www.yoursite.com/useronline/<br />Example: http://www.yoursite.com/?page_id=2"
230
+ msgstr "URL zu UserOnline Seite<br />Beispiel: http://www.yoursite.com/useronline/<br />Beispiel: http://www.yoursite.com/?page_id=2"
231
+
232
+ #: admin.php:128
233
+ #@ wp-useronline
234
+ msgid "Link user names?"
235
+ msgstr "Benutzernamen verlinken?"
236
+
237
+ #: admin.php:132
238
+ #@ wp-useronline
239
+ msgid "Link user names to their author page"
240
+ msgstr "Benutzernamen zu ihren Autorenseiten verlinken?"
241
+
242
+ #: admin.php:190
243
+ #@ wp-useronline
244
+ msgid "Restore Defaults"
245
+ msgstr "Standard einstellen"
246
+
247
+ #: core.php:189
248
+ #@ wp-useronline
249
+ msgid "Admin"
250
+ msgstr "Admin"
251
+
252
+ #: core.php:195
253
+ #@ wp-useronline
254
+ msgid "Archive"
255
+ msgstr "Archiv"
256
+
257
+ #: scb/AdminPage.php:228
258
+ #@ wp-useronline
259
+ msgid "Settings <strong>saved</strong>."
260
+ msgstr "Einstellungen <strong>speichern</strong>."
261
+
262
+ #: scb/AdminPage.php:467
263
+ #@ wp-useronline
264
+ msgid "Settings"
265
+ msgstr "Einstellungen"
266
+
267
+ #. gettext fix: identical singular and plural forms found, that may be ambiguous! Please check the code!
268
+ #: template-tags.php:81
269
+ #, php-format
270
+ #@ wp-useronline
271
+ msgid "There is <strong>%s</strong> online now: <strong>%s</strong>, <strong>%s</strong> and <strong>%s</strong>."
272
+ msgid_plural "There are a total of <strong>%s</strong> online now: <strong>%s</strong>, <strong>%s</strong> and <strong>%s</strong>."
273
+ msgstr[0] "Es sind <strong>%s</strong> jetzt online: <strong>%s</strong>, <strong>%s</strong> und <strong>%s</strong>."
274
+ msgstr[1] "Es sind jetzt insgesamt <strong>%s</strong> online: <strong>%s</strong>, <strong>%s</strong> und <strong>%s</strong>."
275
+
276
+ #: template-tags.php:190
277
+ #@ wp-useronline
278
+ msgid "No one is online now."
279
+ msgstr "Es ist gerade niemand online"
280
+
281
+ #: widget.php:5
282
+ #@ wp-useronline
283
+ msgid "WP-UserOnline users online statistics"
284
+ msgstr "WP-UserOnline Online Benutzer Statistik"
285
+
286
+ #: widget.php:56
287
+ #@ wp-useronline
288
+ msgid "Title:"
289
+ msgstr "Titel:"
290
+
291
+ #: widget.php:59
292
+ #@ wp-useronline
293
+ msgid "Statistics Type:"
294
+ msgstr "Statistik Typ:"
295
+
296
+ #: widget.php:61
297
+ #@ wp-useronline
298
+ msgid "Users Online Count"
299
+ msgstr "Zahl der Online-User"
300
+
301
+ #: widget.php:62
302
+ #@ wp-useronline
303
+ msgid "Users Browsing Current Page"
304
+ msgstr "Benutzer, die auf der aktuellen Seite sind"
305
+
306
+ #: widget.php:63
307
+ #@ wp-useronline
308
+ msgid "Users Browsing Site"
309
+ msgstr "Benutzer Besuchen Seite"
310
+
311
+ #: widget.php:65
312
+ #@ wp-useronline
313
+ msgid "Users Online Count & Users Browsing Current Page"
314
+ msgstr "Benutzer online Zähler & Benutzer besuchen aktuelle Seite"
315
+
316
+ #: widget.php:66
317
+ #@ wp-useronline
318
+ msgid "Users Online Count & Users Browsing Site"
319
+ msgstr "Benutzer online Zähler & Benutzer besuchen Seite"
320
+
321
+ #: wp-stats.php:24
322
+ #, php-format
323
+ #@ wp-useronline
324
+ msgid "<strong>%s</strong> user online now."
325
+ msgid_plural "<strong>%s</strong> users online now."
326
+ msgstr[0] "<strong>%s</strong> Benutzer gerade online."
327
+ msgstr[1] "<strong>%s</strong> Benutzer gerade online."
328
 
329
+ #: wp-useronline.php:47
330
+ #, php-format
331
+ #@ wp-useronline
332
+ msgid "%COUNT% Users"
333
+ msgstr "%COUNT% Benutzer"
334
+
335
+ #: wp-useronline.php:49
336
+ #, php-format
337
+ #@ wp-useronline
338
+ msgid "%COUNT% Members"
339
+ msgstr "%COUNT% Mitglieder"
340
+
341
+ #: wp-useronline.php:51
342
+ #, php-format
343
+ #@ wp-useronline
344
+ msgid "%COUNT% Guests"
345
+ msgstr "%COUNT% Gäste"
346
+
347
+ #: wp-useronline.php:53
348
+ #, php-format
349
+ #@ wp-useronline
350
+ msgid "%COUNT% Bots"
351
+ msgstr "%COUNT% Bots"
352
+
353
+ #: wp-useronline.php:65
354
+ #: wp-useronline.php:74
355
+ #@ wp-useronline
356
+ msgctxt "Template Element"
357
+ msgid "Users"
358
+ msgstr "Benutzer"
359
 
lang/wp-useronline-he_IL.mo CHANGED
Binary file
lang/wp-useronline-he_IL.po CHANGED
@@ -1,349 +1,339 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-UserOnline 2.31\n"
4
- "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2008-07-16 03:37+0800\n"
6
- "PO-Revision-Date: 2010-02-14 02:06+0200\n"
7
- "Last-Translator: GadgetGuru.co.il <info@gadgetguru.co.il>\n"
8
  "Language-Team: GadgetGuru DevTeam <devteam@gadgetguru.co.il>\n"
 
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
13
- "X-Poedit-Language: English\n"
14
- "X-Poedit-Country: SINGAPORE\n"
15
  "X-Poedit-SourceCharset: utf-8\n"
16
- "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n"
 
17
  "X-Poedit-Basepath: .\n"
18
- "X-Poedit-Bookmarks: \n"
 
19
  "X-Poedit-SearchPath-0: .\n"
20
- "X-Textdomain-Support: yes"
21
 
22
- #: wp-useronline.php:72
23
- #@ wp-useronline
24
- msgid "Online"
25
- msgstr "מקוון"
26
 
27
- #: wp-useronline.php:61
28
- #@ wp-useronline
29
- msgid "1 User"
30
- msgstr "גולש אחד"
31
 
32
- #: wp-useronline.php:63
33
- #@ wp-useronline
34
- msgid "1 Member"
35
- msgstr "חבר אחד"
36
 
37
- #: wp-useronline.php:65
38
- #@ wp-useronline
39
- msgid "1 Guest"
40
- msgstr "אורח אחד"
41
 
42
- #: wp-useronline.php:67
43
- #@ wp-useronline
44
- msgid "1 Bot"
45
- msgstr "בוט אחד"
46
 
47
- #: wp-useronline.php:89
48
- #@ wp-useronline
49
- msgid "Browsing This Page."
50
- msgstr "צופים בדף זה."
 
 
 
 
 
51
 
52
- #: admin.php:113
53
- #@ wp-useronline
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  msgid "Time Out"
55
  msgstr "פסק זמן"
56
 
57
- #: admin.php:121
58
- #@ wp-useronline
 
 
 
 
 
59
  msgid "UserOnline URL"
60
  msgstr "כתובת URL לגולשים מקוונים"
61
 
62
- #: admin.php:186
63
- #@ wp-useronline
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  msgid "Naming Conventions:"
65
  msgstr "מוסכמות שמות:"
66
 
67
- #: admin.php:187
68
- #: admin.php:227
69
- #: admin.php:249
70
- #@ wp-useronline
71
  msgid "Allowed Variables:"
72
  msgstr "משתנים מותרים:"
73
 
74
- #: admin.php:232
75
- #: admin.php:257
76
- #@ wp-useronline
77
- msgid "Restore Default Template"
78
- msgstr "שחזר את תבנית ברירת המחדל"
79
 
80
- #: admin.php:195
81
- #@ wp-useronline
82
  msgid "Singular Form"
83
  msgstr "טופס יחיד"
84
 
85
- #: admin.php:196
86
- #@ wp-useronline
87
  msgid "Plural Form"
88
  msgstr "טופס רבים"
89
 
90
- #: admin.php:150
91
- #@ wp-useronline
92
- msgid "Useronline Templates"
93
- msgstr "תבניות גולשים מקוונים"
94
-
95
- #: admin.php:226
96
- #@ wp-useronline
97
  msgid "User(s) Online:"
98
- msgstr "גולשים מקוונים:"
99
 
100
- #: admin.php:162
101
- #@ wp-useronline
102
- msgid "User(s) Browsing Site:"
103
- msgstr "גולשים צופים באתר:"
104
 
105
- #: admin.php:263
106
- #@ wp-useronline
107
  msgid "Member Names Separator"
108
  msgstr "מפריד שמות חברים"
109
 
110
- #: admin.php:264
111
- #@ wp-useronline
112
  msgid "Guests Separator"
113
- msgstr "מפריד אורחים"
114
 
115
- #: admin.php:265
116
- #@ wp-useronline
117
  msgid "Bots Separator"
118
- msgstr "מפריד בוטים"
119
-
120
- #: admin.php:163
121
- #@ wp-useronline
122
- msgid "User(s) Browsing Page:"
123
- msgstr "גולשים צופים בעמוד זה:"
124
-
125
- #: admin.php:176
126
- #: scb/AdminPage.php:178
127
- #: scb/AdminPage.php:189
128
- #@ wp-useronline
129
- msgid "Save Changes"
130
- msgstr "שמור שינויים"
131
-
132
- #: admin.php:56
133
- #: widget.php:6
134
- #: widget.php:49
135
- #@ wp-useronline
136
- msgid "UserOnline"
137
- msgstr "משתמש מקוון"
138
-
139
- #: admin.php:10
140
- #: wp-stats.php:14
141
- #: wp-stats.php:31
142
- #@ wp-useronline
143
- msgid "WP-UserOnline"
144
- msgstr "תוסף WP-UserOnline"
145
-
146
- #: core.php:140
147
- #@ wp-useronline
148
- msgid "Guest"
149
- msgstr "אורח"
150
-
151
- #: template-tags.php:247
152
- #: template-tags.php:249
153
- #, php-format
154
- #@ wp-useronline
155
- msgid "%s @ %s"
156
- msgstr "%s @ %s"
157
-
158
- #: admin.php:9
159
- #@ wp-useronline
160
- msgid "Users Online Now"
161
- msgstr "גולשים מקוונים כעת"
162
-
163
- #: template-tags.php:269
164
- #, php-format
165
- #@ wp-useronline
166
- msgid "Most users ever online were <strong>%s</strong>, on <strong>%s</strong>"
167
- msgstr "הכי הרבה גולשים מקוונים היו <strong>%s</strong>, ב <strong>%s</strong>"
168
 
169
- #: template-tags.php:205
170
- #@ wp-useronline
171
- msgid "Online Now"
172
- msgstr "מקוונים כעת"
 
 
173
 
174
- #: template-tags.php:194
175
- #@ wp-useronline
176
- msgid "referral"
177
- msgstr "הפניה"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
 
 
179
  #: template-tags.php:192
180
- #@ wp-useronline
181
  msgid "on"
182
  msgstr "ב"
183
 
 
184
  #: template-tags.php:193
185
- #@ wp-useronline
186
  msgid "url"
187
  msgstr "כתובת URL"
188
 
189
- #: admin.php:27
190
- #, php-format
191
- #@ wp-useronline
192
- msgid "There is <strong><a href='%s'>%s user</a></strong> online now."
193
- msgid_plural "There are a total of <strong><a href='%s'>%s users</a></strong> online now."
194
- msgstr[0] "יש <strong><a href='%s'>%s user</a></strong> מקוונים כעת."
195
- msgstr[1] "יש בסך הכל <strong><a href='%s'>%s users</a></strong> מקוונים כעת."
196
-
197
- #: admin.php:55
198
- #@ wp-useronline
199
- msgid "UserOnline Options"
200
- msgstr "אפשרויות גולשש מקוון"
201
-
202
- #: admin.php:116
203
- #@ wp-useronline
204
- msgid "How long until it will remove the user from the database (in seconds)."
205
- msgstr "כמה זמן עד שהגולש יוסר ממסד הנתונים (בשניות)."
206
 
207
- #: admin.php:124
208
- #@ wp-useronline
209
- msgid "URL To UserOnline Page<br />Example: http://www.yoursite.com/useronline/<br />Example: http://www.yoursite.com/?page_id=2"
210
- msgstr "כתובת URL לדף UserOnline <br />דוגמה: http://www.yoursite.com/useronline/<br />דוגמה: http://www.yoursite.com/?page_id=2"
211
 
212
- #: admin.php:128
213
- #@ wp-useronline
214
- msgid "User Names"
215
- msgstr "שמות משתמש"
216
 
217
- #: admin.php:131
218
- #@ wp-useronline
219
- msgid "Link user names to their author page"
220
- msgstr "קשר שמות משתמשים לדף שמות המחבר שלהם"
 
 
221
 
222
- #: admin.php:189
223
- #@ wp-useronline
224
- msgid "Restore Defaults"
225
- msgstr "שחזר לברירות המחדל"
226
 
227
- #: core.php:211
228
- #@ wp-useronline
229
  msgid "Admin"
230
- msgstr "ניהול"
231
 
232
- #: core.php:217
233
- #@ wp-useronline
234
  msgid "Archive"
235
  msgstr "ארכיון"
236
 
237
- #: scb/AdminPage.php:165
238
- #@ wp-useronline
239
- msgid "Settings <strong>saved</strong>."
240
- msgstr "ההגדרות <strong>נשמרו</strong>."
241
-
242
- #: scb/AdminPage.php:350
243
- #@ wp-useronline
244
- msgid "Settings"
245
- msgstr "הגדרות"
246
-
247
- #. gettext fix: identical singular and plural forms found, that may be ambiguous! Please check the code!
248
- #: template-tags.php:81
249
- #, php-format
250
- #@ wp-useronline
251
- msgid "There is <strong>%s</strong> online now: <strong>%s</strong>, <strong>%s</strong> and <strong>%s</strong>."
252
- msgid_plural "There are a total of <strong>%s</strong> online now: <strong>%s</strong>, <strong>%s</strong> and <strong>%s</strong>."
253
- msgstr[0] "יש <strong>%s</strong> מקוונים כעת: <strong>%s</strong>, <strong>%s</strong> ו <strong>%s</strong>."
254
- msgstr[1] "יש בסך הכל <strong>%s</strong> מקוונים כעת: <strong>%s</strong>, <strong>%s</strong> ו <strong>%s</strong>."
255
-
256
- #: template-tags.php:190
257
- #@ wp-useronline
258
- msgid "No one is online now."
259
- msgstr "אין אף אחד מקוון כעת."
260
-
261
- #: widget.php:5
262
- #@ wp-useronline
263
- msgid "WP-UserOnline users online statistics"
264
- msgstr "סטטיסטיקת גולשים מקוונים של תוסף WP-UserOnline"
265
-
266
- #: widget.php:56
267
- #@ wp-useronline
268
- msgid "Title:"
269
- msgstr "כותרת:"
270
-
271
- #: widget.php:59
272
- #@ wp-useronline
273
- msgid "Statistics Type:"
274
- msgstr "סוג סטטיסטיקה:"
275
-
276
- #: widget.php:61
277
- #@ wp-useronline
278
- msgid "Users Online Count"
279
- msgstr "מונה גולשים מקוונים"
280
-
281
- #: widget.php:62
282
- #@ wp-useronline
283
- msgid "Users Browsing Current Page"
284
- msgstr "גולשים הנמצאים בדף זה"
285
-
286
- #: widget.php:63
287
- #@ wp-useronline
288
- msgid "Users Browsing Site"
289
- msgstr "גולשים הנמצאים באתר"
290
-
291
- #: widget.php:65
292
- #@ wp-useronline
293
- msgid "Users Online Count & Users Browsing Current Page"
294
- msgstr "מונה גולשים מקוונים וגם גולשים הנמצאים בדף זה"
295
-
296
- #: widget.php:66
297
- #@ wp-useronline
298
- msgid "Users Online Count & Users Browsing Site"
299
- msgstr "מונה גולשים מקוונים וגם גולשים באתר"
300
-
301
- #: wp-stats.php:24
302
- #, php-format
303
- #@ wp-useronline
304
- msgid "<strong>%s</strong> user online now."
305
- msgid_plural "<strong>%s</strong> users online now."
306
- msgstr[0] "<strong>%s</strong> גולש מקוון כעת."
307
- msgstr[1] "<strong>%s</strong> גולשים מקוונים כעת."
308
 
 
309
  #: wp-useronline.php:62
310
- #, php-format
311
- #@ wp-useronline
312
  msgid "%COUNT% Users"
313
  msgstr "%COUNT% משתמשים"
314
 
 
 
 
 
 
 
315
  #: wp-useronline.php:64
316
- #, php-format
317
- #@ wp-useronline
318
  msgid "%COUNT% Members"
319
  msgstr "%COUNT% חברים"
320
 
 
 
 
 
 
 
321
  #: wp-useronline.php:66
322
- #, php-format
323
- #@ wp-useronline
324
  msgid "%COUNT% Guests"
325
  msgstr "%COUNT% אורחים"
326
 
 
 
 
 
 
 
327
  #: wp-useronline.php:68
328
- #, php-format
329
- #@ wp-useronline
330
  msgid "%COUNT% Bots"
331
- msgstr "%COUNT% בוטים"
332
-
333
- #: wp-useronline.php:76
334
- #: wp-useronline.php:77
335
- #: wp-useronline.php:78
336
- #: wp-useronline.php:85
337
- #: wp-useronline.php:86
338
- #: wp-useronline.php:87
339
- #@ wp-useronline
 
340
  msgid ","
341
  msgstr ","
342
 
343
- #: wp-useronline.php:80
344
- #: wp-useronline.php:89
345
- #@ wp-useronline
346
  msgctxt "Template Element"
347
  msgid "Users"
348
- msgstr "גולשים"
 
 
 
 
 
349
 
 
 
 
 
 
 
 
 
 
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-UserOnline 2.31\n"
4
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/wpu\n"
5
+ "POT-Creation-Date: 2015-08-16 21:44+0300\n"
6
+ "PO-Revision-Date: 2015-08-16 21:54+0300\n"
7
+ "Last-Translator: Udi's Blog <blog@udiburg.com>\n"
8
  "Language-Team: GadgetGuru DevTeam <devteam@gadgetguru.co.il>\n"
9
+ "Language: en_SG\n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
 
 
14
  "X-Poedit-SourceCharset: utf-8\n"
15
+ "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
16
+ "_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
17
  "X-Poedit-Basepath: .\n"
18
+ "X-Textdomain-Support: yes\n"
19
+ "X-Generator: Poedit 1.8.3\n"
20
  "X-Poedit-SearchPath-0: .\n"
 
21
 
22
+ # @ wp-useronline
23
+ #: widget.php:5
24
+ msgid "WP-UserOnline users online statistics"
25
+ msgstr "סטטיסטיקת גולשים מקוונים של תוסף WP-UserOnline"
26
 
27
+ # @ wp-useronline
28
+ #: widget.php:6 widget.php:49 admin.php:56
29
+ msgid "UserOnline"
30
+ msgstr "משתמש מקוון"
31
 
32
+ # @ wp-useronline
33
+ #: widget.php:56
34
+ msgid "Title:"
35
+ msgstr "כותרת:"
36
 
37
+ # @ wp-useronline
38
+ #: widget.php:59
39
+ msgid "Statistics Type:"
40
+ msgstr "סוג סטטיסטיקה:"
41
 
42
+ # @ wp-useronline
43
+ #: widget.php:61
44
+ msgid "Users Online Count"
45
+ msgstr "מונה גולשים מקוונים"
46
 
47
+ # @ wp-useronline
48
+ #: widget.php:62
49
+ msgid "Users Browsing Current Page"
50
+ msgstr "גולשים הנמצאים בדף זה"
51
+
52
+ # @ wp-useronline
53
+ #: widget.php:63
54
+ msgid "Users Browsing Site"
55
+ msgstr "גולשים הנמצאים באתר"
56
 
57
+ # @ wp-useronline
58
+ #: widget.php:65
59
+ msgid "Users Online Count & Users Browsing Current Page"
60
+ msgstr "מונה גולשים מקוונים וגם גולשים הנמצאים בדף זה"
61
+
62
+ # @ wp-useronline
63
+ #: widget.php:66
64
+ msgid "Users Online Count & Users Browsing Site"
65
+ msgstr "מונה גולשים מקוונים וגם גולשים באתר"
66
+
67
+ # @ wp-useronline
68
+ #: admin.php:9
69
+ msgid "Users Online Now"
70
+ msgstr "גולשים מקוונים כעת"
71
+
72
+ # @ wp-useronline
73
+ #: admin.php:10 wp-stats.php:14 wp-stats.php:31
74
+ msgid "WP-UserOnline"
75
+ msgstr "תוסף WP-UserOnline"
76
+
77
+ # @ wp-useronline
78
+ #: admin.php:26
79
+ msgid "There is <strong><a href='%s'>%s user</a></strong> online now."
80
+ msgid_plural ""
81
+ "There are a total of <strong><a href='%s'>%s users</a></strong> online now."
82
+ msgstr[0] "ישנו <strong><a href='%s'>%s משתמש</a></strong> מקוון כעת."
83
+ msgstr[1] ""
84
+ "ישנם בסך הכל <strong><a href='%s'>%s משתמשים</a></strong> מקוונים כעת."
85
+
86
+ # @ wp-useronline
87
+ #: admin.php:55
88
+ msgid "UserOnline Options"
89
+ msgstr "אפשרויות התוסף"
90
+
91
+ # @ wp-useronline
92
+ #: admin.php:114
93
  msgid "Time Out"
94
  msgstr "פסק זמן"
95
 
96
+ # @ wp-useronline
97
+ #: admin.php:117
98
+ msgid "How long until it will remove the user from the database (in seconds)."
99
+ msgstr "כמה זמן עד שהגולש יוסר ממסד הנתונים (בשניות)."
100
+
101
+ # @ wp-useronline
102
+ #: admin.php:122
103
  msgid "UserOnline URL"
104
  msgstr "כתובת URL לגולשים מקוונים"
105
 
106
+ # @ wp-useronline
107
+ #: admin.php:125
108
+ msgid ""
109
+ "URL To UserOnline Page<br />Example: http://www.yoursite.com/useronline/<br /"
110
+ ">Example: http://www.yoursite.com/?page_id=2"
111
+ msgstr ""
112
+ "כתובת URL לדף UserOnline <br />דוגמה: http://www.yoursite.com/useronline/"
113
+ "<br />דוגמה: http://www.yoursite.com/?page_id=2"
114
+
115
+ # @ wp-useronline
116
+ #: admin.php:129
117
+ msgid "User Names"
118
+ msgstr "שמות משתמשים"
119
+
120
+ # @ wp-useronline
121
+ #: admin.php:132
122
+ msgid "Link user names to their author page"
123
+ msgstr "קשר שמות משתמשים לדף המחבר שלהם"
124
+
125
+ # @ wp-useronline
126
+ #: admin.php:151
127
+ msgid "Useronline Templates"
128
+ msgstr "תבניות גולשים מקוונים"
129
+
130
+ # @ wp-useronline
131
+ #: admin.php:163
132
+ msgid "User(s) Browsing Site:"
133
+ msgstr "גולש/ים הצופה/ים באתר:"
134
+
135
+ # @ wp-useronline
136
+ #: admin.php:164
137
+ msgid "User(s) Browsing Page:"
138
+ msgstr "גולש/ים הצופה/ים בעמוד זה:"
139
+
140
+ # @ wp-useronline
141
+ #: admin.php:177 scb/AdminPage.php:177 scb/AdminPage.php:187
142
+ msgid "Save Changes"
143
+ msgstr "שמור שינויים"
144
+
145
+ # @ wp-useronline
146
+ #: admin.php:187
147
  msgid "Naming Conventions:"
148
  msgstr "מוסכמות שמות:"
149
 
150
+ # @ wp-useronline
151
+ #: admin.php:188 admin.php:228 admin.php:250
 
 
152
  msgid "Allowed Variables:"
153
  msgstr "משתנים מותרים:"
154
 
155
+ # @ wp-useronline
156
+ #: admin.php:190
157
+ msgid "Restore Defaults"
158
+ msgstr "שחזר לברירות המחדל"
 
159
 
160
+ # @ wp-useronline
161
+ #: admin.php:196
162
  msgid "Singular Form"
163
  msgstr "טופס יחיד"
164
 
165
+ # @ wp-useronline
166
+ #: admin.php:197
167
  msgid "Plural Form"
168
  msgstr "טופס רבים"
169
 
170
+ # @ wp-useronline
171
+ #: admin.php:227
 
 
 
 
 
172
  msgid "User(s) Online:"
173
+ msgstr "גולש/ים מקוונ/ים:"
174
 
175
+ # @ wp-useronline
176
+ #: admin.php:233 admin.php:258
177
+ msgid "Restore Default Template"
178
+ msgstr "שחזר את תבנית ברירת המחדל"
179
 
180
+ # @ wp-useronline
181
+ #: admin.php:264
182
  msgid "Member Names Separator"
183
  msgstr "מפריד שמות חברים"
184
 
185
+ # @ wp-useronline
186
+ #: admin.php:265
187
  msgid "Guests Separator"
188
+ msgstr "מפריד שמות אורחים"
189
 
190
+ # @ wp-useronline
191
+ #: admin.php:266
192
  msgid "Bots Separator"
193
+ msgstr "מפריד סורקי אינטרנט"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
 
195
+ # @ wp-useronline
196
+ #: wp-stats.php:23
197
+ msgid "<strong>%s</strong> user online now."
198
+ msgid_plural "<strong>%s</strong> users online now."
199
+ msgstr[0] "<strong>%s</strong> גולש מקוון כעת."
200
+ msgstr[1] "<strong>%s</strong> גולשים מקוונים כעת."
201
 
202
+ # @ wp-useronline
203
+ #: template-tags.php:80
204
+ msgid ""
205
+ "There is <strong>%s</strong> online now: <strong>%s</strong>, <strong>%s</"
206
+ "strong> and <strong>%s</strong>."
207
+ msgid_plural ""
208
+ "There are a total of <strong>%s</strong> online now: <strong>%s</strong>, "
209
+ "<strong>%s</strong> and <strong>%s</strong>."
210
+ msgstr[0] ""
211
+ "יש <strong>%s</strong> מקוון כעת: <strong>%s</strong>, <strong>%s</strong> ו "
212
+ "<strong>%s</strong>."
213
+ msgstr[1] ""
214
+ "יש בסך הכל <strong>%s</strong> מקוונים כעת: <strong>%s</strong>, <strong>%s</"
215
+ "strong> ו <strong>%s</strong>."
216
+
217
+ # @ wp-useronline
218
+ #: template-tags.php:190
219
+ msgid "No one is online now."
220
+ msgstr "אין אף אחד מקוון כעת."
221
 
222
+ # @ wp-useronline
223
  #: template-tags.php:192
 
224
  msgid "on"
225
  msgstr "ב"
226
 
227
+ # @ wp-useronline
228
  #: template-tags.php:193
 
229
  msgid "url"
230
  msgstr "כתובת URL"
231
 
232
+ # @ wp-useronline
233
+ #: template-tags.php:194
234
+ msgid "referral"
235
+ msgstr "הפניה"
 
 
 
 
 
 
 
 
 
 
 
 
 
236
 
237
+ # @ wp-useronline
238
+ #: template-tags.php:205
239
+ msgid "Online Now"
240
+ msgstr "מקוונים כעת"
241
 
242
+ # @ wp-useronline
243
+ #: template-tags.php:247 template-tags.php:249
244
+ msgid "%s @ %s"
245
+ msgstr "%s @ %s"
246
 
247
+ # @ wp-useronline
248
+ #: template-tags.php:269
249
+ msgid "Most users ever online were <strong>%s</strong>, on <strong>%s</strong>"
250
+ msgstr ""
251
+ "מספר הגולשים המקוונים הגדול ביותר שהיו אי פעם היה <strong>%s</strong>, ב "
252
+ "<strong>%s</strong>"
253
 
254
+ # @ wp-useronline
255
+ #: core.php:137
256
+ msgid "Guest"
257
+ msgstr "אורח"
258
 
259
+ # @ wp-useronline
260
+ #: core.php:208
261
  msgid "Admin"
262
+ msgstr "מנהל"
263
 
264
+ # @ wp-useronline
265
+ #: core.php:214
266
  msgid "Archive"
267
  msgstr "ארכיון"
268
 
269
+ # @ wp-useronline
270
+ #: wp-useronline.php:61
271
+ msgid "1 User"
272
+ msgstr "משתמש אחד"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
273
 
274
+ # @ wp-useronline
275
  #: wp-useronline.php:62
 
 
276
  msgid "%COUNT% Users"
277
  msgstr "%COUNT% משתמשים"
278
 
279
+ # @ wp-useronline
280
+ #: wp-useronline.php:63
281
+ msgid "1 Member"
282
+ msgstr "חבר אחד"
283
+
284
+ # @ wp-useronline
285
  #: wp-useronline.php:64
 
 
286
  msgid "%COUNT% Members"
287
  msgstr "%COUNT% חברים"
288
 
289
+ # @ wp-useronline
290
+ #: wp-useronline.php:65
291
+ msgid "1 Guest"
292
+ msgstr "אורח אחד"
293
+
294
+ # @ wp-useronline
295
  #: wp-useronline.php:66
 
 
296
  msgid "%COUNT% Guests"
297
  msgstr "%COUNT% אורחים"
298
 
299
+ # @ wp-useronline
300
+ #: wp-useronline.php:67
301
+ msgid "1 Bot"
302
+ msgstr "סורק אינטרנט אחד"
303
+
304
+ # @ wp-useronline
305
  #: wp-useronline.php:68
 
 
306
  msgid "%COUNT% Bots"
307
+ msgstr "%COUNT% סורקי אינטרנט"
308
+
309
+ # @ wp-useronline
310
+ #: wp-useronline.php:72
311
+ msgid "Online"
312
+ msgstr "מקוון"
313
+
314
+ # @ wp-useronline
315
+ #: wp-useronline.php:76 wp-useronline.php:77 wp-useronline.php:78
316
+ #: wp-useronline.php:85 wp-useronline.php:86 wp-useronline.php:87
317
  msgid ","
318
  msgstr ","
319
 
320
+ # @ wp-useronline
321
+ #: wp-useronline.php:80 wp-useronline.php:89
 
322
  msgctxt "Template Element"
323
  msgid "Users"
324
+ msgstr "משתמשים "
325
+
326
+ # @ wp-useronline
327
+ #: wp-useronline.php:89
328
+ msgid "Browsing This Page."
329
+ msgstr "מבקרים בדף זה."
330
 
331
+ # @ wp-useronline
332
+ #: scb/AdminPage.php:165
333
+ msgid "Settings <strong>saved</strong>."
334
+ msgstr "ההגדרות <strong>נשמרו</strong>."
335
+
336
+ # @ wp-useronline
337
+ #: scb/AdminPage.php:369
338
+ msgid "Settings"
339
+ msgstr "הגדרות"
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: GamerZ, scribu
3
  Donate link: http://lesterchan.net/site/donation/
4
  Tags: useronline, usersonline, wp-useronline, online, users, user, ajax, widget
5
  Requires at least: 3.1
6
- Tested up to: 4.2
7
- Stable tag: 2.85
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -94,6 +94,9 @@ Make sure your host is running PHP 5. The only foolproof way to do this is to ad
94
  `var_dump(PHP_VERSION);`
95
 
96
  == Changelog ==
 
 
 
97
  = 2.85 =
98
  * NEW: Uses WordPress native uninstall.php
99
 
3
  Donate link: http://lesterchan.net/site/donation/
4
  Tags: useronline, usersonline, wp-useronline, online, users, user, ajax, widget
5
  Requires at least: 3.1
6
+ Tested up to: 4.4
7
+ Stable tag: 2.86
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
94
  `var_dump(PHP_VERSION);`
95
 
96
  == Changelog ==
97
+ = 2.86 =
98
+ * FIXED: Notices in Widget Constructor for WordPress 4.3
99
+
100
  = 2.85 =
101
  * NEW: Uses WordPress native uninstall.php
102
 
scb/AdminPage.php CHANGED
@@ -1,7 +1,6 @@
1
  <?php
2
-
3
  /**
4
- * Administration page base class
5
  */
6
  abstract class scbAdminPage {
7
  /** Page args
@@ -43,17 +42,20 @@ abstract class scbAdminPage {
43
  private static $registered = array();
44
 
45
  /**
46
- * @param string $class
47
- * @param string $file
48
- * @param scbOptions $options
 
 
49
  *
50
  * @return bool
51
  */
52
- static function register( $class, $file, $options = null ) {
53
- if ( isset( self::$registered[$class] ) )
54
  return false;
 
55
 
56
- self::$registered[$class] = array( $file, $options );
57
 
58
  add_action( '_admin_menu', array( __CLASS__, '_pages_init' ) );
59
 
@@ -61,38 +63,50 @@ abstract class scbAdminPage {
61
  }
62
 
63
  /**
 
 
64
  * @param string $old_class
65
  * @param string $new_class
66
  *
67
  * @return bool
68
  */
69
- static function replace( $old_class, $new_class ) {
70
- if ( ! isset( self::$registered[$old_class] ) )
71
  return false;
 
72
 
73
- self::$registered[$new_class] = self::$registered[$old_class];
74
- unset( self::$registered[$old_class] );
75
 
76
  return true;
77
  }
78
 
79
  /**
 
 
80
  * @param string $class
81
  *
82
  * @return bool
83
  */
84
- static function remove( $class ) {
85
- if ( ! isset( self::$registered[$class] ) )
86
  return false;
 
87
 
88
- unset( self::$registered[$class] );
89
 
90
  return true;
91
  }
92
 
93
- static function _pages_init() {
94
- foreach ( self::$registered as $class => $args )
 
 
 
 
 
95
  new $class( $args[0], $args[1] );
 
96
  }
97
 
98
 
@@ -100,14 +114,17 @@ abstract class scbAdminPage {
100
 
101
 
102
  /**
103
- * Constructor
104
  *
105
- * @param string|bool $file
106
- * @param scbOptions $options
 
 
107
  */
108
- function __construct( $file = false, $options = null ) {
109
- if ( is_a( $options, 'scbOptions' ) )
110
  $this->options = $options;
 
111
 
112
  $this->setup();
113
  $this->check_args();
@@ -124,82 +141,96 @@ abstract class scbAdminPage {
124
  $this->file = $file;
125
  $this->plugin_url = plugin_dir_url( $file );
126
 
127
- if ( $this->args['action_link'] )
128
  add_filter( 'plugin_action_links_' . plugin_basename( $file ), array( $this, '_action_link' ) );
 
129
  }
130
  }
131
 
132
  /**
133
- * This is where all the page args can be set
 
 
134
  */
135
- function setup(){}
136
 
137
  /**
138
  * Called when the page is loaded, but before any rendering.
139
- *
140
  * Useful for calling $screen->add_help_tab() etc.
 
 
141
  */
142
- function page_loaded() {
143
  $this->form_handler();
144
  }
145
 
146
  /**
147
- * This is where the css and js go
148
- * Both wp_enqueue_*() and inline code can be added
 
 
149
  */
150
- function page_head(){}
151
 
152
  /**
153
- * This is where the contextual help goes
 
154
  * @return string
155
  */
156
- function page_help(){}
157
 
158
  /**
159
- * A generic page header
 
 
160
  */
161
- function page_header() {
162
  echo "<div class='wrap'>\n";
163
  screen_icon( $this->args['screen_icon'] );
164
  echo html( 'h2', $this->args['page_title'] );
165
  }
166
 
167
  /**
168
- * This is where the page content goes
 
 
169
  */
170
- abstract function page_content();
171
 
172
  /**
173
- * A generic page footer
 
 
174
  */
175
- function page_footer() {
176
  echo "</div>\n";
177
  }
178
 
179
  /**
180
- * This is where the form data should be validated
181
  *
182
  * @param array $new_data
183
  * @param array $old_data
184
  *
185
  * @return array
186
  */
187
- function validate( $new_data, $old_data ) {
188
  return $new_data;
189
  }
190
 
191
  /**
192
- * Manually handle option saving ( use Settings API instead )
193
  *
194
  * @return bool
195
  */
196
- function form_handler() {
197
- if ( empty( $_POST['submit'] ) && empty( $_POST['action'] ) )
198
  return false;
 
199
 
200
  check_admin_referer( $this->nonce );
201
 
202
- if ( !isset($this->options) ) {
203
  trigger_error( 'options handler not set', E_USER_WARNING );
204
  return false;
205
  }
@@ -218,14 +249,17 @@ abstract class scbAdminPage {
218
  }
219
 
220
  /**
221
- * Manually generate a standard admin notice ( use Settings API instead )
222
  *
223
- * @param string $msg
224
- * @param string $class
 
 
225
  */
226
- function admin_msg( $msg = '', $class = 'updated' ) {
227
- if ( empty( $msg ) )
228
  $msg = __( 'Settings <strong>saved</strong>.', $this->textdomain );
 
229
 
230
  echo scb_admin_notice( $msg, $class );
231
  }
@@ -235,15 +269,15 @@ abstract class scbAdminPage {
235
 
236
 
237
  /**
238
- * Generates a form submit button
239
  *
240
- * @param string|array $value button text or array of arguments
241
- * @param string $action
242
- * @param string $class
243
  *
244
  * @return string
245
  */
246
- function submit_button( $value = '', $action = 'submit', $class = 'button' ) {
247
 
248
  $args = is_array( $value ) ? $value : compact( 'value', 'action', 'class' );
249
  $args = wp_parse_args( $args, array(
@@ -271,20 +305,20 @@ abstract class scbAdminPage {
271
  * @see scbForms::form_wrap()
272
  *
273
  * @param string $content
274
- * @param boolean|string|array $submit_button
275
  *
276
  * @return string
277
  */
278
- function form_wrap( $content, $submit_button = true ) {
279
  if ( is_array( $submit_button ) ) {
280
  $content .= $this->submit_button( $submit_button );
281
- } elseif ( true === $submit_button ) {
282
  $content .= $this->submit_button();
283
- } elseif ( false !== strpos( $submit_button, '<input' ) ) {
284
  $content .= $submit_button;
285
- } elseif ( false !== strpos( $submit_button, '<button' ) ) {
286
  $content .= $submit_button;
287
- } elseif ( false !== $submit_button ) {
288
  $button_args = array_slice( func_get_args(), 1 );
289
  $content .= call_user_func_array( array( $this, 'submit_button' ), $button_args );
290
  }
@@ -293,17 +327,18 @@ abstract class scbAdminPage {
293
  }
294
 
295
  /**
296
- * Generates a table wrapped in a form
297
  *
298
  * @param array $rows
299
- * @param array|boolean $formdata
300
  *
301
  * @return string
302
  */
303
- function form_table( $rows, $formdata = false ) {
304
  $output = '';
305
- foreach ( $rows as $row )
306
  $output .= $this->table_row( $row, $formdata );
 
307
 
308
  $output = $this->form_table_wrap( $output );
309
 
@@ -317,7 +352,7 @@ abstract class scbAdminPage {
317
  *
318
  * @return string
319
  */
320
- function form_table_wrap( $content ) {
321
  $output = $this->table_wrap( $content );
322
  $output = $this->form_wrap( $output );
323
 
@@ -325,17 +360,18 @@ abstract class scbAdminPage {
325
  }
326
 
327
  /**
328
- * Generates a form table
329
  *
330
  * @param array $rows
331
- * @param array|boolean $formdata
332
  *
333
  * @return string
334
  */
335
- function table( $rows, $formdata = false ) {
336
  $output = '';
337
- foreach ( $rows as $row )
338
  $output .= $this->table_row( $row, $formdata );
 
339
 
340
  $output = $this->table_wrap( $output );
341
 
@@ -343,19 +379,19 @@ abstract class scbAdminPage {
343
  }
344
 
345
  /**
346
- * Generates a table row
347
  *
348
  * @param array $args
349
- * @param array|boolean $formdata
350
  *
351
  * @return string
352
  */
353
- function table_row( $args, $formdata = false ) {
354
  return $this->row_wrap( $args['title'], $this->input( $args, $formdata ) );
355
  }
356
 
357
  /**
358
- * Mimic scbForms inheritance
359
  *
360
  * @see scbForms
361
  *
@@ -364,37 +400,39 @@ abstract class scbAdminPage {
364
  *
365
  * @return mixed
366
  */
367
- function __call( $method, $args ) {
368
  if ( in_array( $method, array( 'input', 'form' ) ) ) {
369
- if ( empty( $args[1] ) && isset( $this->options ) )
370
  $args[1] = $this->options->get();
 
371
 
372
- if ( 'form' == $method )
373
  $args[2] = $this->nonce;
 
374
  }
375
 
376
  return call_user_func_array( array( 'scbForms', $method ), $args );
377
  }
378
 
379
  /**
380
- * Wraps a string in a <script> tag
381
  *
382
  * @param string $string
383
  *
384
  * @return string
385
  */
386
- function js_wrap( $string ) {
387
  return html( "script type='text/javascript'", $string );
388
  }
389
 
390
  /**
391
- * Wraps a string in a <style> tag
392
  *
393
  * @param string $string
394
  *
395
  * @return string
396
  */
397
- function css_wrap( $string ) {
398
  return html( "style type='text/css'", $string );
399
  }
400
 
@@ -403,9 +441,11 @@ abstract class scbAdminPage {
403
 
404
 
405
  /**
406
- * Registers a page
 
 
407
  */
408
- function page_init() {
409
 
410
  if ( ! $this->args['toplevel'] ) {
411
  $this->pagehook = add_submenu_page(
@@ -438,21 +478,33 @@ abstract class scbAdminPage {
438
  );
439
  }
440
 
441
- if ( ! $this->pagehook )
442
  return;
 
443
 
444
  add_action( 'load-' . $this->pagehook, array( $this, 'page_loaded' ) );
445
 
446
  add_action( 'admin_print_styles-' . $this->pagehook, array( $this, 'page_head' ) );
447
  }
448
 
449
- function option_init() {
 
 
 
 
 
450
  register_setting( $this->option_name, $this->option_name, array( $this, 'validate' ) );
451
  }
452
 
 
 
 
 
 
453
  private function check_args() {
454
- if ( empty( $this->args['page_title'] ) )
455
  trigger_error( 'Page title cannot be empty', E_USER_WARNING );
 
456
 
457
  $this->args = wp_parse_args( $this->args, array(
458
  'toplevel' => '',
@@ -468,46 +520,60 @@ abstract class scbAdminPage {
468
  'admin_action_priority' => 10,
469
  ) );
470
 
471
- if ( empty( $this->args['submenu_title'] ) )
472
  $this->args['submenu_title'] = $this->args['menu_title'];
 
473
 
474
- if ( empty( $this->args['page_slug'] ) )
475
  $this->args['page_slug'] = sanitize_title_with_dashes( $this->args['menu_title'] );
 
476
 
477
- if ( empty( $this->args['nonce'] ) )
478
  $this->nonce = $this->args['page_slug'];
 
479
  }
480
 
481
  /**
 
 
482
  * @param string $help
483
  * @param string|object $screen
484
  *
485
  * @return string
486
  */
487
- function _contextual_help( $help, $screen ) {
488
- if ( is_object( $screen ) )
489
  $screen = $screen->id;
 
490
 
491
  $actual_help = $this->page_help();
492
 
493
- if ( $screen == $this->pagehook && $actual_help )
494
  return $actual_help;
 
495
 
496
  return $help;
497
  }
498
 
499
- function _page_content_hook() {
 
 
 
 
 
500
  $this->page_header();
501
  $this->page_content();
502
  $this->page_footer();
503
  }
504
 
505
  /**
 
 
506
  * @param array $links
507
  *
508
  * @return array
509
  */
510
- function _action_link( $links ) {
511
  $url = add_query_arg( 'page', $this->args['page_slug'], admin_url( $this->args['parent'] ) );
512
 
513
  $links[] = html_link( $url, $this->args['action_link'] );
1
  <?php
 
2
  /**
3
+ * Administration page base class.
4
  */
5
  abstract class scbAdminPage {
6
  /** Page args
42
  private static $registered = array();
43
 
44
  /**
45
+ * Registers class of page.
46
+ *
47
+ * @param string $class
48
+ * @param string $file
49
+ * @param object $options (optional) A scbOptions object.
50
  *
51
  * @return bool
52
  */
53
+ public static function register( $class, $file, $options = null ) {
54
+ if ( isset( self::$registered[ $class ] ) ) {
55
  return false;
56
+ }
57
 
58
+ self::$registered[ $class ] = array( $file, $options );
59
 
60
  add_action( '_admin_menu', array( __CLASS__, '_pages_init' ) );
61
 
63
  }
64
 
65
  /**
66
+ * Replaces class of page.
67
+ *
68
  * @param string $old_class
69
  * @param string $new_class
70
  *
71
  * @return bool
72
  */
73
+ public static function replace( $old_class, $new_class ) {
74
+ if ( ! isset( self::$registered[ $old_class ] ) ) {
75
  return false;
76
+ }
77
 
78
+ self::$registered[ $new_class ] = self::$registered[ $old_class ];
79
+ unset( self::$registered[ $old_class ] );
80
 
81
  return true;
82
  }
83
 
84
  /**
85
+ * Removes class of page.
86
+ *
87
  * @param string $class
88
  *
89
  * @return bool
90
  */
91
+ public static function remove( $class ) {
92
+ if ( ! isset( self::$registered[ $class ] ) ) {
93
  return false;
94
+ }
95
 
96
+ unset( self::$registered[ $class ] );
97
 
98
  return true;
99
  }
100
 
101
+ /**
102
+ * Instantiates classes of pages.
103
+ *
104
+ * @return void
105
+ */
106
+ public static function _pages_init() {
107
+ foreach ( self::$registered as $class => $args ) {
108
  new $class( $args[0], $args[1] );
109
+ }
110
  }
111
 
112
 
114
 
115
 
116
  /**
117
+ * Constructor.
118
  *
119
+ * @param string|bool $file (optional)
120
+ * @param object $options (optional) A scbOptions object.
121
+ *
122
+ * @return void
123
  */
124
+ public function __construct( $file = false, $options = null ) {
125
+ if ( is_a( $options, 'scbOptions' ) ) {
126
  $this->options = $options;
127
+ }
128
 
129
  $this->setup();
130
  $this->check_args();
141
  $this->file = $file;
142
  $this->plugin_url = plugin_dir_url( $file );
143
 
144
+ if ( $this->args['action_link'] ) {
145
  add_filter( 'plugin_action_links_' . plugin_basename( $file ), array( $this, '_action_link' ) );
146
+ }
147
  }
148
  }
149
 
150
  /**
151
+ * This is where all the page args can be set.
152
+ *
153
+ * @return void
154
  */
155
+ protected function setup() { }
156
 
157
  /**
158
  * Called when the page is loaded, but before any rendering.
 
159
  * Useful for calling $screen->add_help_tab() etc.
160
+ *
161
+ * @return void
162
  */
163
+ public function page_loaded() {
164
  $this->form_handler();
165
  }
166
 
167
  /**
168
+ * This is where the css and js go.
169
+ * Both wp_enqueue_*() and inline code can be added.
170
+ *
171
+ * @return void
172
  */
173
+ public function page_head() { }
174
 
175
  /**
176
+ * This is where the contextual help goes.
177
+ *
178
  * @return string
179
  */
180
+ protected function page_help() { }
181
 
182
  /**
183
+ * A generic page header.
184
+ *
185
+ * @return void
186
  */
187
+ protected function page_header() {
188
  echo "<div class='wrap'>\n";
189
  screen_icon( $this->args['screen_icon'] );
190
  echo html( 'h2', $this->args['page_title'] );
191
  }
192
 
193
  /**
194
+ * This is where the page content goes.
195
+ *
196
+ * @return void
197
  */
198
+ abstract protected function page_content();
199
 
200
  /**
201
+ * A generic page footer.
202
+ *
203
+ * @return void
204
  */
205
+ protected function page_footer() {
206
  echo "</div>\n";
207
  }
208
 
209
  /**
210
+ * This is where the form data should be validated.
211
  *
212
  * @param array $new_data
213
  * @param array $old_data
214
  *
215
  * @return array
216
  */
217
+ public function validate( $new_data, $old_data ) {
218
  return $new_data;
219
  }
220
 
221
  /**
222
+ * Manually handle option saving ( use Settings API instead ).
223
  *
224
  * @return bool
225
  */
226
+ protected function form_handler() {
227
+ if ( empty( $_POST['submit'] ) && empty( $_POST['action'] ) ) {
228
  return false;
229
+ }
230
 
231
  check_admin_referer( $this->nonce );
232
 
233
+ if ( ! isset( $this->options ) ) {
234
  trigger_error( 'options handler not set', E_USER_WARNING );
235
  return false;
236
  }
249
  }
250
 
251
  /**
252
+ * Manually generate a standard admin notice ( use Settings API instead ).
253
  *
254
+ * @param string $msg (optional)
255
+ * @param string $class (optional)
256
+ *
257
+ * @return void
258
  */
259
+ public function admin_msg( $msg = '', $class = 'updated' ) {
260
+ if ( empty( $msg ) ) {
261
  $msg = __( 'Settings <strong>saved</strong>.', $this->textdomain );
262
+ }
263
 
264
  echo scb_admin_notice( $msg, $class );
265
  }
269
 
270
 
271
  /**
272
+ * Generates a form submit button.
273
  *
274
+ * @param string|array $value (optional) Button text or array of arguments.
275
+ * @param string $action (optional)
276
+ * @param string $class (optional)
277
  *
278
  * @return string
279
  */
280
+ public function submit_button( $value = '', $action = 'submit', $class = 'button' ) {
281
 
282
  $args = is_array( $value ) ? $value : compact( 'value', 'action', 'class' );
283
  $args = wp_parse_args( $args, array(
305
  * @see scbForms::form_wrap()
306
  *
307
  * @param string $content
308
+ * @param boolean|string|array $submit_button (optional)
309
  *
310
  * @return string
311
  */
312
+ public function form_wrap( $content, $submit_button = true ) {
313
  if ( is_array( $submit_button ) ) {
314
  $content .= $this->submit_button( $submit_button );
315
+ } else if ( true === $submit_button ) {
316
  $content .= $this->submit_button();
317
+ } else if ( false !== strpos( $submit_button, '<input' ) ) {
318
  $content .= $submit_button;
319
+ } else if ( false !== strpos( $submit_button, '<button' ) ) {
320
  $content .= $submit_button;
321
+ } else if ( false !== $submit_button ) {
322
  $button_args = array_slice( func_get_args(), 1 );
323
  $content .= call_user_func_array( array( $this, 'submit_button' ), $button_args );
324
  }
327
  }
328
 
329
  /**
330
+ * Generates a table wrapped in a form.
331
  *
332
  * @param array $rows
333
+ * @param array|boolean $formdata (optional)
334
  *
335
  * @return string
336
  */
337
+ public function form_table( $rows, $formdata = false ) {
338
  $output = '';
339
+ foreach ( $rows as $row ) {
340
  $output .= $this->table_row( $row, $formdata );
341
+ }
342
 
343
  $output = $this->form_table_wrap( $output );
344
 
352
  *
353
  * @return string
354
  */
355
+ public function form_table_wrap( $content ) {
356
  $output = $this->table_wrap( $content );
357
  $output = $this->form_wrap( $output );
358
 
360
  }
361
 
362
  /**
363
+ * Generates a form table.
364
  *
365
  * @param array $rows
366
+ * @param array|boolean $formdata (optional)
367
  *
368
  * @return string
369
  */
370
+ public function table( $rows, $formdata = false ) {
371
  $output = '';
372
+ foreach ( $rows as $row ) {
373
  $output .= $this->table_row( $row, $formdata );
374
+ }
375
 
376
  $output = $this->table_wrap( $output );
377
 
379
  }
380
 
381
  /**
382
+ * Generates a table row.
383
  *
384
  * @param array $args
385
+ * @param array|boolean $formdata (optional)
386
  *
387
  * @return string
388
  */
389
+ public function table_row( $args, $formdata = false ) {
390
  return $this->row_wrap( $args['title'], $this->input( $args, $formdata ) );
391
  }
392
 
393
  /**
394
+ * Mimic scbForms inheritance.
395
  *
396
  * @see scbForms
397
  *
400
  *
401
  * @return mixed
402
  */
403
+ public function __call( $method, $args ) {
404
  if ( in_array( $method, array( 'input', 'form' ) ) ) {
405
+ if ( empty( $args[1] ) && isset( $this->options ) ) {
406
  $args[1] = $this->options->get();
407
+ }
408
 
409
+ if ( 'form' == $method ) {
410
  $args[2] = $this->nonce;
411
+ }
412
  }
413
 
414
  return call_user_func_array( array( 'scbForms', $method ), $args );
415
  }
416
 
417
  /**
418
+ * Wraps a string in a <script> tag.
419
  *
420
  * @param string $string
421
  *
422
  * @return string
423
  */
424
+ public function js_wrap( $string ) {
425
  return html( "script type='text/javascript'", $string );
426
  }
427
 
428
  /**
429
+ * Wraps a string in a <style> tag.
430
  *
431
  * @param string $string
432
  *
433
  * @return string
434
  */
435
+ public function css_wrap( $string ) {
436
  return html( "style type='text/css'", $string );
437
  }
438
 
441
 
442
 
443
  /**
444
+ * Registers a page.
445
+ *
446
+ * @return void
447
  */
448
+ public function page_init() {
449
 
450
  if ( ! $this->args['toplevel'] ) {
451
  $this->pagehook = add_submenu_page(
478
  );
479
  }
480
 
481
+ if ( ! $this->pagehook ) {
482
  return;
483
+ }
484
 
485
  add_action( 'load-' . $this->pagehook, array( $this, 'page_loaded' ) );
486
 
487
  add_action( 'admin_print_styles-' . $this->pagehook, array( $this, 'page_head' ) );
488
  }
489
 
490
+ /**
491
+ * Registers a option.
492
+ *
493
+ * @return void
494
+ */
495
+ public function option_init() {
496
  register_setting( $this->option_name, $this->option_name, array( $this, 'validate' ) );
497
  }
498
 
499
+ /**
500
+ * Checks page args.
501
+ *
502
+ * @return void
503
+ */
504
  private function check_args() {
505
+ if ( empty( $this->args['page_title'] ) ) {
506
  trigger_error( 'Page title cannot be empty', E_USER_WARNING );
507
+ }
508
 
509
  $this->args = wp_parse_args( $this->args, array(
510
  'toplevel' => '',
520
  'admin_action_priority' => 10,
521
  ) );
522
 
523
+ if ( empty( $this->args['submenu_title'] ) ) {
524
  $this->args['submenu_title'] = $this->args['menu_title'];
525
+ }
526
 
527
+ if ( empty( $this->args['page_slug'] ) ) {
528
  $this->args['page_slug'] = sanitize_title_with_dashes( $this->args['menu_title'] );
529
+ }
530
 
531
+ if ( empty( $this->args['nonce'] ) ) {
532
  $this->nonce = $this->args['page_slug'];
533
+ }
534
  }
535
 
536
  /**
537
+ * Adds contextual help.
538
+ *
539
  * @param string $help
540
  * @param string|object $screen
541
  *
542
  * @return string
543
  */
544
+ public function _contextual_help( $help, $screen ) {
545
+ if ( is_object( $screen ) ) {
546
  $screen = $screen->id;
547
+ }
548
 
549
  $actual_help = $this->page_help();
550
 
551
+ if ( $screen == $this->pagehook && $actual_help ) {
552
  return $actual_help;
553
+ }
554
 
555
  return $help;
556
  }
557
 
558
+ /**
559
+ * Displays page content.
560
+ *
561
+ * @return void
562
+ */
563
+ public function _page_content_hook() {
564
  $this->page_header();
565
  $this->page_content();
566
  $this->page_footer();
567
  }
568
 
569
  /**
570
+ * Adds an action link.
571
+ *
572
  * @param array $links
573
  *
574
  * @return array
575
  */
576
+ public function _action_link( $links ) {
577
  $url = add_query_arg( 'page', $this->args['page_slug'], admin_url( $this->args['parent'] ) );
578
 
579
  $links[] = html_link( $url, $this->args['action_link'] );
scb/BoxesPage.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
-
3
- // Admin screen with metaboxes base class
4
-
5
  abstract class scbBoxesPage extends scbAdminPage {
6
  /*
7
  A box definition looks like this:
@@ -11,22 +11,41 @@ abstract class scbBoxesPage extends scbAdminPage {
11
  */
12
  protected $boxes = array();
13
 
14
- function __construct( $file = false, $options = null ) {
 
 
 
 
 
 
 
 
15
  parent::__construct( $file, $options );
16
 
17
  scbUtil::add_uninstall_hook( $this->file, array( $this, 'uninstall' ) );
18
  }
19
 
20
- function page_init() {
21
- if ( !isset( $this->args['columns'] ) )
 
 
 
 
 
22
  $this->args['columns'] = 2;
 
23
 
24
  parent::page_init();
25
 
26
  add_action( 'load-' . $this->pagehook, array( $this, 'boxes_init' ) );
27
  }
28
 
29
- function default_css() {
 
 
 
 
 
30
  ?>
31
  <style type="text/css">
32
  .postbox-container + .postbox-container {
@@ -66,11 +85,20 @@ abstract class scbBoxesPage extends scbAdminPage {
66
  padding: 0 !important;
67
  margin-bottom: 0 !important;
68
  }
 
 
 
 
69
  </style>
70
  <?php
71
  }
72
 
73
- function page_content() {
 
 
 
 
 
74
  $this->default_css();
75
 
76
  global $screen_layout_columns;
@@ -79,29 +107,33 @@ abstract class scbBoxesPage extends scbAdminPage {
79
  $hide2 = $hide3 = $hide4 = '';
80
  switch ( $screen_layout_columns ) {
81
  case 4:
82
- if( !isset( $this->args['column_widths'] ) )
83
  $this->args['column_widths'] = array( 24.5, 24.5, 24.5, 24.5 );
 
84
  break;
85
  case 3:
86
- if( !isset( $this->args['column_widths'] ) )
87
  $this->args['column_widths'] = array( 32.67, 32.67, 32.67 );
 
88
  $hide4 = 'display:none;';
89
  break;
90
  case 2:
91
- if( !isset( $this->args['column_widths'] ) )
92
  $this->args['column_widths'] = array( 49, 49 );
 
93
  $hide3 = $hide4 = 'display:none;';
94
  break;
95
  default:
96
- if( !isset( $this->args['column_widths'] ) )
97
  $this->args['column_widths'] = array( 98 );
 
98
  $hide2 = $hide3 = $hide4 = 'display:none;';
99
  }
100
 
101
  $this->args['column_widths'] = array_pad( $this->args['column_widths'], 4, 0 );
102
  }
103
  ?>
104
- <div id='<?php echo $this->pagehook ?>-widgets' class='metabox-holder'>
105
  <?php
106
  echo "\t<div class='postbox-container' style='width:{$this->args['column_widths'][0]}%'>\n";
107
  do_meta_boxes( $this->pagehook, 'normal', '' );
@@ -119,14 +151,25 @@ abstract class scbBoxesPage extends scbAdminPage {
119
  <?php
120
  }
121
 
122
- function page_footer() {
 
 
 
 
 
123
  parent::page_footer();
124
  $this->_boxes_js_init();
125
  }
126
 
127
- function form_handler() {
128
- if ( empty( $_POST ) )
 
 
 
 
 
129
  return;
 
130
 
131
  check_admin_referer( $this->nonce );
132
 
@@ -136,18 +179,25 @@ abstract class scbBoxesPage extends scbAdminPage {
136
 
137
  $handler = $box[0] . '_handler';
138
 
139
- if ( method_exists( $this, $handler ) )
140
  call_user_func_array( array( $this, $handler ), $args );
 
141
  }
142
  }
143
 
144
- function uninstall() {
 
 
 
 
 
145
  global $wpdb;
146
 
147
  $hook = str_replace( '-', '', $this->pagehook );
148
 
149
- foreach ( array( 'metaboxhidden', 'closedpostboxes', 'wp_metaboxorder', 'screen_layout' ) as $option )
150
  $keys[] = "'{$option}_{$hook}'";
 
151
 
152
  $keys = '( ' . implode( ', ', $keys ) . ' )';
153
 
@@ -157,7 +207,12 @@ abstract class scbBoxesPage extends scbAdminPage {
157
  " );
158
  }
159
 
160
- function boxes_init() {
 
 
 
 
 
161
  wp_enqueue_script( 'postbox' );
162
 
163
  add_screen_option( 'layout_columns', array(
@@ -202,37 +257,65 @@ abstract class scbBoxesPage extends scbAdminPage {
202
  }
203
  }
204
 
 
 
 
 
 
 
 
 
205
  private static function numeric_to_assoc( $argv, $keys ) {
206
  $args = array();
207
 
208
  foreach ( $keys as $i => $key ) {
209
- if ( isset( $argv[ $i ] ) )
210
  $args[ $key ] = $argv[ $i ];
 
211
  }
212
 
213
  return $args;
214
  }
215
 
216
- // Since we don't pass an object to do_meta_boxes(),
217
- // pass $box['args'] directly to each method.
218
- function _intermediate_callback( $_, $box ) {
 
 
 
 
 
 
 
219
  list( $name ) = explode( '-', $box['id'] );
220
 
221
  call_user_func_array( array( $this, $name . '_box' ), $box['args'] );
222
  }
223
 
 
 
 
 
 
 
 
224
  private function _increment( $name ) {
225
  $parts = explode( '-', $name );
226
- if ( isset( $parts[1] ) )
227
  $parts[1]++;
228
- else
229
  $parts[1] = 2;
 
230
 
231
  return implode( '-', $parts );
232
  }
233
 
234
- // Adds necesary code for JS to work
235
- function _boxes_js_init() {
 
 
 
 
236
  echo $this->js_wrap( <<<EOT
237
  jQuery( document ).ready( function( $ ){
238
  // close postboxes that should be closed
@@ -256,5 +339,3 @@ EOT
256
  }
257
  }
258
 
259
-
260
-
1
  <?php
2
+ /**
3
+ * Admin screen with metaboxes base class.
4
+ */
5
  abstract class scbBoxesPage extends scbAdminPage {
6
  /*
7
  A box definition looks like this:
11
  */
12
  protected $boxes = array();
13
 
14
+ /**
15
+ * Constructor.
16
+ *
17
+ * @param string|bool $file (optional)
18
+ * @param object $options (optional) A scbOptions object.
19
+ *
20
+ * @return void
21
+ */
22
+ public function __construct( $file = false, $options = null ) {
23
  parent::__construct( $file, $options );
24
 
25
  scbUtil::add_uninstall_hook( $this->file, array( $this, 'uninstall' ) );
26
  }
27
 
28
+ /**
29
+ * Registers a page.
30
+ *
31
+ * @return void
32
+ */
33
+ public function page_init() {
34
+ if ( ! isset( $this->args['columns'] ) ) {
35
  $this->args['columns'] = 2;
36
+ }
37
 
38
  parent::page_init();
39
 
40
  add_action( 'load-' . $this->pagehook, array( $this, 'boxes_init' ) );
41
  }
42
 
43
+ /**
44
+ * Prints default CSS styles.
45
+ *
46
+ * @return void
47
+ */
48
+ protected function default_css() {
49
  ?>
50
  <style type="text/css">
51
  .postbox-container + .postbox-container {
85
  padding: 0 !important;
86
  margin-bottom: 0 !important;
87
  }
88
+ .meta-box-sortables {
89
+ min-height: 100px;
90
+ width: 100%;
91
+ }
92
  </style>
93
  <?php
94
  }
95
 
96
+ /**
97
+ * Displays page content.
98
+ *
99
+ * @return void
100
+ */
101
+ protected function page_content() {
102
  $this->default_css();
103
 
104
  global $screen_layout_columns;
107
  $hide2 = $hide3 = $hide4 = '';
108
  switch ( $screen_layout_columns ) {
109
  case 4:
110
+ if ( ! isset( $this->args['column_widths'] ) ) {
111
  $this->args['column_widths'] = array( 24.5, 24.5, 24.5, 24.5 );
112
+ }
113
  break;
114
  case 3:
115
+ if ( ! isset( $this->args['column_widths'] ) ) {
116
  $this->args['column_widths'] = array( 32.67, 32.67, 32.67 );
117
+ }
118
  $hide4 = 'display:none;';
119
  break;
120
  case 2:
121
+ if ( ! isset( $this->args['column_widths'] ) ) {
122
  $this->args['column_widths'] = array( 49, 49 );
123
+ }
124
  $hide3 = $hide4 = 'display:none;';
125
  break;
126
  default:
127
+ if ( ! isset( $this->args['column_widths'] ) ) {
128
  $this->args['column_widths'] = array( 98 );
129
+ }
130
  $hide2 = $hide3 = $hide4 = 'display:none;';
131
  }
132
 
133
  $this->args['column_widths'] = array_pad( $this->args['column_widths'], 4, 0 );
134
  }
135
  ?>
136
+ <div id='<?php echo $this->pagehook; ?>-widgets' class='metabox-holder'>
137
  <?php
138
  echo "\t<div class='postbox-container' style='width:{$this->args['column_widths'][0]}%'>\n";
139
  do_meta_boxes( $this->pagehook, 'normal', '' );
151
  <?php
152
  }
153
 
154
+ /**
155
+ * Displays page footer.
156
+ *
157
+ * @return void
158
+ */
159
+ protected function page_footer() {
160
  parent::page_footer();
161
  $this->_boxes_js_init();
162
  }
163
 
164
+ /**
165
+ * Handles option saving.
166
+ *
167
+ * @return void
168
+ */
169
+ protected function form_handler() {
170
+ if ( empty( $_POST ) ) {
171
  return;
172
+ }
173
 
174
  check_admin_referer( $this->nonce );
175
 
179
 
180
  $handler = $box[0] . '_handler';
181
 
182
+ if ( method_exists( $this, $handler ) ) {
183
  call_user_func_array( array( $this, $handler ), $args );
184
+ }
185
  }
186
  }
187
 
188
+ /**
189
+ * Uninstalls boxes.
190
+ *
191
+ * @return void
192
+ */
193
+ public function uninstall() {
194
  global $wpdb;
195
 
196
  $hook = str_replace( '-', '', $this->pagehook );
197
 
198
+ foreach ( array( 'metaboxhidden', 'closedpostboxes', 'wp_metaboxorder', 'screen_layout' ) as $option ) {
199
  $keys[] = "'{$option}_{$hook}'";
200
+ }
201
 
202
  $keys = '( ' . implode( ', ', $keys ) . ' )';
203
 
207
  " );
208
  }
209
 
210
+ /**
211
+ * Adds boxes.
212
+ *
213
+ * @return void
214
+ */
215
+ public function boxes_init() {
216
  wp_enqueue_script( 'postbox' );
217
 
218
  add_screen_option( 'layout_columns', array(
257
  }
258
  }
259
 
260
+ /**
261
+ * Transforms numeric array to associative.
262
+ *
263
+ * @param array $argv
264
+ * @param array $keys
265
+ *
266
+ * @return array
267
+ */
268
  private static function numeric_to_assoc( $argv, $keys ) {
269
  $args = array();
270
 
271
  foreach ( $keys as $i => $key ) {
272
+ if ( isset( $argv[ $i ] ) ) {
273
  $args[ $key ] = $argv[ $i ];
274
+ }
275
  }
276
 
277
  return $args;
278
  }
279
 
280
+ /**
281
+ * Since we don't pass an object to do_meta_boxes(),
282
+ * pass $box['args'] directly to each method.
283
+ *
284
+ * @param string $_
285
+ * @param array $box
286
+ *
287
+ * @return void
288
+ */
289
+ public function _intermediate_callback( $_, $box ) {
290
  list( $name ) = explode( '-', $box['id'] );
291
 
292
  call_user_func_array( array( $this, $name . '_box' ), $box['args'] );
293
  }
294
 
295
+ /**
296
+ * Adds/Increments ID in box name.
297
+ *
298
+ * @param string $name
299
+ *
300
+ * @return string
301
+ */
302
  private function _increment( $name ) {
303
  $parts = explode( '-', $name );
304
+ if ( isset( $parts[1] ) ) {
305
  $parts[1]++;
306
+ } else {
307
  $parts[1] = 2;
308
+ }
309
 
310
  return implode( '-', $parts );
311
  }
312
 
313
+ /**
314
+ * Adds necesary code for JS to work.
315
+ *
316
+ * @return void
317
+ */
318
+ protected function _boxes_js_init() {
319
  echo $this->js_wrap( <<<EOT
320
  jQuery( document ).ready( function( $ ){
321
  // close postboxes that should be closed
339
  }
340
  }
341
 
 
 
scb/Cron.php CHANGED
@@ -1,7 +1,6 @@
1
  <?php
2
-
3
  /**
4
- * wp-cron job container
5
  */
6
  class scbCron {
7
  protected $schedule;
@@ -12,19 +11,22 @@ class scbCron {
12
  protected $callback_args = array();
13
 
14
  /**
15
- * Create a new cron job
16
  *
17
- * @param string|bool $file Reference to main plugin file
18
  * @param array $args List of args:
19
  * string $action OR callback $callback
20
  * string $schedule OR number $interval
21
  * array $callback_args (optional)
 
 
22
  */
23
- function __construct( $file = false, $args ) {
24
 
25
  // Set time & schedule
26
- if ( isset( $args['time'] ) )
27
  $this->time = $args['time'];
 
28
 
29
  if ( isset( $args['interval'] ) ) {
30
  $this->schedule = $args['interval'] . 'secs';
@@ -36,18 +38,19 @@ class scbCron {
36
  // Set hook
37
  if ( isset( $args['action'] ) ) {
38
  $this->hook = $args['action'];
39
- } elseif ( isset( $args['callback'] ) ) {
40
  $this->hook = self::_callback_to_string( $args['callback'] );
41
  add_action( $this->hook, $args['callback'] );
42
- } elseif ( method_exists( $this, 'callback' ) ) {
43
  $this->hook = self::_callback_to_string( array( $this, 'callback' ) );
44
  add_action( $this->hook, $args['callback'] );
45
  } else {
46
  trigger_error( '$action OR $callback not set', E_USER_WARNING );
47
  }
48
 
49
- if ( isset( $args['callback_args'] ) )
50
  $this->callback_args = (array) $args['callback_args'];
 
51
 
52
  if ( $file && $this->schedule ) {
53
  scbUtil::add_activation_hook( $file, array( $this, 'reset' ) );
@@ -58,13 +61,15 @@ class scbCron {
58
  }
59
 
60
  /**
61
- * Change the interval of the cron job
62
  *
63
  * @param array $args List of args:
64
  * string $schedule OR number $interval
65
  * timestamp $time ( optional )
 
 
66
  */
67
- function reschedule( $args ) {
68
 
69
  if ( $args['schedule'] && $this->schedule != $args['schedule'] ) {
70
  $this->schedule = $args['schedule'];
@@ -79,40 +84,52 @@ class scbCron {
79
  }
80
 
81
  /**
82
- * Reset the schedule
 
 
83
  */
84
- function reset() {
85
  $this->unschedule();
86
  $this->schedule();
87
  }
88
 
89
  /**
90
- * Clear the cron job
 
 
91
  */
92
- function unschedule() {
93
  # wp_clear_scheduled_hook( $this->hook, $this->callback_args );
94
  self::really_clear_scheduled_hook( $this->hook );
95
  }
96
 
97
  /**
98
- * Execute the job now
99
- * @param array $args List of arguments to pass to the callback
 
 
 
100
  */
101
- function do_now( $args = null ) {
102
- if ( is_null( $args ) )
103
  $args = $this->callback_args;
 
104
 
105
  do_action_ref_array( $this->hook, $args );
106
  }
107
 
108
  /**
109
- * Execute the job with a given delay
110
- * @param int $delay in seconds
111
- * @param array $args List of arguments to pass to the callback
 
 
 
112
  */
113
- function do_once( $delay = 0, $args = null ) {
114
- if ( is_null( $args ) )
115
  $args = $this->callback_args;
 
116
 
117
  wp_clear_scheduled_hook( $this->hook, $args );
118
  wp_schedule_single_event( time() + $delay, $this->hook, $args );
@@ -122,15 +139,18 @@ class scbCron {
122
  //_____INTERNAL METHODS_____
123
 
124
  /**
 
 
125
  * @param array $schedules
126
  *
127
  * @return array
128
  */
129
- function _add_timing( $schedules ) {
130
- if ( isset( $schedules[$this->schedule] ) )
131
  return $schedules;
 
132
 
133
- $schedules[$this->schedule] = array(
134
  'interval' => $this->interval,
135
  'display' => $this->interval . ' seconds',
136
  );
@@ -138,43 +158,59 @@ class scbCron {
138
  return $schedules;
139
  }
140
 
 
 
 
 
 
141
  protected function schedule() {
142
- if ( ! $this->time )
143
  $this->time = time();
 
144
 
145
  wp_schedule_event( $this->time, $this->schedule, $this->hook, $this->callback_args );
146
  }
147
 
148
  /**
 
 
149
  * @param string $name
 
 
150
  */
151
  protected static function really_clear_scheduled_hook( $name ) {
152
  $crons = _get_cron_array();
153
 
154
  foreach ( $crons as $timestamp => $hooks ) {
155
- foreach ( $hooks as $hook => $args )
156
- if ( $hook == $name )
157
- unset( $crons[$timestamp][$hook] );
158
-
159
- if ( empty( $crons[$timestamp] ) )
160
- unset( $crons[$timestamp] );
 
 
 
161
  }
162
 
163
  _set_cron_array( $crons );
164
  }
165
 
166
  /**
 
 
167
  * @param callback $callback
168
  *
169
  * @return string
170
  */
171
  protected static function _callback_to_string( $callback ) {
172
- if ( ! is_array( $callback ) )
173
  $str = $callback;
174
- elseif ( ! is_string( $callback[0] ) )
175
  $str = get_class( $callback[0] ) . '_' . $callback[1];
176
- else
177
  $str = $callback[0] . '::' . $callback[1];
 
178
 
179
  $str .= '_hook';
180
 
1
  <?php
 
2
  /**
3
+ * WP Cron job container.
4
  */
5
  class scbCron {
6
  protected $schedule;
11
  protected $callback_args = array();
12
 
13
  /**
14
+ * Create a new cron job.
15
  *
16
+ * @param string|bool $file (optional) Reference to main plugin file
17
  * @param array $args List of args:
18
  * string $action OR callback $callback
19
  * string $schedule OR number $interval
20
  * array $callback_args (optional)
21
+ *
22
+ * @return void
23
  */
24
+ public function __construct( $file = false, $args ) {
25
 
26
  // Set time & schedule
27
+ if ( isset( $args['time'] ) ) {
28
  $this->time = $args['time'];
29
+ }
30
 
31
  if ( isset( $args['interval'] ) ) {
32
  $this->schedule = $args['interval'] . 'secs';
38
  // Set hook
39
  if ( isset( $args['action'] ) ) {
40
  $this->hook = $args['action'];
41
+ } else if ( isset( $args['callback'] ) ) {
42
  $this->hook = self::_callback_to_string( $args['callback'] );
43
  add_action( $this->hook, $args['callback'] );
44
+ } else if ( method_exists( $this, 'callback' ) ) {
45
  $this->hook = self::_callback_to_string( array( $this, 'callback' ) );
46
  add_action( $this->hook, $args['callback'] );
47
  } else {
48
  trigger_error( '$action OR $callback not set', E_USER_WARNING );
49
  }
50
 
51
+ if ( isset( $args['callback_args'] ) ) {
52
  $this->callback_args = (array) $args['callback_args'];
53
+ }
54
 
55
  if ( $file && $this->schedule ) {
56
  scbUtil::add_activation_hook( $file, array( $this, 'reset' ) );
61
  }
62
 
63
  /**
64
+ * Change the interval of the cron job.
65
  *
66
  * @param array $args List of args:
67
  * string $schedule OR number $interval
68
  * timestamp $time ( optional )
69
+ *
70
+ * @return void
71
  */
72
+ public function reschedule( $args ) {
73
 
74
  if ( $args['schedule'] && $this->schedule != $args['schedule'] ) {
75
  $this->schedule = $args['schedule'];
84
  }
85
 
86
  /**
87
+ * Reset the schedule.
88
+ *
89
+ * @return void
90
  */
91
+ public function reset() {
92
  $this->unschedule();
93
  $this->schedule();
94
  }
95
 
96
  /**
97
+ * Clear the cron job.
98
+ *
99
+ * @return void
100
  */
101
+ public function unschedule() {
102
  # wp_clear_scheduled_hook( $this->hook, $this->callback_args );
103
  self::really_clear_scheduled_hook( $this->hook );
104
  }
105
 
106
  /**
107
+ * Execute the job now.
108
+ *
109
+ * @param array $args (optional) List of arguments to pass to the callback.
110
+ *
111
+ * @return void
112
  */
113
+ public function do_now( $args = null ) {
114
+ if ( is_null( $args ) ) {
115
  $args = $this->callback_args;
116
+ }
117
 
118
  do_action_ref_array( $this->hook, $args );
119
  }
120
 
121
  /**
122
+ * Execute the job with a given delay.
123
+ *
124
+ * @param int $delay (optional) Delay in seconds.
125
+ * @param array $args (optional) List of arguments to pass to the callback.
126
+ *
127
+ * @return void
128
  */
129
+ public function do_once( $delay = 0, $args = null ) {
130
+ if ( is_null( $args ) ) {
131
  $args = $this->callback_args;
132
+ }
133
 
134
  wp_clear_scheduled_hook( $this->hook, $args );
135
  wp_schedule_single_event( time() + $delay, $this->hook, $args );
139
  //_____INTERNAL METHODS_____
140
 
141
  /**
142
+ * Adds custom schedule timing.
143
+ *
144
  * @param array $schedules
145
  *
146
  * @return array
147
  */
148
+ public function _add_timing( $schedules ) {
149
+ if ( isset( $schedules[ $this->schedule ] ) ) {
150
  return $schedules;
151
+ }
152
 
153
+ $schedules[ $this->schedule ] = array(
154
  'interval' => $this->interval,
155
  'display' => $this->interval . ' seconds',
156
  );
158
  return $schedules;
159
  }
160
 
161
+ /**
162
+ * Schedule the job.
163
+ *
164
+ * @return void
165
+ */
166
  protected function schedule() {
167
+ if ( ! $this->time ) {
168
  $this->time = time();
169
+ }
170
 
171
  wp_schedule_event( $this->time, $this->schedule, $this->hook, $this->callback_args );
172
  }
173
 
174
  /**
175
+ * Clears scheduled job.
176
+ *
177
  * @param string $name
178
+ *
179
+ * @return void
180
  */
181
  protected static function really_clear_scheduled_hook( $name ) {
182
  $crons = _get_cron_array();
183
 
184
  foreach ( $crons as $timestamp => $hooks ) {
185
+ foreach ( $hooks as $hook => $args ) {
186
+ if ( $hook == $name ) {
187
+ unset( $crons[ $timestamp ][ $hook ] );
188
+ }
189
+ }
190
+
191
+ if ( empty( $crons[ $timestamp ] ) ) {
192
+ unset( $crons[ $timestamp ] );
193
+ }
194
  }
195
 
196
  _set_cron_array( $crons );
197
  }
198
 
199
  /**
200
+ * Generates a hook name from given callback.
201
+ *
202
  * @param callback $callback
203
  *
204
  * @return string
205
  */
206
  protected static function _callback_to_string( $callback ) {
207
+ if ( ! is_array( $callback ) ) {
208
  $str = $callback;
209
+ } else if ( ! is_string( $callback[0] ) ) {
210
  $str = get_class( $callback[0] ) . '_' . $callback[1];
211
+ } else {
212
  $str = $callback[0] . '::' . $callback[1];
213
+ }
214
 
215
  $str .= '_hook';
216
 
scb/Forms.php CHANGED
@@ -1,48 +1,52 @@
1
  <?php
2
-
3
  /**
4
- * Data-aware form generator
5
  */
6
  class scbForms {
7
 
8
  const TOKEN = '%input%';
9
 
10
  /**
 
 
11
  * @param array|scbFormField_I $args
12
  * @param mixed $value
13
  *
14
  * @return string
15
  */
16
- static function input_with_value( $args, $value ) {
17
  $field = scbFormField::create( $args );
18
 
19
  return $field->render( $value );
20
  }
21
 
22
  /**
 
 
23
  * @param array|scbFormField_I $args
24
- * @param array $formdata
25
  *
26
  * @return string
27
  */
28
- static function input( $args, $formdata = null ) {
29
  $field = scbFormField::create( $args );
30
 
31
  return $field->render( scbForms::get_value( $args['name'], $formdata ) );
32
  }
33
 
34
  /**
35
- * Generates a table wrapped in a form
36
  *
37
  * @param array $rows
38
- * @param array $formdata
39
  *
40
  * @return string
41
  */
42
- static function form_table( $rows, $formdata = null ) {
43
  $output = '';
44
- foreach ( $rows as $row )
45
  $output .= self::table_row( $row, $formdata );
 
46
 
47
  $output = self::form_table_wrap( $output );
48
 
@@ -50,18 +54,19 @@ class scbForms {
50
  }
51
 
52
  /**
53
- * Generates a form
54
  *
55
  * @param array $inputs
56
- * @param array $formdata
57
  * @param string $nonce
58
  *
59
  * @return string
60
  */
61
- static function form( $inputs, $formdata = null, $nonce ) {
62
  $output = '';
63
- foreach ( $inputs as $input )
64
  $output .= self::input( $input, $formdata );
 
65
 
66
  $output = self::form_wrap( $output, $nonce );
67
 
@@ -69,17 +74,18 @@ class scbForms {
69
  }
70
 
71
  /**
72
- * Generates a table
73
  *
74
  * @param array $rows
75
- * @param array $formdata
76
  *
77
  * @return string
78
  */
79
- static function table( $rows, $formdata = null ) {
80
  $output = '';
81
- foreach ( $rows as $row )
82
  $output .= self::table_row( $row, $formdata );
 
83
 
84
  $output = self::table_wrap( $output );
85
 
@@ -87,14 +93,14 @@ class scbForms {
87
  }
88
 
89
  /**
90
- * Generates a table row
91
  *
92
  * @param array $args
93
- * @param array $formdata
94
  *
95
  * @return string
96
  */
97
- static function table_row( $args, $formdata = null ) {
98
  return self::row_wrap( $args['title'], self::input( $args, $formdata ) );
99
  }
100
 
@@ -102,22 +108,26 @@ class scbForms {
102
  // ____________WRAPPERS____________
103
 
104
  /**
 
 
105
  * @param string $content
106
- * @param string $nonce
107
  *
108
  * @return string
109
  */
110
- static function form_table_wrap( $content, $nonce = 'update_options' ) {
111
  return self::form_wrap( self::table_wrap( $content ), $nonce );
112
  }
113
 
114
  /**
 
 
115
  * @param string $content
116
- * @param string $nonce
117
  *
118
  * @return string
119
  */
120
- static function form_wrap( $content, $nonce = 'update_options' ) {
121
  return html( "form method='post' action=''",
122
  $content,
123
  wp_nonce_field( $nonce, '_wpnonce', $referer = true, $echo = false )
@@ -125,21 +135,25 @@ class scbForms {
125
  }
126
 
127
  /**
 
 
128
  * @param string $content
129
  *
130
  * @return string
131
  */
132
- static function table_wrap( $content ) {
133
  return html( "table class='form-table'", $content );
134
  }
135
 
136
  /**
 
 
137
  * @param string $title
138
  * @param string $content
139
  *
140
  * @return string
141
  */
142
- static function row_wrap( $title, $content ) {
143
  return html( 'tr',
144
  html( "th scope='row'", $title ),
145
  html( 'td', $content )
@@ -160,7 +174,7 @@ class scbForms {
160
  *
161
  * @return string
162
  */
163
- static function get_name( $name ) {
164
  $name = (array) $name;
165
 
166
  $name_str = array_shift( $name );
@@ -177,16 +191,17 @@ class scbForms {
177
  *
178
  * @param string $name The name of the value
179
  * @param array $value The data that will be traversed
180
- * @param mixed $fallback The value returned when the key is not found
181
  *
182
  * @return mixed
183
  */
184
- static function get_value( $name, $value, $fallback = null ) {
185
  foreach ( (array) $name as $key ) {
186
- if ( !isset( $value[ $key ] ) )
187
  return $fallback;
 
188
 
189
- $value = $value[$key];
190
  }
191
 
192
  return $value;
@@ -196,12 +211,12 @@ class scbForms {
196
  * Given a list of fields, validate some data.
197
  *
198
  * @param array $fields List of args that would be sent to scbForms::input()
199
- * @param array $data The data to validate. Defaults to $_POST
200
- * @param array $to_update Existing data to populate. Necessary for nested values
201
  *
202
  * @return array
203
  */
204
- static function validate_post_data( $fields, $data = null, $to_update = array() ) {
205
  if ( null === $data ) {
206
  $data = stripslashes_deep( $_POST );
207
  }
@@ -213,8 +228,9 @@ class scbForms {
213
 
214
  $value = $fieldObj->validate( $value );
215
 
216
- if ( null !== $value )
217
  self::set_value( $to_update, $field['name'], $value );
 
218
  }
219
 
220
  return $to_update;
@@ -227,11 +243,11 @@ class scbForms {
227
  *
228
  * @param array $args Field arguments.
229
  * @param int $object_id The object ID the metadata is attached to
230
- * @param string $meta_type
231
  *
232
  * @return string
233
  */
234
- static function input_from_meta( $args, $object_id, $meta_type = 'post' ) {
235
  $single = ( 'checkbox' != $args['type'] );
236
 
237
  $key = (array) $args['name'];
@@ -243,51 +259,63 @@ class scbForms {
243
  }
244
 
245
  /**
 
 
246
  * @param array $fields
247
  * @param array $data
248
- * @param int $object_id
249
- * @param string $meta_type
 
 
250
  */
251
- static function update_meta( $fields, $data, $object_id, $meta_type = 'post' ) {
252
  foreach ( $fields as $field_args ) {
253
  $key = $field_args['name'];
254
 
255
  if ( 'checkbox' == $field_args['type'] ) {
256
- $new_values = isset( $data[$key] ) ? $data[$key] : array();
257
 
258
  $old_values = get_metadata( $meta_type, $object_id, $key );
259
 
260
- foreach ( array_diff( $new_values, $old_values ) as $value )
261
  add_metadata( $meta_type, $object_id, $key, $value );
 
262
 
263
- foreach ( array_diff( $old_values, $new_values ) as $value )
264
  delete_metadata( $meta_type, $object_id, $key, $value );
 
265
  } else {
266
- $value = isset( $data[$key] ) ? $data[$key] : '';
267
 
268
- if ( '' === $value )
269
  delete_metadata( $meta_type, $object_id, $key );
270
- else
271
  update_metadata( $meta_type, $object_id, $key, $value );
 
272
  }
273
  }
274
  }
275
 
276
  /**
 
 
277
  * @param array $arr
278
  * @param string $name
279
  * @param mixed $value
 
 
280
  */
281
  private static function set_value( &$arr, $name, $value ) {
282
  $name = (array) $name;
283
 
284
  $final_key = array_pop( $name );
285
 
286
- while ( !empty( $name ) ) {
287
  $key = array_shift( $name );
288
 
289
- if ( !isset( $arr[ $key ] ) )
290
  $arr[ $key ] = array();
 
291
 
292
  $arr =& $arr[ $key ];
293
  }
@@ -298,30 +326,38 @@ class scbForms {
298
 
299
 
300
  /**
301
- * A wrapper for scbForms, containing the formdata
302
  */
303
  class scbForm {
304
  protected $data = array();
305
  protected $prefix = array();
306
 
307
  /**
 
 
308
  * @param array $data
309
- * @param string|boolean $prefix
 
 
310
  */
311
- function __construct( $data, $prefix = false ) {
312
- if ( is_array( $data ) )
313
  $this->data = $data;
 
314
 
315
- if ( $prefix )
316
  $this->prefix = (array) $prefix;
 
317
  }
318
 
319
  /**
 
 
320
  * @param string $path
321
  *
322
- * @return scbForm
323
  */
324
- function traverse_to( $path ) {
325
  $data = scbForms::get_value( $path, $this->data );
326
 
327
  $prefix = array_merge( $this->prefix, (array) $path );
@@ -330,14 +366,16 @@ class scbForm {
330
  }
331
 
332
  /**
 
 
333
  * @param array $args
334
  *
335
  * @return string
336
  */
337
- function input( $args ) {
338
  $value = scbForms::get_value( $args['name'], $this->data );
339
 
340
- if ( !empty( $this->prefix ) ) {
341
  $args['name'] = array_merge( $this->prefix, (array) $args['name'] );
342
  }
343
 
@@ -351,9 +389,9 @@ class scbForm {
351
  interface scbFormField_I {
352
 
353
  /**
354
- * Generate the corresponding HTML for a field
355
  *
356
- * @param mixed $value The value to use
357
  *
358
  * @return string
359
  */
@@ -362,7 +400,7 @@ interface scbFormField_I {
362
  /**
363
  * Validates a value against a field.
364
  *
365
- * @param mixed $value The value to check
366
  *
367
  * @return mixed null if the validation failed, sanitized value otherwise.
368
  */
@@ -377,13 +415,16 @@ abstract class scbFormField implements scbFormField_I {
377
  protected $args;
378
 
379
  /**
 
 
380
  * @param array|scbFormField_I $args
381
  *
382
  * @return mixed false on failure or instance of form class
383
  */
384
  public static function create( $args ) {
385
- if ( is_a( $args, 'scbFormField_I' ) )
386
  return $args;
 
387
 
388
  if ( empty( $args['name'] ) ) {
389
  return trigger_error( 'Empty name', E_USER_WARNING );
@@ -399,8 +440,9 @@ abstract class scbFormField implements scbFormField_I {
399
  unset( $args['values'] );
400
  }
401
 
402
- if ( isset( $args['extra'] ) && !is_array( $args['extra'] ) )
403
  $args['extra'] = shortcode_parse_atts( $args['extra'] );
 
404
 
405
  $args = wp_parse_args( $args, array(
406
  'desc' => '',
@@ -410,34 +452,42 @@ abstract class scbFormField implements scbFormField_I {
410
  ) );
411
 
412
  // depends on $args['desc']
413
- if ( isset( $args['choices'] ) )
414
  self::_expand_choices( $args );
 
415
 
416
  switch ( $args['type'] ) {
417
- case 'radio':
418
- return new scbRadiosField( $args );
419
- case 'select':
420
- return new scbSelectField( $args );
421
- case 'checkbox':
422
- if ( isset( $args['choices'] ) )
423
- return new scbMultipleChoiceField( $args );
424
- else
425
- return new scbSingleCheckboxField( $args );
426
- case 'custom':
427
- return new scbCustomField( $args );
428
- default:
429
- return new scbTextField( $args );
 
430
  }
431
  }
432
 
433
  /**
 
 
434
  * @param array $args
 
 
435
  */
436
  protected function __construct( $args ) {
437
  $this->args = $args;
438
  }
439
 
440
  /**
 
 
441
  * @param string $key
442
  *
443
  * @return mixed
@@ -447,6 +497,8 @@ abstract class scbFormField implements scbFormField_I {
447
  }
448
 
449
  /**
 
 
450
  * @param string $key
451
  *
452
  * @return bool
@@ -456,18 +508,22 @@ abstract class scbFormField implements scbFormField_I {
456
  }
457
 
458
  /**
459
- * @param mixed $value
 
 
460
  *
461
  * @return string
462
  */
463
  public function render( $value = null ) {
464
- if ( null === $value && isset( $this->default ) )
465
  $value = $this->default;
 
466
 
467
  $args = $this->args;
468
 
469
- if ( null !== $value )
470
  $this->_set_value( $args, $value );
 
471
 
472
  $args['name'] = scbForms::get_name( $args['name'] );
473
 
@@ -483,14 +539,14 @@ abstract class scbFormField implements scbFormField_I {
483
  abstract protected function _set_value( &$args, $value );
484
 
485
  /**
486
- * The actual rendering
487
  *
488
  * @param array $args
489
  */
490
  abstract protected function _render( $args );
491
 
492
  /**
493
- * Handle args for a single checkbox or radio input
494
  *
495
  * @param array $args
496
  *
@@ -506,14 +562,15 @@ abstract class scbFormField implements scbFormField_I {
506
 
507
  $args['extra']['checked'] = $args['checked'];
508
 
509
- if ( is_null( $args['desc'] ) && ! is_bool( $args['value'] ) )
510
  $args['desc'] = str_replace( '[]', '', $args['value'] );
 
511
 
512
  return self::_input_gen( $args );
513
  }
514
 
515
  /**
516
- * Generate html with the final args
517
  *
518
  * @param array $args
519
  *
@@ -540,6 +597,8 @@ abstract class scbFormField implements scbFormField_I {
540
  }
541
 
542
  /**
 
 
543
  * @param string $input
544
  * @param string $desc
545
  * @param string $desc_pos
@@ -551,6 +610,8 @@ abstract class scbFormField implements scbFormField_I {
551
  }
552
 
553
  /**
 
 
554
  * @param string $input
555
  * @param string $desc
556
  * @param string $desc_pos
@@ -558,13 +619,15 @@ abstract class scbFormField implements scbFormField_I {
558
  * @return string
559
  */
560
  protected static function add_desc( $input, $desc, $desc_pos ) {
561
- if ( empty( $desc ) )
562
  return $input;
 
563
 
564
- if ( 'before' == $desc_pos )
565
  return $desc . ' ' . $input;
566
- else
567
  return $input . ' ' . $desc;
 
568
  }
569
 
570
  /**
@@ -573,17 +636,19 @@ abstract class scbFormField implements scbFormField_I {
573
  private static function _expand_choices( &$args ) {
574
  $choices =& $args['choices'];
575
 
576
- if ( !empty( $choices ) && !self::is_associative( $choices ) ) {
577
  if ( is_array( $args['desc'] ) ) {
578
  $choices = array_combine( $choices, $args['desc'] ); // back-compat
579
  $args['desc'] = false;
580
- } elseif ( !isset( $args['numeric'] ) || !$args['numeric'] ) {
581
  $choices = array_combine( $choices, $choices );
582
  }
583
  }
584
  }
585
 
586
  /**
 
 
587
  * @param array $array
588
  *
589
  * @return bool
@@ -600,6 +665,8 @@ abstract class scbFormField implements scbFormField_I {
600
  class scbTextField extends scbFormField {
601
 
602
  /**
 
 
603
  * @param string $value
604
  *
605
  * @return string
@@ -611,6 +678,8 @@ class scbTextField extends scbFormField {
611
  }
612
 
613
  /**
 
 
614
  * @param array $args
615
  *
616
  * @return string
@@ -622,15 +691,20 @@ class scbTextField extends scbFormField {
622
  'extra' => array( 'class' => 'regular-text' ),
623
  ) );
624
 
625
- if ( ! isset( $args['extra']['id'] ) && ! is_array( $args['name'] ) && false === strpos( $args['name'], '[' ) )
626
  $args['extra']['id'] = $args['name'];
 
627
 
628
  return scbFormField::_input_gen( $args );
629
  }
630
 
631
  /**
 
 
632
  * @param array $args
633
  * @param string $value
 
 
634
  */
635
  protected function _set_value( &$args, $value ) {
636
  $args['value'] = $value;
@@ -643,18 +717,23 @@ class scbTextField extends scbFormField {
643
  abstract class scbSingleChoiceField extends scbFormField {
644
 
645
  /**
 
 
646
  * @param mixed $value
647
  *
648
  * @return mixed|null
649
  */
650
  public function validate( $value ) {
651
- if ( isset( $this->choices[ $value ] ) )
652
  return $value;
 
653
 
654
  return null;
655
  }
656
 
657
  /**
 
 
658
  * @param array $args
659
  *
660
  * @return string
@@ -667,21 +746,27 @@ abstract class scbSingleChoiceField extends scbFormField {
667
  if ( isset( $args['selected'] ) ) {
668
  $args['selected'] = (string) $args['selected'];
669
  } else {
670
- $args['selected'] = array('foo'); // hack to make default blank
671
  }
672
 
673
  return $this->_render_specific( $args );
674
  }
675
 
676
  /**
677
- * @param array $args
678
- * @param mixed $value
 
 
 
 
679
  */
680
  protected function _set_value( &$args, $value ) {
681
  $args['selected'] = $value;
682
  }
683
 
684
  /**
 
 
685
  * @param array $args
686
  *
687
  * @return string
@@ -695,6 +780,8 @@ abstract class scbSingleChoiceField extends scbFormField {
695
  class scbSelectField extends scbSingleChoiceField {
696
 
697
  /**
 
 
698
  * @param array $args
699
  *
700
  * @return string
@@ -744,6 +831,8 @@ class scbSelectField extends scbSingleChoiceField {
744
  class scbRadiosField extends scbSelectField {
745
 
746
  /**
 
 
747
  * @param array $args
748
  *
749
  * @return string
@@ -781,6 +870,8 @@ class scbRadiosField extends scbSelectField {
781
  class scbMultipleChoiceField extends scbFormField {
782
 
783
  /**
 
 
784
  * @param mixed $value
785
  *
786
  * @return array
@@ -790,6 +881,8 @@ class scbMultipleChoiceField extends scbFormField {
790
  }
791
 
792
  /**
 
 
793
  * @param array $args
794
  *
795
  * @return string
@@ -800,8 +893,9 @@ class scbMultipleChoiceField extends scbFormField {
800
  'checked' => null,
801
  ) );
802
 
803
- if ( ! is_array( $args['checked'] ) )
804
  $args['checked'] = array();
 
805
 
806
  $opts = '';
807
  foreach ( $args['choices'] as $value => $title ) {
@@ -821,8 +915,12 @@ class scbMultipleChoiceField extends scbFormField {
821
  }
822
 
823
  /**
824
- * @param array $args
825
- * @param mixed $value
 
 
 
 
826
  */
827
  protected function _set_value( &$args, $value ) {
828
  $args['checked'] = (array) $value;
@@ -835,6 +933,8 @@ class scbMultipleChoiceField extends scbFormField {
835
  class scbSingleCheckboxField extends scbFormField {
836
 
837
  /**
 
 
838
  * @param mixed $value
839
  *
840
  * @return boolean
@@ -844,6 +944,8 @@ class scbSingleCheckboxField extends scbFormField {
844
  }
845
 
846
  /**
 
 
847
  * @param array $args
848
  *
849
  * @return string
@@ -858,15 +960,20 @@ class scbSingleCheckboxField extends scbFormField {
858
 
859
  $args['extra']['checked'] = $args['checked'];
860
 
861
- if ( is_null( $args['desc'] ) && ! is_bool( $args['value'] ) )
862
  $args['desc'] = str_replace( '[]', '', $args['value'] );
 
863
 
864
  return scbFormField::_input_gen( $args );
865
  }
866
 
867
  /**
868
- * @param array $args
869
- * @param mixed $value
 
 
 
 
870
  */
871
  protected function _set_value( &$args, $value ) {
872
  $args['checked'] = ( $value || ( isset( $args['value'] ) && $value == $args['value'] ) );
@@ -881,7 +988,11 @@ class scbCustomField implements scbFormField_I {
881
  protected $args;
882
 
883
  /**
 
 
884
  * @param array $args
 
 
885
  */
886
  function __construct( $args ) {
887
  $this->args = wp_parse_args( $args, array(
@@ -891,6 +1002,8 @@ class scbCustomField implements scbFormField_I {
891
  }
892
 
893
  /**
 
 
894
  * @param string $key
895
  *
896
  * @return mixed
@@ -900,6 +1013,8 @@ class scbCustomField implements scbFormField_I {
900
  }
901
 
902
  /**
 
 
903
  * @param string $key
904
  *
905
  * @return boolean
@@ -909,7 +1024,9 @@ class scbCustomField implements scbFormField_I {
909
  }
910
 
911
  /**
912
- * @param mixed $value
 
 
913
  *
914
  * @return string
915
  */
@@ -918,6 +1035,8 @@ class scbCustomField implements scbFormField_I {
918
  }
919
 
920
  /**
 
 
921
  * @param mixed $value
922
  *
923
  * @return mixed
1
  <?php
 
2
  /**
3
+ * Data-aware form generator.
4
  */
5
  class scbForms {
6
 
7
  const TOKEN = '%input%';
8
 
9
  /**
10
+ * Generates form field.
11
+ *
12
  * @param array|scbFormField_I $args
13
  * @param mixed $value
14
  *
15
  * @return string
16
  */
17
+ public static function input_with_value( $args, $value ) {
18
  $field = scbFormField::create( $args );
19
 
20
  return $field->render( $value );
21
  }
22
 
23
  /**
24
+ * Generates form field.
25
+ *
26
  * @param array|scbFormField_I $args
27
+ * @param array $formdata (optional)
28
  *
29
  * @return string
30
  */
31
+ public static function input( $args, $formdata = null ) {
32
  $field = scbFormField::create( $args );
33
 
34
  return $field->render( scbForms::get_value( $args['name'], $formdata ) );
35
  }
36
 
37
  /**
38
+ * Generates a table wrapped in a form.
39
  *
40
  * @param array $rows
41
+ * @param array $formdata (optional)
42
  *
43
  * @return string
44
  */
45
+ public static function form_table( $rows, $formdata = null ) {
46
  $output = '';
47
+ foreach ( $rows as $row ) {
48
  $output .= self::table_row( $row, $formdata );
49
+ }
50
 
51
  $output = self::form_table_wrap( $output );
52
 
54
  }
55
 
56
  /**
57
+ * Generates a form.
58
  *
59
  * @param array $inputs
60
+ * @param array $formdata (optional)
61
  * @param string $nonce
62
  *
63
  * @return string
64
  */
65
+ public static function form( $inputs, $formdata = null, $nonce ) {
66
  $output = '';
67
+ foreach ( $inputs as $input ) {
68
  $output .= self::input( $input, $formdata );
69
+ }
70
 
71
  $output = self::form_wrap( $output, $nonce );
72
 
74
  }
75
 
76
  /**
77
+ * Generates a table.
78
  *
79
  * @param array $rows
80
+ * @param array $formdata (optional)
81
  *
82
  * @return string
83
  */
84
+ public static function table( $rows, $formdata = null ) {
85
  $output = '';
86
+ foreach ( $rows as $row ) {
87
  $output .= self::table_row( $row, $formdata );
88
+ }
89
 
90
  $output = self::table_wrap( $output );
91
 
93
  }
94
 
95
  /**
96
+ * Generates a table row.
97
  *
98
  * @param array $args
99
+ * @param array $formdata (optional)
100
  *
101
  * @return string
102
  */
103
+ public static function table_row( $args, $formdata = null ) {
104
  return self::row_wrap( $args['title'], self::input( $args, $formdata ) );
105
  }
106
 
108
  // ____________WRAPPERS____________
109
 
110
  /**
111
+ * Wraps a table in a form.
112
+ *
113
  * @param string $content
114
+ * @param string $nonce (optional)
115
  *
116
  * @return string
117
  */
118
+ public static function form_table_wrap( $content, $nonce = 'update_options' ) {
119
  return self::form_wrap( self::table_wrap( $content ), $nonce );
120
  }
121
 
122
  /**
123
+ * Wraps a content in a form.
124
+ *
125
  * @param string $content
126
+ * @param string $nonce (optional)
127
  *
128
  * @return string
129
  */
130
+ public static function form_wrap( $content, $nonce = 'update_options' ) {
131
  return html( "form method='post' action=''",
132
  $content,
133
  wp_nonce_field( $nonce, '_wpnonce', $referer = true, $echo = false )
135
  }
136
 
137
  /**
138
+ * Wraps a content in a table.
139
+ *
140
  * @param string $content
141
  *
142
  * @return string
143
  */
144
+ public static function table_wrap( $content ) {
145
  return html( "table class='form-table'", $content );
146
  }
147
 
148
  /**
149
+ * Wraps a content in a table row.
150
+ *
151
  * @param string $title
152
  * @param string $content
153
  *
154
  * @return string
155
  */
156
+ public static function row_wrap( $title, $content ) {
157
  return html( 'tr',
158
  html( "th scope='row'", $title ),
159
  html( 'td', $content )
174
  *
175
  * @return string
176
  */
177
+ public static function get_name( $name ) {
178
  $name = (array) $name;
179
 
180
  $name_str = array_shift( $name );
191
  *
192
  * @param string $name The name of the value
193
  * @param array $value The data that will be traversed
194
+ * @param mixed $fallback (optional) The value returned when the key is not found
195
  *
196
  * @return mixed
197
  */
198
+ public static function get_value( $name, $value, $fallback = null ) {
199
  foreach ( (array) $name as $key ) {
200
+ if ( ! isset( $value[ $key ] ) ) {
201
  return $fallback;
202
+ }
203
 
204
+ $value = $value[ $key ];
205
  }
206
 
207
  return $value;
211
  * Given a list of fields, validate some data.
212
  *
213
  * @param array $fields List of args that would be sent to scbForms::input()
214
+ * @param array $data (optional) The data to validate. Defaults to $_POST
215
+ * @param array $to_update (optional) Existing data to populate. Necessary for nested values
216
  *
217
  * @return array
218
  */
219
+ public static function validate_post_data( $fields, $data = null, $to_update = array() ) {
220
  if ( null === $data ) {
221
  $data = stripslashes_deep( $_POST );
222
  }
228
 
229
  $value = $fieldObj->validate( $value );
230
 
231
+ if ( null !== $value ) {
232
  self::set_value( $to_update, $field['name'], $value );
233
+ }
234
  }
235
 
236
  return $to_update;
243
  *
244
  * @param array $args Field arguments.
245
  * @param int $object_id The object ID the metadata is attached to
246
+ * @param string $meta_type (optional)
247
  *
248
  * @return string
249
  */
250
+ public static function input_from_meta( $args, $object_id, $meta_type = 'post' ) {
251
  $single = ( 'checkbox' != $args['type'] );
252
 
253
  $key = (array) $args['name'];
259
  }
260
 
261
  /**
262
+ * Updates metadata for passed list of fields.
263
+ *
264
  * @param array $fields
265
  * @param array $data
266
+ * @param int $object_id The object ID the metadata is attached to
267
+ * @param string $meta_type (optional) Defaults to 'post'
268
+ *
269
+ * @return void
270
  */
271
+ public static function update_meta( $fields, $data, $object_id, $meta_type = 'post' ) {
272
  foreach ( $fields as $field_args ) {
273
  $key = $field_args['name'];
274
 
275
  if ( 'checkbox' == $field_args['type'] ) {
276
+ $new_values = isset( $data[ $key ] ) ? $data[ $key ] : array();
277
 
278
  $old_values = get_metadata( $meta_type, $object_id, $key );
279
 
280
+ foreach ( array_diff( $new_values, $old_values ) as $value ) {
281
  add_metadata( $meta_type, $object_id, $key, $value );
282
+ }
283
 
284
+ foreach ( array_diff( $old_values, $new_values ) as $value ) {
285
  delete_metadata( $meta_type, $object_id, $key, $value );
286
+ }
287
  } else {
288
+ $value = isset( $data[ $key ] ) ? $data[ $key ] : '';
289
 
290
+ if ( '' === $value ) {
291
  delete_metadata( $meta_type, $object_id, $key );
292
+ } else {
293
  update_metadata( $meta_type, $object_id, $key, $value );
294
+ }
295
  }
296
  }
297
  }
298
 
299
  /**
300
+ * Sets value using a reference.
301
+ *
302
  * @param array $arr
303
  * @param string $name
304
  * @param mixed $value
305
+ *
306
+ * @return void
307
  */
308
  private static function set_value( &$arr, $name, $value ) {
309
  $name = (array) $name;
310
 
311
  $final_key = array_pop( $name );
312
 
313
+ while ( ! empty( $name ) ) {
314
  $key = array_shift( $name );
315
 
316
+ if ( ! isset( $arr[ $key ] ) ) {
317
  $arr[ $key ] = array();
318
+ }
319
 
320
  $arr =& $arr[ $key ];
321
  }
326
 
327
 
328
  /**
329
+ * A wrapper for scbForms, containing the formdata.
330
  */
331
  class scbForm {
332
  protected $data = array();
333
  protected $prefix = array();
334
 
335
  /**
336
+ * Constructor.
337
+ *
338
  * @param array $data
339
+ * @param string|boolean $prefix (optional)
340
+ *
341
+ * @return void
342
  */
343
+ public function __construct( $data, $prefix = false ) {
344
+ if ( is_array( $data ) ) {
345
  $this->data = $data;
346
+ }
347
 
348
+ if ( $prefix ) {
349
  $this->prefix = (array) $prefix;
350
+ }
351
  }
352
 
353
  /**
354
+ * Traverses the form.
355
+ *
356
  * @param string $path
357
  *
358
+ * @return object A scbForm
359
  */
360
+ public function traverse_to( $path ) {
361
  $data = scbForms::get_value( $path, $this->data );
362
 
363
  $prefix = array_merge( $this->prefix, (array) $path );
366
  }
367
 
368
  /**
369
+ * Generates form field.
370
+ *
371
  * @param array $args
372
  *
373
  * @return string
374
  */
375
+ public function input( $args ) {
376
  $value = scbForms::get_value( $args['name'], $this->data );
377
 
378
+ if ( ! empty( $this->prefix ) ) {
379
  $args['name'] = array_merge( $this->prefix, (array) $args['name'] );
380
  }
381
 
389
  interface scbFormField_I {
390
 
391
  /**
392
+ * Generate the corresponding HTML for a field.
393
  *
394
+ * @param mixed $value (optional) The value to use.
395
  *
396
  * @return string
397
  */
400
  /**
401
  * Validates a value against a field.
402
  *
403
+ * @param mixed $value The value to check.
404
  *
405
  * @return mixed null if the validation failed, sanitized value otherwise.
406
  */
415
  protected $args;
416
 
417
  /**
418
+ * Creates form field.
419
+ *
420
  * @param array|scbFormField_I $args
421
  *
422
  * @return mixed false on failure or instance of form class
423
  */
424
  public static function create( $args ) {
425
+ if ( is_a( $args, 'scbFormField_I' ) ) {
426
  return $args;
427
+ }
428
 
429
  if ( empty( $args['name'] ) ) {
430
  return trigger_error( 'Empty name', E_USER_WARNING );
440
  unset( $args['values'] );
441
  }
442
 
443
+ if ( isset( $args['extra'] ) && ! is_array( $args['extra'] ) ) {
444
  $args['extra'] = shortcode_parse_atts( $args['extra'] );
445
+ }
446
 
447
  $args = wp_parse_args( $args, array(
448
  'desc' => '',
452
  ) );
453
 
454
  // depends on $args['desc']
455
+ if ( isset( $args['choices'] ) ) {
456
  self::_expand_choices( $args );
457
+ }
458
 
459
  switch ( $args['type'] ) {
460
+ case 'radio':
461
+ return new scbRadiosField( $args );
462
+ case 'select':
463
+ return new scbSelectField( $args );
464
+ case 'checkbox':
465
+ if ( isset( $args['choices'] ) ) {
466
+ return new scbMultipleChoiceField( $args );
467
+ } else {
468
+ return new scbSingleCheckboxField( $args );
469
+ }
470
+ case 'custom':
471
+ return new scbCustomField( $args );
472
+ default:
473
+ return new scbTextField( $args );
474
  }
475
  }
476
 
477
  /**
478
+ * Constructor.
479
+ *
480
  * @param array $args
481
+ *
482
+ * @return void
483
  */
484
  protected function __construct( $args ) {
485
  $this->args = $args;
486
  }
487
 
488
  /**
489
+ * Magic method: $field->arg
490
+ *
491
  * @param string $key
492
  *
493
  * @return mixed
497
  }
498
 
499
  /**
500
+ * Magic method: isset( $field->arg )
501
+ *
502
  * @param string $key
503
  *
504
  * @return bool
508
  }
509
 
510
  /**
511
+ * Generate the corresponding HTML for a field.
512
+ *
513
+ * @param mixed $value (optional)
514
  *
515
  * @return string
516
  */
517
  public function render( $value = null ) {
518
+ if ( null === $value && isset( $this->default ) ) {
519
  $value = $this->default;
520
+ }
521
 
522
  $args = $this->args;
523
 
524
+ if ( null !== $value ) {
525
  $this->_set_value( $args, $value );
526
+ }
527
 
528
  $args['name'] = scbForms::get_name( $args['name'] );
529
 
539
  abstract protected function _set_value( &$args, $value );
540
 
541
  /**
542
+ * The actual rendering.
543
  *
544
  * @param array $args
545
  */
546
  abstract protected function _render( $args );
547
 
548
  /**
549
+ * Handle args for a single checkbox or radio input.
550
  *
551
  * @param array $args
552
  *
562
 
563
  $args['extra']['checked'] = $args['checked'];
564
 
565
+ if ( is_null( $args['desc'] ) && ! is_bool( $args['value'] ) ) {
566
  $args['desc'] = str_replace( '[]', '', $args['value'] );
567
+ }
568
 
569
  return self::_input_gen( $args );
570
  }
571
 
572
  /**
573
+ * Generate html with the final args.
574
  *
575
  * @param array $args
576
  *
597
  }
598
 
599
  /**
600
+ * Wraps a form field in a label, and position field description.
601
+ *
602
  * @param string $input
603
  * @param string $desc
604
  * @param string $desc_pos
610
  }
611
 
612
  /**
613
+ * Adds description before/after the form field.
614
+ *
615
  * @param string $input
616
  * @param string $desc
617
  * @param string $desc_pos
619
  * @return string
620
  */
621
  protected static function add_desc( $input, $desc, $desc_pos ) {
622
+ if ( empty( $desc ) ) {
623
  return $input;
624
+ }
625
 
626
+ if ( 'before' == $desc_pos ) {
627
  return $desc . ' ' . $input;
628
+ } else {
629
  return $input . ' ' . $desc;
630
+ }
631
  }
632
 
633
  /**
636
  private static function _expand_choices( &$args ) {
637
  $choices =& $args['choices'];
638
 
639
+ if ( ! empty( $choices ) && ! self::is_associative( $choices ) ) {
640
  if ( is_array( $args['desc'] ) ) {
641
  $choices = array_combine( $choices, $args['desc'] ); // back-compat
642
  $args['desc'] = false;
643
+ } else if ( ! isset( $args['numeric'] ) || ! $args['numeric'] ) {
644
  $choices = array_combine( $choices, $choices );
645
  }
646
  }
647
  }
648
 
649
  /**
650
+ * Checks if passed array is associative.
651
+ *
652
  * @param array $array
653
  *
654
  * @return bool
665
  class scbTextField extends scbFormField {
666
 
667
  /**
668
+ * Sanitizes value.
669
+ *
670
  * @param string $value
671
  *
672
  * @return string
678
  }
679
 
680
  /**
681
+ * Generate the corresponding HTML for a field.
682
+ *
683
  * @param array $args
684
  *
685
  * @return string
691
  'extra' => array( 'class' => 'regular-text' ),
692
  ) );
693
 
694
+ if ( ! isset( $args['extra']['id'] ) && ! is_array( $args['name'] ) && false === strpos( $args['name'], '[' ) ) {
695
  $args['extra']['id'] = $args['name'];
696
+ }
697
 
698
  return scbFormField::_input_gen( $args );
699
  }
700
 
701
  /**
702
+ * Sets value using a reference.
703
+ *
704
  * @param array $args
705
  * @param string $value
706
+ *
707
+ * @return void
708
  */
709
  protected function _set_value( &$args, $value ) {
710
  $args['value'] = $value;
717
  abstract class scbSingleChoiceField extends scbFormField {
718
 
719
  /**
720
+ * Validates a value against a field.
721
+ *
722
  * @param mixed $value
723
  *
724
  * @return mixed|null
725
  */
726
  public function validate( $value ) {
727
+ if ( isset( $this->choices[ $value ] ) ) {
728
  return $value;
729
+ }
730
 
731
  return null;
732
  }
733
 
734
  /**
735
+ * Generate the corresponding HTML for a field.
736
+ *
737
  * @param array $args
738
  *
739
  * @return string
746
  if ( isset( $args['selected'] ) ) {
747
  $args['selected'] = (string) $args['selected'];
748
  } else {
749
+ $args['selected'] = array( 'foo' ); // hack to make default blank
750
  }
751
 
752
  return $this->_render_specific( $args );
753
  }
754
 
755
  /**
756
+ * Sets value using a reference.
757
+ *
758
+ * @param array $args
759
+ * @param string $value
760
+ *
761
+ * @return void
762
  */
763
  protected function _set_value( &$args, $value ) {
764
  $args['selected'] = $value;
765
  }
766
 
767
  /**
768
+ * Generate the corresponding HTML for a field.
769
+ *
770
  * @param array $args
771
  *
772
  * @return string
780
  class scbSelectField extends scbSingleChoiceField {
781
 
782
  /**
783
+ * Generate the corresponding HTML for a field.
784
+ *
785
  * @param array $args
786
  *
787
  * @return string
831
  class scbRadiosField extends scbSelectField {
832
 
833
  /**
834
+ * Generate the corresponding HTML for a field.
835
+ *
836
  * @param array $args
837
  *
838
  * @return string
870
  class scbMultipleChoiceField extends scbFormField {
871
 
872
  /**
873
+ * Validates a value against a field.
874
+ *
875
  * @param mixed $value
876
  *
877
  * @return array
881
  }
882
 
883
  /**
884
+ * Generate the corresponding HTML for a field.
885
+ *
886
  * @param array $args
887
  *
888
  * @return string
893
  'checked' => null,
894
  ) );
895
 
896
+ if ( ! is_array( $args['checked'] ) ) {
897
  $args['checked'] = array();
898
+ }
899
 
900
  $opts = '';
901
  foreach ( $args['choices'] as $value => $title ) {
915
  }
916
 
917
  /**
918
+ * Sets value using a reference.
919
+ *
920
+ * @param array $args
921
+ * @param string $value
922
+ *
923
+ * @return void
924
  */
925
  protected function _set_value( &$args, $value ) {
926
  $args['checked'] = (array) $value;
933
  class scbSingleCheckboxField extends scbFormField {
934
 
935
  /**
936
+ * Validates a value against a field.
937
+ *
938
  * @param mixed $value
939
  *
940
  * @return boolean
944
  }
945
 
946
  /**
947
+ * Generate the corresponding HTML for a field.
948
+ *
949
  * @param array $args
950
  *
951
  * @return string
960
 
961
  $args['extra']['checked'] = $args['checked'];
962
 
963
+ if ( is_null( $args['desc'] ) && ! is_bool( $args['value'] ) ) {
964
  $args['desc'] = str_replace( '[]', '', $args['value'] );
965
+ }
966
 
967
  return scbFormField::_input_gen( $args );
968
  }
969
 
970
  /**
971
+ * Sets value using a reference.
972
+ *
973
+ * @param array $args
974
+ * @param string $value
975
+ *
976
+ * @return void
977
  */
978
  protected function _set_value( &$args, $value ) {
979
  $args['checked'] = ( $value || ( isset( $args['value'] ) && $value == $args['value'] ) );
988
  protected $args;
989
 
990
  /**
991
+ * Constructor.
992
+ *
993
  * @param array $args
994
+ *
995
+ * @return void
996
  */
997
  function __construct( $args ) {
998
  $this->args = wp_parse_args( $args, array(
1002
  }
1003
 
1004
  /**
1005
+ * Magic method: $field->arg
1006
+ *
1007
  * @param string $key
1008
  *
1009
  * @return mixed
1013
  }
1014
 
1015
  /**
1016
+ * Magic method: isset( $field->arg )
1017
+ *
1018
  * @param string $key
1019
  *
1020
  * @return boolean
1024
  }
1025
 
1026
  /**
1027
+ * Generate the corresponding HTML for a field.
1028
+ *
1029
+ * @param mixed $value (optional)
1030
  *
1031
  * @return string
1032
  */
1035
  }
1036
 
1037
  /**
1038
+ * Sanitizes value.
1039
+ *
1040
  * @param mixed $value
1041
  *
1042
  * @return mixed
scb/Hooks.php CHANGED
@@ -1,16 +1,40 @@
1
  <?php
2
-
 
 
3
  class scbHooks {
4
  private static $mangle_name;
5
 
 
 
 
 
 
 
 
6
  public static function add( $class ) {
7
  self::_do( 'add_filter', $class );
8
  }
9
 
 
 
 
 
 
 
 
10
  public static function remove( $class ) {
11
  self::_do( 'remove_filter', $class );
12
  }
13
 
 
 
 
 
 
 
 
 
14
  public static function debug( $class, $mangle_name = false ) {
15
  self::$mangle_name = $mangle_name;
16
 
@@ -19,15 +43,26 @@ class scbHooks {
19
  echo "</pre>";
20
  }
21
 
 
 
 
 
 
 
 
 
 
 
22
  private static function _print( $tag, $callback, $prio, $argc ) {
23
- $static = !is_object( $callback[0] );
24
 
25
- if ( self::$mangle_name )
26
  $class = $static ? '__CLASS__' : '$this';
27
- else if ( $static )
28
  $class = "'" . $callback[0] . "'";
29
- else
30
  $class = '$' . get_class( $callback[0] );
 
31
 
32
  $func = "array( $class, '$callback[1]' )";
33
 
@@ -36,18 +71,27 @@ class scbHooks {
36
  if ( $prio != 10 || $argc > 1 ) {
37
  echo ", $prio";
38
 
39
- if ( $argc > 1 )
40
  echo ", $argc";
 
41
  }
42
 
43
  echo " );\n";
44
  }
45
 
 
 
 
 
 
 
 
 
46
  private static function _do( $action, $class ) {
47
  $reflection = new ReflectionClass( $class );
48
 
49
  foreach ( $reflection->getMethods() as $method ) {
50
- if ( $method->isPublic() && !$method->isConstructor() ) {
51
  $comment = $method->getDocComment();
52
 
53
  if ( preg_match( '/@nohook[ \t\*\n]+/', $comment ) ) {
@@ -55,10 +99,11 @@ class scbHooks {
55
  }
56
 
57
  preg_match_all( '/@hook:?\s+([^\s]+)/', $comment, $matches ) ? $matches[1] : $method->name;
58
- if ( empty( $matches[1] ) )
59
  $hooks = array( $method->name );
60
- else
61
  $hooks = $matches[1];
 
62
 
63
  $priority = preg_match( '/@priority:?\s+(\d+)/', $comment, $matches ) ? $matches[1] : 10;
64
 
@@ -67,6 +112,8 @@ class scbHooks {
67
  }
68
  }
69
  }
 
70
  }
 
71
  }
72
 
1
  <?php
2
+ /**
3
+ * Automatic filter binding.
4
+ */
5
  class scbHooks {
6
  private static $mangle_name;
7
 
8
+ /**
9
+ * Adds.
10
+ *
11
+ * @param string $class
12
+ *
13
+ * @return void
14
+ */
15
  public static function add( $class ) {
16
  self::_do( 'add_filter', $class );
17
  }
18
 
19
+ /**
20
+ * Removes.
21
+ *
22
+ * @param string $class
23
+ *
24
+ * @return void
25
+ */
26
  public static function remove( $class ) {
27
  self::_do( 'remove_filter', $class );
28
  }
29
 
30
+ /**
31
+ * Prints debug.
32
+ *
33
+ * @param string $class
34
+ * @param string $mangle_name (optional)
35
+ *
36
+ * @return void
37
+ */
38
  public static function debug( $class, $mangle_name = false ) {
39
  self::$mangle_name = $mangle_name;
40
 
43
  echo "</pre>";
44
  }
45
 
46
+ /**
47
+ * Prints.
48
+ *
49
+ * @param string $tag
50
+ * @param array $callback
51
+ * @param int $prio
52
+ * @param int $argc
53
+ *
54
+ * @return void
55
+ */
56
  private static function _print( $tag, $callback, $prio, $argc ) {
57
+ $static = ! is_object( $callback[0] );
58
 
59
+ if ( self::$mangle_name ) {
60
  $class = $static ? '__CLASS__' : '$this';
61
+ } else if ( $static ) {
62
  $class = "'" . $callback[0] . "'";
63
+ } else {
64
  $class = '$' . get_class( $callback[0] );
65
+ }
66
 
67
  $func = "array( $class, '$callback[1]' )";
68
 
71
  if ( $prio != 10 || $argc > 1 ) {
72
  echo ", $prio";
73
 
74
+ if ( $argc > 1 ) {
75
  echo ", $argc";
76
+ }
77
  }
78
 
79
  echo " );\n";
80
  }
81
 
82
+ /**
83
+ * Processes.
84
+ *
85
+ * @param string $action
86
+ * @param string $class
87
+ *
88
+ * @return void
89
+ */
90
  private static function _do( $action, $class ) {
91
  $reflection = new ReflectionClass( $class );
92
 
93
  foreach ( $reflection->getMethods() as $method ) {
94
+ if ( $method->isPublic() && ! $method->isConstructor() ) {
95
  $comment = $method->getDocComment();
96
 
97
  if ( preg_match( '/@nohook[ \t\*\n]+/', $comment ) ) {
99
  }
100
 
101
  preg_match_all( '/@hook:?\s+([^\s]+)/', $comment, $matches ) ? $matches[1] : $method->name;
102
+ if ( empty( $matches[1] ) ) {
103
  $hooks = array( $method->name );
104
+ } else {
105
  $hooks = $matches[1];
106
+ }
107
 
108
  $priority = preg_match( '/@priority:?\s+(\d+)/', $comment, $matches ) ? $matches[1] : 10;
109
 
112
  }
113
  }
114
  }
115
+
116
  }
117
+
118
  }
119
 
scb/Options.php CHANGED
@@ -1,21 +1,35 @@
1
  <?php
2
-
3
- // Container for an array of options
4
-
5
  class scbOptions {
6
 
7
- protected $key; // the option name
 
 
 
 
8
 
9
- protected $defaults; // the default values
 
 
 
 
10
 
11
- public $wp_filter_id; // used by WP hooks
 
 
 
 
12
 
13
  /**
14
- * Create a new set of options
 
 
 
 
15
  *
16
- * @param string $key Option name
17
- * @param string $file Reference to main plugin file
18
- * @param array $defaults An associative array of default values (optional)
19
  */
20
  public function __construct( $key, $file, $defaults = array() ) {
21
  $this->key = $key;
@@ -28,17 +42,21 @@ class scbOptions {
28
  }
29
 
30
  /**
31
- * Get option name
 
 
32
  */
33
  public function get_key() {
34
  return $this->key;
35
  }
36
 
37
  /**
38
- * Get option values for one or all fields
 
 
 
39
  *
40
- * @param string|array $field The field to get
41
- * @return mixed Whatever is in those fields
42
  */
43
  public function get( $field = null, $default = null ) {
44
  $data = array_merge( $this->defaults, get_option( $this->key, array() ) );
@@ -47,67 +65,72 @@ class scbOptions {
47
  }
48
 
49
  /**
50
- * Get default values for one or all fields
 
 
51
  *
52
- * @param string|array $field The field to get
53
- * @return mixed Whatever is in those fields
54
  */
55
  public function get_defaults( $field = null ) {
56
  return scbForms::get_value( $field, $this->defaults );
57
  }
58
 
59
  /**
60
- * Set all data fields, certain fields or a single field
61
  *
62
- * @param string|array $field The field to update or an associative array
63
- * @param mixed $value The new value ( ignored if $field is array )
64
- * @return null
 
65
  */
66
  public function set( $field, $value = '' ) {
67
- if ( is_array( $field ) )
68
  $newdata = $field;
69
- else
70
  $newdata = array( $field => $value );
 
71
 
72
  $this->update( array_merge( $this->get(), $newdata ) );
73
  }
74
 
75
  /**
76
- * Reset option to defaults
77
  *
78
- * @return null
79
  */
80
  public function reset() {
81
  $this->update( $this->defaults, false );
82
  }
83
 
84
  /**
85
- * Remove any keys that are not in the defaults array
86
  *
87
- * @return bool
88
  */
89
  public function cleanup() {
90
  $this->update( $this->get(), true );
91
  }
92
 
93
  /**
94
- * Update raw data
95
  *
96
  * @param mixed $newdata
97
- * @param bool $clean wether to remove unrecognized keys or not
98
- * @return null
 
99
  */
100
  public function update( $newdata, $clean = true ) {
101
- if ( $clean )
102
  $newdata = $this->_clean( $newdata );
 
103
 
104
  update_option( $this->key, array_merge( $this->get(), $newdata ) );
105
  }
106
 
107
  /**
108
- * Delete the option
109
  *
110
- * @return null
111
  */
112
  public function delete() {
113
  delete_option( $this->key );
@@ -117,12 +140,22 @@ class scbOptions {
117
  //_____INTERNAL METHODS_____
118
 
119
 
120
- // Saves an extra query
121
- function _activation() {
 
 
 
 
122
  add_option( $this->key, $this->defaults );
123
  }
124
 
125
- // Keep only the keys defined in $this->defaults
 
 
 
 
 
 
126
  private function _clean( $data ) {
127
  return wp_array_slice_assoc( $data, array_keys( $this->defaults ) );
128
  }
@@ -130,20 +163,34 @@ class scbOptions {
130
  private function &_get( $field, $data ) {
131
  }
132
 
133
- // Magic method: $options->field
134
- function __get( $field ) {
 
 
 
 
 
 
135
  return $this->get( $field );
136
  }
137
 
138
- // Magic method: $options->field = $value
139
- function __set( $field, $value ) {
 
 
 
 
140
  $this->set( $field, $value );
141
  }
142
 
143
- // Magic method: isset( $options->field )
144
- function __isset( $field ) {
 
 
 
 
145
  $data = $this->get();
146
- return isset( $data[$field] );
147
  }
148
  }
149
 
1
  <?php
2
+ /**
3
+ * Container for an array of options.
4
+ */
5
  class scbOptions {
6
 
7
+ /**
8
+ * The option name.
9
+ * @var string
10
+ */
11
+ protected $key;
12
 
13
+ /**
14
+ * The default values.
15
+ * @var array
16
+ */
17
+ protected $defaults;
18
 
19
+ /**
20
+ * Used by WP hooks.
21
+ * @var null
22
+ */
23
+ public $wp_filter_id;
24
 
25
  /**
26
+ * Create a new set of options.
27
+ *
28
+ * @param string $key Option name.
29
+ * @param string $file Reference to main plugin file.
30
+ * @param array $defaults (optional) An associative array of default values.
31
  *
32
+ * @return void
 
 
33
  */
34
  public function __construct( $key, $file, $defaults = array() ) {
35
  $this->key = $key;
42
  }
43
 
44
  /**
45
+ * Returns option name.
46
+ *
47
+ * @return string
48
  */
49
  public function get_key() {
50
  return $this->key;
51
  }
52
 
53
  /**
54
+ * Get option values for one or all fields.
55
+ *
56
+ * @param string|array $field (optional) The field to get.
57
+ * @param mixed $default (optional) The value returned when the key is not found.
58
  *
59
+ * @return mixed Whatever is in those fields.
 
60
  */
61
  public function get( $field = null, $default = null ) {
62
  $data = array_merge( $this->defaults, get_option( $this->key, array() ) );
65
  }
66
 
67
  /**
68
+ * Get default values for one or all fields.
69
+ *
70
+ * @param string|array $field (optional) The field to get.
71
  *
72
+ * @return mixed Whatever is in those fields.
 
73
  */
74
  public function get_defaults( $field = null ) {
75
  return scbForms::get_value( $field, $this->defaults );
76
  }
77
 
78
  /**
79
+ * Set all data fields, certain fields or a single field.
80
  *
81
+ * @param string|array $field The field to update or an associative array.
82
+ * @param mixed $value (optional) The new value ( ignored if $field is array ).
83
+ *
84
+ * @return void
85
  */
86
  public function set( $field, $value = '' ) {
87
+ if ( is_array( $field ) ) {
88
  $newdata = $field;
89
+ } else {
90
  $newdata = array( $field => $value );
91
+ }
92
 
93
  $this->update( array_merge( $this->get(), $newdata ) );
94
  }
95
 
96
  /**
97
+ * Reset option to defaults.
98
  *
99
+ * @return void
100
  */
101
  public function reset() {
102
  $this->update( $this->defaults, false );
103
  }
104
 
105
  /**
106
+ * Remove any keys that are not in the defaults array.
107
  *
108
+ * @return void
109
  */
110
  public function cleanup() {
111
  $this->update( $this->get(), true );
112
  }
113
 
114
  /**
115
+ * Update raw data.
116
  *
117
  * @param mixed $newdata
118
+ * @param bool $clean (optional) Whether to remove unrecognized keys or not.
119
+ *
120
+ * @return void
121
  */
122
  public function update( $newdata, $clean = true ) {
123
+ if ( $clean ) {
124
  $newdata = $this->_clean( $newdata );
125
+ }
126
 
127
  update_option( $this->key, array_merge( $this->get(), $newdata ) );
128
  }
129
 
130
  /**
131
+ * Delete the option.
132
  *
133
+ * @return void
134
  */
135
  public function delete() {
136
  delete_option( $this->key );
140
  //_____INTERNAL METHODS_____
141
 
142
 
143
+ /**
144
+ * Saves an extra query.
145
+ *
146
+ * @return void
147
+ */
148
+ public function _activation() {
149
  add_option( $this->key, $this->defaults );
150
  }
151
 
152
+ /**
153
+ * Keep only the keys defined in $this->defaults
154
+ *
155
+ * @param array $data
156
+ *
157
+ * @return array
158
+ */
159
  private function _clean( $data ) {
160
  return wp_array_slice_assoc( $data, array_keys( $this->defaults ) );
161
  }
163
  private function &_get( $field, $data ) {
164
  }
165
 
166
+ /**
167
+ * Magic method: $options->field
168
+ *
169
+ * @param string|array $field The field to get.
170
+ *
171
+ * @return mixed
172
+ */
173
+ public function __get( $field ) {
174
  return $this->get( $field );
175
  }
176
 
177
+ /**
178
+ * Magic method: $options->field = $value
179
+ *
180
+ * @return void
181
+ */
182
+ public function __set( $field, $value ) {
183
  $this->set( $field, $value );
184
  }
185
 
186
+ /**
187
+ * Magic method: isset( $options->field )
188
+ *
189
+ * @return bool
190
+ */
191
+ public function __isset( $field ) {
192
  $data = $this->get();
193
+ return isset( $data[ $field ] );
194
  }
195
  }
196
 
scb/PostMetabox.php CHANGED
@@ -1,15 +1,48 @@
1
  <?php
2
-
 
 
3
  class scbPostMetabox {
4
 
5
- private $id, $title;
6
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  private $post_types;
8
 
 
 
 
 
9
  private $post_data = array();
10
 
 
 
 
 
11
  protected $actions = array( 'admin_enqueue_scripts', 'post_updated_messages' );
12
 
 
 
 
 
 
 
 
 
 
13
  public function __construct( $id, $title, $args = array() ) {
14
  $this->id = $id;
15
  $this->title = $title;
@@ -17,13 +50,14 @@ class scbPostMetabox {
17
  $args = wp_parse_args( $args, array(
18
  'post_type' => 'post',
19
  'context' => 'advanced',
20
- 'priority' => 'default'
21
  ) );
22
 
23
- if ( is_string( $args['post_type'] ) )
24
  $args['post_type'] = array( $args['post_type'] );
25
- $this->post_types = $args['post_type'];
26
 
 
27
  $this->context = $args['context'];
28
  $this->priority = $args['priority'];
29
 
@@ -31,42 +65,76 @@ class scbPostMetabox {
31
  add_action( 'load-post-new.php', array( $this, 'pre_register' ) );
32
  }
33
 
 
 
 
 
 
34
  final public function pre_register() {
35
- if ( ! in_array( get_current_screen()->post_type, $this->post_types ) )
36
  return;
 
37
 
38
- if ( ! $this->condition() )
39
  return;
 
40
 
41
- if ( isset( $_GET['post'] ) )
42
  $this->post_data = $this->get_meta( intval( $_GET['post'] ) );
 
43
 
44
  add_action( 'add_meta_boxes', array( $this, 'register' ) );
45
  add_action( 'save_post', array( $this, '_save_post' ), 10, 2 );
46
 
47
  foreach ( $this->actions as $action ) {
48
- if ( method_exists( $this, $action ) )
49
  add_action( $action, array( $this, $action ) );
 
50
  }
51
  }
52
 
53
- // Additional checks before registering the metabox
 
 
 
 
54
  protected function condition() {
55
  return true;
56
  }
57
 
 
 
 
 
 
58
  final public function register() {
59
  add_meta_box( $this->id, $this->title, array( $this, 'display' ), null, $this->context, $this->priority );
60
  }
61
 
 
 
 
 
 
 
 
 
62
  public function before_display( $form_data, $post ) {
63
  return $form_data;
64
  }
65
 
 
 
 
 
 
 
 
66
  public function display( $post ) {
67
  $form_fields = $this->form_fields();
68
- if ( ! $form_fields )
69
  return;
 
70
 
71
  $form_data = $this->post_data;
72
  $error_fields = array();
@@ -76,6 +144,8 @@ class scbPostMetabox {
76
 
77
  $error_fields = $data['fields'];
78
  $form_data = $data['data'];
 
 
79
  }
80
 
81
  $form_data = $this->before_display( $form_data, $post );
@@ -87,6 +157,15 @@ class scbPostMetabox {
87
  delete_post_meta( $post->ID, '_error_data_' . $this->id );
88
  }
89
 
 
 
 
 
 
 
 
 
 
90
  public function table( $rows, $formdata, $errors = array() ) {
91
  $output = '';
92
  foreach ( $rows as $row ) {
@@ -98,11 +177,20 @@ class scbPostMetabox {
98
  return $output;
99
  }
100
 
 
 
 
 
 
 
 
 
 
101
  public function table_row( $row, $formdata, $errors = array() ) {
102
  $input = scbForms::input( $row, $formdata );
103
 
104
  // If row has an error, highlight it
105
- $style = ( in_array( $row['name'], $errors ) ) ? 'style= "background-color: #FFCCCC"' : '';
106
 
107
  return html( 'tr',
108
  html( "th $style scope='row'", $row['title'] ),
@@ -110,31 +198,81 @@ class scbPostMetabox {
110
  );
111
  }
112
 
113
- // Display some extra HTML before the form
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  public function before_form( $post ) { }
115
 
116
- // Return the list of form fields
 
 
 
 
117
  public function form_fields() {
118
  return array();
119
  }
120
 
121
- // Display some extra HTML after the form
 
 
 
 
 
 
122
  public function after_form( $post ) { }
123
 
124
- // Makes sure that the saving occurs only for the post being edited
 
 
 
 
 
 
 
125
  final public function _save_post( $post_id, $post ) {
126
- if ( ! isset( $_POST['action'] ) || $_POST['action'] != 'editpost' )
127
  return;
 
128
 
129
- if ( $post_id != $_POST['post_ID'] )
130
  return;
 
131
 
132
- if ( ! in_array( $post->post_type, $this->post_types ) )
133
  return;
 
134
 
135
  $this->save( $post->ID );
136
  }
137
 
 
 
 
 
 
 
 
138
  protected function save( $post_id ) {
139
  $form_fields = $this->form_fields();
140
 
@@ -149,12 +287,13 @@ class scbPostMetabox {
149
 
150
  $error_data = array(
151
  'fields' => $is_valid->get_error_codes(),
152
- 'data' => $to_update
 
153
  );
154
  update_post_meta( $post_id, '_error_data_' . $this->id, $error_data );
155
 
156
  $location = add_query_arg( 'message', 1, get_edit_post_link( $post_id, 'url' ) );
157
- wp_redirect( apply_filters( 'redirect_post_location', $location, $post_id ) );
158
  exit;
159
  }
160
 
@@ -163,20 +302,45 @@ class scbPostMetabox {
163
  }
164
  }
165
 
 
 
 
 
 
 
 
 
166
  protected function before_save( $post_data, $post_id ) {
167
  return $post_data;
168
  }
169
 
 
 
 
 
 
 
 
 
170
  protected function validate_post_data( $post_data, $post_id ) {
171
  return false;
172
  }
173
 
 
 
 
 
 
 
 
174
  private function get_meta( $post_id ) {
175
  $meta = get_post_custom( $post_id );
176
- foreach ( $meta as $key => $values )
177
  $meta[ $key ] = maybe_unserialize( $meta[ $key ][0] );
 
178
 
179
  return $meta;
180
  }
 
181
  }
182
 
1
  <?php
2
+ /**
3
+ * Class that creates metaboxes on the post editing page.
4
+ */
5
  class scbPostMetabox {
6
 
7
+ /**
8
+ * Metabox ID.
9
+ * @var string
10
+ */
11
+ private $id;
12
+
13
+ /**
14
+ * Title.
15
+ * @var string
16
+ */
17
+ private $title;
18
+
19
+ /**
20
+ * Post types.
21
+ * @var array
22
+ */
23
  private $post_types;
24
 
25
+ /**
26
+ * Post meta data.
27
+ * @var array
28
+ */
29
  private $post_data = array();
30
 
31
+ /**
32
+ * Action hooks.
33
+ * @var array
34
+ */
35
  protected $actions = array( 'admin_enqueue_scripts', 'post_updated_messages' );
36
 
37
+ /**
38
+ * Sets up metabox.
39
+ *
40
+ * @param string $id
41
+ * @param string $title
42
+ * @param array $args (optional)
43
+ *
44
+ * @return void
45
+ */
46
  public function __construct( $id, $title, $args = array() ) {
47
  $this->id = $id;
48
  $this->title = $title;
50
  $args = wp_parse_args( $args, array(
51
  'post_type' => 'post',
52
  'context' => 'advanced',
53
+ 'priority' => 'default',
54
  ) );
55
 
56
+ if ( is_string( $args['post_type'] ) ) {
57
  $args['post_type'] = array( $args['post_type'] );
58
+ }
59
 
60
+ $this->post_types = $args['post_type'];
61
  $this->context = $args['context'];
62
  $this->priority = $args['priority'];
63
 
65
  add_action( 'load-post-new.php', array( $this, 'pre_register' ) );
66
  }
67
 
68
+ /**
69
+ * Pre register the metabox.
70
+ *
71
+ * @return void
72
+ */
73
  final public function pre_register() {
74
+ if ( ! in_array( get_current_screen()->post_type, $this->post_types ) ) {
75
  return;
76
+ }
77
 
78
+ if ( ! $this->condition() ) {
79
  return;
80
+ }
81
 
82
+ if ( isset( $_GET['post'] ) ) {
83
  $this->post_data = $this->get_meta( intval( $_GET['post'] ) );
84
+ }
85
 
86
  add_action( 'add_meta_boxes', array( $this, 'register' ) );
87
  add_action( 'save_post', array( $this, '_save_post' ), 10, 2 );
88
 
89
  foreach ( $this->actions as $action ) {
90
+ if ( method_exists( $this, $action ) ) {
91
  add_action( $action, array( $this, $action ) );
92
+ }
93
  }
94
  }
95
 
96
+ /**
97
+ * Additional checks before registering the metabox.
98
+ *
99
+ * @return bool
100
+ */
101
  protected function condition() {
102
  return true;
103
  }
104
 
105
+ /**
106
+ * Registers the metabox.
107
+ *
108
+ * @return void
109
+ */
110
  final public function register() {
111
  add_meta_box( $this->id, $this->title, array( $this, 'display' ), null, $this->context, $this->priority );
112
  }
113
 
114
+ /**
115
+ * Filter data before display.
116
+ *
117
+ * @param array $form_data
118
+ * @param object $post
119
+ *
120
+ * @return array
121
+ */
122
  public function before_display( $form_data, $post ) {
123
  return $form_data;
124
  }
125
 
126
+ /**
127
+ * Displays metabox content.
128
+ *
129
+ * @param object $post
130
+ *
131
+ * @return void
132
+ */
133
  public function display( $post ) {
134
  $form_fields = $this->form_fields();
135
+ if ( ! $form_fields ) {
136
  return;
137
+ }
138
 
139
  $form_data = $this->post_data;
140
  $error_fields = array();
144
 
145
  $error_fields = $data['fields'];
146
  $form_data = $data['data'];
147
+
148
+ $this->display_notices( $data['messages'], 'error' );
149
  }
150
 
151
  $form_data = $this->before_display( $form_data, $post );
157
  delete_post_meta( $post->ID, '_error_data_' . $this->id );
158
  }
159
 
160
+ /**
161
+ * Returns table.
162
+ *
163
+ * @param array $rows
164
+ * @param array $formdata
165
+ * @param array $errors (optional)
166
+ *
167
+ * @return string
168
+ */
169
  public function table( $rows, $formdata, $errors = array() ) {
170
  $output = '';
171
  foreach ( $rows as $row ) {
177
  return $output;
178
  }
179
 
180
+ /**
181
+ * Returns table row.
182
+ *
183
+ * @param array $row
184
+ * @param array $formdata
185
+ * @param array $errors (optional)
186
+ *
187
+ * @return string
188
+ */
189
  public function table_row( $row, $formdata, $errors = array() ) {
190
  $input = scbForms::input( $row, $formdata );
191
 
192
  // If row has an error, highlight it
193
+ $style = ( in_array( $row['name'], $errors ) ) ? 'style="background-color: #FFCCCC"' : '';
194
 
195
  return html( 'tr',
196
  html( "th $style scope='row'", $row['title'] ),
198
  );
199
  }
200
 
201
+ /**
202
+ * Displays notices.
203
+ *
204
+ * @param array|string $notices
205
+ * @param string $class (optional)
206
+ *
207
+ * @return void
208
+ */
209
+ public function display_notices( $notices, $class = 'updated' ) {
210
+ // add inline class so the notices stays in metabox
211
+ $class .= ' inline';
212
+
213
+ foreach ( (array) $notices as $notice ) {
214
+ echo scb_admin_notice( $notice, $class );
215
+ }
216
+ }
217
+
218
+ /**
219
+ * Display some extra HTML before the form.
220
+ *
221
+ * @param object $post
222
+ *
223
+ * @return void
224
+ */
225
  public function before_form( $post ) { }
226
 
227
+ /**
228
+ * Return an array of form fields.
229
+ *
230
+ * @return array
231
+ */
232
  public function form_fields() {
233
  return array();
234
  }
235
 
236
+ /**
237
+ * Display some extra HTML after the form.
238
+ *
239
+ * @param object $post
240
+ *
241
+ * @return void
242
+ */
243
  public function after_form( $post ) { }
244
 
245
+ /**
246
+ * Makes sure that the saving occurs only for the post being edited.
247
+ *
248
+ * @param int $post_id
249
+ * @param object $post
250
+ *
251
+ * @return void
252
+ */
253
  final public function _save_post( $post_id, $post ) {
254
+ if ( ! isset( $_POST['action'] ) || $_POST['action'] != 'editpost' ) {
255
  return;
256
+ }
257
 
258
+ if ( ! isset( $_POST['post_ID'] ) || $_POST['post_ID'] != $post_id ) {
259
  return;
260
+ }
261
 
262
+ if ( ! in_array( $post->post_type, $this->post_types ) ) {
263
  return;
264
+ }
265
 
266
  $this->save( $post->ID );
267
  }
268
 
269
+ /**
270
+ * Saves metabox form data.
271
+ *
272
+ * @param int $post_id
273
+ *
274
+ * @return void
275
+ */
276
  protected function save( $post_id ) {
277
  $form_fields = $this->form_fields();
278
 
287
 
288
  $error_data = array(
289
  'fields' => $is_valid->get_error_codes(),
290
+ 'messages' => $is_valid->get_error_messages(),
291
+ 'data' => $to_update,
292
  );
293
  update_post_meta( $post_id, '_error_data_' . $this->id, $error_data );
294
 
295
  $location = add_query_arg( 'message', 1, get_edit_post_link( $post_id, 'url' ) );
296
+ wp_redirect( esc_url_raw( apply_filters( 'redirect_post_location', $location, $post_id ) ) );
297
  exit;
298
  }
299
 
302
  }
303
  }
304
 
305
+ /**
306
+ * Filter data before save.
307
+ *
308
+ * @param array $post_data
309
+ * @param int $post_id
310
+ *
311
+ * @return array
312
+ */
313
  protected function before_save( $post_data, $post_id ) {
314
  return $post_data;
315
  }
316
 
317
+ /**
318
+ * Validate posted data.
319
+ *
320
+ * @param array $post_data
321
+ * @param int $post_id
322
+ *
323
+ * @return bool|object A WP_Error object if posted data are invalid.
324
+ */
325
  protected function validate_post_data( $post_data, $post_id ) {
326
  return false;
327
  }
328
 
329
+ /**
330
+ * Returns an array of post meta.
331
+ *
332
+ * @param int $post_id
333
+ *
334
+ * @return array
335
+ */
336
  private function get_meta( $post_id ) {
337
  $meta = get_post_custom( $post_id );
338
+ foreach ( $meta as $key => $values ) {
339
  $meta[ $key ] = maybe_unserialize( $meta[ $key ][0] );
340
+ }
341
 
342
  return $meta;
343
  }
344
+
345
  }
346
 
scb/Table.php CHANGED
@@ -1,13 +1,38 @@
1
  <?php
2
-
3
- // Takes care of creating, updating and deleting database tables
4
-
5
  class scbTable {
 
 
 
 
 
6
  protected $name;
 
 
 
 
 
7
  protected $columns;
 
 
 
 
 
8
  protected $upgrade_method;
9
 
10
- function __construct( $name, $file, $columns, $upgrade_method = 'dbDelta' ) {
 
 
 
 
 
 
 
 
 
 
11
  $this->name = $name;
12
  $this->columns = $columns;
13
  $this->upgrade_method = $upgrade_method;
@@ -20,11 +45,21 @@ class scbTable {
20
  }
21
  }
22
 
23
- function install() {
 
 
 
 
 
24
  scb_install_table( $this->name, $this->columns, $this->upgrade_method );
25
  }
26
 
27
- function uninstall() {
 
 
 
 
 
28
  scb_uninstall_table( $this->name );
29
  }
30
  }
1
  <?php
2
+ /**
3
+ * Takes care of creating, updating and deleting database tables.
4
+ */
5
  class scbTable {
6
+
7
+ /**
8
+ * The table name.
9
+ * @var string
10
+ */
11
  protected $name;
12
+
13
+ /**
14
+ * The table columns.
15
+ * @var string
16
+ */
17
  protected $columns;
18
+
19
+ /**
20
+ * The upgrade method.
21
+ * @var string
22
+ */
23
  protected $upgrade_method;
24
 
25
+ /**
26
+ * Sets up table.
27
+ *
28
+ * @param string $name Table name.
29
+ * @param string $file Reference to main plugin file.
30
+ * @param string $columns The SQL columns for the CREATE TABLE statement.
31
+ * @param array $upgrade_method (optional)
32
+ *
33
+ * @return void
34
+ */
35
+ public function __construct( $name, $file, $columns, $upgrade_method = 'dbDelta' ) {
36
  $this->name = $name;
37
  $this->columns = $columns;
38
  $this->upgrade_method = $upgrade_method;
45
  }
46
  }
47
 
48
+ /**
49
+ * Installs table.
50
+ *
51
+ * @return void
52
+ */
53
+ public function install() {
54
  scb_install_table( $this->name, $this->columns, $this->upgrade_method );
55
  }
56
 
57
+ /**
58
+ * Uninstalls table.
59
+ *
60
+ * @return void
61
+ */
62
+ public function uninstall() {
63
  scb_uninstall_table( $this->name );
64
  }
65
  }
scb/Util.php CHANGED
@@ -1,27 +1,41 @@
1
  <?php
2
-
3
- // Various utilities
4
-
5
  class scbUtil {
6
 
7
- // Force script enqueue
8
- static function do_scripts( $handles ) {
 
 
 
 
 
 
9
  global $wp_scripts;
10
 
11
- if ( ! is_a( $wp_scripts, 'WP_Scripts' ) )
12
  $wp_scripts = new WP_Scripts();
 
13
 
14
  $wp_scripts->do_items( ( array ) $handles );
15
  }
16
 
17
- // Force style enqueue
18
- static function do_styles( $handles ) {
 
 
 
 
 
 
19
  self::do_scripts( 'jquery' );
20
 
21
  global $wp_styles;
22
 
23
- if ( ! is_a( $wp_styles, 'WP_Styles' ) )
24
  $wp_styles = new WP_Styles();
 
25
 
26
  ob_start();
27
  $wp_styles->do_items( ( array ) $handles );
@@ -34,83 +48,173 @@ class scbUtil {
34
  echo "</script>";
35
  }
36
 
37
- // Enable delayed activation; to be used with scb_init()
38
- static function add_activation_hook( $plugin, $callback ) {
39
- if ( defined( 'SCB_LOAD_MU' ) )
 
 
 
 
 
 
 
40
  register_activation_hook( $plugin, $callback );
41
- else
42
  add_action( 'scb_activation_' . plugin_basename( $plugin ), $callback );
 
43
  }
44
 
45
- // For debugging
46
- static function do_activation( $plugin ) {
 
 
 
 
 
 
 
47
  do_action( 'scb_activation_' . plugin_basename( $plugin ) );
48
  }
49
 
50
- // Allows more than one uninstall hooks.
51
- // Also prevents an UPDATE query on each page load.
52
- static function add_uninstall_hook( $plugin, $callback ) {
53
- if ( !is_admin() )
 
 
 
 
 
 
 
54
  return;
 
55
 
56
  register_uninstall_hook( $plugin, '__return_false' ); // dummy
57
 
58
  add_action( 'uninstall_' . plugin_basename( $plugin ), $callback );
59
  }
60
 
61
- // For debugging
62
- static function do_uninstall( $plugin ) {
 
 
 
 
 
 
 
63
  do_action( 'uninstall_' . plugin_basename( $plugin ) );
64
  }
65
 
66
- // Get the current, full URL
67
- static function get_current_url() {
 
 
 
 
68
  return ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
69
  }
70
 
71
- // Apply a function to each element of a ( nested ) array recursively
72
- static function array_map_recursive( $callback, $array ) {
 
 
 
 
 
 
 
73
  array_walk_recursive( $array, array( __CLASS__, 'array_map_recursive_helper' ), $callback );
74
 
75
  return $array;
76
  }
77
 
78
- static function array_map_recursive_helper( &$val, $key, $callback ) {
79
  $val = call_user_func( $callback, $val );
80
  }
81
 
82
- // Extract certain $keys from $array
83
- static function array_extract( $array, $keys ) {
 
 
 
 
 
 
 
 
 
 
 
84
  _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'WP 3.1', 'wp_array_slice_assoc()' );
85
  return wp_array_slice_assoc( $array, $keys );
86
  }
87
 
88
- // Extract a certain value from a list of arrays
89
- static function array_pluck( $array, $key ) {
 
 
 
 
 
 
 
 
 
 
 
90
  _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'WP 3.1', 'wp_list_pluck()' );
91
  return wp_list_pluck( $array, $key );
92
  }
93
 
94
- // Transform a list of objects into an associative array
95
- static function objects_to_assoc( $objects, $key, $value ) {
 
 
 
 
 
 
 
 
 
 
 
 
96
  _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'r41', 'scb_list_fold()' );
97
  return scb_list_fold( $objects, $key, $value );
98
  }
99
 
100
- // Prepare an array for an IN statement
101
- static function array_to_sql( $values ) {
102
- foreach ( $values as &$val )
 
 
 
 
 
 
103
  $val = "'" . esc_sql( trim( $val ) ) . "'";
 
104
 
105
  return implode( ',', $values );
106
  }
107
 
108
- // Example: split_at( '</', '<a></a>' ) => array( '<a>', '</a>' )
109
- static function split_at( $delim, $str ) {
 
 
 
 
 
 
 
110
  $i = strpos( $str, $delim );
111
 
112
- if ( false === $i )
113
  return false;
 
114
 
115
  $start = substr( $str, 0, $i );
116
  $finish = substr( $str, $i );
@@ -119,21 +223,38 @@ class scbUtil {
119
  }
120
  }
121
 
122
- // Return a standard admin notice
 
 
 
 
 
 
 
123
  function scb_admin_notice( $msg, $class = 'updated' ) {
124
  return html( "div class='$class fade'", html( "p", $msg ) );
125
  }
126
 
127
- // Transform a list of objects into an associative array
 
 
 
 
 
 
 
 
128
  function scb_list_fold( $list, $key, $value ) {
129
  $r = array();
130
 
131
  if ( is_array( reset( $list ) ) ) {
132
- foreach ( $list as $item )
133
  $r[ $item[ $key ] ] = $item[ $value ];
 
134
  } else {
135
- foreach ( $list as $item )
136
  $r[ $item->$key ] = $item->$value;
 
137
  }
138
 
139
  return $r;
@@ -142,8 +263,10 @@ function scb_list_fold( $list, $key, $value ) {
142
  /**
143
  * Splits a list into sets, grouped by the result of running each value through $fn.
144
  *
145
- * @param array List of items to be partitioned
146
- * @param callback Function that takes an element and returns a string key
 
 
147
  */
148
  function scb_list_group_by( $list, $fn ) {
149
  $groups = array();
@@ -151,8 +274,9 @@ function scb_list_group_by( $list, $fn ) {
151
  foreach ( $list as $item ) {
152
  $key = call_user_func( $fn, $item );
153
 
154
- if ( null === $key )
155
  continue;
 
156
 
157
  $groups[ $key ][] = $item;
158
  }
@@ -163,27 +287,32 @@ function scb_list_group_by( $list, $fn ) {
163
  //_____Database Table Utilities_____
164
 
165
  /**
166
- * Register a table with $wpdb
167
  *
168
- * @param string $key The key to be used on the $wpdb object
169
- * @param string $name The actual name of the table, without $wpdb->prefix
 
 
170
  */
171
  function scb_register_table( $key, $name = false ) {
172
  global $wpdb;
173
 
174
- if ( !$name )
175
  $name = $key;
 
176
 
177
  $wpdb->tables[] = $name;
178
  $wpdb->$key = $wpdb->prefix . $name;
179
  }
180
 
181
  /**
182
- * Runs the SQL query for installing/upgrading a table
 
 
 
 
183
  *
184
- * @param string $key The key used in scb_register_table()
185
- * @param string $columns The SQL columns for the CREATE TABLE statement
186
- * @param array $opts Various other options
187
  */
188
  function scb_install_table( $key, $columns, $opts = array() ) {
189
  global $wpdb;
@@ -201,10 +330,12 @@ function scb_install_table( $key, $columns, $opts = array() ) {
201
 
202
  $charset_collate = '';
203
  if ( $wpdb->has_cap( 'collation' ) ) {
204
- if ( ! empty( $wpdb->charset ) )
205
  $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
206
- if ( ! empty( $wpdb->collate ) )
 
207
  $charset_collate .= " COLLATE $wpdb->collate";
 
208
  }
209
 
210
  $table_options = $charset_collate . ' ' . $opts['table_options'];
@@ -215,12 +346,20 @@ function scb_install_table( $key, $columns, $opts = array() ) {
215
  return;
216
  }
217
 
218
- if ( 'delete_first' == $opts['upgrade_method'] )
219
  $wpdb->query( "DROP TABLE IF EXISTS $full_table_name;" );
 
220
 
221
  $wpdb->query( "CREATE TABLE IF NOT EXISTS $full_table_name ( $columns ) $table_options;" );
222
  }
223
 
 
 
 
 
 
 
 
224
  function scb_uninstall_table( $key ) {
225
  global $wpdb;
226
 
@@ -231,6 +370,10 @@ function scb_uninstall_table( $key ) {
231
 
232
  /**
233
  * Generate an HTML tag. Atributes are escaped. Content is NOT escaped.
 
 
 
 
234
  */
235
  if ( ! function_exists( 'html' ) ):
236
  function html( $tag ) {
@@ -244,11 +387,13 @@ function html( $tag ) {
244
  $closing = $tag;
245
  $attributes = array_shift( $args );
246
  foreach ( $attributes as $key => $value ) {
247
- if ( false === $value )
248
  continue;
 
249
 
250
- if ( true === $value )
251
  $value = $key;
 
252
 
253
  $tag .= ' ' . $key . '="' . esc_attr( $value ) . '"';
254
  }
@@ -266,24 +411,41 @@ function html( $tag ) {
266
  }
267
  endif;
268
 
269
- // Generate an <a> tag
 
 
 
 
 
 
 
270
  if ( ! function_exists( 'html_link' ) ):
271
  function html_link( $url, $title = '' ) {
272
- if ( empty( $title ) )
273
  $title = $url;
 
274
 
275
- return html( 'a', array( 'href' => $url ), $title );
276
  }
277
  endif;
278
 
 
 
 
 
 
 
 
279
  function scb_get_query_flags( $wp_query = null ) {
280
- if ( !$wp_query )
281
  $wp_query = $GLOBALS['wp_query'];
 
282
 
283
  $flags = array();
284
  foreach ( get_object_vars( $wp_query ) as $key => $val ) {
285
- if ( 'is_' == substr( $key, 0, 3 ) && $val )
286
  $flags[] = substr( $key, 3 );
 
287
  }
288
 
289
  return $flags;
@@ -291,7 +453,16 @@ function scb_get_query_flags( $wp_query = null ) {
291
 
292
  //_____Compatibility layer_____
293
 
294
- // WP < ?
 
 
 
 
 
 
 
 
 
295
  if ( ! function_exists( 'set_post_field' ) ) :
296
  function set_post_field( $field, $value, $post_id ) {
297
  global $wpdb;
1
  <?php
2
+ /**
3
+ * Various utilities.
4
+ */
5
  class scbUtil {
6
 
7
+ /**
8
+ * Force script enqueue.
9
+ *
10
+ * @param array $handles
11
+ *
12
+ * @return void
13
+ */
14
+ public static function do_scripts( $handles ) {
15
  global $wp_scripts;
16
 
17
+ if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
18
  $wp_scripts = new WP_Scripts();
19
+ }
20
 
21
  $wp_scripts->do_items( ( array ) $handles );
22
  }
23
 
24
+ /**
25
+ * Force style enqueue.
26
+ *
27
+ * @param array $handles
28
+ *
29
+ * @return void
30
+ */
31
+ public static function do_styles( $handles ) {
32
  self::do_scripts( 'jquery' );
33
 
34
  global $wp_styles;
35
 
36
+ if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
37
  $wp_styles = new WP_Styles();
38
+ }
39
 
40
  ob_start();
41
  $wp_styles->do_items( ( array ) $handles );
48
  echo "</script>";
49
  }
50
 
51
+ /**
52
+ * Enable delayed plugin activation. To be used with scb_init()
53
+ *
54
+ * @param string $plugin
55
+ * @param string|array $callback
56
+ *
57
+ * @return void
58
+ */
59
+ public static function add_activation_hook( $plugin, $callback ) {
60
+ if ( defined( 'SCB_LOAD_MU' ) ) {
61
  register_activation_hook( $plugin, $callback );
62
+ } else {
63
  add_action( 'scb_activation_' . plugin_basename( $plugin ), $callback );
64
+ }
65
  }
66
 
67
+ /**
68
+ * Execute activation hook.
69
+ * For debugging.
70
+ *
71
+ * @param string $plugin
72
+ *
73
+ * @return void
74
+ */
75
+ public static function do_activation( $plugin ) {
76
  do_action( 'scb_activation_' . plugin_basename( $plugin ) );
77
  }
78
 
79
+ /**
80
+ * Allows more than one uninstall hooks.
81
+ * Also prevents an UPDATE query on each page load.
82
+ *
83
+ * @param string $plugin
84
+ * @param string|array $callback
85
+ *
86
+ * @return void
87
+ */
88
+ public static function add_uninstall_hook( $plugin, $callback ) {
89
+ if ( ! is_admin() ) {
90
  return;
91
+ }
92
 
93
  register_uninstall_hook( $plugin, '__return_false' ); // dummy
94
 
95
  add_action( 'uninstall_' . plugin_basename( $plugin ), $callback );
96
  }
97
 
98
+ /**
99
+ * Execute uninstall hook.
100
+ * For debugging.
101
+ *
102
+ * @param string $plugin
103
+ *
104
+ * @return void
105
+ */
106
+ public static function do_uninstall( $plugin ) {
107
  do_action( 'uninstall_' . plugin_basename( $plugin ) );
108
  }
109
 
110
+ /**
111
+ * Get the current, full URL.
112
+ *
113
+ * @return string
114
+ */
115
+ public static function get_current_url() {
116
  return ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
117
  }
118
 
119
+ /**
120
+ * Apply a function to each element of a ( nested ) array recursively.
121
+ *
122
+ * @param string|array $callback
123
+ * @param array $array
124
+ *
125
+ * @return array
126
+ */
127
+ public static function array_map_recursive( $callback, $array ) {
128
  array_walk_recursive( $array, array( __CLASS__, 'array_map_recursive_helper' ), $callback );
129
 
130
  return $array;
131
  }
132
 
133
+ public static function array_map_recursive_helper( &$val, $key, $callback ) {
134
  $val = call_user_func( $callback, $val );
135
  }
136
 
137
+ /**
138
+ * Extract certain $keys from $array.
139
+ *
140
+ * @deprecated WP 3.1
141
+ * @deprecated Use wp_array_slice_assoc()
142
+ * @see wp_array_slice_assoc()
143
+ *
144
+ * @param array $array
145
+ * @param array $keys
146
+ *
147
+ * @return array
148
+ */
149
+ public static function array_extract( $array, $keys ) {
150
  _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'WP 3.1', 'wp_array_slice_assoc()' );
151
  return wp_array_slice_assoc( $array, $keys );
152
  }
153
 
154
+ /**
155
+ * Extract a certain value from a list of arrays.
156
+ *
157
+ * @deprecated WP 3.1
158
+ * @deprecated Use wp_list_pluck()
159
+ * @see wp_list_pluck()
160
+ *
161
+ * @param array $array
162
+ * @param string $key
163
+ *
164
+ * @return array
165
+ */
166
+ public static function array_pluck( $array, $key ) {
167
  _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'WP 3.1', 'wp_list_pluck()' );
168
  return wp_list_pluck( $array, $key );
169
  }
170
 
171
+ /**
172
+ * Transform a list of objects into an associative array.
173
+ *
174
+ * @deprecated r41
175
+ * @deprecated Use scb_list_fold()
176
+ * @see scb_list_fold()
177
+ *
178
+ * @param array $objects
179
+ * @param string $key
180
+ * @param string $value
181
+ *
182
+ * @return array
183
+ */
184
+ public static function objects_to_assoc( $objects, $key, $value ) {
185
  _deprecated_function( __CLASS__ . '::' . __FUNCTION__, 'r41', 'scb_list_fold()' );
186
  return scb_list_fold( $objects, $key, $value );
187
  }
188
 
189
+ /**
190
+ * Prepare an array for an IN statement.
191
+ *
192
+ * @param array $values
193
+ *
194
+ * @return string
195
+ */
196
+ public static function array_to_sql( $values ) {
197
+ foreach ( $values as &$val ) {
198
  $val = "'" . esc_sql( trim( $val ) ) . "'";
199
+ }
200
 
201
  return implode( ',', $values );
202
  }
203
 
204
+ /**
205
+ * Example: split_at( '</', '<a></a>' ) => array( '<a>', '</a>' )
206
+ *
207
+ * @param string $delim
208
+ * @param string $str
209
+ *
210
+ * @return array
211
+ */
212
+ public static function split_at( $delim, $str ) {
213
  $i = strpos( $str, $delim );
214
 
215
+ if ( false === $i ) {
216
  return false;
217
+ }
218
 
219
  $start = substr( $str, 0, $i );
220
  $finish = substr( $str, $i );
223
  }
224
  }
225
 
226
+ /**
227
+ * Return a standard admin notice.
228
+ *
229
+ * @param string $msg
230
+ * @param string $class (optional)
231
+ *
232
+ * @return string
233
+ */
234
  function scb_admin_notice( $msg, $class = 'updated' ) {
235
  return html( "div class='$class fade'", html( "p", $msg ) );
236
  }
237
 
238
+ /**
239
+ * Transform a list of objects into an associative array.
240
+ *
241
+ * @param array $objects
242
+ * @param string $key
243
+ * @param string $value
244
+ *
245
+ * @return array
246
+ */
247
  function scb_list_fold( $list, $key, $value ) {
248
  $r = array();
249
 
250
  if ( is_array( reset( $list ) ) ) {
251
+ foreach ( $list as $item ) {
252
  $r[ $item[ $key ] ] = $item[ $value ];
253
+ }
254
  } else {
255
+ foreach ( $list as $item ) {
256
  $r[ $item->$key ] = $item->$value;
257
+ }
258
  }
259
 
260
  return $r;
263
  /**
264
  * Splits a list into sets, grouped by the result of running each value through $fn.
265
  *
266
+ * @param array $list List of items to be partitioned.
267
+ * @param callback $fn Function that takes an element and returns a string key.
268
+ *
269
+ * @return array
270
  */
271
  function scb_list_group_by( $list, $fn ) {
272
  $groups = array();
274
  foreach ( $list as $item ) {
275
  $key = call_user_func( $fn, $item );
276
 
277
+ if ( null === $key ) {
278
  continue;
279
+ }
280
 
281
  $groups[ $key ][] = $item;
282
  }
287
  //_____Database Table Utilities_____
288
 
289
  /**
290
+ * Register a table with $wpdb.
291
  *
292
+ * @param string $key The key to be used on the $wpdb object.
293
+ * @param string $name (optional) The actual name of the table, without $wpdb->prefix.
294
+ *
295
+ * @return void
296
  */
297
  function scb_register_table( $key, $name = false ) {
298
  global $wpdb;
299
 
300
+ if ( ! $name ) {
301
  $name = $key;
302
+ }
303
 
304
  $wpdb->tables[] = $name;
305
  $wpdb->$key = $wpdb->prefix . $name;
306
  }
307
 
308
  /**
309
+ * Runs the SQL query for installing/upgrading a table.
310
+ *
311
+ * @param string $key The key used in scb_register_table().
312
+ * @param string $columns The SQL columns for the CREATE TABLE statement.
313
+ * @param array $opts (optional) Various other options.
314
  *
315
+ * @return void
 
 
316
  */
317
  function scb_install_table( $key, $columns, $opts = array() ) {
318
  global $wpdb;
330
 
331
  $charset_collate = '';
332
  if ( $wpdb->has_cap( 'collation' ) ) {
333
+ if ( ! empty( $wpdb->charset ) ) {
334
  $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
335
+ }
336
+ if ( ! empty( $wpdb->collate ) ) {
337
  $charset_collate .= " COLLATE $wpdb->collate";
338
+ }
339
  }
340
 
341
  $table_options = $charset_collate . ' ' . $opts['table_options'];
346
  return;
347
  }
348
 
349
+ if ( 'delete_first' == $opts['upgrade_method'] ) {
350
  $wpdb->query( "DROP TABLE IF EXISTS $full_table_name;" );
351
+ }
352
 
353
  $wpdb->query( "CREATE TABLE IF NOT EXISTS $full_table_name ( $columns ) $table_options;" );
354
  }
355
 
356
+ /**
357
+ * Runs the SQL query for uninstalling a table.
358
+ *
359
+ * @param string $key The key used in scb_register_table().
360
+ *
361
+ * @return void
362
+ */
363
  function scb_uninstall_table( $key ) {
364
  global $wpdb;
365
 
370
 
371
  /**
372
  * Generate an HTML tag. Atributes are escaped. Content is NOT escaped.
373
+ *
374
+ * @param string $tag
375
+ *
376
+ * @return string
377
  */
378
  if ( ! function_exists( 'html' ) ):
379
  function html( $tag ) {
387
  $closing = $tag;
388
  $attributes = array_shift( $args );
389
  foreach ( $attributes as $key => $value ) {
390
+ if ( false === $value ) {
391
  continue;
392
+ }
393
 
394
+ if ( true === $value ) {
395
  $value = $key;
396
+ }
397
 
398
  $tag .= ' ' . $key . '="' . esc_attr( $value ) . '"';
399
  }
411
  }
412
  endif;
413
 
414
+ /**
415
+ * Generate an <a> tag.
416
+ *
417
+ * @param string $url
418
+ * @param string $title (optional)
419
+ *
420
+ * @return string
421
+ */
422
  if ( ! function_exists( 'html_link' ) ):
423
  function html_link( $url, $title = '' ) {
424
+ if ( empty( $title ) ) {
425
  $title = $url;
426
+ }
427
 
428
+ return html( 'a', array( 'href' => esc_url( $url ) ), $title );
429
  }
430
  endif;
431
 
432
+ /**
433
+ * Returns an array of query flags.
434
+ *
435
+ * @param object $wp_query (optional)
436
+ *
437
+ * @return array
438
+ */
439
  function scb_get_query_flags( $wp_query = null ) {
440
+ if ( ! $wp_query ) {
441
  $wp_query = $GLOBALS['wp_query'];
442
+ }
443
 
444
  $flags = array();
445
  foreach ( get_object_vars( $wp_query ) as $key => $val ) {
446
+ if ( 'is_' == substr( $key, 0, 3 ) && $val ) {
447
  $flags[] = substr( $key, 3 );
448
+ }
449
  }
450
 
451
  return $flags;
453
 
454
  //_____Compatibility layer_____
455
 
456
+ /**
457
+ * Update data from a post field based on Post ID.
458
+ * @see https://core.trac.wordpress.org/ticket/10946
459
+ *
460
+ * @param string $field Post field name.
461
+ * @param string $value Post field value.
462
+ * @param int $post_id Post ID.
463
+ *
464
+ * @return bool Result of UPDATE query.
465
+ */
466
  if ( ! function_exists( 'set_post_field' ) ) :
467
  function set_post_field( $field, $value, $post_id ) {
468
  global $wpdb;
scb/Widget.php CHANGED
@@ -1,29 +1,61 @@
1
  <?php
2
-
3
- // Adds compatibility methods between WP_Widget and scbForms
4
-
5
  abstract class scbWidget extends WP_Widget {
 
 
 
 
 
6
  protected $defaults = array();
7
 
 
 
 
 
8
  private static $scb_widgets = array();
9
 
10
- static function init( $class, $file = '', $base = '' ) {
 
 
 
 
 
 
 
 
 
11
  self::$scb_widgets[] = $class;
12
 
13
  add_action( 'widgets_init', array( __CLASS__, '_scb_register' ) );
14
 
15
  // for auto-uninstall
16
- if ( $file && $base && class_exists( 'scbOptions' ) )
17
  new scbOptions( "widget_$base", $file );
 
18
  }
19
 
20
- static function _scb_register() {
21
- foreach ( self::$scb_widgets as $widget )
 
 
 
 
 
22
  register_widget( $widget );
 
23
  }
24
 
25
- // A pre-filled method, for convenience
26
- function widget( $args, $instance ) {
 
 
 
 
 
 
 
27
  $instance = wp_parse_args( $instance, $this->defaults );
28
 
29
  extract( $args );
@@ -32,44 +64,61 @@ abstract class scbWidget extends WP_Widget {
32
 
33
  $title = apply_filters( 'widget_title', isset( $instance['title'] ) ? $instance['title'] : '', $instance, $this->id_base );
34
 
35
- if ( ! empty( $title ) )
36
  echo $before_title . $title . $after_title;
 
37
 
38
  $this->content( $instance );
39
 
40
  echo $after_widget;
41
  }
42
 
43
- // This is where the actual widget content goes
44
- function content( $instance ) {}
 
 
 
 
 
 
45
 
46
 
47
  //_____HELPER METHODS_____
48
 
49
 
50
- // See scbForms::input()
51
- // Allows extra parameter $args['title']
 
 
 
 
 
 
52
  protected function input( $args, $formdata = array() ) {
53
  $prefix = array( 'widget-' . $this->id_base, $this->number );
54
 
55
  $form = new scbForm( $formdata, $prefix );
56
 
57
  // Add default class
58
- if ( !isset( $args['extra'] ) && 'text' == $args['type'] )
59
  $args['extra'] = array( 'class' => 'widefat' );
 
60
 
61
  // Add default label position
62
- if ( !in_array( $args['type'], array( 'checkbox', 'radio' ) ) && empty( $args['desc_pos'] ) )
63
  $args['desc_pos'] = 'before';
 
64
 
65
  $name = $args['name'];
66
 
67
- if ( !is_array( $name ) && '[]' == substr( $name, -2 ) )
68
  $name = array( substr( $name, 0, -2 ), '' );
 
69
 
70
  $args['name'] = $name;
71
 
72
  return $form->input( $args );
73
  }
 
74
  }
75
 
1
  <?php
2
+ /**
3
+ * Adds compatibility methods between WP_Widget and scbForms.
4
+ */
5
  abstract class scbWidget extends WP_Widget {
6
+
7
+ /**
8
+ * Widget defaults.
9
+ * @var array
10
+ */
11
  protected $defaults = array();
12
 
13
+ /**
14
+ * Widgets to register.
15
+ * @var array
16
+ */
17
  private static $scb_widgets = array();
18
 
19
+ /**
20
+ * Initializes widget.
21
+ *
22
+ * @param string $class
23
+ * @param string $file (optional)
24
+ * @param string $base (optional)
25
+ *
26
+ * @return void
27
+ */
28
+ public static function init( $class, $file = '', $base = '' ) {
29
  self::$scb_widgets[] = $class;
30
 
31
  add_action( 'widgets_init', array( __CLASS__, '_scb_register' ) );
32
 
33
  // for auto-uninstall
34
+ if ( $file && $base && class_exists( 'scbOptions' ) ) {
35
  new scbOptions( "widget_$base", $file );
36
+ }
37
  }
38
 
39
+ /**
40
+ * Registers widgets.
41
+ *
42
+ * @return void
43
+ */
44
+ public static function _scb_register() {
45
+ foreach ( self::$scb_widgets as $widget ) {
46
  register_widget( $widget );
47
+ }
48
  }
49
 
50
+ /**
51
+ * Displays widget content.
52
+ *
53
+ * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
54
+ * @param array $instance The settings for the particular instance of the widget.
55
+ *
56
+ * @return void
57
+ */
58
+ public function widget( $args, $instance ) {
59
  $instance = wp_parse_args( $instance, $this->defaults );
60
 
61
  extract( $args );
64
 
65
  $title = apply_filters( 'widget_title', isset( $instance['title'] ) ? $instance['title'] : '', $instance, $this->id_base );
66
 
67
+ if ( ! empty( $title ) ) {
68
  echo $before_title . $title . $after_title;
69
+ }
70
 
71
  $this->content( $instance );
72
 
73
  echo $after_widget;
74
  }
75
 
76
+ /**
77
+ * This is where the actual widget content goes.
78
+ *
79
+ * @param array $instance The settings for the particular instance of the widget.
80
+ *
81
+ * @return void
82
+ */
83
+ protected function content( $instance ) { }
84
 
85
 
86
  //_____HELPER METHODS_____
87
 
88
 
89
+ /**
90
+ * Generates a input form field.
91
+ *
92
+ * @param array $args
93
+ * @param array $formdata (optional)
94
+ *
95
+ * @return string
96
+ */
97
  protected function input( $args, $formdata = array() ) {
98
  $prefix = array( 'widget-' . $this->id_base, $this->number );
99
 
100
  $form = new scbForm( $formdata, $prefix );
101
 
102
  // Add default class
103
+ if ( ! isset( $args['extra'] ) && 'text' == $args['type'] ) {
104
  $args['extra'] = array( 'class' => 'widefat' );
105
+ }
106
 
107
  // Add default label position
108
+ if ( ! in_array( $args['type'], array( 'checkbox', 'radio' ) ) && empty( $args['desc_pos'] ) ) {
109
  $args['desc_pos'] = 'before';
110
+ }
111
 
112
  $name = $args['name'];
113
 
114
+ if ( ! is_array( $name ) && '[]' == substr( $name, -2 ) ) {
115
  $name = array( substr( $name, 0, -2 ), '' );
116
+ }
117
 
118
  $args['name'] = $name;
119
 
120
  return $form->input( $args );
121
  }
122
+
123
  }
124
 
scb/load-composer.php CHANGED
@@ -6,6 +6,7 @@
6
  * @param callable $callback
7
  */
8
  function scb_init( $callback = null ) {
9
- if ( $callback )
10
  call_user_func( $callback );
11
- }
 
6
  * @param callable $callback
7
  */
8
  function scb_init( $callback = null ) {
9
+ if ( $callback ) {
10
  call_user_func( $callback );
11
+ }
12
+ }
scb/load.php CHANGED
@@ -1,12 +1,19 @@
1
  <?php
2
 
3
  $GLOBALS['_scb_data'] = array( 60, __FILE__, array(
4
- 'scbUtil', 'scbOptions', 'scbForms', 'scbTable',
5
- 'scbWidget', 'scbAdminPage', 'scbBoxesPage', 'scbPostMetabox',
6
- 'scbCron', 'scbHooks',
 
 
 
 
 
 
 
7
  ) );
8
 
9
- if ( !class_exists( 'scbLoad4' ) ) :
10
  /**
11
  * The main idea behind this class is to load the most recent version of the scb classes available.
12
  *
@@ -23,26 +30,28 @@ class scbLoad4 {
23
  static function init( $callback = '' ) {
24
  list( $rev, $file, $classes ) = $GLOBALS['_scb_data'];
25
 
26
- self::$candidates[$file] = $rev;
27
- self::$classes[$file] = $classes;
28
 
29
- if ( !empty( $callback ) ) {
30
- self::$callbacks[$file] = $callback;
31
 
32
  add_action( 'activate_plugin', array( __CLASS__, 'delayed_activation' ) );
33
  }
34
 
35
- if ( did_action( 'plugins_loaded' ) )
36
  self::load();
37
- else
38
  add_action( 'plugins_loaded', array( __CLASS__, 'load' ), 9, 0 );
 
39
  }
40
 
41
- static function delayed_activation( $plugin ) {
42
  $plugin_dir = dirname( $plugin );
43
 
44
- if ( '.' == $plugin_dir )
45
  return;
 
46
 
47
  foreach ( self::$callbacks as $file => $callback ) {
48
  if ( dirname( dirname( plugin_basename( $file ) ) ) == $plugin_dir ) {
@@ -54,16 +63,17 @@ class scbLoad4 {
54
  }
55
  }
56
 
57
- static function load( $do_callbacks = true ) {
58
  arsort( self::$candidates );
59
 
60
  $file = key( self::$candidates );
61
 
62
  $path = dirname( $file ) . '/';
63
 
64
- foreach ( self::$classes[$file] as $class_name ) {
65
- if ( class_exists( $class_name ) )
66
  continue;
 
67
 
68
  $fpath = $path . substr( $class_name, 3 ) . '.php';
69
  if ( file_exists( $fpath ) ) {
@@ -72,9 +82,11 @@ class scbLoad4 {
72
  }
73
  }
74
 
75
- if ( $do_callbacks )
76
- foreach ( self::$callbacks as $callback )
77
  call_user_func( $callback );
 
 
78
  }
79
 
80
  static function get_info() {
@@ -85,7 +97,7 @@ class scbLoad4 {
85
  }
86
  endif;
87
 
88
- if ( !function_exists( 'scb_init' ) ) :
89
  function scb_init( $callback = '' ) {
90
  scbLoad4::init( $callback );
91
  }
1
  <?php
2
 
3
  $GLOBALS['_scb_data'] = array( 60, __FILE__, array(
4
+ 'scbUtil',
5
+ 'scbOptions',
6
+ 'scbForms',
7
+ 'scbTable',
8
+ 'scbWidget',
9
+ 'scbAdminPage',
10
+ 'scbBoxesPage',
11
+ 'scbPostMetabox',
12
+ 'scbCron',
13
+ 'scbHooks',
14
  ) );
15
 
16
+ if ( ! class_exists( 'scbLoad4' ) ) :
17
  /**
18
  * The main idea behind this class is to load the most recent version of the scb classes available.
19
  *
30
  static function init( $callback = '' ) {
31
  list( $rev, $file, $classes ) = $GLOBALS['_scb_data'];
32
 
33
+ self::$candidates[ $file ] = $rev;
34
+ self::$classes[ $file ] = $classes;
35
 
36
+ if ( ! empty( $callback ) ) {
37
+ self::$callbacks[ $file ] = $callback;
38
 
39
  add_action( 'activate_plugin', array( __CLASS__, 'delayed_activation' ) );
40
  }
41
 
42
+ if ( did_action( 'plugins_loaded' ) ) {
43
  self::load();
44
+ } else {
45
  add_action( 'plugins_loaded', array( __CLASS__, 'load' ), 9, 0 );
46
+ }
47
  }
48
 
49
+ public static function delayed_activation( $plugin ) {
50
  $plugin_dir = dirname( $plugin );
51
 
52
+ if ( '.' == $plugin_dir ) {
53
  return;
54
+ }
55
 
56
  foreach ( self::$callbacks as $file => $callback ) {
57
  if ( dirname( dirname( plugin_basename( $file ) ) ) == $plugin_dir ) {
63
  }
64
  }
65
 
66
+ public static function load( $do_callbacks = true ) {
67
  arsort( self::$candidates );
68
 
69
  $file = key( self::$candidates );
70
 
71
  $path = dirname( $file ) . '/';
72
 
73
+ foreach ( self::$classes[ $file ] as $class_name ) {
74
+ if ( class_exists( $class_name ) ) {
75
  continue;
76
+ }
77
 
78
  $fpath = $path . substr( $class_name, 3 ) . '.php';
79
  if ( file_exists( $fpath ) ) {
82
  }
83
  }
84
 
85
+ if ( $do_callbacks ) {
86
+ foreach ( self::$callbacks as $callback ) {
87
  call_user_func( $callback );
88
+ }
89
+ }
90
  }
91
 
92
  static function get_info() {
97
  }
98
  endif;
99
 
100
+ if ( ! function_exists( 'scb_init' ) ) :
101
  function scb_init( $callback = '' ) {
102
  scbLoad4::init( $callback );
103
  }
widget.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
 
3
  class UserOnline_Widget extends scbWidget {
4
- function UserOnline_Widget() {
5
  $widget_ops = array( 'description' => __( 'WP-UserOnline users online statistics', 'wp-useronline' ) );
6
- $this->WP_Widget( 'useronline', __( 'UserOnline', 'wp-useronline' ), $widget_ops );
7
  }
8
 
9
  function content( $instance ) {
1
  <?php
2
 
3
  class UserOnline_Widget extends scbWidget {
4
+ function __construct() {
5
  $widget_ops = array( 'description' => __( 'WP-UserOnline users online statistics', 'wp-useronline' ) );
6
+ parent::__construct( 'useronline', __( 'UserOnline', 'wp-useronline' ), $widget_ops );
7
  }
8
 
9
  function content( $instance ) {
wp-useronline.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP-UserOnline
4
  Plugin URI: http://lesterchan.net/portfolio/programming/php/
5
  Description: Enable you to display how many users are online on your Wordpress site
6
- Version: 2.85
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: http://lesterchan.net
9
  Text Domain: wp-useronline
3
  Plugin Name: WP-UserOnline
4
  Plugin URI: http://lesterchan.net/portfolio/programming/php/
5
  Description: Enable you to display how many users are online on your Wordpress site
6
+ Version: 2.86
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: http://lesterchan.net
9
  Text Domain: wp-useronline