Skip to content

Commit 074b780

Browse files
committed
Theme selectors are disabled if supported already
1 parent 6a3f0f1 commit 074b780

File tree

1 file changed

+85
-56
lines changed

1 file changed

+85
-56
lines changed

includes/admin/settings/class-alnp-settings-theme-selectors.php

Lines changed: 85 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -99,62 +99,91 @@ public static function no_theme_selectors_set() {
9999
public function get_settings() {
100100
global $blog_id;
101101

102-
return apply_filters(
103-
'alnp_selectors_settings', array(
104-
105-
array(
106-
'title' => esc_html__( 'Theme Selectors', 'auto-load-next-post' ),
107-
'type' => 'title',
108-
'desc' => sprintf( esc_html__( 'Here you set the theme selectors below according to your active theme. All are required for %s to work.', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ),
109-
'id' => 'theme_selectors_options'
110-
),
111-
112-
array(
113-
'title' => esc_html__( 'Content Container', 'auto-load-next-post' ),
114-
'desc' => sprintf( __( 'The primary container where the post content is loaded in. Default: %s', 'auto-load-next-post' ), '<code>main.site-main</code>' ),
115-
'id' => 'auto_load_next_post_content_container',
116-
'default' => 'main.site-main',
117-
'placeholder' => esc_html__( 'Required', 'auto-load-next-post' ),
118-
'type' => 'text',
119-
'css' => 'min-width:300px;',
120-
'autoload' => false
121-
),
122-
123-
array(
124-
'title' => esc_html__( 'Post Title', 'auto-load-next-post' ),
125-
'desc' => sprintf( __( 'Used to identify which article the user is reading and track should Google Analytics or other analytics be enabled. Default: %s', 'auto-load-next-post' ), '<code>h1.entry-title</code>' ),
126-
'id' => 'auto_load_next_post_title_selector',
127-
'default' => 'h1.entry-title',
128-
'type' => 'text',
129-
'css' => 'min-width:300px;',
130-
'autoload' => false
131-
),
132-
133-
array(
134-
'title' => esc_html__( 'Post Navigation', 'auto-load-next-post' ),
135-
'desc' => sprintf( __( 'Used to identify which post to load next if any. Default: %s', 'auto-load-next-post' ), '<code>nav.post-navigation</code>' ),
136-
'id' => 'auto_load_next_post_navigation_container',
137-
'default' => 'nav.post-navigation',
138-
'type' => 'text',
139-
'css' => 'min-width:300px;',
140-
'autoload' => false
141-
),
142-
143-
array(
144-
'title' => esc_html__( 'Comments Container', 'auto-load-next-post' ),
145-
'desc' => sprintf( __( 'Used to remove comments if enabled under %1$sMisc%2$s settings. Default: %3$s', 'auto-load-next-post' ), '<strong><a href="' . add_query_arg( array( 'page' => 'auto-load-next-post', 'view' => 'misc' ), get_admin_url( $blog_id, 'options-general.php' ) ) . '">', '</a></strong>', '<code>div#comments</code>' ),
146-
'id' => 'auto_load_next_post_comments_container',
147-
'default' => 'div#comments',
148-
'type' => 'text',
149-
'css' => 'min-width:300px;',
150-
'autoload' => false
151-
),
152-
153-
array(
154-
'type' => 'sectionend',
155-
'id' => 'theme_selectors_options'
156-
),
157-
) ); // End theme selectors settings
102+
$settings = array();
103+
104+
$settings[] = array(
105+
'title' => esc_html__( 'Theme Selectors', 'auto-load-next-post' ),
106+
'type' => 'title',
107+
'desc' => sprintf( esc_html__( 'Here you set the theme selectors below according to your active theme. All are required for %s to work.', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ),
108+
'id' => 'theme_selectors_options'
109+
);
110+
111+
$container_readonly = 'no';
112+
$post_title_readonly = 'no';
113+
$post_navigation_readonly = 'no';
114+
$comments_container_readonly = 'no';
115+
116+
// Checks if the Content Container selector has been set by theme support.
117+
if ( ! empty( alnp_get_theme_support( 'content_container' ) ) ) {
118+
$container_readonly = 'yes';
119+
}
120+
121+
$settings[] = array(
122+
'title' => esc_html__( 'Content Container', 'auto-load-next-post' ),
123+
'desc' => sprintf( __( 'The primary container where the post content is loaded in. Default: %s', 'auto-load-next-post' ), '<code>main.site-main</code>' ),
124+
'id' => 'auto_load_next_post_content_container',
125+
'default' => 'main.site-main',
126+
'placeholder' => esc_html__( 'Required', 'auto-load-next-post' ),
127+
'readonly' => $container_readonly,
128+
'type' => 'text',
129+
'css' => 'min-width:300px;',
130+
'autoload' => false
131+
);
132+
133+
// Checks if the Post Title selector has been set by theme support.
134+
if ( ! empty( alnp_get_theme_support( 'title_selector' ) ) ) {
135+
$post_title_readonly = 'yes';
136+
}
137+
138+
$settings[] = array(
139+
'title' => esc_html__( 'Post Title', 'auto-load-next-post' ),
140+
'desc' => sprintf( __( 'Used to identify which article the user is reading and track should Google Analytics or other analytics be enabled. Default: %s', 'auto-load-next-post' ), '<code>h1.entry-title</code>' ),
141+
'id' => 'auto_load_next_post_title_selector',
142+
'default' => 'h1.entry-title',
143+
'readonly' => $post_title_readonly,
144+
'type' => 'text',
145+
'css' => 'min-width:300px;',
146+
'autoload' => false
147+
);
148+
149+
// Checks if the Post Navigation selector has been set by theme support.
150+
if ( ! empty( alnp_get_theme_support( 'navigation_container' ) ) ) {
151+
$post_navigation_readonly = 'yes';
152+
}
153+
154+
$settings[] = array(
155+
'title' => esc_html__( 'Post Navigation', 'auto-load-next-post' ),
156+
'desc' => sprintf( __( 'Used to identify which post to load next if any. Default: %s', 'auto-load-next-post' ), '<code>nav.post-navigation</code>' ),
157+
'id' => 'auto_load_next_post_navigation_container',
158+
'default' => 'nav.post-navigation',
159+
'readonly' => $post_navigation_readonly,
160+
'type' => 'text',
161+
'css' => 'min-width:300px;',
162+
'autoload' => false
163+
);
164+
165+
// Checks if the Comments Container selector has been set by theme support.
166+
if ( ! empty( alnp_get_theme_support( 'comments_container' ) ) ) {
167+
$comments_container_readonly = 'yes';
168+
}
169+
170+
$settings[] = array(
171+
'title' => esc_html__( 'Comments Container', 'auto-load-next-post' ),
172+
'desc' => sprintf( __( 'Used to remove comments if enabled under %1$sMisc%2$s settings. Default: %3$s', 'auto-load-next-post' ), '<strong><a href="' . add_query_arg( array( 'page' => 'auto-load-next-post', 'view' => 'misc' ), get_admin_url( $blog_id, 'options-general.php' ) ) . '">', '</a></strong>', '<code>div#comments</code>' ),
173+
'id' => 'auto_load_next_post_comments_container',
174+
'default' => 'div#comments',
175+
'readonly' => $comments_container_readonly,
176+
'type' => 'text',
177+
'css' => 'min-width:300px;',
178+
'autoload' => false
179+
);
180+
181+
$settings[] = array(
182+
'type' => 'sectionend',
183+
'id' => 'theme_selectors_options'
184+
);
185+
186+
return apply_filters( 'alnp_selectors_settings', $settings );
158187
} // END get_settings()
159188

160189
/**

0 commit comments

Comments
 (0)