2019-11-15 23:26:29 +01:00
< ? php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* Grunion Contact Form
* Add a contact form to any post , page or text widget .
* Emails will be sent to the post ' s author by default , or any email address you choose .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use automattic / jetpack - forms
2021-04-27 08:32:47 +02:00
* @ package automattic / jetpack
2019-11-15 23:26:29 +01:00
*/
2023-04-26 17:39:43 +02:00
// phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files.
2024-04-17 11:32:24 +02:00
use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Block ;
use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field ;
use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin ;
use Automattic\Jetpack\Forms\ContactForm\Util ;
2019-11-15 23:26:29 +01:00
define ( 'GRUNION_PLUGIN_DIR' , plugin_dir_path ( __FILE__ ) );
define ( 'GRUNION_PLUGIN_URL' , plugin_dir_url ( __FILE__ ) );
if ( is_admin () ) {
require_once GRUNION_PLUGIN_DIR . 'admin.php' ;
}
add_action ( 'rest_api_init' , 'grunion_contact_form_require_endpoint' );
2022-12-15 17:41:53 +01:00
/**
* Require the Grunion endpoint .
2024-04-17 11:32:24 +02:00
*
* @ deprecated 13.3
2022-12-15 17:41:53 +01:00
*/
2019-11-15 23:26:29 +01:00
function grunion_contact_form_require_endpoint () {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __FUNCTION__ , 'jetpack-13.3' );
2019-11-15 23:26:29 +01:00
require_once GRUNION_PLUGIN_DIR . 'class-grunion-contact-form-endpoint.php' ;
}
2022-12-15 17:41:53 +01:00
/**
* Sets the 'block_template' attribute on all instances of wp : jetpack / contact - form in
* the $_wp_current_template_content global variable .
*
* The $_wp_current_template_content global variable is hydrated immediately prior to
* 'template_include' in wp - includes / template - loader . php .
*
* This fixes Contact Form Blocks added to FSE _templates_ ( e . g . Single or 404 ) .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Util :: grunion_contact_form_set_block_template_attribute
2022-12-15 17:41:53 +01:00
* @ param string $template Template to be loaded .
*/
function grunion_contact_form_set_block_template_attribute ( $template ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __FUNCTION__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Util::grunion_contact_form_set_block_template_attribute' );
return Util :: grunion_contact_form_set_block_template_attribute ( $template );
2022-12-15 17:41:53 +01:00
}
add_filter ( 'template_include' , 'grunion_contact_form_set_block_template_attribute' );
/**
* Sets the $grunion_block_template_part_id global .
*
* This is part of the fix for Contact Form Blocks added to FSE _template parts_ ( e . g footer ) .
* The global is processed in Grunion_Contact_Form :: parse () .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Util :: grunion_contact_form_set_block_template_part_id_global
2022-12-15 17:41:53 +01:00
* @ param string $template_part_id ID for the currently rendered template part .
*/
function grunion_contact_form_set_block_template_part_id_global ( $template_part_id ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __FUNCTION__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Util::grunion_contact_form_set_block_template_part_id_global' );
return Util :: grunion_contact_form_set_block_template_part_id_global ( $template_part_id );
2022-12-15 17:41:53 +01:00
}
add_action ( 'render_block_core_template_part_post' , 'grunion_contact_form_set_block_template_part_id_global' );
add_action ( 'render_block_core_template_part_file' , 'grunion_contact_form_set_block_template_part_id_global' );
add_action ( 'render_block_core_template_part_none' , 'grunion_contact_form_set_block_template_part_id_global' );
add_action ( 'gutenberg_render_block_core_template_part_post' , 'grunion_contact_form_set_block_template_part_id_global' );
add_action ( 'gutenberg_render_block_core_template_part_file' , 'grunion_contact_form_set_block_template_part_id_global' );
add_action ( 'gutenberg_render_block_core_template_part_none' , 'grunion_contact_form_set_block_template_part_id_global' );
/**
* Unsets the global when block is done rendering .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Util :: grunion_contact_form_unset_block_template_part_id_global
2022-12-15 17:41:53 +01:00
* @ param string $content Rendered block content .
* @ param array $block The full block , including name and attributes .
* @ return string
*/
function grunion_contact_form_unset_block_template_part_id_global ( $content , $block ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __FUNCTION__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Util::grunion_contact_form_unset_block_template_part_id_global' );
return Util :: grunion_contact_form_unset_block_template_part_id_global ( $content , $block );
2022-12-15 17:41:53 +01:00
}
add_filter ( 'render_block' , 'grunion_contact_form_unset_block_template_part_id_global' , 10 , 2 );
/**
* Sets the 'widget' attribute on all instances of the contact form in the widget block .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Util :: grunion_contact_form_filter_widget_block_content
2022-12-15 17:41:53 +01:00
* @ param string $content Existing widget block content .
* @ param array $instance Array of settings for the current widget .
* @ param WP_Widget_Block $widget Current Block widget instance .
* @ return string
*/
function grunion_contact_form_filter_widget_block_content ( $content , $instance , $widget ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __FUNCTION__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Util::grunion_contact_form_filter_widget_block_content' );
return Util :: grunion_contact_form_filter_widget_block_content ( $content , $instance , $widget );
2022-12-15 17:41:53 +01:00
}
add_filter ( 'widget_block_content' , 'grunion_contact_form_filter_widget_block_content' , 1 , 3 );
/**
* Adds a given attribute to all instances of the Contact Form block .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Util :: grunion_contact_form_apply_block_attribute
2022-12-15 17:41:53 +01:00
* @ param string $content Existing content to process .
* @ param array $new_attr New attributes to add .
* @ return string
*/
function grunion_contact_form_apply_block_attribute ( $content , $new_attr ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __FUNCTION__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Util::grunion_contact_form_apply_block_attribute' );
return Util :: grunion_contact_form_apply_block_attribute ( $content , $new_attr );
2022-12-15 17:41:53 +01:00
}
2019-11-15 23:26:29 +01:00
/**
* Sets up various actions , filters , post types , post statuses , shortcodes .
2024-04-17 11:32:24 +02:00
*
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin
2019-11-15 23:26:29 +01:00
*/
class Grunion_Contact_Form_Plugin {
/**
2022-12-15 17:41:53 +01:00
*
* The Widget ID of the widget currently being processed . Used to build the unique contact - form ID for forms embedded in widgets .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 See Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin
2022-12-15 17:41:53 +01:00
* @ var string
2019-11-15 23:26:29 +01:00
*/
public $current_widget_id ;
2022-12-15 17:41:53 +01:00
/**
* If the contact form field is being used .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 See Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin
2022-12-15 17:41:53 +01:00
* @ var bool
*/
public static $using_contact_form_field = false ;
2019-11-15 23:26:29 +01:00
/**
2022-12-15 17:41:53 +01:00
*
* The last Feedback Post ID Erased as part of the Personal Data Eraser .
2019-11-15 23:26:29 +01:00
* Helps with pagination .
2022-12-15 17:41:53 +01:00
*
* @ var int
2019-11-15 23:26:29 +01:00
*/
private $pde_last_post_id_erased = 0 ;
/**
2022-12-15 17:41:53 +01:00
*
* The email address for which we are deleting / exporting all feedbacks
2019-11-15 23:26:29 +01:00
* as part of a Personal Data Eraser or Personal Data Exporter request .
2022-12-15 17:41:53 +01:00
*
* @ var string
2019-11-15 23:26:29 +01:00
*/
private $pde_email_address = '' ;
2022-12-15 17:41:53 +01:00
/**
* Initializing function .
2024-04-17 11:32:24 +02:00
*
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin :: init
2022-12-15 17:41:53 +01:00
*/
public static function init () {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin::init' );
2019-11-15 23:26:29 +01:00
static $instance = false ;
if ( ! $instance ) {
2024-04-17 11:32:24 +02:00
$instance = Contact_Form_Plugin :: init ();
2019-11-15 23:26:29 +01:00
}
return $instance ;
}
/**
* Runs daily to clean up spam detection metadata after 15 days . Keeps your DB squeaky clean .
2024-04-17 11:32:24 +02:00
*
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> daily_akismet_meta_cleanup
2019-11-15 23:26:29 +01:00
*/
public function daily_akismet_meta_cleanup () {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->daily_akismet_meta_cleanup' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return self :: $instance -> daily_akismet_meta_cleanup ();
2019-11-15 23:26:29 +01:00
}
/**
* Strips HTML tags from input . Output is NOT HTML safe .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin :: strip_tags
2022-12-15 17:41:53 +01:00
* @ param mixed $data_with_tags - data we ' re stripping HTML tags from .
2019-11-15 23:26:29 +01:00
* @ return mixed
*/
public static function strip_tags ( $data_with_tags ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin::strip_tags' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return Contact_Form_Plugin :: strip_tags ( $data_with_tags );
2023-04-26 17:39:43 +02:00
}
/**
* Prevent 'contact-form-styles' script from being concatenated .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 See Automattic\Jetpack\Forms\ContactForm
2023-04-26 17:39:43 +02:00
* @ param array $do_concat - the concatenation flag .
* @ param string $handle - script name .
*/
public static function disable_forms_style_script_concat ( $do_concat , $handle ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' );
2023-04-26 17:39:43 +02:00
if ( 'jetpack-block-contact-form' === $handle ) {
$do_concat = false ;
}
return $do_concat ;
}
2022-12-15 17:41:53 +01:00
/**
* Register the contact form block .
*/
2019-11-15 23:26:29 +01:00
private static function register_contact_form_blocks () {
2024-04-17 11:32:24 +02:00
Contact_Form_Block :: register_child_blocks ();
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Render the gutenblock form .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\ontact_Form_Block :: gutenblock_render_form
2022-12-15 17:41:53 +01:00
* @ param array $atts - the block attributes .
* @ param string $content - html content .
*
* @ return string
*/
2019-11-15 23:26:29 +01:00
public static function gutenblock_render_form ( $atts , $content ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Block::gutenblock_render_form' );
2023-04-26 17:39:43 +02:00
2024-04-17 11:32:24 +02:00
return Contact_Form_Block :: gutenblock_render_form ( $atts , $content );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Turn block attribute to shortcode attributes .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin :: block_attributes_to_shortcode_attributes
2022-12-15 17:41:53 +01:00
* @ param array $atts - the block attributes .
* @ param string $type - the type .
*
* @ return array
*/
2019-11-15 23:26:29 +01:00
public static function block_attributes_to_shortcode_attributes ( $atts , $type ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin::block_attributes_to_shortcode_attributes' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return Contact_Form_Plugin :: block_attributes_to_shortcode_attributes ( $atts , $type );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Render the text field .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin :: gutenblock_render_field_text
2022-12-15 17:41:53 +01:00
* @ param array $atts - the block attributes .
* @ param string $content - html content .
*
* @ return string HTML for the contact form field .
*/
2019-11-15 23:26:29 +01:00
public static function gutenblock_render_field_text ( $atts , $content ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin::gutenblock_render_field_text' );
return Contact_Form_Plugin :: gutenblock_render_field_text ( $atts , $content );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Render the name field .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin :: gutenblock_render_field_name
2022-12-15 17:41:53 +01:00
* @ param array $atts - the block attributes .
* @ param string $content - html content .
*
* @ return string HTML for the contact form field .
*/
2019-11-15 23:26:29 +01:00
public static function gutenblock_render_field_name ( $atts , $content ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin::gutenblock_render_field_name' );
return Contact_Form_Plugin :: gutenblock_render_field_name ( $atts , $content );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Render the email field .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin :: gutenblock_render_field_email
2022-12-15 17:41:53 +01:00
* @ param array $atts - the block attributes .
* @ param string $content - html content .
*
* @ return string HTML for the contact form field .
*/
2019-11-15 23:26:29 +01:00
public static function gutenblock_render_field_email ( $atts , $content ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin::gutenblock_render_field_email' );
return Contact_Form_Plugin :: gutenblock_render_field_email ( $atts , $content );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Render the url field .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin :: gutenblock_render_field_url
2022-12-15 17:41:53 +01:00
* @ param array $atts - the block attributes .
* @ param string $content - html content .
*
* @ return string HTML for the contact form field .
*/
2019-11-15 23:26:29 +01:00
public static function gutenblock_render_field_url ( $atts , $content ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin::gutenblock_render_field_url' );
return Contact_Form_Plugin :: gutenblock_render_field_url ( $atts , $content );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Render the date field .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin :: gutenblock_render_field_date
2022-12-15 17:41:53 +01:00
* @ param array $atts - the block attributes .
* @ param string $content - html content .
*
* @ return string HTML for the contact form field .
*/
2019-11-15 23:26:29 +01:00
public static function gutenblock_render_field_date ( $atts , $content ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin::gutenblock_render_field_date' );
return Contact_Form_Plugin :: gutenblock_render_field_date ( $atts , $content );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Render the telephone field .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin :: gutenblock_render_field_telephone
2022-12-15 17:41:53 +01:00
* @ param array $atts - the block attributes .
* @ param string $content - html content .
*
* @ return string HTML for the contact form field .
*/
2019-11-15 23:26:29 +01:00
public static function gutenblock_render_field_telephone ( $atts , $content ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin::gutenblock_render_field_telephone' );
return Contact_Form_Plugin :: gutenblock_render_field_telephone ( $atts , $content );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Render the text area field .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin :: gutenblock_render_field_textarea
2022-12-15 17:41:53 +01:00
* @ param array $atts - the block attributes .
* @ param string $content - html content .
*
* @ return string HTML for the contact form field .
*/
2019-11-15 23:26:29 +01:00
public static function gutenblock_render_field_textarea ( $atts , $content ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin::gutenblock_render_field_textarea' );
return Contact_Form_Plugin :: gutenblock_render_field_textarea ( $atts , $content );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Render the checkbox field .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin :: gutenblock_render_field_checkbox
2022-12-15 17:41:53 +01:00
* @ param array $atts - the block attributes .
* @ param string $content - html content .
*
* @ return string HTML for the contact form field .
*/
2019-11-15 23:26:29 +01:00
public static function gutenblock_render_field_checkbox ( $atts , $content ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin::gutenblock_render_field_checkbox' );
return Contact_Form_Plugin :: gutenblock_render_field_checkbox ( $atts , $content );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Render the multiple checkbox field .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin :: Contact_Form_Plugin :: gutenblock_render_field_checkbox_multiple
2022-12-15 17:41:53 +01:00
* @ param array $atts - the block attributes .
* @ param string $content - html content .
*
* @ return string HTML for the contact form field .
*/
2019-11-15 23:26:29 +01:00
public static function gutenblock_render_field_checkbox_multiple ( $atts , $content ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin::Contact_Form_Plugin::gutenblock_render_field_checkbox_multiple' );
return Contact_Form_Plugin :: gutenblock_render_field_checkbox_multiple ( $atts , $content );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
2023-04-26 17:39:43 +02:00
/**
* Render the multiple choice field option .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin :: gutenblock_render_field_option
2023-04-26 17:39:43 +02:00
* @ param array $atts - the block attributes .
* @ param string $content - html content .
*
* @ return string HTML for the contact form field .
*/
public static function gutenblock_render_field_option ( $atts , $content ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin::gutenblock_render_field_option' );
return Contact_Form_Plugin :: gutenblock_render_field_option ( $atts , $content );
2023-04-26 17:39:43 +02:00
}
2022-12-15 17:41:53 +01:00
/**
* Render the radio button field .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin :: gutenblock_render_field_radio
2022-12-15 17:41:53 +01:00
* @ param array $atts - the block attributes .
* @ param string $content - html content .
*
* @ return string HTML for the contact form field .
*/
2019-11-15 23:26:29 +01:00
public static function gutenblock_render_field_radio ( $atts , $content ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin::gutenblock_render_field_radio' );
return Contact_Form_Plugin :: gutenblock_render_field_radio ( $atts , $content );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Render the select field .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin :: gutenblock_render_field_select
2022-12-15 17:41:53 +01:00
* @ param array $atts - the block attributes .
* @ param string $content - html content .
*
* @ return string HTML for the contact form field .
*/
2019-11-15 23:26:29 +01:00
public static function gutenblock_render_field_select ( $atts , $content ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin::gutenblock_render_field_select' );
return Contact_Form_Plugin :: gutenblock_render_field_select ( $atts , $content );
2019-11-15 23:26:29 +01:00
}
2020-09-15 14:30:05 +02:00
/**
* Render the consent field .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin :: gutenblock_render_field_consent
2020-09-15 14:30:05 +02:00
* @ param string $atts consent attributes .
* @ param string $content html content .
*/
public static function gutenblock_render_field_consent ( $atts , $content ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin::gutenblock_render_field_consent' );
2020-09-15 14:30:05 +02:00
2024-04-17 11:32:24 +02:00
return Contact_Form_Plugin :: gutenblock_render_field_consent ( $atts , $content );
2020-09-15 14:30:05 +02:00
}
2019-11-15 23:26:29 +01:00
/**
2021-07-23 11:58:50 +02:00
* Add the 'Form Responses' menu item as a submenu of Feedback .
2024-04-17 11:32:24 +02:00
*
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> admin_menu
2019-11-15 23:26:29 +01:00
*/
public function admin_menu () {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->admin_menu' );
return self :: $instance -> admin_menu ();
2019-11-15 23:26:29 +01:00
}
/**
2020-09-15 14:30:05 +02:00
* Add to REST API post type allowed list .
2022-12-15 17:41:53 +01:00
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> allow_feedback_rest_api_type
2022-12-15 17:41:53 +01:00
* @ param array $post_types - the post types .
2019-11-15 23:26:29 +01:00
*/
2022-12-15 17:41:53 +01:00
public function allow_feedback_rest_api_type ( $post_types ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->allow_feedback_rest_api_type' );
return self :: $instance -> allow_feedback_rest_api_type ( $post_types );
2019-11-15 23:26:29 +01:00
}
/**
* Display the count of new feedback entries received . It ' s reset when user visits the Feedback screen .
*
* @ since 4.1 . 0
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> unread_count
2019-11-15 23:26:29 +01:00
* @ param object $screen Information about the current screen .
*/
2022-12-15 17:41:53 +01:00
public function unread_count ( $screen ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->unread_count' );
return self :: $instance -> unread_count ( $screen );
2019-11-15 23:26:29 +01:00
}
/**
* Handles all contact - form POST submissions
*
* Conditionally attached to `template_redirect`
2024-04-17 11:32:24 +02:00
*
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> process_form_submission
2019-11-15 23:26:29 +01:00
*/
2022-04-02 10:26:41 +02:00
public function process_form_submission () {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->process_form_submission' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return self :: $instance -> process_form_submission ();
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Handle the ajax request .
2024-04-17 11:32:24 +02:00
*
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> ajax_request
2022-12-15 17:41:53 +01:00
*/
public function ajax_request () {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->ajax_request' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return self :: $instance -> ajax_request ();
2019-11-15 23:26:29 +01:00
}
/**
* Ensure the post author is always zero for contact - form feedbacks
* Attached to `wp_insert_post_data`
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> insert_feedback_filter
2019-11-15 23:26:29 +01:00
* @ see Grunion_Contact_Form :: process_submission ()
2022-12-15 17:41:53 +01:00
* @ param array $data the data to insert .
* @ param array $postarr the data sent to wp_insert_post () .
* @ return array The filtered $data to insert .
2019-11-15 23:26:29 +01:00
*/
2022-12-15 17:41:53 +01:00
public function insert_feedback_filter ( $data , $postarr ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->insert_feedback_filter' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return self :: $instance -> insert_feedback_filter ( $data , $postarr );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
2019-11-15 23:26:29 +01:00
* Adds our contact - form shortcode
* The " child " contact - field shortcode is enabled as needed by the contact - form shortcode handler
2024-04-17 11:32:24 +02:00
*
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> add_shortcode
2019-11-15 23:26:29 +01:00
*/
2022-12-15 17:41:53 +01:00
public function add_shortcode () {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->add_shortcode' );
2023-04-26 17:39:43 +02:00
2024-04-17 11:32:24 +02:00
return self :: $instance -> add_shortcode ();
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Tokenize the label .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> tokenize_label
2022-12-15 17:41:53 +01:00
* @ param string $label - the label .
* @ return string
*/
public static function tokenize_label ( $label ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->tokenize_label' );
return Contact_Form_Plugin :: tokenize_label ( $label );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Sanitize the value .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> sanitize_value
2022-12-15 17:41:53 +01:00
* @ param string $value - the value to sanitize .
* @ return string
*/
public static function sanitize_value ( $value ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->sanitize_value' );
return Contact_Form_Plugin :: sanitize_value ( $value );
2019-11-15 23:26:29 +01:00
}
/**
* Replaces tokens like { city } or { City } ( case insensitive ) with the value
* of an input field of that name
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> replace_tokens_with_input
2022-12-15 17:41:53 +01:00
* @ param string $subject - the subject .
* @ param array $field_values Array with field label => field value associations .
* @ return string The filtered $subject with the tokens replaced .
2019-11-15 23:26:29 +01:00
*/
2022-12-15 17:41:53 +01:00
public function replace_tokens_with_input ( $subject , $field_values ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->replace_tokens_with_input' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return self :: $instance -> replace_tokens_with_input ( $subject , $field_values );
2019-11-15 23:26:29 +01:00
}
/**
* Tracks the widget currently being processed .
* Attached to `dynamic_sidebar`
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> track_current_widget
2022-12-15 17:41:53 +01:00
* @ see $current_widget_id - the current widget ID .
* @ param array $widget The widget data .
2019-11-15 23:26:29 +01:00
*/
2022-12-15 17:41:53 +01:00
public function track_current_widget ( $widget ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->track_current_widget' );
return self :: $instance -> track_current_widget ( $widget );
2019-11-15 23:26:29 +01:00
}
/**
* Adds a " widget " attribute to every contact - form embedded in a text widget .
* Used to tell the difference between post - embedded contact - forms and widget - embedded contact - forms
* Attached to `widget_text`
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> widget_atts
2022-12-15 17:41:53 +01:00
* @ param string $text The widget text .
* @ return string The filtered widget text .
2019-11-15 23:26:29 +01:00
*/
2022-12-15 17:41:53 +01:00
public function widget_atts ( $text ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->widget_atts' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return self :: $instance -> widget_atts ( $text );
2019-11-15 23:26:29 +01:00
}
/**
* For sites where text widgets are not processed for shortcodes , we add this hack to process just our shortcode
* Attached to `widget_text`
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> widget_shortcode_hack
2022-12-15 17:41:53 +01:00
* @ param string $text The widget text .
2019-11-15 23:26:29 +01:00
* @ return string The contact - form filtered widget text
*/
2022-12-15 17:41:53 +01:00
public function widget_shortcode_hack ( $text ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->widget_shortcode_hack' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return self :: $instance -> widget_shortcode_hack ( $text );
2019-11-15 23:26:29 +01:00
}
/**
2020-09-15 14:30:05 +02:00
* Check if a submission matches the Comment Blocklist .
* The Comment Blocklist is a means to moderate discussion , and contact
2019-11-15 23:26:29 +01:00
* forms are 1 : 1 discussion forums , ripe for abuse by users who are being
* removed from the public discussion .
* Attached to `jetpack_contact_form_is_spam`
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> is_spam_blocklist
2022-12-15 17:41:53 +01:00
* @ param bool $is_spam - if the submission is spam .
* @ param array $form - the form data .
2019-11-15 23:26:29 +01:00
* @ return bool TRUE => spam , FALSE => not spam
*/
2020-09-15 14:30:05 +02:00
public function is_spam_blocklist ( $is_spam , $form = array () ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->is_spam_blocklist' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return self :: $instance -> is_spam_blocklist ( $is_spam , $form );
2020-09-15 14:30:05 +02:00
}
/**
* Check if a submission matches the comment disallowed list .
* Attached to `jetpack_contact_form_in_comment_disallowed_list` .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> is_in_disallowed_list
2020-09-15 14:30:05 +02:00
* @ param boolean $in_disallowed_list Whether the feedback is in the disallowed list .
* @ param array $form The form array .
* @ return bool Returns true if the form submission matches the disallowed list and false if it doesn ' t .
*/
public function is_in_disallowed_list ( $in_disallowed_list , $form = array () ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->is_in_disallowed_list' );
2020-09-15 14:30:05 +02:00
2024-04-17 11:32:24 +02:00
return self :: $instance -> is_in_disallowed_list ( $in_disallowed_list , $form );
2019-11-15 23:26:29 +01:00
}
/**
* Populate an array with all values necessary to submit a NEW contact - form feedback to Akismet .
* Note that this includes the current user_ip etc , so this should only be called when accepting a new item via $_POST
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> prepare_for_akismet
2022-12-15 17:41:53 +01:00
* @ param array $form - contact form feedback array .
* @ return array feedback array with additional data ready for submission to Akismet .
2019-11-15 23:26:29 +01:00
*/
2022-12-15 17:41:53 +01:00
public function prepare_for_akismet ( $form ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->prepare_for_akismet' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return self :: $instance -> prepare_for_akismet ( $form );
2019-11-15 23:26:29 +01:00
}
/**
* Submit contact - form data to Akismet to check for spam .
* If you ' re accepting a new item via $_POST , run it Grunion_Contact_Form_Plugin :: prepare_for_akismet () first
* Attached to `jetpack_contact_form_is_spam`
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> is_spam_akismet
2022-12-15 17:41:53 +01:00
* @ param bool $is_spam - if the submission is spam .
* @ param array $form - the form data .
2019-11-15 23:26:29 +01:00
* @ return bool | WP_Error TRUE => spam , FALSE => not spam , WP_Error => stop processing entirely
*/
2022-12-15 17:41:53 +01:00
public function is_spam_akismet ( $is_spam , $form = array () ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->is_spam_akismet' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return self :: $instance -> is_spam_akismet ( $is_spam , $form );
2019-11-15 23:26:29 +01:00
}
/**
* Submit a feedback as either spam or ham
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> akismet_submit
2022-12-15 17:41:53 +01:00
* @ param string $as - Either 'spam' or 'ham' .
* @ param array $form - the contact - form data .
* @ return bool | string
2019-11-15 23:26:29 +01:00
*/
2022-12-15 17:41:53 +01:00
public function akismet_submit ( $as , $form ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->akismet_submit' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return self :: $instance -> akismet_submit ( $as , $form );
2019-11-15 23:26:29 +01:00
}
/**
2022-12-15 17:41:53 +01:00
* Prints a dropdown of posts with forms .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin :: form_posts_dropdown
2022-12-15 17:41:53 +01:00
* @ param int $selected_id Currently selected post ID .
* @ return void
2019-11-15 23:26:29 +01:00
*/
2022-12-15 17:41:53 +01:00
public static function form_posts_dropdown ( $selected_id ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin::form_posts_dropdown' );
Contact_Form_Plugin :: form_posts_dropdown ( $selected_id );
2019-11-15 23:26:29 +01:00
}
/**
* Fetch post content for a post and extract just the comment .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> get_post_content_for_csv_export
2019-11-15 23:26:29 +01:00
* @ param int $post_id The post id to fetch the content for .
* @ return string Trimmed post comment .
*
* @ codeCoverageIgnore
*/
public function get_post_content_for_csv_export ( $post_id ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->get_post_content_for_csv_export' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return self :: $instance -> get_post_content_for_csv_export ( $post_id );
2019-11-15 23:26:29 +01:00
}
/**
* Get `_feedback_extra_fields` field from post meta data .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> get_post_meta_for_csv_export
2019-11-15 23:26:29 +01:00
* @ param int $post_id Id of the post to fetch meta data for .
* @ return mixed
*/
public function get_post_meta_for_csv_export ( $post_id ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->get_post_meta_for_csv_export' );
2020-09-15 14:30:05 +02:00
2024-04-17 11:32:24 +02:00
return self :: $instance -> get_post_meta_for_csv_export ( $post_id );
2019-11-15 23:26:29 +01:00
}
/**
* Get parsed feedback post fields .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> get_parsed_field_contents_of_post
2019-11-15 23:26:29 +01:00
* @ param int $post_id Id of the post to fetch parsed contents for .
* @ return array
*
* @ codeCoverageIgnore - No need to be covered .
*/
public function get_parsed_field_contents_of_post ( $post_id ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->get_parsed_field_contents_of_post' );
return self :: $instance -> get_parsed_field_contents_of_post ( $post_id );
2019-11-15 23:26:29 +01:00
}
/**
* Properly maps fields that are missing from the post meta data
* to names , that are similar to those of the post meta .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> map_parsed_field_contents_of_post_to_field_names
2022-12-15 17:41:53 +01:00
* @ param array $parsed_post_content Parsed post content .
2019-11-15 23:26:29 +01:00
* @ see parse_fields_from_content for how the input data is generated .
* @ return array Mapped fields .
*/
public function map_parsed_field_contents_of_post_to_field_names ( $parsed_post_content ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->map_parsed_field_contents_of_post_to_field_names' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return self :: $instance -> map_parsed_field_contents_of_post_to_field_names ( $parsed_post_content );
2019-11-15 23:26:29 +01:00
}
/**
* Registers the personal data exporter .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> register_personal_data_exporter
2019-11-15 23:26:29 +01:00
* @ since 6.1 . 1
* @ param array $exporters An array of personal data exporters .
* @ return array $exporters An array of personal data exporters .
*/
public function register_personal_data_exporter ( $exporters ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->register_personal_data_exporter' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return self :: $instance -> register_personal_data_exporter ( $exporters );
2019-11-15 23:26:29 +01:00
}
/**
* Registers the personal data eraser .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> register_personal_data_eraser
2019-11-15 23:26:29 +01:00
* @ since 6.1 . 1
* @ param array $erasers An array of personal data erasers .
* @ return array $erasers An array of personal data erasers .
*/
public function register_personal_data_eraser ( $erasers ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->register_personal_data_eraser' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return self :: $instance -> register_personal_data_eraser ( $erasers );
2019-11-15 23:26:29 +01:00
}
/**
* Exports personal data .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> personal_data_exporter
2019-11-15 23:26:29 +01:00
* @ since 6.1 . 1
* @ param string $email Email address .
* @ param int $page Page to export .
* @ return array $return Associative array with keys expected by core .
*/
public function personal_data_exporter ( $email , $page = 1 ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->personal_data_exporter' );
return self :: $instance -> personal_data_exporter ( $email , $page );
2019-11-15 23:26:29 +01:00
}
/**
* Internal method for exporting personal data .
*
* Allows us to have a different signature than core expects
* while protecting against future core API changes .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> internal_personal_data_exporter
2019-11-15 23:26:29 +01:00
* @ internal
* @ since 6.5
* @ param string $email Email address .
* @ param int $page Page to export .
2022-12-15 17:41:53 +01:00
* @ param int $per_page Number of feedbacks to process per page . Internal use only ( testing ) .
2019-11-15 23:26:29 +01:00
* @ return array Associative array with keys expected by core .
*/
2022-12-15 17:41:53 +01:00
public function internal_personal_data_exporter ( $email , $page = 1 , $per_page = 250 ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->internal_personal_data_exporter' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return self :: $instance -> internal_personal_data_exporter ( $email , $page , $per_page );
2019-11-15 23:26:29 +01:00
}
/**
* Erases personal data .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> personal_data_eraser
2019-11-15 23:26:29 +01:00
* @ since 6.1 . 1
* @ param string $email Email address .
* @ param int $page Page to erase .
* @ return array Associative array with keys expected by core .
*/
public function personal_data_eraser ( $email , $page = 1 ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->personal_data_eraser' );
return self :: $instance -> personal_data_eraser ( $email , $page );
2019-11-15 23:26:29 +01:00
}
/**
* Internal method for erasing personal data .
*
* Allows us to have a different signature than core expects
* while protecting against future core API changes .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> _internal_personal_data_eraser
2019-11-15 23:26:29 +01:00
* @ internal
* @ since 6.5
* @ param string $email Email address .
* @ param int $page Page to erase .
2022-12-15 17:41:53 +01:00
* @ param int $per_page Number of feedbacks to process per page . Internal use only ( testing ) .
2019-11-15 23:26:29 +01:00
* @ return array Associative array with keys expected by core .
*/
2022-12-15 17:41:53 +01:00
public function _internal_personal_data_eraser ( $email , $page = 1 , $per_page = 250 ) { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore -- this is called in other files.
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->_internal_personal_data_eraser' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return self :: $instance -> _internal_personal_data_eraser ( $email , $page , $per_page );
2019-11-15 23:26:29 +01:00
}
/**
* Queries personal data by email address .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> personal_data_post_ids_by_email
2019-11-15 23:26:29 +01:00
* @ since 6.1 . 1
* @ param string $email Email address .
* @ param int $per_page Post IDs per page . Default is `250` .
* @ param int $page Page to query . Default is `1` .
* @ param int $last_post_id Page to query . Default is `0` . If non - zero , used instead of $page .
* @ return array An array of post IDs .
*/
public function personal_data_post_ids_by_email ( $email , $per_page = 250 , $page = 1 , $last_post_id = 0 ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->personal_data_post_ids_by_email' );
return self :: $instance -> personal_data_post_ids_by_email ( $email , $per_page , $page , $last_post_id );
2019-11-15 23:26:29 +01:00
}
/**
* Filters searches by email address .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> personal_data_search_filter
2019-11-15 23:26:29 +01:00
* @ since 6.1 . 1
* @ param string $search SQL where clause .
* @ return array Filtered SQL where clause .
*/
public function personal_data_search_filter ( $search ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->personal_data_search_filter' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return self :: $instance -> personal_data_search_filter ( $search );
2019-11-15 23:26:29 +01:00
}
/**
* Prepares feedback post data for CSV export .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> get_export_data_for_posts
2019-11-15 23:26:29 +01:00
* @ param array $post_ids Post IDs to fetch the data for . These need to be Feedback posts .
* @ return array
*/
public function get_export_data_for_posts ( $post_ids ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->get_export_data_for_posts' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return self :: $instance -> get_export_data_for_posts ( $post_ids );
2019-11-15 23:26:29 +01:00
}
2023-04-26 17:39:43 +02:00
/**
* Returns an array of [ prefixed column name ] => [ translated column name ], used on export .
* Prefix indicates the position in which the column will be rendered :
* - Negative numbers render BEFORE any form field / value column : - 5 , - 3 , - 1. ..
* - Positive values render AFTER any form field / value column : 1 , 30 , 93. ..
* Mind using high numbering on these ones as the prefix is used on regular inputs : 1_ Name , 2_ Email , etc
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> get_well_known_column_names
2023-04-26 17:39:43 +02:00
* @ return array
*/
public function get_well_known_column_names () {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->get_well_known_column_names' );
return self :: $instance -> get_well_known_column_names ();
2023-04-26 17:39:43 +02:00
}
2019-11-15 23:26:29 +01:00
/**
2023-01-25 20:43:46 +01:00
* Extracts feedback entries based on POST data .
2024-04-17 11:32:24 +02:00
*
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> get_feedback_entries_from_post
2019-11-15 23:26:29 +01:00
*/
2023-01-25 20:43:46 +01:00
public function get_feedback_entries_from_post () {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->get_feedback_entries_from_post' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return self :: $instance -> get_feedback_entries_from_post ();
2023-01-25 20:43:46 +01:00
}
/**
* Download exported data as CSV
2024-04-17 11:32:24 +02:00
*
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> download_feedback_as_csv
2023-01-25 20:43:46 +01:00
*/
public function download_feedback_as_csv () {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->download_feedback_as_csv' );
2023-01-25 20:43:46 +01:00
2024-04-17 11:32:24 +02:00
return self :: $instance -> download_feedback_as_csv ();
2023-04-26 17:39:43 +02:00
}
/**
* Send an event to Tracks
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> record_tracks_event
2023-04-26 17:39:43 +02:00
* @ param string $event_name - the name of the event .
* @ param array $event_props - event properties to send .
* @ return null | void
*/
public function record_tracks_event ( $event_name , $event_props ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->record_tracks_event' );
2023-04-26 17:39:43 +02:00
2024-04-17 11:32:24 +02:00
return self :: $instance -> record_tracks_event ( $event_name , $event_props );
2019-11-15 23:26:29 +01:00
}
/**
* Escape a string to be used in a CSV context
*
* Malicious input can inject formulas into CSV files , opening up the possibility for phishing attacks and
* disclosure of sensitive information .
*
* Additionally , Excel exposes the ability to launch arbitrary commands through the DDE protocol .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> esc_csv
2019-11-15 23:26:29 +01:00
* @ see https :// www . contextis . com / en / blog / comma - separated - vulnerabilities
2022-12-15 17:41:53 +01:00
* @ param string $field - the CSV field .
2019-11-15 23:26:29 +01:00
* @ return string
*/
public function esc_csv ( $field ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->esc_csv' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return self :: $instance -> esc_csv ( $field );
2019-11-15 23:26:29 +01:00
}
/**
2024-04-17 11:32:24 +02:00
* Parse the contact form fields .
2019-11-15 23:26:29 +01:00
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> parse_fields_from_content
* @ param int $post_id - the post ID .
* @ return array Fields .
*/
public static function parse_fields_from_content ( $post_id ) {
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->parse_fields_from_content' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return Contact_Form_Plugin :: parse_fields_from_content ( $post_id );
2019-11-15 23:26:29 +01:00
}
/**
2024-04-17 11:32:24 +02:00
* Get the IP address .
2019-11-15 23:26:29 +01:00
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> get_ip_address
* @ return string | null IP address .
2019-11-15 23:26:29 +01:00
*/
2024-04-17 11:32:24 +02:00
public static function get_ip_address () {
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->get_ip_address' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return Contact_Form_Plugin :: get_ip_address ();
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
2024-04-17 11:32:24 +02:00
* Disable Block Editor for feedbacks .
2022-12-15 17:41:53 +01:00
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin -> use_block_editor_for_post_type
* @ param bool $can_edit Whether the post type can be edited or not .
* @ param string $post_type The post type being checked .
* @ return bool
2022-12-15 17:41:53 +01:00
*/
2024-04-17 11:32:24 +02:00
public function use_block_editor_for_post_type ( $can_edit , $post_type ) {
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin->use_block_editor_for_post_type' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return self :: $instance -> use_block_editor_for_post_type ( $can_edit , $post_type );
2021-09-07 21:40:48 +02:00
}
2023-04-26 17:39:43 +02:00
/**
* Kludge method : reverses the output of a standard print_r ( $array ) .
* Sort of what unserialize does to a serialized object .
* This is here while we work on a better data storage inside the posts . See :
* - p1675781140892129 - slack - C01CSBEN0QZ
* - https :// www . php . net / manual / en / function . print - r . php #93529
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin :: reverse_that_print
2023-04-26 17:39:43 +02:00
* @ param string $print_r_output The array string to be reverted . Needs to being with 'Array' .
* @ param bool $parse_html Whether to run html_entity_decode on each line .
* As strings are stored right now , they are all escaped , so '=>' are '>' .
* @ return array | string Array when succesfully reconstructed , string otherwise . Output will always be esc_html ' d .
*/
public static function reverse_that_print ( $print_r_output , $parse_html = false ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Plugin::reverse_that_print' );
2023-04-26 17:39:43 +02:00
2024-04-17 11:32:24 +02:00
return Contact_Form_Plugin :: reverse_that_print ( $print_r_output , $parse_html );
2023-04-26 17:39:43 +02:00
}
2019-11-15 23:26:29 +01:00
}
/**
* Generic shortcode class .
* Does nothing other than store structured data and output the shortcode as a string
*
* Not very general - specific to Grunion .
2022-12-15 17:41:53 +01:00
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Shortcode
*
2022-12-15 17:41:53 +01:00
* // phpcs:disable Generic.Files.OneObjectStructurePerFile.MultipleFound
2019-11-15 23:26:29 +01:00
*/
class Crunion_Contact_Form_Shortcode {
/**
2022-12-15 17:41:53 +01:00
* The name of the shortcode : [ $shortcode_name / ] .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 See Automattic\Jetpack\Forms\ContactForm\Contact_Form_Shortcode
2022-12-15 17:41:53 +01:00
* @ var string
2019-11-15 23:26:29 +01:00
*/
2024-04-17 11:32:24 +02:00
private $shortcode_name ;
2019-11-15 23:26:29 +01:00
/**
2022-12-15 17:41:53 +01:00
* Key => value pairs for the shortcode ' s attributes : [ $shortcode_name key = " value " ... / ]
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 See Automattic\Jetpack\Forms\ContactForm\Contact_Form_Shortcode
2022-12-15 17:41:53 +01:00
* @ var array
2019-11-15 23:26:29 +01:00
*/
2024-04-17 11:32:24 +02:00
private $attributes ;
2019-11-15 23:26:29 +01:00
/**
2022-12-15 17:41:53 +01:00
* Key => value pair for attribute defaults .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 See Automattic\Jetpack\Forms\ContactForm\Contact_Form_Shortcode
2022-12-15 17:41:53 +01:00
* @ var array
2019-11-15 23:26:29 +01:00
*/
2024-04-17 11:32:24 +02:00
private $defaults = array ();
2019-11-15 23:26:29 +01:00
/**
2022-12-15 17:41:53 +01:00
* The inner content of otherwise : [ $shortcode_name ] $content [ / $shortcode_name ] . Null for selfclosing shortcodes .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 See Automattic\Jetpack\Forms\ContactForm\Contact_Form_Shortcode
2022-12-15 17:41:53 +01:00
* @ var null | string
2019-11-15 23:26:29 +01:00
*/
2024-04-17 11:32:24 +02:00
private $content ;
2019-11-15 23:26:29 +01:00
/**
2022-12-15 17:41:53 +01:00
* Associative array of inner " child " shortcodes equivalent to the $content : [ $shortcode_name ][ child 1 / ][ child 2 / ][ / $shortcode_name ]
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 See Automattic\Jetpack\Forms\ContactForm\Contact_Form_Shortcode
2022-12-15 17:41:53 +01:00
* @ var array
2019-11-15 23:26:29 +01:00
*/
2024-04-17 11:32:24 +02:00
private $fields ;
2019-11-15 23:26:29 +01:00
/**
2022-12-15 17:41:53 +01:00
* The HTML of the parsed inner " child " shortcodes " . Null for selfclosing shortcodes.
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 See Automattic\Jetpack\Forms\ContactForm\Contact_Form_Shortcode
2022-12-15 17:41:53 +01:00
* @ var null | string
2019-11-15 23:26:29 +01:00
*/
2024-04-17 11:32:24 +02:00
private $body ;
/**
* We ' re using object composition to call code from the `forms` package .
* This holds the reference to the Contact_Form_Shortcode instance .
*
* @ var Contact_Form_Shortcode
*/
private $shortcode ;
2019-11-15 23:26:29 +01:00
/**
2022-12-15 17:41:53 +01:00
* Constructor function .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Shortcode -> __construct
2022-12-15 17:41:53 +01:00
* @ param array $attributes An associative array of shortcode attributes . @ see shortcode_atts () .
2019-11-15 23:26:29 +01:00
* @ param null | string $content Null for selfclosing shortcodes . The inner content otherwise .
*/
2022-12-15 17:41:53 +01:00
public function __construct ( $attributes , $content = null ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Shortcode->__construct' );
$this -> shortcode = new Contact_Form_Shortcode ( $attributes , $content );
}
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
/**
* Set properties on the Contact_Form_Shortcode instance .
*
* @ param string $name Name of the property .
* @ param mixed $value Value of the property .
*/
public function __set ( $name , $value ) {
$this -> shortcode -> { $name } = $value ;
}
/**
* Get properties from the Contact_Form_Shortcode instance .
*
* @ param string $name Name of the property .
* @ return mixed
*/
public function __get ( $name ) {
return $this -> shortcode -> { $name };
2019-11-15 23:26:29 +01:00
}
/**
2022-12-15 17:41:53 +01:00
* Processes the shortcode ' s inner content for " child " shortcodes .
2019-11-15 23:26:29 +01:00
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Shortcode -> parse_content
2022-12-15 17:41:53 +01:00
* @ param string $content The shortcode ' s inner content : [ shortcode ] $content [ / shortcode ] .
2019-11-15 23:26:29 +01:00
*/
2022-12-15 17:41:53 +01:00
public function parse_content ( $content ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Shortcode->parse_content' );
return $this -> shortcode -> parse_content ( $content );
2019-11-15 23:26:29 +01:00
}
/**
* Returns the value of the requested attribute .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Shortcode -> get_attribute
2022-12-15 17:41:53 +01:00
* @ param string $key The attribute to retrieve .
2019-11-15 23:26:29 +01:00
* @ return mixed
*/
2022-12-15 17:41:53 +01:00
public function get_attribute ( $key ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Shortcode->get_attribute' );
return $this -> shortcode -> get_attribute ( $key );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Escape attributes .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Shortcode -> esc_attr
2022-12-15 17:41:53 +01:00
* @ param array $value - the value we ' re escaping .
* @ return array
*/
public function esc_attr ( $value ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Shortcode->esc_attr' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return $this -> shortcode -> esc_attr ( $value );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Unescape attributes .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Shortcode -> unesc_attr
2022-12-15 17:41:53 +01:00
* @ param array $value - the value we ' re escaping .
* @ return array
*/
public function unesc_attr ( $value ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Shortcode->unesc_attr' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return $this -> shortcode -> unesc_attr ( $value );
2019-11-15 23:26:29 +01:00
}
/**
* Generates the shortcode
2024-04-17 11:32:24 +02:00
*
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Shortcode -> __toString
2019-11-15 23:26:29 +01:00
*/
2022-12-15 17:41:53 +01:00
public function __toString () {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Shortcode->__toString' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return $this -> shortcode -> __toString ();
2019-11-15 23:26:29 +01:00
}
}
/**
* Class for the contact - form shortcode .
* Parses shortcode to output the contact form as HTML
* Sends email and stores the contact form response ( a . k . a . " feedback " )
2024-04-17 11:32:24 +02:00
*
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form
2019-11-15 23:26:29 +01:00
*/
class Grunion_Contact_Form extends Crunion_Contact_Form_Shortcode {
2022-12-15 17:41:53 +01:00
/**
* The shortcode name .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 See Automattic\Jetpack\Forms\ContactForm\Contact_Form
2022-12-15 17:41:53 +01:00
* @ var string
*/
2024-04-17 11:32:24 +02:00
private $shortcode_name = 'contact-form' ;
2019-11-15 23:26:29 +01:00
/**
2022-12-15 17:41:53 +01:00
*
* Stores form submission errors .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 See Automattic\Jetpack\Forms\ContactForm\Contact_Form
2022-12-15 17:41:53 +01:00
* @ var WP_Error
2019-11-15 23:26:29 +01:00
*/
2024-04-17 11:32:24 +02:00
private $errors ;
2019-11-15 23:26:29 +01:00
/**
2022-12-15 17:41:53 +01:00
* The SHA1 hash of the attributes that comprise the form .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 See Automattic\Jetpack\Forms\ContactForm\Contact_Form
2022-12-15 17:41:53 +01:00
* @ var string
2019-11-15 23:26:29 +01:00
*/
2024-04-17 11:32:24 +02:00
private $hash ;
2019-11-15 23:26:29 +01:00
/**
2022-12-15 17:41:53 +01:00
* The most recent ( inclusive ) contact - form shortcode processed .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 See Automattic\Jetpack\Forms\ContactForm\Contact_Form
2022-12-15 17:41:53 +01:00
* @ var Grunion_Contact_Form
2019-11-15 23:26:29 +01:00
*/
2024-04-17 11:32:24 +02:00
private static $last ;
2019-11-15 23:26:29 +01:00
/**
2022-12-15 17:41:53 +01:00
* Form we are currently looking at . If processed , will become $last
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 See Automattic\Jetpack\Forms\ContactForm\Contact_Form
2022-12-15 17:41:53 +01:00
* @ var Whatever
2019-11-15 23:26:29 +01:00
*/
2024-04-17 11:32:24 +02:00
private static $current_form ;
2019-11-15 23:26:29 +01:00
/**
2022-12-15 17:41:53 +01:00
* All found forms , indexed by hash .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 See Automattic\Jetpack\Forms\ContactForm\Contact_Form
2022-12-15 17:41:53 +01:00
* @ var array
2019-11-15 23:26:29 +01:00
*/
2024-04-17 11:32:24 +02:00
private static $forms = array ();
2019-11-15 23:26:29 +01:00
/**
2022-12-15 17:41:53 +01:00
* Whether to print the grunion . css style when processing the contact - form shortcode
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 See Automattic\Jetpack\Forms\ContactForm\Contact_Form
2022-12-15 17:41:53 +01:00
* @ var bool
2019-11-15 23:26:29 +01:00
*/
2024-04-17 11:32:24 +02:00
private static $style = false ;
2019-11-15 23:26:29 +01:00
/**
2022-12-15 17:41:53 +01:00
* When printing the submit button , what tags are allowed
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 See Automattic\Jetpack\Forms\ContactForm\Contact_Form
2022-12-15 17:41:53 +01:00
* @ var array
2019-11-15 23:26:29 +01:00
*/
2024-04-17 11:32:24 +02:00
private static $allowed_html_tags_for_submit_button = array ( 'br' => array () );
/**
* We ' re using object composition to call code from the `forms` package .
* This holds the reference to the Contact_Form instance .
*
* @ var Contact_Form
*/
private $form ;
2019-11-15 23:26:29 +01:00
2022-12-15 17:41:53 +01:00
/**
* Construction function .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form -> __construct
2022-12-15 17:41:53 +01:00
* @ param array $attributes - the attributes .
* @ param string $content - the content .
*/
public function __construct ( $attributes , $content = null ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form->__construct' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
$this -> form = new Contact_Form ( $attributes , $content );
}
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
/**
* Set properties on the Contact_Form instance .
*
* @ param string $name Name of the property .
* @ param mixed $value Value of the property .
*/
public function __set ( $name , $value ) {
$this -> form -> { $name } = $value ;
}
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
/**
* Get properties from the Contact_Form instance .
*
* @ param string $name Name of the property .
* @ return mixed
*/
public function __get ( $name ) {
return $this -> form -> { $name };
2019-11-15 23:26:29 +01:00
}
/**
* Store shortcode content for recall later
* - used to receate shortcode when user uses do_shortcode
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form :: store_shortcode
2022-12-15 17:41:53 +01:00
* @ param string $content - the content .
* @ param array $attributes - the attributes .
* @ param string $hash - the hash .
2019-11-15 23:26:29 +01:00
*/
2022-12-15 17:41:53 +01:00
public static function store_shortcode ( $content = null , $attributes = null , $hash = null ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form::store_shortcode' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return Contact_Form :: store_shortcode ( $content , $attributes , $hash );
2019-11-15 23:26:29 +01:00
}
/**
* Toggle for printing the grunion . css stylesheet
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form :: style
2022-12-15 17:41:53 +01:00
* @ param bool $style - the CSS style .
* @ return bool
2019-11-15 23:26:29 +01:00
*/
2022-12-15 17:41:53 +01:00
public static function style ( $style ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form::style' );
return Contact_Form :: style ( $style );
2019-11-15 23:26:29 +01:00
}
/**
* Turn on printing of grunion . css stylesheet
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form :: style_on
2019-11-15 23:26:29 +01:00
* @ see :: style ()
* @ internal
2022-12-15 17:41:53 +01:00
* @ return bool
2019-11-15 23:26:29 +01:00
*/
2022-12-15 17:41:53 +01:00
public static function style_on () {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form::style_on' );
return Contact_Form :: style_on ();
2019-11-15 23:26:29 +01:00
}
/**
* The contact - form shortcode processor
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form :: parse
2022-12-15 17:41:53 +01:00
* @ param array $attributes Key => Value pairs as parsed by shortcode_parse_atts () .
* @ param string | null $content The shortcode ' s inner content : [ contact - form ] $content [ / contact - form ] .
2019-11-15 23:26:29 +01:00
* @ return string HTML for the concat form .
*/
2022-12-15 17:41:53 +01:00
public static function parse ( $attributes , $content ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form::parse' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return Contact_Form :: parse ( $attributes , $content );
2019-11-15 23:26:29 +01:00
}
/**
* Returns a success message to be returned if the form is sent via AJAX .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form :: success_message
2022-12-15 17:41:53 +01:00
* @ param int $feedback_id - the feedback ID .
* @ param object Grunion_Contact_Form $form - the contact form .
2019-11-15 23:26:29 +01:00
* @ return string $message
*/
2022-12-15 17:41:53 +01:00
public static function success_message ( $feedback_id , $form ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form::success_message' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return Contact_Form :: success_message ( $feedback_id , $form );
2019-11-15 23:26:29 +01:00
}
2022-04-02 10:26:41 +02:00
/**
* Returns a script that disables the contact form button after a form submission .
*
* @ return string The script .
*/
private static function get_script_for_form () {
return " <script>
( function () {
const contact_forms = document . getElementsByClassName ( 'contact-form' );
for ( const form of contact_forms ) {
form . onsubmit = function () {
const buttons = form . getElementsByTagName ( 'button' );
for ( const button of buttons ) {
button . setAttribute ( 'disabled' , true );
}
}
}
} )();
</ script > " ;
}
2019-11-15 23:26:29 +01:00
/**
* Returns a compiled form with labels and values in a form of an array
* of lines .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form :: get_compiled_form
2022-12-15 17:41:53 +01:00
* @ param int $feedback_id - the feedback ID .
* @ param object Grunion_Contact_Form $form - the form .
2019-11-15 23:26:29 +01:00
* @ return array $lines
*/
2022-12-15 17:41:53 +01:00
public static function get_compiled_form ( $feedback_id , $form ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form::get_compiled_form' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return Contact_Form :: get_compiled_form ( $feedback_id , $form );
2019-11-15 23:26:29 +01:00
}
2023-01-25 20:43:46 +01:00
/**
* Returns a compiled form with labels and values formatted for the email response
* in a form of an array of lines .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form :: get_compiled_form_for_email
2023-01-25 20:43:46 +01:00
* @ param int $feedback_id - the feedback ID .
* @ param object Grunion_Contact_Form $form - the form .
* @ return array $lines
*/
public static function get_compiled_form_for_email ( $feedback_id , $form ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form::get_compiled_form_for_email' );
2023-01-25 20:43:46 +01:00
2024-04-17 11:32:24 +02:00
return Contact_Form :: get_compiled_form_for_email ( $feedback_id , $form );
2023-01-25 20:43:46 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Escape and sanitize the field value .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form :: escape_and_sanitize_field_value
2022-12-15 17:41:53 +01:00
* @ param string $value - the value we ' re escaping and sanitizing .
* @ return string
*/
public static function escape_and_sanitize_field_value ( $value ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form::escape_and_sanitize_field_value' );
return Contact_Form :: escape_and_sanitize_field_value ( $value );
2022-12-15 17:41:53 +01:00
}
2019-11-15 23:26:29 +01:00
/**
* Only strip out empty string values and keep all the other values as they are .
2022-12-15 17:41:53 +01:00
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form :: remove_empty
2022-12-15 17:41:53 +01:00
* @ param string $single_value - the single value .
2019-11-15 23:26:29 +01:00
* @ return bool
*/
2022-12-15 17:41:53 +01:00
public static function remove_empty ( $single_value ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form::remove_empty' );
return Contact_Form :: remove_empty ( $single_value );
2019-11-15 23:26:29 +01:00
}
2020-11-18 09:10:44 +01:00
/**
* Escape a shortcode value .
*
* Shortcode attribute values have a number of unfortunate restrictions , which fortunately we
* can get around by adding some extra HTML encoding .
*
* The output HTML will have a few extra escapes , but that makes no functional difference .
*
* @ since 9.1 . 0
* @ param string $val Value to escape .
* @ return string
*/
private static function esc_shortcode_val ( $val ) {
2024-04-17 11:32:24 +02:00
return Contact_Form :: esc_shortcode_val ( $val );
2020-11-18 09:10:44 +01:00
}
2019-11-15 23:26:29 +01:00
/**
2022-12-15 17:41:53 +01:00
* The contact - field shortcode processor .
2019-11-15 23:26:29 +01:00
* We use an object method here instead of a static Grunion_Contact_Form_Field class method to parse contact - field shortcodes so that we can tie them to the contact - form object .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form :: parse_contact_field
2022-12-15 17:41:53 +01:00
* @ param array $attributes Key => Value pairs as parsed by shortcode_parse_atts () .
* @ param string | null $content The shortcode ' s inner content : [ contact - field ] $content [ / contact - field ] .
* @ return string HTML for the contact form field
2019-11-15 23:26:29 +01:00
*/
2022-12-15 17:41:53 +01:00
public static function parse_contact_field ( $attributes , $content ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form::parse_contact_field' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return Contact_Form :: parse_contact_field ( $attributes , $content );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Get the default label from type .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form :: get_default_label_from_type
2022-12-15 17:41:53 +01:00
* @ param string $type - the type of label .
* @ return string
*/
public static function get_default_label_from_type ( $type ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form::get_default_label_from_type' );
return Contact_Form :: get_default_label_from_type ( $type );
2019-11-15 23:26:29 +01:00
}
/**
* Loops through $this -> fields to generate a ( structured ) list of field IDs .
*
2020-09-15 14:30:05 +02:00
* Important : Currently the allowed fields are defined as follows :
2019-11-15 23:26:29 +01:00
* `name` , `email` , `url` , `subject` , `textarea`
*
* If you need to add new fields to the Contact Form , please don ' t add them
2020-09-15 14:30:05 +02:00
* to the allowed fields and leave them as extra fields .
2019-11-15 23:26:29 +01:00
*
* The reasoning behind this is that both the admin Feedback view and the CSV
* export will not include any fields that are added to the list of
2020-09-15 14:30:05 +02:00
* allowed fields without taking proper care to add them to all the
2019-11-15 23:26:29 +01:00
* other places where they accessed / used / saved .
*
* The safest way to add new fields is to add them to the dropdown and the
* HTML list ( @ see Grunion_Contact_Form_Field :: render ) and don ' t add them
2020-09-15 14:30:05 +02:00
* to the list of allowed fields . This way they will become a part of the
2019-11-15 23:26:29 +01:00
* `extra fields` which are saved in the post meta and will be properly
* handled by the admin Feedback view and the CSV Export without any extra
* work .
*
2020-09-15 14:30:05 +02:00
* If there is need to add a field to the allowed fields , then please
2019-11-15 23:26:29 +01:00
* take proper care to add logic to handle the field in the following places :
*
2020-09-15 14:30:05 +02:00
* - Below in the switch statement - so the field is recognized as allowed .
2019-11-15 23:26:29 +01:00
*
* - Grunion_Contact_Form :: process_submission - validation and logic .
*
* - Grunion_Contact_Form :: process_submission - add the field as an additional
* field in the `post_content` when saving the feedback content .
*
* - Grunion_Contact_Form_Plugin :: parse_fields_from_content - add mapping
* for the field , defined in the above method .
*
* - Grunion_Contact_Form_Plugin :: map_parsed_field_contents_of_post_to_field_names -
* add mapping of the field for the CSV Export . Otherwise it will be missing
* from the exported data .
*
* - admin . php / grunion_manage_post_columns - add the field to the render logic .
* Otherwise it will be missing from the admin Feedback view .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form -> get_field_ids
2019-11-15 23:26:29 +01:00
* @ return array
*/
2022-12-15 17:41:53 +01:00
public function get_field_ids () {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form->get_field_ids' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return $this -> form -> get_field_ids ();
2019-11-15 23:26:29 +01:00
}
/**
* Process the contact form ' s POST submission
* Stores feedback . Sends email .
2024-04-17 11:32:24 +02:00
*
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form -> process_submission
2019-11-15 23:26:29 +01:00
*/
2022-12-15 17:41:53 +01:00
public function process_submission () {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form->process_submission' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return $this -> form -> process_submission ();
2019-11-15 23:26:29 +01:00
}
/**
* Wrapper for wp_mail () that enables HTML messages with text alternatives
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form :: wp_mail
2019-11-15 23:26:29 +01:00
* @ param string | array $to Array or comma - separated list of email addresses to send message .
* @ param string $subject Email subject .
* @ param string $message Message contents .
* @ param string | array $headers Optional . Additional headers .
* @ param string | array $attachments Optional . Files to attach .
* @ return bool Whether the email contents were sent successfully .
*/
public static function wp_mail ( $to , $subject , $message , $headers = '' , $attachments = array () ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form::wp_mail' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return Contact_Form :: wp_mail ( $to , $subject , $message , $headers , $attachments );
2019-11-15 23:26:29 +01:00
}
/**
* Add a display name part to an email address
*
* SpamAssassin doesn ' t like addresses in HTML messages that are missing display names ( e . g . , `foo@bar.org`
2021-07-23 11:58:50 +02:00
* instead of `Foo Bar <foo@bar.org>` .
2019-11-15 23:26:29 +01:00
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form -> add_name_to_address
2022-12-15 17:41:53 +01:00
* @ param string $address - the email address .
2019-11-15 23:26:29 +01:00
* @ return string
*/
2022-12-15 17:41:53 +01:00
public function add_name_to_address ( $address ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form->add_name_to_address' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return $this -> form -> add_name_to_address ( $address );
2019-11-15 23:26:29 +01:00
}
/**
* Get the content type that should be assigned to outbound emails
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form :: get_mail_content_type
2019-11-15 23:26:29 +01:00
* @ return string
*/
2022-12-15 17:41:53 +01:00
public static function get_mail_content_type () {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form::get_mail_content_type' );
return Contact_Form :: get_mail_content_type ();
2019-11-15 23:26:29 +01:00
}
/**
* Wrap a message body with the appropriate in HTML tags
*
* This helps to ensure correct parsing by clients , and also helps avoid triggering spam filtering rules
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form :: wrap_message_in_html_tags
2023-09-26 10:24:36 +02:00
* @ param string $title - title of the email .
2022-12-15 17:41:53 +01:00
* @ param string $body - the message body .
2023-09-26 10:24:36 +02:00
* @ param string $footer - the footer containing meta information .
2019-11-15 23:26:29 +01:00
* @ return string
*/
2023-09-26 10:24:36 +02:00
public static function wrap_message_in_html_tags ( $title , $body , $footer ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form::wrap_message_in_html_tags' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return Contact_Form :: wrap_message_in_html_tags ( $title , $body , $footer );
2019-11-15 23:26:29 +01:00
}
/**
* Add a plain - text alternative part to an outbound email
*
* This makes the message more accessible to mail clients that aren ' t HTML - aware , and decreases the likelihood
* that the message will be flagged as spam .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form :: add_plain_text_alternative
2022-12-15 17:41:53 +01:00
* @ param PHPMailer $phpmailer - the phpmailer .
2019-11-15 23:26:29 +01:00
*/
2022-12-15 17:41:53 +01:00
public static function add_plain_text_alternative ( $phpmailer ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form::add_plain_text_alternative' );
2022-12-15 17:41:53 +01:00
2024-04-17 11:32:24 +02:00
return Contact_Form :: add_plain_text_alternative ( $phpmailer );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Add deepslashes .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Block -> addslashes_deep
2022-12-15 17:41:53 +01:00
* @ param array $value - the value .
* @ return array The value , with slashes added .
*/
public function addslashes_deep ( $value ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Block->addslashes_deep' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return $this -> form -> addslashes_deep ( $value );
2019-11-15 23:26:29 +01:00
}
2020-06-23 13:49:54 +02:00
2022-12-15 17:41:53 +01:00
/**
* Rough implementation of Gutenberg ' s align - attribute - to - css - class map .
* Only allowin " wide " and " full " as " center " , " left " and " right " don ' t
* make much sense for the form .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Block :: get_block_alignment_class
2022-12-15 17:41:53 +01:00
* @ param array $attributes Block attributes .
* @ return string The CSS alignment class : alignfull | alignwide .
*/
public static function get_block_alignment_class ( $attributes = array () ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Block::get_block_alignment_class' );
return Contact_Form :: get_block_alignment_class ( $attributes );
2022-12-15 17:41:53 +01:00
}
2020-06-23 13:49:54 +02:00
} // end class Grunion_Contact_Form
2019-11-15 23:26:29 +01:00
2022-12-15 17:41:53 +01:00
// phpcs:disable Generic.Files.OneObjectStructurePerFile.MultipleFound -- how many times I have to disable this?
2019-11-15 23:26:29 +01:00
/**
* Class for the contact - field shortcode .
* Parses shortcode to output the contact form field as HTML .
* Validates input .
2024-04-17 11:32:24 +02:00
*
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field
2019-11-15 23:26:29 +01:00
*/
class Grunion_Contact_Form_Field extends Crunion_Contact_Form_Shortcode {
2022-12-15 17:41:53 +01:00
/**
* The shortcode name .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 See Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field
2022-12-15 17:41:53 +01:00
* @ var string
*/
2024-04-17 11:32:24 +02:00
private $shortcode_name = 'contact-field' ;
2019-11-15 23:26:29 +01:00
/**
2022-12-15 17:41:53 +01:00
* The parent form .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 See Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field
2022-12-15 17:41:53 +01:00
* @ var Grunion_Contact_Form
2019-11-15 23:26:29 +01:00
*/
2024-04-17 11:32:24 +02:00
private $form ;
2019-11-15 23:26:29 +01:00
/**
2022-12-15 17:41:53 +01:00
* Default or POSTed value .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 See Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field
2022-12-15 17:41:53 +01:00
* @ var string
2019-11-15 23:26:29 +01:00
*/
2024-04-17 11:32:24 +02:00
private $value ;
2019-11-15 23:26:29 +01:00
/**
2022-12-15 17:41:53 +01:00
* Is the input valid ?
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 See Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field
2022-12-15 17:41:53 +01:00
* @ var bool
2019-11-15 23:26:29 +01:00
*/
2024-04-17 11:32:24 +02:00
private $error = false ;
2019-11-15 23:26:29 +01:00
2023-04-26 17:39:43 +02:00
/**
* Styles to be applied to the field
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 See Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field
2023-04-26 17:39:43 +02:00
* @ var string
*/
2024-04-17 11:32:24 +02:00
private $block_styles = '' ;
2023-04-26 17:39:43 +02:00
/**
* Styles to be applied to the field
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 See Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field
2023-04-26 17:39:43 +02:00
* @ var string
*/
2024-04-17 11:32:24 +02:00
private $field_styles = '' ;
2023-04-26 17:39:43 +02:00
/**
* Styles to be applied to the field option
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 See Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field
2023-04-26 17:39:43 +02:00
* @ var string
*/
2024-04-17 11:32:24 +02:00
private $option_styles = '' ;
2023-04-26 17:39:43 +02:00
/**
* Styles to be applied to the field
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 See Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field
2023-04-26 17:39:43 +02:00
* @ var string
*/
2024-04-17 11:32:24 +02:00
private $label_styles = '' ;
/**
* We ' re using object composition to call code from the `forms` package .
* This holds the reference to the Contact_Form_Field instance .
*
* @ var Contact_Form_Field
*/
private $field ;
2023-04-26 17:39:43 +02:00
2019-11-15 23:26:29 +01:00
/**
2022-12-15 17:41:53 +01:00
* Constructor function .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field -> __construct
2022-12-15 17:41:53 +01:00
* @ param array $attributes An associative array of shortcode attributes . @ see shortcode_atts () .
2019-11-15 23:26:29 +01:00
* @ param null | string $content Null for selfclosing shortcodes . The inner content otherwise .
2022-12-15 17:41:53 +01:00
* @ param Grunion_Contact_Form $form The parent form .
2019-11-15 23:26:29 +01:00
*/
2022-12-15 17:41:53 +01:00
public function __construct ( $attributes , $content = null , $form = null ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field->__construct' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
$this -> field = new Contact_Form_Field ( $attributes , $content , $form );
}
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
/**
* Set properties on the Contact_Form_Field instance .
*
* @ param string $name Name of the property .
* @ param mixed $value Value of the property .
*/
public function __set ( $name , $value ) {
$this -> field -> { $name } = $value ;
}
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
/**
* Get properties from the Contact_Form_Field instance .
*
* @ param string $name Name of the property .
* @ return mixed
*/
public function __get ( $name ) {
return $this -> field -> { $name };
2019-11-15 23:26:29 +01:00
}
/**
* This field ' s input is invalid . Flag as invalid and add an error to the parent form
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field -> add_error
2019-11-15 23:26:29 +01:00
* @ param string $message The error message to display on the form .
*/
2022-12-15 17:41:53 +01:00
public function add_error ( $message ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field->add_error' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return $this -> field -> add_error ( $message );
2019-11-15 23:26:29 +01:00
}
/**
* Is the field input invalid ?
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field -> is_error
2019-11-15 23:26:29 +01:00
* @ see $error
* @ return bool
*/
2022-12-15 17:41:53 +01:00
public function is_error () {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field->is_error' );
return $this -> field -> is_error ();
2019-11-15 23:26:29 +01:00
}
/**
* Validates the form input
2024-04-17 11:32:24 +02:00
*
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field -> validate
2019-11-15 23:26:29 +01:00
*/
2022-12-15 17:41:53 +01:00
public function validate () {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field->validate' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return $this -> field -> validate ();
2019-11-15 23:26:29 +01:00
}
/**
* Check the default value for options field
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field -> get_option_value
2022-12-15 17:41:53 +01:00
* @ param string $value - the value we ' re checking .
* @ param int $index - the index .
* @ param string $options - default field option .
2019-11-15 23:26:29 +01:00
* @ return string
*/
public function get_option_value ( $value , $index , $options ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field->get_option_value' );
return $this -> field -> get_option_value ( $value , $index , $options );
2019-11-15 23:26:29 +01:00
}
/**
* Outputs the HTML for this form field
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field -> render
2019-11-15 23:26:29 +01:00
* @ return string HTML
*/
2022-12-15 17:41:53 +01:00
public function render () {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field->render' );
2023-04-26 17:39:43 +02:00
2024-04-17 11:32:24 +02:00
return $this -> field -> render ();
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Return the HTML for the label .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field -> render_label
2022-12-15 17:41:53 +01:00
* @ param string $type - the field type .
* @ param int $id - the ID .
* @ param string $label - the label .
* @ param bool $required - if the field is marked as required .
* @ param string $required_field_text - the text in the required text field .
2023-04-26 17:39:43 +02:00
* @ param array $extra_attrs Array of key / value pairs to append as attributes to the element .
2022-12-15 17:41:53 +01:00
* @ return string HTML
*/
2023-04-26 17:39:43 +02:00
public function render_label ( $type , $id , $label , $required , $required_field_text , $extra_attrs = array () ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field->render_label' );
2023-04-26 17:39:43 +02:00
2024-04-17 11:32:24 +02:00
return $this -> field -> render_label ( $type , $id , $label , $required , $required_field_text , $extra_attrs );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Return the HTML for the input field .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field -> render_input_field
2022-12-15 17:41:53 +01:00
* @ param string $type - the field type .
* @ param int $id - the ID .
* @ param string $value - the value of the field .
* @ param string $class - the field class .
* @ param string $placeholder - the field placeholder content .
* @ param bool $required - if the field is marked as required .
* @ param array $extra_attrs Array of key / value pairs to append as attributes to the element .
* @ return string HTML
*/
public function render_input_field ( $type , $id , $value , $class , $placeholder , $required , $extra_attrs = array () ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field->render_input_field' );
2023-04-26 17:39:43 +02:00
2024-04-17 11:32:24 +02:00
return $this -> field -> render_input_field ( $type , $id , $value , $class , $placeholder , $required , $extra_attrs );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Return the HTML for the email field .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field -> render_email_field
2022-12-15 17:41:53 +01:00
* @ param int $id - the ID .
* @ param string $label - the label .
* @ param string $value - the value of the field .
* @ param string $class - the field class .
* @ param bool $required - if the field is marked as required .
* @ param string $required_field_text - the text in the required text field .
* @ param string $placeholder - the field placeholder content .
* @ return string HTML
*/
public function render_email_field ( $id , $label , $value , $class , $required , $required_field_text , $placeholder ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field->render_email_field' );
return $this -> field -> render_email_field ( $id , $label , $value , $class , $required , $required_field_text , $placeholder );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Return the HTML for the telephone field .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field -> render_telephone_field
2022-12-15 17:41:53 +01:00
* @ param int $id - the ID .
* @ param string $label - the label .
* @ param string $value - the value of the field .
* @ param string $class - the field class .
* @ param bool $required - if the field is marked as required .
* @ param string $required_field_text - the text in the required text field .
* @ param string $placeholder - the field placeholder content .
* @ return string HTML
*/
public function render_telephone_field ( $id , $label , $value , $class , $required , $required_field_text , $placeholder ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field->render_telephone_field' );
return $this -> field -> render_telephone_field ( $id , $label , $value , $class , $required , $required_field_text , $placeholder );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Return the HTML for the URL field .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field -> render_url_field
2022-12-15 17:41:53 +01:00
* @ param int $id - the ID .
* @ param string $label - the label .
* @ param string $value - the value of the field .
* @ param string $class - the field class .
* @ param bool $required - if the field is marked as required .
* @ param string $required_field_text - the text in the required text field .
* @ param string $placeholder - the field placeholder content .
* @ return string HTML
*/
public function render_url_field ( $id , $label , $value , $class , $required , $required_field_text , $placeholder ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field->render_url_field' );
return $this -> field -> render_url_field ( $id , $label , $value , $class , $required , $required_field_text , $placeholder );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Return the HTML for the text area field .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field -> render_textarea_field
2022-12-15 17:41:53 +01:00
* @ param int $id - the ID .
* @ param string $label - the label .
* @ param string $value - the value of the field .
* @ param string $class - the field class .
* @ param bool $required - if the field is marked as required .
* @ param string $required_field_text - the text in the required text field .
* @ param string $placeholder - the field placeholder content .
* @ return string HTML
*/
public function render_textarea_field ( $id , $label , $value , $class , $required , $required_field_text , $placeholder ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field->render_textarea_field' );
return $this -> field -> render_textarea_field ( $id , $label , $value , $class , $required , $required_field_text , $placeholder );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Return the HTML for the radio field .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field -> render_radio_field
2022-12-15 17:41:53 +01:00
* @ param int $id - the ID .
* @ param string $label - the label .
* @ param string $value - the value of the field .
* @ param string $class - the field class .
* @ param bool $required - if the field is marked as required .
* @ param string $required_field_text - the text in the required text field .
* @ return string HTML
*/
public function render_radio_field ( $id , $label , $value , $class , $required , $required_field_text ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field->render_radio_field' );
return $this -> field -> render_radio_field ( $id , $label , $value , $class , $required , $required_field_text );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Return the HTML for the checkbox field .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field -> render_checkbox_field
2022-12-15 17:41:53 +01:00
* @ param int $id - the ID .
* @ param string $label - the label .
* @ param string $value - the value of the field .
* @ param string $class - the field class .
* @ param bool $required - if the field is marked as required .
* @ param string $required_field_text - the text in the required text field .
* @ return string HTML
*/
public function render_checkbox_field ( $id , $label , $value , $class , $required , $required_field_text ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field->render_checkbox_field' );
return $this -> field -> render_checkbox_field ( $id , $label , $value , $class , $required , $required_field_text );
2019-11-15 23:26:29 +01:00
}
2020-09-15 14:30:05 +02:00
/**
2022-12-15 17:41:53 +01:00
* Return the HTML for the consent field .
2020-09-15 14:30:05 +02:00
*
* @ param string $id field id .
* @ param string $class html classes ( can be set by the admin ) .
*/
private function render_consent_field ( $id , $class ) {
$consent_type = 'explicit' === $this -> get_attribute ( 'consenttype' ) ? 'explicit' : 'implicit' ;
$consent_message = 'explicit' === $consent_type ? $this -> get_attribute ( 'explicitconsentmessage' ) : $this -> get_attribute ( 'implicitconsentmessage' );
2023-04-26 17:39:43 +02:00
$field = " <label class='grunion-field-label consent consent- " . $consent_type . " ' style=' " . $this -> label_styles . " '> " ;
2020-09-15 14:30:05 +02:00
if ( 'implicit' === $consent_type ) {
$field .= " \t \t <input aria-hidden='true' type='checkbox' checked name=' " . esc_attr ( $id ) . " ' value=' " . esc_attr__ ( 'Yes' , 'jetpack' ) . " ' style='display:none;' /> \n " ;
} else {
$field .= " \t \t <input type='checkbox' name=' " . esc_attr ( $id ) . " ' value=' " . esc_attr__ ( 'Yes' , 'jetpack' ) . " ' " . $class . " /> \n " ;
}
$field .= " \t \t " . esc_html ( $consent_message );
$field .= " </label> \n " ;
$field .= " <div class='clear-form'></div> \n " ;
return $field ;
}
2022-12-15 17:41:53 +01:00
/**
* Return the HTML for the multiple checkbox field .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field -> render_checkbox_multiple_field
2022-12-15 17:41:53 +01:00
* @ param int $id - the ID .
* @ param string $label - the label .
* @ param string $value - the value of the field .
* @ param string $class - the field class .
* @ param bool $required - if the field is marked as required .
* @ param string $required_field_text - the text in the required text field .
* @ return string HTML
*/
public function render_checkbox_multiple_field ( $id , $label , $value , $class , $required , $required_field_text ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field->render_checkbox_multiple_field' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return $this -> field -> render_checkbox_multiple_field ( $id , $label , $value , $class , $required , $required_field_text );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Return the HTML for the select field .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field -> render_select_field
2022-12-15 17:41:53 +01:00
* @ param int $id - the ID .
* @ param string $label - the label .
* @ param string $value - the value of the field .
* @ param string $class - the field class .
* @ param bool $required - if the field is marked as required .
* @ param string $required_field_text - the text in the required text field .
* @ return string HTML
*/
public function render_select_field ( $id , $label , $value , $class , $required , $required_field_text ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field->render_select_field' );
2023-04-26 17:39:43 +02:00
2024-04-17 11:32:24 +02:00
return $this -> field -> render_select_field ( $id , $label , $value , $class , $required , $required_field_text );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Return the HTML for the email field .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field -> render_date_field
2022-12-15 17:41:53 +01:00
* @ param int $id - the ID .
* @ param string $label - the label .
* @ param string $value - the value of the field .
* @ param string $class - the field class .
* @ param bool $required - if the field is marked as required .
* @ param string $required_field_text - the text in the required text field .
* @ param string $placeholder - the field placeholder content .
* @ return string HTML
*/
public function render_date_field ( $id , $label , $value , $class , $required , $required_field_text , $placeholder ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field->render_date_field' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return $this -> field -> render_date_field ( $id , $label , $value , $class , $required , $required_field_text , $placeholder );
2019-11-15 23:26:29 +01:00
}
2022-12-15 17:41:53 +01:00
/**
* Return the HTML for the default field .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field -> render_default_field
2022-12-15 17:41:53 +01:00
* @ param int $id - the ID .
* @ param string $label - the label .
* @ param string $value - the value of the field .
* @ param string $class - the field class .
* @ param bool $required - if the field is marked as required .
* @ param string $required_field_text - the text in the required text field .
* @ param string $placeholder - the field placeholder content .
* @ param string $type - the type .
* @ return string HTML
*/
public function render_default_field ( $id , $label , $value , $class , $required , $required_field_text , $placeholder , $type ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field->render_default_field' );
return $this -> field -> render_default_field ( $id , $label , $value , $class , $required , $required_field_text , $placeholder , $type );
2019-11-15 23:26:29 +01:00
}
2023-04-26 17:39:43 +02:00
/**
* Return the HTML for the outlined label .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field -> render_outline_label
2023-04-26 17:39:43 +02:00
* @ param int $id - the ID .
* @ param string $label - the label .
* @ param bool $required - if the field is marked as required .
* @ param string $required_field_text - the text in the required text field .
* @ return string HTML
*/
public function render_outline_label ( $id , $label , $required , $required_field_text ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field->render_outline_label' );
return $this -> field -> render_outline_label ( $id , $label , $required , $required_field_text );
2023-04-26 17:39:43 +02:00
}
/**
* Return the HTML for the animated label .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field -> render_animated_label
2023-04-26 17:39:43 +02:00
* @ param int $id - the ID .
* @ param string $label - the label .
* @ param bool $required - if the field is marked as required .
* @ param string $required_field_text - the text in the required text field .
* @ return string HTML
*/
public function render_animated_label ( $id , $label , $required , $required_field_text ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field->render_animated_label' );
return $this -> field -> render_animated_label ( $id , $label , $required , $required_field_text );
2023-04-26 17:39:43 +02:00
}
/**
* Return the HTML for the below label .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field -> render_below_label
2023-04-26 17:39:43 +02:00
* @ param int $id - the ID .
* @ param string $label - the label .
* @ param bool $required - if the field is marked as required .
* @ param string $required_field_text - the text in the required text field .
* @ return string HTML
*/
public function render_below_label ( $id , $label , $required , $required_field_text ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field->render_below_label' );
return $this -> field -> render_below_label ( $id , $label , $required , $required_field_text );
2023-04-26 17:39:43 +02:00
}
2022-12-15 17:41:53 +01:00
/**
* Return the HTML for the email field .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field -> render_field
2022-12-15 17:41:53 +01:00
* @ param string $type - the type .
* @ param int $id - the ID .
* @ param string $label - the label .
* @ param string $value - the value of the field .
* @ param string $class - the field class .
* @ param string $placeholder - the field placeholder content .
* @ param bool $required - if the field is marked as required .
2023-01-25 20:43:46 +01:00
* @ param string $required_field_text - the text for a field marked as required .
2022-12-15 17:41:53 +01:00
* @ return string HTML
*/
2023-01-25 20:43:46 +01:00
public function render_field ( $type , $id , $label , $value , $class , $placeholder , $required , $required_field_text ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __METHOD__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Contact_Form_Field->render_field' );
2023-04-26 17:39:43 +02:00
2024-04-17 11:32:24 +02:00
return $this -> field -> render_field ( $type , $id , $label , $value , $class , $placeholder , $required , $required_field_text );
2019-11-15 23:26:29 +01:00
}
2021-09-07 21:40:48 +02:00
2022-12-15 17:41:53 +01:00
/**
* Overrides input type ( maybe ) .
*
* @ module contact - form
*
* Custom input types , like URL , will rely on browser ' s implementation to validate
* the value . If the input carries a data - type - override , we allow to override
* the type at render / submit so it can be validated with custom patterns .
* This method will try to match the input ' s type to a custom data - type - override
* attribute and return it . Defaults to input ' s type .
*
* @ return string The input ' s type attribute or the overriden type .
*/
private function maybe_override_type () {
// Define overridables-to-custom-type, extend as needed.
$overridable_types = array ( 'text' => array ( 'url' ) );
$type = $this -> get_attribute ( 'type' );
if ( ! array_key_exists ( $type , $overridable_types ) ) {
return $type ;
}
$override_type = $this -> get_attribute ( 'data-type-override' );
if ( in_array ( $override_type , $overridable_types [ $type ], true ) ) {
return $override_type ;
}
return $type ;
}
2023-04-26 17:39:43 +02:00
/**
* Gets the form style based on its CSS class .
*
* @ return string The form style type .
*/
private function get_form_style () {
$class_name = $this -> form -> get_attribute ( 'className' );
preg_match ( '/is-style-([^\s]+)/i' , $class_name , $matches );
return count ( $matches ) >= 2 ? $matches [ 1 ] : null ;
}
2019-11-15 23:26:29 +01:00
}
add_action ( 'init' , array ( 'Grunion_Contact_Form_Plugin' , 'init' ), 9 );
add_action ( 'grunion_scheduled_delete' , 'grunion_delete_old_spam' );
/**
* Deletes old spam feedbacks to keep the posts table size under control
2024-04-17 11:32:24 +02:00
*
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Util :: grunion_delete_old_spam '
2019-11-15 23:26:29 +01:00
*/
function grunion_delete_old_spam () {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __FUNCTION__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Util::grunion_delete_old_spam' );
2019-11-15 23:26:29 +01:00
2024-04-17 11:32:24 +02:00
return Util :: grunion_delete_old_spam ();
2019-11-15 23:26:29 +01:00
}
/**
* Send an event to Tracks on form submission .
*
2024-04-17 11:32:24 +02:00
* @ deprecated 13.3 Use Automattic\Jetpack\Forms\ContactForm\Util :: jetpack_tracks_record_grunion_pre_message_sent
2023-04-26 17:39:43 +02:00
* @ param int $post_id - the post_id for the CPT that is created .
2019-11-15 23:26:29 +01:00
* @ return null | void
*/
2023-04-26 17:39:43 +02:00
function jetpack_tracks_record_grunion_pre_message_sent ( $post_id ) {
2024-04-17 11:32:24 +02:00
_deprecated_function ( __FUNCTION__ , 'jetpack-13.3' , 'Automattic\Jetpack\Forms\ContactForm\Util::jetpack_tracks_record_grunion_pre_message_sent' );
2023-04-26 17:39:43 +02:00
2024-04-17 11:32:24 +02:00
return Util :: jetpack_tracks_record_grunion_pre_message_sent ( $post_id );
2019-11-15 23:26:29 +01:00
}
2023-04-26 17:39:43 +02:00
add_action ( 'grunion_pre_message_sent' , 'jetpack_tracks_record_grunion_pre_message_sent' , 12 );