ALNP_Admin_Help::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Auto Load Next Post: Help Tab.
4
 *
5
 * Adds a help tab to the settings page providing useful
6
 * and helpful information for the users.
7
 *
8
 * @since    1.0.0
9
 * @version  1.6.0
10
 * @author   Sébastien Dumont
11
 * @category Admin
12
 * @package  Auto Load Next Post/Admin/Help
13
 * @license  GPL-2.0+
14
 */
15
16
// Exit if accessed directly.
17
if ( ! defined( 'ABSPATH' ) ) {
18
	exit;
19
}
20
21
if ( ! class_exists( 'ALNP_Admin_Help' ) ) {
22
23
	class ALNP_Admin_Help {
24
25
		/**
26
		 * Constructor
27
		 *
28
		 * @access public
29
		 * @since  1.0.0
30
		 */
31
		public function __construct() {
32
			add_action( 'current_screen', array( $this, 'add_help_tabs' ), 50 );
33
		} // END __construct()
34
35
		/**
36
		 * Adds help tabs to the plugin pages.
37
		 *
38
		 * @access  public
39
		 * @since   1.0.0
40
		 * @version 1.6.0
41
		 */
42
		public function add_help_tabs() {
43
			$screen    = get_current_screen();
44
			$screen_id = $screen ? $screen->id : '';
45
46
			if ( $screen_id != 'settings_page_auto-load-next-post' ) {
47
				return;
48
			}
49
50
			$current_view = ! empty( $_GET['view'] ) ? sanitize_title( wp_unslash( $_GET['view'] ) ) : '';
51
52
			if ( in_array( $current_view, array( 'getting-started', 'setup-wizard', 'extensions' ) ) ) {
53
				return;
54
			}
55
56
			$screen->add_help_tab( array(
57
				'id'      => 'auto_load_next_post_support_tab',
58
				'title'   => esc_html__( 'Help & Support', 'auto-load-next-post' ),
59
				'content' =>
60
					'<h2>' . esc_html__( 'Help & Support', 'auto-load-next-post' ) . '</h2>' .
61
62
					'<p>' . sprintf( __( 'Should you need help understanding, using, or extending %1$s, please %2$sread the documentation%3$s. You will find snippets, tutorials and much more.', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ), '<a href="' . esc_url( AUTO_LOAD_NEXT_POST_DOCUMENTATION_URL ) . '" aria-label="' . esc_attr__( 'View Auto Load Next Post documentation', 'auto-load-next-post' ) . '" target="_blank">', '</a>' ) . '</p>' .
63
64
					'<p>' . sprintf( __( 'For further assistance with %1$s you can use the %2$scommunity forum%3$s.', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ), '<a href="'. esc_url( AUTO_LOAD_NEXT_POST_SUPPORT_URL ) . '"aria-label="' . esc_attr__( 'Get support from the community', 'auto-load-next-post' ). '" target="_blank">', '</a>' ) . '</p> ' .
65
66
					'<p>' . sprintf( __( '%1$s is in need of translations. Is the plugin not translated in your language or do you spot errors with the current translations? Helping out is easy! Head over to the project on WordPress.org and click %2$sTranslate %1$s%3$s.', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ), '<a href="https://translate.wordpress.org/projects/wp-plugins/auto-load-next-post" target="_blank">', '</a>' ) . '</p>' .
67
68
					'<p><a href="' . esc_url( AUTO_LOAD_NEXT_POST_DOCUMENTATION_URL ) . '" class="button button-primary" aria-label="' . esc_attr__( 'View Auto Load Next Post documentation', 'auto-load-next-post' ) . '" target="_blank">' . esc_html__( 'Documentation', 'auto-load-next-post' ) . '</a> <a href="'. esc_url( AUTO_LOAD_NEXT_POST_SUPPORT_URL ) . '" class="button button-secondary" aria-label="' . esc_attr__( 'Get support from the community', 'auto-load-next-post' ). '" target="_blank">' . esc_html__( 'Community Forum', 'auto-load-next-post' ) . '</a> <a href="' . esc_url( AUTO_LOAD_NEXT_POST_PLUGIN_URL . '#faq' ) . '" class="button button-secondary" target="_blank">' . esc_html__( 'Frequently Asked Questions', 'auto-load-next-post' ) . '</a> <a href="https://translate.wordpress.org/projects/wp-plugins/auto-load-next-post" class="button button-secondary" target="_blank">' . sprintf( esc_html__( 'Translate %s', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ) . '</a></p>'
69
			) );
70
71
			$screen->add_help_tab( array(
72
				'id'      => 'auto_load_next_post_theme_selectors_tab',
73
				'title'   => __( 'Theme Selectors', 'auto-load-next-post' ),
74
				'content' =>
75
					'<h2>' . __( 'Theme Selectors', 'auto-load-next-post' ) . '</h2>' .
76
77
					'<p>' . sprintf(
78
						__( 'Theme Selectors allows %s know where to load the content in, which post is being read, the next post to load and whether to show or hide comments per post.', 'auto-load-next-post' ),
79
						esc_html__( 'Auto Load Next Post', 'auto-load-next-post' )
80
					) . '</p>' .
81
82
					'<p>' . sprintf(
83
						__( 'Each theme is different so in order for %1$s to work, the theme selectors must be set according to the theme you currently have active for each section.', 'auto-load-next-post' ),
84
						esc_html__( 'Auto Load Next Post', 'auto-load-next-post' )
85
					) . '</p>' .
86
87
					'<p>' . sprintf(
88
						__( 'When %1$s is activated, default theme selectors are set for you. These theme selectors are the most commonly used in any WordPress theme. If they don’t work for your theme then you need to find the matching theme selectors.', 'auto-load-next-post' ),
89
						esc_html__( 'Auto Load Next Post', 'auto-load-next-post' )
90
					) . '</p>' .
91
92
					'<p>' . sprintf(
93
						__( 'If the theme you have active supports %s then it will set the theme selectors for you and display a notice on the theme selectors page.', 'auto-load-next-post' ),
94
						esc_html__( 'Auto Load Next Post', 'auto-load-next-post' )
95
					) . '</p>' .
96
97
					'<h3 class="alnp-default-theme-selectors">' . esc_html__( 'Default Theme Selectors', 'auto-load-next-post' ) . '</h3>' .
98
99
					'<ul class="alnp-default-theme-selectors">' .
100
						'<li><strong>' . esc_html__( 'Content Container', 'auto-load-next-post' ) . '</strong>' . ' <code>main.site-main</code></li>' .
101
						'<li><strong>' . esc_html__( 'Post Title', 'auto-load-next-post' ) . '</strong>' . ' <code>h1.entry-title</code></li>' .
102
						'<li><strong>' . esc_html__( 'Post Navigation', 'auto-load-next-post' ) . '</strong>' . ' <code>nav.post-navigation</code></li>' .
103
						'<li><strong>' . esc_html__( 'Comments Container', 'auto-load-next-post' ) . '</strong>' . ' <code>div#comments</code></li>' .
104
					'</ul>' .
105
106
					'<p><a href="https://github.com/autoloadnextpost/alnp-documentation/blob/master/en_US/theme-selectors.md#how-to-find-your-theme-selectors" class="button button-primary" target="_blank">' . esc_html__( 'How to find your theme selectors', 'auto-load-next-post' ) . '</a></p>'
107
			) );
108
109
			$screen->add_help_tab( array(
110
				'id'      => 'auto_load_next_post_templates_tab',
111
				'title'   => __( 'Templates', 'auto-load-next-post' ),
112
				'content' =>
113
					'<h2>' . __( 'Templates', 'auto-load-next-post' ) . '</h2>' .
114
115
					'<p>' . sprintf(
116
						__( 'Every WordPress theme manages there %1$sTemplate Hierarchy%2$s in there own way. This makes it a little difficult for %3$s to auto detect the appropriate template location. If the appropriate template was not detected then %3$s will automatically use a fallback template in order to display your sites content while your viewers scroll.', 'auto-load-next-post' ), '<a href="https://developer.wordpress.org/themes/basics/template-hierarchy/" target="_blank">', '</a>',
117
						esc_html__( 'Auto Load Next Post', 'auto-load-next-post' )
118
					) . '</p>' .
119
120
					'<p>' . sprintf( __( 'By providing an accurate location to your theme\'s template, %1$s will then use your theme\'s template instead and will display your content matching the theme\'s design.' , 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' )
121
					) . '</p>' .
122
123
					'<p><a href="https://github.com/autoloadnextpost/alnp-documentation/blob/master/en_US/content-and-structure.md" class="button button-primary" target="_blank">' . esc_html__( 'Content and Structure', 'auto-load-next-post' ) . '</a></p>'
124
			) );
125
126
			$screen->add_help_tab( array(
127
				'id'      => 'auto_load_next_post_bugs_tab',
128
				'title'   => esc_html__( 'Found a bug?', 'auto-load-next-post' ),
129
				'content' =>
130
					'<h2>' . esc_html__( 'Found a bug?', 'auto-load-next-post' ) . '</h2>' .
131
132
					'<p>' . sprintf( __( 'If you find a bug within %1$s core you can create a ticket via %2$sGithub issues%4$s. Ensure you read the %3$scontribution guide%4$s prior to submitting your report. To help me solve your issue, please be as descriptive as possible.', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ), '<a href="https://github.com/autoloadnextpost/auto-load-next-post/issues?state=open" target="_blank">', '<a href="https://github.com/autoloadnextpost/auto-load-next-post/blob/master/CONTRIBUTING.md" target="_blank">', '</a>' ) . '</p>' .
133
134
					'<p><a href="https://github.com/autoloadnextpost/auto-load-next-post/issues?state=open" class="button button-primary" target="_blank">' . esc_html__( 'Report a bug', 'auto-load-next-post' ) . '</a></p>'
135
			) );
136
137
			$screen->add_help_tab( array(
138
				'id'      => 'auto_load_next_post_feedback_tab',
139
				'title'   => esc_html__( 'Contribute', 'auto-load-next-post' ),
140
				'content' =>
141
					'<h2>' . esc_html__( 'Contribute', 'auto-load-next-post' ) . '</h2>' .
142
143
					'<p>' . sprintf( __( 'If you or your company use %1$s, please consider supporting me directly so I can continue maintaining it and keep evolving the project.', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ) . '</p>' .
144
145
					'<p>' . esc_html__( 'You\'ll be helping to ensure I can spend the time not just fixing bugs, adding features or releasing new versions but also keeping the project afloat. Any contribution you make is a big help and is greatly appreciated.', 'auto-load-next-post' ) . '</p>' .
146
147
					'<p>' . sprintf( __( 'Your review of the plugin is also important as it will help others decide to use %s so please consider leaving a review on WordPress.org', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ) . '</p>' .
148
149
					'<p><a href="' . esc_url( AUTO_LOAD_NEXT_POST_REVIEW_URL ) . '" class="button button-primary" target="_blank" aria-label="' . esc_attr( __( 'Review Auto Load Next Post on WordPress.org', 'auto-load-next-post' ) ) . '">' . esc_html__( 'Leave a Review', 'auto-load-next-post' ) . '</a> <a href="https://sebdumont.xyz/donate/" class="button button-secondary" target="_blank">' . esc_html__( 'Support the Developer', 'auto-load-next-post' ) . '</a></p>'
150
			) );
151
152
			$screen->add_help_tab( array(
153
				'id'      => 'auto_load_next_post_wizard_tab',
154
				'title'   => esc_html__( 'Setup Wizard', 'auto-load-next-post' ),
155
				'content' =>
156
					'<h2>' . esc_html__( 'Setup Wizard', 'auto-load-next-post' ) . '</h2>' .
157
158
					'<p>' . sprintf( esc_html__( 'If you need to access the setup wizard again, please click on the button below. %1$sNote:%2$s Setup wizard is designed for themes that have not declared support for %3$s.', 'auto-load-next-post' ), '<strong class="red">', '</strong>', esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ) . '</p>' .
159
160
					'<p><a href="' . add_query_arg( array( 'page' => 'auto-load-next-post', 'view' => 'setup-wizard', 'force-setup' => 'yes' ), admin_url( 'options-general.php' ) ) . '" class="button button-primary" aria-label="' . sprintf( esc_attr__( 'View %s setup wizard', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ) . '">' . esc_html__( 'Setup Wizard', 'auto-load-next-post' ) . '</a></p>'
161
			) );
162
163
			$screen->set_help_sidebar(
164
				'<p><strong>' . esc_html__( 'For more information:', 'auto-load-next-post' ) . '</strong></p>' .
165
166
				'<p><a href="' . esc_url( AUTO_LOAD_NEXT_POST_STORE_URL ) . 'about/?utm_source=wpadmin&utm_campaign=plugin-settings-help-tab" target="_blank">' . sprintf( esc_html__( 'About %s', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ) . '</a></p>' .
167
168
				'<p><a href="' . esc_url( AUTO_LOAD_NEXT_POST_PLUGIN_URL ) . '" target="_blank">' . esc_html__( 'WordPress.org Project', 'auto-load-next-post' ) . '</a></p>' .
169
170
				'<p><a href="https://github.com/autoloadnextpost/auto-load-next-post/" target="_blank">' . esc_html__( 'GitHub Project', 'auto-load-next-post' ) . '</a></p>'
171
			);
172
173
		} // END add_help_tabs()
174
175
	} // END ALNP_Admin_Help class.
176
177
} // END if class exists.
178
179
return new ALNP_Admin_Help();
180