|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the Subway WordPress Plugin Package. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Joseph Gabito <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
* |
|
10
|
|
|
* PHP Version 5.4 |
|
11
|
|
|
* |
|
12
|
|
|
* @category Subway\Options |
|
13
|
|
|
* @package Subway |
|
14
|
|
|
* @author Joseph G. <[email protected]> |
|
15
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
|
16
|
|
|
* @version GIT:github.com/codehaiku/subway |
|
17
|
|
|
* @link github.com/codehaiku/subway The Plugin Repository |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
namespace Subway; |
|
21
|
|
|
|
|
22
|
|
|
if (! defined('ABSPATH') ) { |
|
23
|
|
|
return; |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Subway Option Methods. |
|
28
|
|
|
* |
|
29
|
|
|
* @category Subway\Options |
|
30
|
|
|
* @package Subway |
|
31
|
|
|
* @author Joseph G. <[email protected]> |
|
32
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
|
33
|
|
|
* @link github.com/codehaiku/subway The Plugin Repository |
|
34
|
|
|
* @since 1.0 |
|
35
|
|
|
*/ |
|
36
|
|
|
final class Options |
|
37
|
|
|
{ |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Get the redirect page url. |
|
41
|
|
|
* |
|
42
|
|
|
* @return mixed The redirect url of our settings. Otherwise, false. |
|
43
|
|
|
*/ |
|
44
|
|
|
public static function getRedirectPageUrl() |
|
45
|
|
|
{ |
|
46
|
|
|
|
|
47
|
|
|
$selected_login_post_id = intval(get_option('subway_login_page')); |
|
48
|
|
|
|
|
49
|
|
|
if (0 === $selected_login_post_id ) { |
|
50
|
|
|
|
|
51
|
|
|
return; |
|
52
|
|
|
|
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
$login_post = get_post($selected_login_post_id); |
|
56
|
|
|
|
|
57
|
|
|
if (! empty($login_post) ) { |
|
58
|
|
|
|
|
59
|
|
|
return trailingslashit(get_permalink($login_post->ID)); |
|
60
|
|
|
|
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
return false; |
|
64
|
|
|
|
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Fetches the public post ids. |
|
69
|
|
|
* |
|
70
|
|
|
* @return array The collection of public 'post' IDs. |
|
71
|
|
|
*/ |
|
72
|
|
|
public static function getPublicPostsIdentifiers() |
|
73
|
|
|
{ |
|
74
|
|
|
|
|
75
|
|
|
$subway_public_post = get_option('subway_public_post'); |
|
76
|
|
|
|
|
77
|
|
|
$excluded_pages_collection = array(); |
|
78
|
|
|
|
|
79
|
|
|
if (! empty($subway_public_post) ) { |
|
80
|
|
|
|
|
81
|
|
|
$excluded_pages_collection = explode(',', $subway_public_post); |
|
82
|
|
|
|
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
// Should filter it by integer, spaces will be ignored, other strings. |
|
86
|
|
|
// Will be converted to zero '0'. |
|
87
|
|
|
return array_filter(array_map('intval', $excluded_pages_collection)); |
|
88
|
|
|
|
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Check if site is public or not. |
|
93
|
|
|
* |
|
94
|
|
|
* @return boolean True on success. Otherwise, false. |
|
95
|
|
|
*/ |
|
96
|
|
|
public static function isPublicSite() |
|
97
|
|
|
{ |
|
98
|
|
|
|
|
99
|
|
|
$subway_public_post = get_option('subway_is_public'); |
|
100
|
|
|
|
|
101
|
|
|
if (! empty($subway_public_post) ) { |
|
102
|
|
|
|
|
103
|
|
|
return true; |
|
104
|
|
|
|
|
105
|
|
|
} |
|
106
|
|
|
return false; |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
|