| Server IP : 38.190.208.107 / Your IP : 216.73.217.46 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.9/wp-content/plugins/mailchimp-for-wp/includes/forms/ |
Upload File : |
<?php
/**
* Class MC4WP_Form_AMP
*/
class MC4WP_Form_AMP
{
/**
* Hook!
*/
public function add_hooks()
{
add_filter('mc4wp_form_content', [ $this, 'add_response_templates' ], 10, 2);
add_filter('mc4wp_form_element_attributes', [ $this, 'add_amp_request' ]);
add_filter('mc4wp_load_form_scripts', [ $this, 'suppress_scripts' ]);
}
/**
* Add AMP templates for submit/success/error.
*
* @param string $content The form content.
* @param MC4WP_Form $form The form object.
* @return string Modified $content.
*/
public function add_response_templates($content, $form)
{
if (! function_exists('amp_is_request') || ! amp_is_request()) {
return $content;
}
ob_start();
?>
<div submitting>
<template type="amp-mustache">
<?php echo esc_html__('Submitting...', 'mailchimp-for-wp'); ?>
</template>
</div>
<div submit-success>
<template type="amp-mustache">
<?php
echo wp_kses(
$form->get_message('subscribed'),
[
'a' => [],
'strong' => [],
'em' => [],
]
);
?>
</template>
</div>
<div submit-error>
<template type="amp-mustache">
{{message}}
</template>
</div>
<?php
$content .= ob_get_clean();
return $content;
}
/**
* Add 'action-xhr' to AMP forms.
*
* @param array $attributes Key-Value pairs of attributes output on form.
* @return array Modified $attributes.
*/
public function add_amp_request($attributes)
{
if (function_exists('amp_is_request') && amp_is_request()) {
$attributes['action-xhr'] = get_rest_url(null, 'mc4wp/v1/form');
}
return $attributes;
}
/**
* Suppress form scripts on AMP pages.
*
* @param bool $load_scripts Whether scripts should be loaded.
* @return bool Modified $load_scripts.
*/
public function suppress_scripts($load_scripts)
{
if (function_exists('amp_is_request') && amp_is_request()) {
return false;
}
return $load_scripts;
}
}