PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 1.9.7.2
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v1.9.7.2
3.4.3 3.4.2 3.4.1 3.4.0 3.3.9 3.3.8 3.3.7 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 All 196 releases
← All changes | admin/class-convertkit-admin-settings.php +90 -137 2.2.81.9.7.2 View file →
@@ -55,19 +55,17 @@
55 55 if ( $hook !== 'settings_page_' . self::SETTINGS_PAGE_SLUG ) {
56 56 return;
57 57 }
58 58
59 - // Get active settings section / tab that has been requested.
60 - $section = $this->get_active_section();
59 + // Enqueue Select2 JS.
60 + convertkit_select2_enqueue_scripts();
61 61
62 62 /**
63 63 * Enqueue JavaScript for the Settings Screen at Settings > ConvertKit
64 64 *
65 65 * @since 1.9.6
66 - *
67 - * @param string $section Settings section / tab (general|tools|restrict-content).
68 66 */
69 - do_action( 'convertkit_admin_settings_enqueue_scripts', $section );
67 + do_action( 'convertkit_admin_settings_enqueue_scripts' );
70 68
71 69 }
72 70
73 71 /**
@@ -83,22 +81,20 @@
83 81 if ( $hook !== 'settings_page_' . self::SETTINGS_PAGE_SLUG ) {
84 82 return;
85 83 }
86 84
87 - // Get active settings section / tab that has been requested.
88 - $section = $this->get_active_section();
85 + // Enqueue Select2 CSS.
86 + convertkit_select2_enqueue_styles();
89 87
90 - // Always enqueue Settings CSS, as this is used for the UI across all settings sections.
91 - wp_enqueue_style( 'convertkit-admin-settings', CONVERTKIT_PLUGIN_URL . 'resources/backend/css/settings.css', array(), CONVERTKIT_PLUGIN_VERSION );
88 + // Enqueue Settings CSS.
89 + wp_enqueue_style( 'convertkit-admin-settings', CONVERTKIT_PLUGIN_URL . '/resources/backend/css/settings.css', array(), CONVERTKIT_PLUGIN_VERSION );
92 90
93 91 /**
94 92 * Enqueue CSS for the Settings Screen at Settings > ConvertKit
95 93 *
96 94 * @since 1.9.6
97 - *
98 - * @param string $section Settings section / tab (general|tools|restrict-content).
99 95 */
100 - do_action( 'convertkit_admin_settings_enqueue_styles', $section );
96 + do_action( 'convertkit_admin_settings_enqueue_styles' );
101 97
102 98 }
103 99
104 100 /**
@@ -131,8 +127,12 @@
131 127 <header>
132 128 <h1><?php esc_html_e( 'ConvertKit', 'convertkit' ); ?></h1>
133 129 </header>
134 130
131 + <?php
132 + $this->maybe_display_notices();
133 + ?>
134 +
135 135 <div class="wrap">
136 136 <?php
137 137 if ( count( $this->sections ) > 1 ) {
138 138 $this->display_section_nav( $active_section );
@@ -138,9 +138,9 @@
138 138 $this->display_section_nav( $active_section );
139 139 }
140 140 ?>
141 141
142 - <form method="post" action="options.php" enctype="multipart/form-data">
142 + <form method="post" action="options.php">
143 143 <?php
144 144 // Iterate through sections to find the active section to render.
145 145 if ( isset( $this->sections[ $active_section ] ) ) {
146 146 $this->sections[ $active_section ]->render();
@@ -145,24 +145,20 @@
145 145 if ( isset( $this->sections[ $active_section ] ) ) {
146 146 $this->sections[ $active_section ]->render();
147 147 }
148 148 ?>
149 - </form>
150 149
151 - <p class="description">
152 - <?php
153 - // Output Documentation link, if it exists.
154 - $documentation_url = $this->get_active_section_documentation_url( $active_section );
155 - if ( $documentation_url !== false ) {
156 - echo sprintf(
157 - '%s <a href="%s" target="_blank">%s</a>',
158 - esc_html__( 'If you need help setting up the plugin please refer to the', 'convertkit' ),
159 - esc_attr( $documentation_url ),
160 - esc_html__( 'plugin documentation', 'convertkit' )
150 + <hr />
151 +
152 + <p class="description">
153 + <?php
154 + printf(
155 + 'If you need help setting up the plugin please refer to the %s plugin documentation.</a>',
156 + '<a href="https://help.convertkit.com/en/articles/2502591-the-convertkit-wordpress-plugin" target="_blank">'
161 157 );
162 - }
163 - ?>
164 - </p>
158 + ?>
159 + </p>
160 + </form>
165 161 </div>
166 162 <?php
167 163
168 164 }
@@ -175,10 +171,10 @@
175 171 * @return string Tab Name
176 172 */
177 173 private function get_active_section() {
178 174
179 - if ( isset( $_GET['tab'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
180 - return sanitize_text_field( wp_unslash( $_GET['tab'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
175 + if ( isset( $_GET['tab'] ) ) { // phpcs:ignore
176 + return sanitize_text_field( wp_unslash( $_GET['tab'] ) ); // phpcs:ignore
181 177 }
182 178
183 179 // First registered section will be the active section.
184 180 return current( $this->sections )->name;
@@ -185,36 +181,71 @@
185 181
186 182 }
187 183
188 184 /**
185 + * Display notice(s) immediately after the settings screen header.
186 + *
187 + * @since 1.9.6
188 + */
189 + private function maybe_display_notices() {
190 +
191 + $notices = array();
192 +
193 + // Check the mbstring extension is loaded.
194 + if ( ! extension_loaded( 'mbstring' ) ) {
195 + $notices[] = array(
196 + 'type' => 'warning',
197 + 'message' => sprintf(
198 + /* translators: link to php.net manual */
199 + __( 'Notice: Your server does not support the %s function - this is required for better character encoding. Please contact your webhost to have it installed.', 'convertkit' ),
200 + '<a href="https://php.net/manual/en/mbstring.installation.php">mbstring</a>'
201 + ),
202 + );
203 + }
204 +
205 + // Bail if no notices exist.
206 + if ( ! count( $notices ) ) {
207 + return;
208 + }
209 + ?>
210 + <div class="notices">
211 + <?php
212 + // Output inline notices.
213 + foreach ( $notices as $notice ) {
214 + ?>
215 + <div class="inline notice notice-<?php echo esc_attr( $notice['type'] ); ?>">
216 + <p>
217 + <?php echo esc_attr( $notice['message'] ); ?>
218 + </p>
219 + </div>
220 + <?php
221 + }
222 + ?>
223 + </div>
224 + <?php
225 +
226 + }
227 +
228 + /**
189 229 * Define links to display below the Plugin Name on the WP_List_Table at in the Plugins screen.
190 230 *
191 231 * @param array $links Links.
192 232 * @return array Links
193 233 */
194 - public function add_settings_page_link( $links ) {
234 + public static function add_settings_page_link( $links ) {
195 235
196 - // Add link to Plugin settings screen.
197 - $links['settings'] = sprintf(
198 - '<a href="%s">%s</a>',
199 - convertkit_get_settings_link(),
200 - __( 'Settings', 'convertkit' )
236 + return array_merge(
237 + array(
238 + 'settings' => sprintf(
239 + '<a href="%s">%s</a>',
240 + convertkit_get_settings_link(),
241 + __( 'Settings', 'convertkit' )
242 + ),
243 + ),
244 + $links
201 245 );
202 246
203 - /**
204 - * Define links to display below the Plugin Name on the WP_List_Table at Plugins > Installed Plugins.
205 - *
206 - * @since 2.1.2
207 - *
208 - * @param array $links HTML Links.
209 - */
210 - $links = apply_filters( 'convertkit_plugin_screen_action_links', $links );
211 -
212 - // Return.
213 - return $links;
214 -
215 247 }
216 -
217 248 /**
218 249 * Output tabs, one for each registered settings section.
219 250 *
220 251 * @param string $active_section Currently displayed/selected section.
@@ -221,72 +252,26 @@
221 252 */
222 253 public function display_section_nav( $active_section ) {
223 254
224 255 ?>
225 - <ul class="convertkit-tabs">
226 - <?php
227 - foreach ( $this->sections as $section ) {
228 - printf(
229 - '<li><a href="%s" class="convertkit-tab %s">%s%s</a></li>',
230 - esc_url(
231 - add_query_arg(
232 - array(
233 - 'page' => self::SETTINGS_PAGE_SLUG,
234 - 'tab' => $section->name,
235 - ),
236 - admin_url( 'options-general.php' )
237 - )
238 - ),
239 - ( $active_section === $section->name ? 'convertkit-tab-active' : '' ),
240 - esc_html( $section->tab_text ),
241 - $section->is_beta ? $this->get_beta_tab() : '' // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
242 - );
243 - }
244 -
245 - // Output Documentation link tab, if it exists.
246 - $documentation_url = $this->get_active_section_documentation_url( $active_section );
247 - if ( $documentation_url !== false ) {
248 - printf(
249 - '<li class="convertkit-docs"><a href="%s" class="convertkit-tab" target="_blank">%s <span class="dashicons dashicons-external"></span></a></li>',
250 - esc_attr( $documentation_url ),
251 - esc_html__( 'Documentation', 'convertkit' )
252 - );
253 - }
254 - ?>
255 - </ul>
256 + <h2 class="nav-tab-wrapper">
256 257 <?php
257 - // WordPress' JS will automatically move any .notice elements to be immediately below .wp-header-end
258 - // or <h2>, whichever comes first.
259 - // As our <h2> is inside our .metabox-holder, we output .wp-header-end first to control the notification
260 - // placement to be before the white background container/box.
258 + foreach ( $this->sections as $section ) {
259 + printf(
260 + '<a href="?page=%s&tab=%s" class="nav-tab right %s">%s</a>',
261 + sanitize_text_field( $_REQUEST['page'] ), // phpcs:ignore
262 + esc_html( $section->name ),
263 + $active_section === $section->name ? 'nav-tab-active' : '',
264 + esc_html( $section->tab_text )
265 + );
266 + }
261 267 ?>
262 - <hr class="wp-header-end">
268 + </h2>
263 269 <?php
264 270
265 271 }
266 272
267 273 /**
268 - * Returns a 'beta' tab wrapped in a span, using wp_kses to ensure only permitted
269 - * HTML elements are included in the output.
270 - *
271 - * @since 2.1.0
272 - *
273 - * @return string
274 - */
275 - private function get_beta_tab() {
276 -
277 - return wp_kses(
278 - '<span class="convertkit-beta-label">' . esc_html__( 'Beta', 'convertkit' ) . '</span>',
279 - array(
280 - 'span' => array(
281 - 'class' => array(),
282 - ),
283 - )
284 - );
285 -
286 - }
287 -
288 - /**
289 274 * Registers settings sections at Settings > ConvertKit.
290 275 *
291 276 * Each section has its own tab.
292 277 *
@@ -310,40 +295,8 @@
310 295 $sections = apply_filters( 'convertkit_admin_settings_register_sections', $sections );
311 296
312 297 // With our sections now registered, assign them to this class.
313 298 $this->sections = $sections;
314 -
315 - }
316 -
317 - /**
318 - * Returns the documentation URL for the active settings section viewed by the user.
319 - *
320 - * @since 2.0.8
321 - *
322 - * @param string $active_section Currently displayed/selected section.
323 - * @return bool|string
324 - */
325 - private function get_active_section_documentation_url( $active_section ) {
326 -
327 - // Bail if no sections registered.
328 - if ( ! $this->sections ) {
329 - return false;
330 - }
331 -
332 - // Bail if the active section isn't registered.
333 - if ( ! array_key_exists( $active_section, $this->sections ) ) {
334 - return false;
335 - }
336 -
337 - // Pass request to section's documentation_url() function, including UTM parameters.
338 - return add_query_arg(
339 - array(
340 - 'utm_source' => 'wordpress',
341 - 'utm_term' => get_locale(),
342 - 'utm_content' => 'convertkit',
343 - ),
344 - $this->sections[ $active_section ]->documentation_url()
345 - );
346 299
347 300 }
348 301
349 302 }