| 1 |
<?php |
| 2 |
/** |
| 3 |
* Shortcode Subscription Form |
| 4 |
* |
| 5 |
* @link https://codesupply.co |
| 6 |
* @since 1.0.0 |
| 7 |
* |
| 8 |
* @package Powerkit |
| 9 |
* @subpackage Powerkit/shortcodes |
| 10 |
*/ |
| 11 |
|
| 12 |
/** |
| 13 |
* Subscription Form Shortcode |
| 14 |
* |
| 15 |
* @param array $atts User defined attributes in shortcode tag. |
| 16 |
* @param string $content Shorcode tag content. |
| 17 |
* @return string Shortcode result HTML. |
| 18 |
*/ |
| 19 |
function powerkit_subscription_shortcode( $atts, $content = '' ) { |
| 20 |
|
| 21 |
$params = powerkit_shortcode_atts( shortcode_atts( array( |
| 22 |
'privacy' => powerkit_mailchimp_get_privacy_text(), |
| 23 |
'title' => '', |
| 24 |
'text' => '', |
| 25 |
'bg_image_id' => '', |
| 26 |
'list_id' => 'default', |
| 27 |
'type' => 'block', |
| 28 |
'display_name' => false, |
| 29 |
), $atts ) ); |
| 30 |
|
| 31 |
ob_start(); |
| 32 |
|
| 33 |
$tag = apply_filters( 'powerkit_subscription_title_tag', 'h3' ); |
| 34 |
|
| 35 |
if ( $params['title'] ) { |
| 36 |
$params['title'] = sprintf( '<%1$s class="pk-title">%2$s</%1$s>', $tag, $params['title'] ); |
| 37 |
} |
| 38 |
|
| 39 |
do_action( 'powerkit_subscribe_template', $params ); |
| 40 |
|
| 41 |
return ob_get_clean(); |
| 42 |
} |
| 43 |
add_shortcode( 'powerkit_subscription_form', 'powerkit_subscription_shortcode' ); |
| 44 |
|
| 45 |
/** |
| 46 |
* Map Facebook Page Shortcode into the Basic Shortcodes Plugin |
| 47 |
*/ |
| 48 |
if ( function_exists( 'powerkit_basic_shortcodes_register' ) ) { |
| 49 |
|
| 50 |
$shortcode_map = array( |
| 51 |
'name' => 'subscription_form', |
| 52 |
'title' => esc_html__( 'Subscription Form', 'powerkit' ), |
| 53 |
'priority' => 160, |
| 54 |
'base' => 'powerkit_subscription_form', |
| 55 |
'autoregister' => false, |
| 56 |
'fields' => array( |
| 57 |
array( |
| 58 |
'type' => 'input', |
| 59 |
'name' => 'title', |
| 60 |
'label' => esc_html__( 'Title', 'powerkit' ), |
| 61 |
), |
| 62 |
array( |
| 63 |
'type' => 'input', |
| 64 |
'name' => 'bg_image_id', |
| 65 |
'label' => esc_html__( 'Background image ID', 'powerkit' ), |
| 66 |
), |
| 67 |
array( |
| 68 |
'type' => 'input', |
| 69 |
'name' => 'text', |
| 70 |
'label' => esc_html__( 'Message', 'powerkit' ), |
| 71 |
), |
| 72 |
array( |
| 73 |
'type' => 'input', |
| 74 |
'name' => 'list_id', |
| 75 |
'label' => esc_html__( 'List ID', 'powerkit' ), |
| 76 |
'desc' => '1. ' . esc_html__( 'Log in to your', 'powerkit' ) . ' ' . sprintf( '<a href="%1$s" target="_blank">%2$s</a>', esc_url( 'https://mailchimp.com' ), esc_html__( 'MailChimp account', 'powerkit' ) ) |
| 77 |
. '<br>2. ' . esc_html__( 'Go to your Lists.', 'powerkit' ) |
| 78 |
. '<br>3. ' . esc_html__( 'Select the desired list and in the drop-down menu and go to Settings.', 'powerkit' ) |
| 79 |
. '<br>4. ' . esc_html__( 'Copy your list ID from the field “Unique ID for list …”.', 'powerkit' ), |
| 80 |
), |
| 81 |
array( |
| 82 |
'type' => 'checkbox', |
| 83 |
'name' => 'display_name', |
| 84 |
'label' => esc_html__( 'Display first name field', 'powerkit' ), |
| 85 |
'desc' => esc_html__( 'Make sure you map the field in the MailChimp settings', 'powerkit' ), |
| 86 |
'default' => false, |
| 87 |
), |
| 88 |
), |
| 89 |
); |
| 90 |
|
| 91 |
powerkit_basic_shortcodes_register( $shortcode_map ); |
| 92 |
} |
| 93 |
|