Completed
Branch master (16c0f9)
by
unknown
02:07
created

Auto_Load_Next_Post_Settings_General_Tab::output()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Auto Load Next Post Settings - General
4
 *
5
 * @since    1.0.0
6
 * @version  1.4.10
7
 * @author   Sébastien Dumont
8
 * @category Admin
9
 * @package  Auto Load Next Post
10
 * @license  GPL-2.0+
11
 */
12
13
// Exit if accessed directly.
14
if ( ! defined( 'ABSPATH' ) ) {
15
	exit;
16
}
17
18
if ( ! class_exists( 'Auto_Load_Next_Post_Settings_General_Tab' ) ) {
19
20
	class Auto_Load_Next_Post_Settings_General_Tab extends Auto_Load_Next_Post_Settings_Page {
21
22
		/**
23
		 * Constructor.
24
		 *
25
		 * @access  public
26
		 * @since   1.0.0
27
		 * @version 1.4.10
28
		 */
29
		public function __construct() {
30
			$this->id    = 'general';
31
			$this->label = __( 'General', 'auto-load-next-post' );
32
33
			parent::__construct();
34
		} // END __construct()
35
36
		/**
37
		 * Get settings array.
38
		 *
39
		 * @access public
40
		 * @since  1.0.0
41
		 * @return array
42
		 */
43
		public function get_settings() {
44
			return apply_filters(
45
				'auto_load_next_post_general_settings', array(
46
47
					array(
48
						'title' => __( 'General', 'auto-load-next-post' ),
49
						'type'  => 'title',
50
						'desc'  => sprintf( __( 'Set the theme selectors below according to your active theme. All are required for %s to work. <a href="https://autoloadnextpost.com/documentation/find-theme-selectors/?utm_source=wpadmin&utm_campaign=plugin-settings-general" target="_blank">How to find my theme selectors?</a>', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ),
51
						'id'    => 'general_options'
52
					),
53
54
					array(
55
						'title'    => __( 'Content Container', 'auto-load-next-post' ),
56
						'desc'     => __( 'This is the primary container were the post content is loaded in. Example: <code>main.site-main</code>', 'auto-load-next-post' ),
57
						//'desc_tip' => true,
58
						'id'       => 'auto_load_next_post_content_container',
59
						'default'  => 'main.site-main',
60
						'type'     => 'text',
61
						'css'      => 'min-width:300px;',
62
						'autoload' => false
63
					),
64
65
					array(
66
						'title'    => __( 'Post Title', 'auto-load-next-post' ),
67
						'desc'     => __( 'This is used to identify which article the user is reading and track if Google Analytics is enabled. Example: <code>h1.entry-title</code>', 'auto-load-next-post' ),
68
						//'desc_tip' => true,
69
						'id'       => 'auto_load_next_post_title_selector',
70
						'default'  => 'h1.entry-title',
71
						'type'     => 'text',
72
						'css'      => 'min-width:300px;',
73
						'autoload' => false
74
					),
75
76
					array(
77
						'title'    => __( 'Post Navigation', 'auto-load-next-post' ),
78
						'desc'     => __( 'The post navigation needs to be indentified to find the next post. Example: <code>nav.post-navigation</code>', 'auto-load-next-post' ),
79
						//'desc_tip' => true,
80
						'id'       => 'auto_load_next_post_navigation_container',
81
						'default'  => 'nav.post-navigation',
82
						'type'     => 'text',
83
						'css'      => 'min-width:300px;',
84
						'autoload' => false
85
					),
86
87
					array(
88
						'title'    => __( 'Comments Container', 'auto-load-next-post' ),
89
						'desc'     => __( 'This is so comments can be removed if enabled below. Example: <code>div#comments</code>', 'auto-load-next-post' ),
90
						//'desc_tip' => true,
91
						'id'       => 'auto_load_next_post_comments_container',
92
						'default'  => 'div#comments',
93
						'type'     => 'text',
94
						'css'      => 'min-width:300px;',
95
						'autoload' => false
96
					),
97
98
					array(
99
						'title'   => __( 'Remove Comments', 'auto-load-next-post' ),
100
						'desc'    => __( 'Enable to remove comments when each post loads including the initial post.', 'auto-load-next-post' ),
101
						'id'      => 'auto_load_next_post_remove_comments',
102
						'default' => 'yes',
103
						'type'    => 'checkbox'
104
					),
105
106
					array(
107
						'title'   => __( 'Update Google Analytics', 'auto-load-next-post' ),
108
						'desc'    => __( 'Each time a post has loaded and is in view it will count as a pageview. Must have reference to Google Analytics tracking code on the site.', 'auto-load-next-post' ),
109
						'id'      => 'auto_load_next_post_google_analytics',
110
						'default' => 'no',
111
						'type'    => 'checkbox'
112
					),
113
114
					array(
115
						'title'   => __( 'Reset all data?', 'auto-load-next-post' ),
116
						'desc'    => __( 'Press the reset button to clear all settings for this plugin and re-install the default settings.', 'auto-load-next-post' ),
117
						'id'      => 'auto_load_next_post_reset_data',
118
						'default' => 'no',
119
						'type'    => 'reset_data'
120
					),
121
122
					array(
123
						'title'   => __( 'Remove all data on uninstall?', 'auto-load-next-post' ),
124
						'desc'    => __( 'If enabled, all settings for this plugin will all be deleted when uninstalling via Plugins > Delete.', 'auto-load-next-post' ),
125
						'id'      => 'auto_load_next_post_uninstall_data',
126
						'default' => 'no',
127
						'type'    => 'checkbox'
128
					),
129
130
					array(
131
						'type' => 'sectionend',
132
						'id'   => 'general_options'
133
					),
134
			) ); // End general settings
135
		} // END get_settings()
136
137
		/**
138
		 * Output the settings.
139
		 *
140
		 * @access public
141
		 * @since  1.4.10
142
		 */
143
		public function output() {
144
			$settings = $this->get_settings();
145
146
			Auto_Load_Next_Post_Admin_Settings::output_fields( $settings );
147
		} // END output()
148
149
		/**
150
		 * Save settings.
151
		 *
152
		 * @access public
153
		 * @since  1.0.0
154
		 * @global $current_tab
155
		 */
156
		public function save() {
157
			global $current_tab;
158
159
			$settings = $this->get_settings();
160
161
			Auto_Load_Next_Post_Admin_Settings::save_fields( $settings, $current_tab );
162
		} // END save()
163
164
		/**
165
		 * Get post types.
166
		 *
167
		 * This returns a list of public registered post types.
168
		 *
169
		 * @access public
170
		 * @since  1.3.2
171
		 * @return array
172
		 */
173
		public function get_post_types() {
174
			$post_types = get_post_types( array( 'public' => true ), 'names' );
175
176
			return $post_types;
177
		} // END get_post_types()
178
179
	} // END class
180
181
} // END if class exists
182
183
return new Auto_Load_Next_Post_Settings_General_Tab();
184