1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Auto Load Next Post Settings - Misc |
4
|
|
|
* |
5
|
|
|
* @since 1.5.0 |
6
|
|
|
* @version 1.6.0 |
7
|
|
|
* @author Sébastien Dumont |
8
|
|
|
* @category Admin |
9
|
|
|
* @package Auto Load Next Post/Admin/Settings |
10
|
|
|
* @license GPL-2.0+ |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
// Exit if accessed directly. |
14
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
15
|
|
|
exit; |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
if ( ! class_exists( 'ALNP_Settings_Misc' ) ) { |
19
|
|
|
|
20
|
|
|
class ALNP_Settings_Misc extends ALNP_Settings_Page { |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Constructor. |
24
|
|
|
* |
25
|
|
|
* @access public |
26
|
|
|
* @since 1.5.0 |
27
|
|
|
* @version 1.5.5 |
28
|
|
|
*/ |
29
|
|
View Code Duplication |
public function __construct() { |
30
|
|
|
$this->id = 'misc'; |
31
|
|
|
$this->label = esc_html__( 'Misc', 'auto-load-next-post' ); |
32
|
|
|
|
33
|
|
|
parent::__construct(); |
34
|
|
|
|
35
|
|
|
add_filter( 'auto_load_next_post_misc_settings', array( __CLASS__, 'lock_js_in_footer' ), 0, 1 ); |
36
|
|
|
add_action( 'auto_load_next_post_settings_misc', array( __CLASS__, 'no_comment_selector_set' ), 0 ); |
37
|
|
|
} // END __construct() |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* This notifies the user if the comment selector is NOT set. |
41
|
|
|
* |
42
|
|
|
* @access public |
43
|
|
|
* @static |
44
|
|
|
* @since 1.5.0 |
45
|
|
|
*/ |
46
|
|
|
public static function no_comment_selector_set() { |
47
|
|
|
$comments_container = get_option( 'auto_load_next_post_comments_container' ); |
48
|
|
|
$remove_comments = get_option( 'auto_load_next_post_remove_comments' ); |
49
|
|
|
|
50
|
|
|
if ( empty( $comments_container ) && ! empty( $remove_comments ) ) { |
51
|
|
|
include( dirname( AUTO_LOAD_NEXT_POST_FILE ) . '/includes/admin/views/html-notice-no-comment-selector.php' ); |
52
|
|
|
} |
53
|
|
|
} // END no_comment_selector_set() |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Checks if the theme locked the JavaScript to load in the footer |
57
|
|
|
* and filters the settings to remove the option so it can not |
58
|
|
|
* be unset by the user. |
59
|
|
|
* |
60
|
|
|
* @access public |
61
|
|
|
* @static |
62
|
|
|
* @since 1.5.0 |
63
|
|
|
* @version 1.5.3 |
64
|
|
|
* @param array $settings |
65
|
|
|
* @return array $settings |
66
|
|
|
*/ |
67
|
|
|
public static function lock_js_in_footer( $settings ) { |
68
|
|
|
$js_locked_in_footer = get_option( 'auto_load_next_post_lock_js_in_footer' ); |
69
|
|
|
|
70
|
|
|
if ( ! empty( $js_locked_in_footer ) && $js_locked_in_footer == 'yes' ) { |
71
|
|
|
// Setting key to look for. |
72
|
|
|
$key = 'load_js_in_footer'; |
73
|
|
|
|
74
|
|
|
// Find the setting. |
75
|
|
|
$find_setting = array_search( $key, $settings ); |
76
|
|
|
|
77
|
|
|
// Does the setting exist? |
78
|
|
|
if ( is_bool( $find_setting ) === true ) { |
79
|
|
|
unset( $settings[$key] ); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
return $settings; |
84
|
|
|
} // END lock_js_in_footer() |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Get settings array |
88
|
|
|
* |
89
|
|
|
* @access public |
90
|
|
|
* @since 1.5.0 |
91
|
|
|
* @version 1.6.0 |
92
|
|
|
* @return array |
93
|
|
|
*/ |
94
|
|
|
public function get_settings() { |
95
|
|
|
return apply_filters( |
96
|
|
|
'alnp_misc_settings', array( |
97
|
|
|
|
98
|
|
|
'title' => array( |
99
|
|
|
'title' => $this->label, |
100
|
|
|
'type' => 'title', |
101
|
|
|
'desc' => esc_html__( 'Further optional options can be found here should you want to use or need.', 'auto-load-next-post' ), |
102
|
|
|
'id' => 'misc_options' |
103
|
|
|
), |
104
|
|
|
|
105
|
|
|
'remove_comments' => array( |
106
|
|
|
'title' => esc_html__( 'Remove Comments', 'auto-load-next-post' ), |
107
|
|
|
'desc' => esc_html__( 'Enable to remove comments when each post loads including the initial post.', 'auto-load-next-post' ), |
108
|
|
|
'id' => 'auto_load_next_post_remove_comments', |
109
|
|
|
'default' => 'yes', |
110
|
|
|
'type' => 'checkbox', |
111
|
|
|
'autoload' => false |
112
|
|
|
), |
113
|
|
|
|
114
|
|
|
'google_analytics' => array( |
115
|
|
|
'title' => esc_html__( 'Update Google Analytics', 'auto-load-next-post' ), |
116
|
|
|
'desc' => esc_html__( 'Enable to track each post the visitor is reading. This will count as a pageview. You must already have Google Analytics setup.', 'auto-load-next-post' ), |
117
|
|
|
'id' => 'auto_load_next_post_google_analytics', |
118
|
|
|
'default' => 'no', |
119
|
|
|
'type' => 'checkbox', |
120
|
|
|
'autoload' => false |
121
|
|
|
), |
122
|
|
|
|
123
|
|
|
'load_js_in_footer' => array( |
124
|
|
|
'title' => esc_html__( 'JavaScript in Footer?', 'auto-load-next-post' ), |
125
|
|
|
'desc' => sprintf( esc_html__( 'Enable to load %s in the footer instead of the header. Can be useful to optimize your site or if the current theme requires it.', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ), |
126
|
|
|
'id' => 'auto_load_next_post_load_js_in_footer', |
127
|
|
|
'default' => 'no', |
128
|
|
|
'type' => 'checkbox', |
129
|
|
|
'autoload' => false |
130
|
|
|
), |
131
|
|
|
|
132
|
|
|
'disable_on_mobile' => array( |
133
|
|
|
'title' => esc_html__( 'Disable for Mobile?', 'auto-load-next-post' ), |
134
|
|
|
'desc' => sprintf( esc_html__( 'Enable to disable %s from running on mobile devices.', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ), |
135
|
|
|
'id' => 'auto_load_next_post_disable_on_mobile', |
136
|
|
|
'default' => 'no', |
137
|
|
|
'type' => 'checkbox', |
138
|
|
|
'autoload' => false |
139
|
|
|
), |
140
|
|
|
|
141
|
|
|
'reset_data' => array( |
142
|
|
|
'title' => esc_html__( 'Reset all data?', 'auto-load-next-post' ), |
143
|
|
|
'desc' => esc_html__( 'Press the reset button to clear all settings for this plugin and re-initialize.', 'auto-load-next-post' ), |
144
|
|
|
'id' => 'auto_load_next_post_reset_data', |
145
|
|
|
'class' => 'reset-settings', |
146
|
|
|
'value' => esc_html__( 'Reset', 'auto-load-next-post' ), |
147
|
|
|
'url' => add_query_arg( array( 'page' => 'auto-load-next-post', 'view' => esc_attr( $this->id ), 'reset-alnp' => 'yes' ), admin_url( 'options-general.php' ) ), |
148
|
|
|
'type' => 'button' |
149
|
|
|
), |
150
|
|
|
|
151
|
|
|
'uninstall' => array( |
152
|
|
|
'title' => esc_html__( 'Remove all data on uninstall?', 'auto-load-next-post' ), |
153
|
|
|
'desc' => esc_html__( 'If enabled, all settings for this plugin will all be deleted when uninstalling via Plugins > Delete.', 'auto-load-next-post' ), |
154
|
|
|
'id' => 'auto_load_next_post_uninstall_data', |
155
|
|
|
'default' => 'no', |
156
|
|
|
'type' => 'checkbox', |
157
|
|
|
'autoload' => false |
158
|
|
|
), |
159
|
|
|
|
160
|
|
|
'section_end' => array( |
161
|
|
|
'type' => 'sectionend', |
162
|
|
|
'id' => 'misc_options' |
163
|
|
|
), |
164
|
|
|
) |
165
|
|
|
); // End misc settings |
166
|
|
|
} // END get_settings() |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* Output the settings. |
170
|
|
|
* |
171
|
|
|
* @access public |
172
|
|
|
* @since 1.5.0 |
173
|
|
|
*/ |
174
|
|
|
public function output() { |
175
|
|
|
$settings = $this->get_settings(); |
176
|
|
|
|
177
|
|
|
ALNP_Admin_Settings::output_fields( $settings ); |
178
|
|
|
} // END output() |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* Save settings. |
182
|
|
|
* |
183
|
|
|
* @access public |
184
|
|
|
* @since 1.5.0 |
185
|
|
|
*/ |
186
|
|
|
public function save() { |
187
|
|
|
$settings = $this->get_settings(); |
188
|
|
|
|
189
|
|
|
ALNP_Admin_Settings::save_fields( $settings ); |
190
|
|
|
} // END save() |
191
|
|
|
|
192
|
|
|
} // END class |
193
|
|
|
|
194
|
|
|
} // END if class exists |
195
|
|
|
|
196
|
|
|
return new ALNP_Settings_Misc(); |
197
|
|
|
|