| @@ -130,8 +130,12 @@ | ||
| 130 | 130 | <header> |
| 131 | 131 | <h1><?php esc_html_e( 'ConvertKit', 'convertkit' ); ?></h1> |
| 132 | 132 | </header> |
| 133 | 133 | |
| 134 | + <?php | |
| 135 | + $this->maybe_display_notices(); | |
| 136 | + ?> | |
| 137 | + | |
| 134 | 138 | <div class="wrap"> |
| 135 | 139 | <?php |
| 136 | 140 | if ( count( $this->sections ) > 1 ) { |
| 137 | 141 | $this->display_section_nav( $active_section ); |
| @@ -148,18 +152,12 @@ | ||
| 148 | 152 | </form> |
| 149 | 153 | |
| 150 | 154 | <p class="description"> |
| 151 | 155 | <?php |
| 152 | - // Output Documentation link, if it exists. | |
| 153 | - $documentation_url = $this->get_active_section_documentation_url( $active_section ); | |
| 154 | - if ( $documentation_url !== false ) { | |
| 155 | - echo sprintf( | |
| 156 | - '%s <a href="%s" target="_blank">%s</a>', | |
| 157 | - esc_html__( 'If you need help setting up the plugin please refer to the', 'convertkit' ), | |
| 158 | - esc_attr( $documentation_url ), | |
| 159 | - esc_html__( 'plugin documentation', 'convertkit' ) | |
| 160 | - ); | |
| 161 | - } | |
| 156 | + printf( | |
| 157 | + 'If you need help setting up the plugin please refer to the %s plugin documentation.</a>', | |
| 158 | + '<a href="https://help.convertkit.com/en/articles/2502591-the-convertkit-wordpress-plugin" target="_blank">' | |
| 159 | + ); | |
| 162 | 160 | ?> |
| 163 | 161 | </p> |
| 164 | 162 | </div> |
| 165 | 163 | <?php |
| @@ -184,36 +182,71 @@ | ||
| 184 | 182 | |
| 185 | 183 | } |
| 186 | 184 | |
| 187 | 185 | /** |
| 186 | + * Display notice(s) immediately after the settings screen header. | |
| 187 | + * | |
| 188 | + * @since 1.9.6 | |
| 189 | + */ | |
| 190 | + private function maybe_display_notices() { | |
| 191 | + | |
| 192 | + $notices = array(); | |
| 193 | + | |
| 194 | + // Check the mbstring extension is loaded. | |
| 195 | + if ( ! extension_loaded( 'mbstring' ) ) { | |
| 196 | + $notices[] = array( | |
| 197 | + 'type' => 'warning', | |
| 198 | + 'message' => sprintf( | |
| 199 | + /* translators: link to php.net manual */ | |
| 200 | + __( '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' ), | |
| 201 | + '<a href="https://php.net/manual/en/mbstring.installation.php">mbstring</a>' | |
| 202 | + ), | |
| 203 | + ); | |
| 204 | + } | |
| 205 | + | |
| 206 | + // Bail if no notices exist. | |
| 207 | + if ( ! count( $notices ) ) { | |
| 208 | + return; | |
| 209 | + } | |
| 210 | + ?> | |
| 211 | + <div class="notices"> | |
| 212 | + <?php | |
| 213 | + // Output inline notices. | |
| 214 | + foreach ( $notices as $notice ) { | |
| 215 | + ?> | |
| 216 | + <div class="inline notice notice-<?php echo esc_attr( $notice['type'] ); ?>"> | |
| 217 | + <p> | |
| 218 | + <?php echo esc_attr( $notice['message'] ); ?> | |
| 219 | + </p> | |
| 220 | + </div> | |
| 221 | + <?php | |
| 222 | + } | |
| 223 | + ?> | |
| 224 | + </div> | |
| 225 | + <?php | |
| 226 | + | |
| 227 | + } | |
| 228 | + | |
| 229 | + /** | |
| 188 | 230 | * Define links to display below the Plugin Name on the WP_List_Table at in the Plugins screen. |
| 189 | 231 | * |
| 190 | 232 | * @param array $links Links. |
| 191 | 233 | * @return array Links |
| 192 | 234 | */ |
| 193 | - public function add_settings_page_link( $links ) { | |
| 235 | + public static function add_settings_page_link( $links ) { | |
| 194 | 236 | |
| 195 | - // Add link to Plugin settings screen. | |
| 196 | - $links['settings'] = sprintf( | |
| 197 | - '<a href="%s">%s</a>', | |
| 198 | - convertkit_get_settings_link(), | |
| 199 | - __( 'Settings', 'convertkit' ) | |
| 237 | + return array_merge( | |
| 238 | + array( | |
| 239 | + 'settings' => sprintf( | |
| 240 | + '<a href="%s">%s</a>', | |
| 241 | + convertkit_get_settings_link(), | |
| 242 | + __( 'Settings', 'convertkit' ) | |
| 243 | + ), | |
| 244 | + ), | |
| 245 | + $links | |
| 200 | 246 | ); |
| 201 | 247 | |
| 202 | - /** | |
| 203 | - * Define links to display below the Plugin Name on the WP_List_Table at Plugins > Installed Plugins. | |
| 204 | - * | |
| 205 | - * @since 2.1.2 | |
| 206 | - * | |
| 207 | - * @param array $links HTML Links. | |
| 208 | - */ | |
| 209 | - $links = apply_filters( 'convertkit_plugin_screen_action_links', $links ); | |
| 210 | - | |
| 211 | - // Return. | |
| 212 | - return $links; | |
| 213 | - | |
| 214 | 248 | } |
| 215 | - | |
| 216 | 249 | /** |
| 217 | 250 | * Output tabs, one for each registered settings section. |
| 218 | 251 | * |
| 219 | 252 | * @param string $active_section Currently displayed/selected section. |
| @@ -224,33 +257,15 @@ | ||
| 224 | 257 | <ul class="convertkit-tabs"> |
| 225 | 258 | <?php |
| 226 | 259 | foreach ( $this->sections as $section ) { |
| 227 | 260 | printf( |
| 228 | - '<li><a href="%s" class="convertkit-tab %s">%s%s</a></li>', | |
| 229 | - esc_url( | |
| 230 | - add_query_arg( | |
| 231 | - array( | |
| 232 | - 'page' => self::SETTINGS_PAGE_SLUG, | |
| 233 | - 'tab' => $section->name, | |
| 234 | - ), | |
| 235 | - admin_url( 'options-general.php' ) | |
| 236 | - ) | |
| 237 | - ), | |
| 238 | - ( $active_section === $section->name ? 'convertkit-tab-active' : '' ), | |
| 239 | - esc_html( $section->tab_text ), | |
| 240 | - $section->is_beta ? $this->get_beta_tab() : '' // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 261 | + '<li><a href="?page=%s&tab=%s" class="convertkit-tab %s">%s</a></li>', | |
| 262 | + sanitize_text_field( $_REQUEST['page'] ), // phpcs:ignore WordPress.Security.NonceVerification | |
| 263 | + esc_html( $section->name ), | |
| 264 | + $active_section === $section->name ? 'convertkit-tab-active' : '', | |
| 265 | + esc_html( $section->tab_text ) | |
| 241 | 266 | ); |
| 242 | 267 | } |
| 243 | - | |
| 244 | - // Output Documentation link tab, if it exists. | |
| 245 | - $documentation_url = $this->get_active_section_documentation_url( $active_section ); | |
| 246 | - if ( $documentation_url !== false ) { | |
| 247 | - printf( | |
| 248 | - '<li class="convertkit-docs"><a href="%s" class="convertkit-tab" target="_blank">%s <span class="dashicons dashicons-external"></span></a></li>', | |
| 249 | - esc_attr( $documentation_url ), | |
| 250 | - esc_html__( 'Documentation', 'convertkit' ) | |
| 251 | - ); | |
| 252 | - } | |
| 253 | 268 | ?> |
| 254 | 269 | </ul> |
| 255 | 270 | <?php |
| 256 | 271 | // WordPress' JS will automatically move any .notice elements to be immediately below .wp-header-end |
| @@ -263,29 +278,8 @@ | ||
| 263 | 278 | |
| 264 | 279 | } |
| 265 | 280 | |
| 266 | 281 | /** |
| 267 | - * Returns a 'beta' tab wrapped in a span, using wp_kses to ensure only permitted | |
| 268 | - * HTML elements are included in the output. | |
| 269 | - * | |
| 270 | - * @since 2.1.0 | |
| 271 | - * | |
| 272 | - * @return string | |
| 273 | - */ | |
| 274 | - private function get_beta_tab() { | |
| 275 | - | |
| 276 | - return wp_kses( | |
| 277 | - '<span class="convertkit-beta-label">' . esc_html__( 'Beta', 'convertkit' ) . '</span>', | |
| 278 | - array( | |
| 279 | - 'span' => array( | |
| 280 | - 'class' => array(), | |
| 281 | - ), | |
| 282 | - ) | |
| 283 | - ); | |
| 284 | - | |
| 285 | - } | |
| 286 | - | |
| 287 | - /** | |
| 288 | 282 | * Registers settings sections at Settings > ConvertKit. |
| 289 | 283 | * |
| 290 | 284 | * Each section has its own tab. |
| 291 | 285 | * |
| @@ -309,40 +303,8 @@ | ||
| 309 | 303 | $sections = apply_filters( 'convertkit_admin_settings_register_sections', $sections ); |
| 310 | 304 | |
| 311 | 305 | // With our sections now registered, assign them to this class. |
| 312 | 306 | $this->sections = $sections; |
| 313 | - | |
| 314 | - } | |
| 315 | - | |
| 316 | - /** | |
| 317 | - * Returns the documentation URL for the active settings section viewed by the user. | |
| 318 | - * | |
| 319 | - * @since 2.0.8 | |
| 320 | - * | |
| 321 | - * @param string $active_section Currently displayed/selected section. | |
| 322 | - * @return bool|string | |
| 323 | - */ | |
| 324 | - private function get_active_section_documentation_url( $active_section ) { | |
| 325 | - | |
| 326 | - // Bail if no sections registered. | |
| 327 | - if ( ! $this->sections ) { | |
| 328 | - return false; | |
| 329 | - } | |
| 330 | - | |
| 331 | - // Bail if the active section isn't registered. | |
| 332 | - if ( ! array_key_exists( $active_section, $this->sections ) ) { | |
| 333 | - return false; | |
| 334 | - } | |
| 335 | - | |
| 336 | - // Pass request to section's documentation_url() function, including UTM parameters. | |
| 337 | - return add_query_arg( | |
| 338 | - array( | |
| 339 | - 'utm_source' => 'wordpress', | |
| 340 | - 'utm_term' => get_locale(), | |
| 341 | - 'utm_content' => 'convertkit', | |
| 342 | - ), | |
| 343 | - $this->sections[ $active_section ]->documentation_url() | |
| 344 | - ); | |
| 345 | 307 | |
| 346 | 308 | } |
| 347 | 309 | |
| 348 | 310 | } |