Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update contact-form.php #541

Merged
merged 1 commit into from
Aug 31, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions includes/contact-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,30 @@ class WPCF7_ContactForm {
private $scanned_form_tags;
private $shortcode_atts = array();


/**
* Returns count of contact forms found by the previous retrieval.
*
* @return int Count of contact forms.
*/
public static function count() {
return self::$found_items;
}


/**
* Returns the contact form that is currently processed.
*
* @return WPCF7_ContactForm Current contact form object.
*/
public static function get_current() {
return self::$current;
}


/**
* Registers the post type for contact forms.
*/
public static function register_post_type() {
register_post_type( self::post_type, array(
'labels' => array(
Expand All @@ -47,6 +63,13 @@ public static function register_post_type() {
) );
}


/**
* Retrieves contact form data that match given conditions.
*
* @param string|array $args Optional. Arguments to be passed to WP_Query.
* @return array Array of WPCF7_ContactForm objects.
*/
public static function find( $args = '' ) {
$defaults = array(
'post_status' => 'any',
Expand Down Expand Up @@ -74,6 +97,13 @@ public static function find( $args = '' ) {
return $objs;
}


/**
* Returns a contact form data filled by default template contents.
*
* @param string|array $args Optional. Contact form options.
* @return WPCF7_ContactForm A new contact form object.
*/
public static function get_template( $args = '' ) {
$args = wp_parse_args( $args, array(
'locale' => '',
Expand Down Expand Up @@ -112,6 +142,12 @@ public static function get_template( $args = '' ) {
return $contact_form;
}


/**
* Returns an instance of WPCF7_ContactForm.
*
* @return WPCF7_ContactForm A new contact form object.
*/
public static function get_instance( $post ) {
$post = get_post( $post );

Expand All @@ -123,6 +159,12 @@ public static function get_instance( $post ) {
return self::$current = new self( $post );
}


/**
* Generates a "unit-tag" for the given contact form ID.
*
* @return string Unit-tag.
*/
private static function generate_unit_tag( $id = 0 ) {
static $global_count = 0;

Expand All @@ -144,6 +186,10 @@ private static function generate_unit_tag( $id = 0 ) {
return $unit_tag;
}


/**
* Constructor.
*/
private function __construct( $post = null ) {
$post = get_post( $post );

Expand Down