|
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
|
|
|
* @package Subway |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace Subway; |
|
14
|
|
|
|
|
15
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
|
16
|
|
|
return; |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Class Subway\Options handles basic 'get' of options saved in our settings page. |
|
21
|
|
|
* |
|
22
|
|
|
* @since 2.0 |
|
23
|
|
|
*/ |
|
24
|
|
|
final class Options { |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Get the redirect page url. |
|
28
|
|
|
* |
|
29
|
|
|
* @return mixed The redirect url of our settings. Otherwise, false. |
|
30
|
|
|
*/ |
|
31
|
|
|
public static function get_redirect_page_url() { |
|
32
|
|
|
|
|
33
|
|
|
$selected_login_post_id = intval( get_option( 'subway_login_page' ) ); |
|
34
|
|
|
|
|
35
|
|
|
if ( 0 === $selected_login_post_id ) { |
|
36
|
|
|
|
|
37
|
|
|
return; |
|
38
|
|
|
|
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
$login_post = get_post( $selected_login_post_id ); |
|
42
|
|
|
|
|
43
|
|
|
if ( ! empty( $login_post ) ) { |
|
44
|
|
|
|
|
45
|
|
|
return trailingslashit( get_permalink( $login_post->ID ) ); |
|
46
|
|
|
|
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
return false; |
|
50
|
|
|
|
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Fetches the public post ids. |
|
55
|
|
|
* |
|
56
|
|
|
* @return array The collection of public 'post' IDs. |
|
57
|
|
|
*/ |
|
58
|
|
|
public static function get_public_post_ids() { |
|
59
|
|
|
|
|
60
|
|
|
$subway_public_post = get_option( 'subway_public_post' ); |
|
61
|
|
|
|
|
62
|
|
|
$excluded_pages_collection = array(); |
|
63
|
|
|
|
|
64
|
|
|
if ( ! empty( $subway_public_post ) ) { |
|
65
|
|
|
|
|
66
|
|
|
$excluded_pages_collection = explode( ',', $subway_public_post ); |
|
67
|
|
|
|
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
// Should filter it by integer, spaces will be ignored, other strings. |
|
71
|
|
|
// Will be converted to zero '0'. |
|
72
|
|
|
return array_filter( array_map( 'intval', $excluded_pages_collection ) ); |
|
73
|
|
|
|
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Check if site is public or not. |
|
78
|
|
|
* |
|
79
|
|
|
* @return boolean True on success. Otherwise, false. |
|
80
|
|
|
*/ |
|
81
|
|
|
public static function is_public_site() { |
|
82
|
|
|
|
|
83
|
|
|
$subway_public_post = get_option( 'subway_is_public' ); |
|
84
|
|
|
|
|
85
|
|
|
if ( ! empty ( $subway_public_post ) ) { |
|
86
|
|
|
|
|
87
|
|
|
return true; |
|
88
|
|
|
|
|
89
|
|
|
} |
|
90
|
|
|
return false; |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|