PluginProbe ʕ •ᴥ•ʔ
Nested Pages / 1.3.4
Nested Pages v1.3.4
3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 trunk 1.0 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.3.0 1.3.1 1.3.10 1.3.11 1.3.12 1.3.13 1.3.14 1.3.15 1.3.2 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.3.1 1.6.3.2 1.6.4 1.6.5 1.6.5.1 1.6.5.2 1.6.6 1.6.7 1.6.8 1.7.0 1.7.1 2.0.1 2.0.2 2.0.3 2.0.4 3.0.1 3.0.10 3.0.11 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.20 3.1.21 3.1.22 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7
wp-nested-pages / app / Form / Handlers / ListingSortHandler.php
wp-nested-pages / app / Form / Handlers Last commit date
BaseHandler.php 11 years ago EmptyTrashHandler.php 11 years ago GetTaxonomiesHandler.php 11 years ago ListingSortHandler.php 11 years ago NestToggleHandler.php 11 years ago NewChildHandler.php 11 years ago NewLinkHandler.php 11 years ago QuickEditHandler.php 11 years ago QuickEditLinkHandler.php 11 years ago SearchHandler.php 11 years ago SortHandler.php 11 years ago SyncMenuHandler.php 11 years ago
ListingSortHandler.php
74 lines
1 <?php namespace NestedPages\Form\Handlers;
2 /**
3 * Redirect to Listing with Specified Sorting Options Applied
4 */
5 class ListingSortHandler {
6
7 /**
8 * URL to redirect to
9 * @var string
10 */
11 private $url;
12
13
14 public function __construct()
15 {
16 $this->setURL();
17 $this->redirect();
18 }
19
20
21 /**
22 * Build the URL to Redirect to
23 */
24 private function setURL()
25 {
26 $this->url = sanitize_text_field($_POST['page']);
27 $this->setOrderBy();
28 $this->setOrder();
29 $this->setAuthor();
30 }
31
32
33 /**
34 * Set Order by parameters
35 */
36 private function setOrderBy()
37 {
38 $allowed = array('menu_order', 'date', 'title'); // prevent tomfoolery
39 if ( ($_POST['np_orderby'] !== "") && (!in_array($_POST['np_orderby'], $allowed)) ) $this->url .= '&orderby=menu_order';
40 $this->url .= '&orderby=' . sanitize_text_field($_POST['np_orderby']);
41 }
42
43
44 /**
45 * Set Order parameters
46 */
47 private function setOrder()
48 {
49 $allowed = array('ASC', 'DESC'); // prevent tomfoolery
50 if ( !in_array($_POST['np_order'], $allowed) ) $this->url .= '&order=DESC';
51 $this->url .= '&order=' . sanitize_text_field($_POST['np_order']);
52 }
53
54
55 /**
56 * Set Author parameters
57 */
58 private function setAuthor()
59 {
60 if ( (isset($_POST['np_author'])) && ($_POST['np_author'] !== "") ){
61 $this->url .= '&author=' . sanitize_text_field($_POST['np_author']);
62 }
63 }
64
65
66 /**
67 * Redirect to new URL
68 */
69 private function redirect()
70 {
71 header('Location:' . $this->url);
72 }
73
74 }