← All changes
|
admin/section/class-convertkit-admin-section-base.php
+29
-1
3.3.9
→
3.4.3
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(); |
| @@ -862,8 +867,31 @@ | ||
| 862 | 867 | echo wp_kses( |
| 863 | 868 | $this->get_link_button( $url, $label, $css_classes ), |
| 864 | 869 | convertkit_kses_allowed_html() |
| 865 | 870 | ); |
| 871 | + | |
| 872 | + } | |
| 873 | + | |
| 874 | + /** | |
| 875 | + * Outputs the given code in a code block, with a button to copy the code | |
| 876 | + * to the clipboard. | |
| 877 | + * | |
| 878 | + * Requires the settings.css and ui.js resources to be enqueued on the screen | |
| 879 | + * calling this method. | |
| 880 | + * | |
| 881 | + * @since 3.4.1 | |
| 882 | + * | |
| 883 | + * @param string $code Code to display. | |
| 884 | + * @param string $id Optional ID attribute to assign to the code element. | |
| 885 | + */ | |
| 886 | + public function output_code_block( $code, $id = '' ) { | |
| 887 | + | |
| 888 | + ?> | |
| 889 | + <div class="kit-code"> | |
| 890 | + <pre><code<?php echo ( ! empty( $id ) ? ' id="' . esc_attr( $id ) . '"' : '' ); ?>><?php echo esc_html( $code ); ?></code></pre> | |
| 891 | + <button type="button" class="button button-secondary kit-code-copy"><?php esc_html_e( 'Copy', 'convertkit' ); ?></button> | |
| 892 | + </div> | |
| 893 | + <?php | |
| 866 | 894 | |
| 867 | 895 | } |
| 868 | 896 | |
| 869 | 897 | /** |