static::get('html'),
'php' => static::get('php'),
'iframe' => static::get('iframe'),
'shortcode' => static::get('shortcode'),
];
}
public static function get($type = 'html') {
switch ($type) {
case 'iframe':
// generate url to load iframe's content
$iframeUrl = WPFunctions::get()->addQueryArg([
'mailpoet_form_iframe' => ':form_id:',
], WPFunctions::get()->trailingslashit(WPFunctions::get()->siteUrl()));
$onload = "var _this = this; window.addEventListener('message', function(e) {if(e.data.MailPoetIframeHeight){_this.style.height = e.data.MailPoetIframeHeight;}})";
// generate iframe
return join(' ', [
'',
]);
case 'php':
$output = [
'$form_widget = new \MailPoet\Form\Widget();',
'echo $form_widget->widget(array(\'form\' => ' .
':form_id:' .
', \'form_type\' => \'php\'));',
];
return join("\n", $output);
case 'html':
$output = [];
$output[] = '';
// CSS
$output[] = '';
// jQuery
$output[] = '';
// JS
$output[] = '';
$output[] = '';
// (JS) variables...
$output[] = '';
$output[] = '';
$formWidget = new Widget();
$output[] = $formWidget->widget([
'form' => ':form_id:',
'form_type' => 'php',
]);
return join("\n", $output);
case 'shortcode':
return '[mailpoet_form id=":form_id:"]';
}
}
}