← All changes
|
admin/section/class-convertkit-admin-section-base.php
+23
-0
3.4.0
→
3.4.3
View file →
| @@ -871,8 +871,31 @@ | ||
| 871 | 871 | |
| 872 | 872 | } |
| 873 | 873 | |
| 874 | 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 | |
| 894 | + | |
| 895 | + } | |
| 896 | + | |
| 897 | + /** | |
| 875 | 898 | * Returns the given text wrapped in a paragraph with the description class. |
| 876 | 899 | * |
| 877 | 900 | * @since 1.9.6 |
| 878 | 901 | * |