← All changes
|
admin/section/class-convertkit-admin-section-base.php
+62
-1
3.3.9
→
3.4.5
View file →
| @@ -46,9 +46,9 @@ | ||
| 46 | 46 | * Holds the settings class for the section. |
| 47 | 47 | * |
| 48 | 48 | * @since 1.9.6 |
| 49 | 49 | * |
| 50 | - * @var false|ConvertKit_Settings|ConvertKit_ContactForm7_Settings|ConvertKit_Wishlist_Settings|ConvertKit_Settings_Restrict_Content|ConvertKit_Settings_Broadcasts|ConvertKit_Forminator_Settings | |
| 50 | + * @var false|ConvertKit_Settings|ConvertKit_ContactForm7_Settings|ConvertKit_Wishlist_Settings|ConvertKit_Settings_Restrict_Content|ConvertKit_Settings_Broadcasts|ConvertKit_Forminator_Settings|ConvertKit_Settings_MCP | |
| 51 | 51 | */ |
| 52 | 52 | public $settings; |
| 53 | 53 | |
| 54 | 54 | /** |
| @@ -139,8 +139,13 @@ | ||
| 139 | 139 | * Register settings section. |
| 140 | 140 | */ |
| 141 | 141 | public function register_section() { |
| 142 | 142 | |
| 143 | + // Don't register a settings section if no settings key is defined. | |
| 144 | + if ( empty( $this->settings_key ) ) { | |
| 145 | + return; | |
| 146 | + } | |
| 147 | + | |
| 143 | 148 | // Register settings sections. |
| 144 | 149 | foreach ( $this->settings_sections as $name => $settings_section ) { |
| 145 | 150 | // Determine if this settings section needs to be wrapped in its own container. |
| 146 | 151 | $wrap = array(); |
| @@ -428,8 +433,41 @@ | ||
| 428 | 433 | |
| 429 | 434 | } |
| 430 | 435 | |
| 431 | 436 | /** |
| 437 | + * Outputs the given warning message in an inline notice, permitting links | |
| 438 | + * so the message can tell the user where to go. | |
| 439 | + * | |
| 440 | + * @since 3.4.5 | |
| 441 | + * | |
| 442 | + * @param string $warning_message Warning Message. | |
| 443 | + * @param string $css_class Additional CSS class for the notice. | |
| 444 | + */ | |
| 445 | + public function output_warning( $warning_message, $css_class = '' ) { | |
| 446 | + | |
| 447 | + ?> | |
| 448 | + <div class="notice notice-warning <?php echo esc_attr( sanitize_html_class( $css_class ) ); ?>"> | |
| 449 | + <p> | |
| 450 | + <?php | |
| 451 | + echo wp_kses( | |
| 452 | + $warning_message, | |
| 453 | + array( | |
| 454 | + 'a' => array( | |
| 455 | + 'href' => array(), | |
| 456 | + 'target' => array(), | |
| 457 | + ), | |
| 458 | + 'code' => array(), | |
| 459 | + 'strong' => array(), | |
| 460 | + ) | |
| 461 | + ); | |
| 462 | + ?> | |
| 463 | + </p> | |
| 464 | + </div> | |
| 465 | + <?php | |
| 466 | + | |
| 467 | + } | |
| 468 | + | |
| 469 | + /** | |
| 432 | 470 | * Outputs the given error message in an inline notice. |
| 433 | 471 | * |
| 434 | 472 | * @since 1.9.6 |
| 435 | 473 | * |
| @@ -862,8 +900,31 @@ | ||
| 862 | 900 | echo wp_kses( |
| 863 | 901 | $this->get_link_button( $url, $label, $css_classes ), |
| 864 | 902 | convertkit_kses_allowed_html() |
| 865 | 903 | ); |
| 904 | + | |
| 905 | + } | |
| 906 | + | |
| 907 | + /** | |
| 908 | + * Outputs the given code in a code block, with a button to copy the code | |
| 909 | + * to the clipboard. | |
| 910 | + * | |
| 911 | + * Requires the settings.css and ui.js resources to be enqueued on the screen | |
| 912 | + * calling this method. | |
| 913 | + * | |
| 914 | + * @since 3.4.1 | |
| 915 | + * | |
| 916 | + * @param string $code Code to display. | |
| 917 | + * @param string $id Optional ID attribute to assign to the code element. | |
| 918 | + */ | |
| 919 | + public function output_code_block( $code, $id = '' ) { | |
| 920 | + | |
| 921 | + ?> | |
| 922 | + <div class="kit-code"> | |
| 923 | + <pre><code<?php echo ( ! empty( $id ) ? ' id="' . esc_attr( $id ) . '"' : '' ); ?>><?php echo esc_html( $code ); ?></code></pre> | |
| 924 | + <button type="button" class="button button-secondary kit-code-copy"><?php esc_html_e( 'Copy', 'convertkit' ); ?></button> | |
| 925 | + </div> | |
| 926 | + <?php | |
| 866 | 927 | |
| 867 | 928 | } |
| 868 | 929 | |
| 869 | 930 | /** |