llms_merge_code_button( string $target = 'content', boolean $echo = true, array $codes = array() )
Add a “merge code” button that to auto-add merge codes to email & etc.
Description Description
..
Parameters Parameters
- $target
-
(string) (Optional) Target to add the merge code to. Accepts the ID of a tinymce editor or a DOM ID (#element-id).
Default value: 'content'
- $echo
-
(boolean) (Optional) If
true
, echos the HTML output.Default value: true
- $codes
-
(array) (Optional) array of custom codes to pass in, otherwise the codes are determined what is available for the post type.
Default value: array()
Return Return
(string) Returns the HTML for the merge code button.
Source Source
File: includes/admin/llms.functions.admin.php
function llms_merge_code_button( $target = 'content', $echo = true, $codes = array() ) { $screen = get_current_screen(); if ( ! $codes && $screen && isset( $screen->post_type ) ) { switch ( $screen->post_type ) { case 'llms_certificate': $codes = llms_get_certificate_merge_codes(); break; case 'llms_email': $codes = array( '{site_title}' => __( 'Website Title', 'lifterlms' ), '{site_url}' => __( 'Website URL', 'lifterlms' ), '{email_address}' => __( 'Student Email Address', 'lifterlms' ), '{user_login}' => __( 'Student Username', 'lifterlms' ), '{first_name}' => __( 'Student First Name', 'lifterlms' ), '{last_name}' => __( 'Student Last Name', 'lifterlms' ), '{current_date}' => __( 'Current Date', 'lifterlms' ), ); break; default: $codes = array(); } } /** * Filters the list of available merge codes in the specified context. * * @since Unknown * * @param array[] $codes Associative array of merge codes where the array key is the merge code and the array value is a name / description of the merge code. * @param WP_Screen|null $screen The screen object from `get_current_screen(). * @param string $target Target to add the merge code to. Accepts the ID of a tinymce editor or a DOM ID (#element-id). */ $codes = apply_filters( 'llms_merge_codes_for_button', $codes, $screen, $target ); $html = ''; if ( $codes ) { ob_start(); include LLMS_PLUGIN_DIR . 'includes/admin/views/merge-code-button.php'; $html = ob_get_clean(); } if ( $echo ) { echo $html; } return $html; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
6.0.0 | Move HTML into view file: includes/admin/views/merge-code-editor-button.php . Move certificate merge code list to llms_get_certificate_merge_codes() . |
3.17.4 | Unknown. |
3.1.0 | Introduced. |