Skip to content

Commit

Permalink
Merge pull request #40 from qutrwp/master
Browse files Browse the repository at this point in the history
Add support for Contact Form 7 4.6
  • Loading branch information
felixarntz authored Dec 15, 2016
2 parents 951d14e + d84b571 commit c30bf26
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 35 deletions.
11 changes: 9 additions & 2 deletions modules/acceptance.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_acceptance' );

function cf7bs_add_shortcode_acceptance() {
wpcf7_add_shortcode( 'acceptance', 'cf7bs_acceptance_shortcode_handler', true );
$tags = array(
'acceptance'
);
foreach ( $tags as $tag ) {
wpcf7_remove_form_tag( $tag );
}

wpcf7_add_form_tag( $tags, 'cf7bs_acceptance_shortcode_handler', true );
}

function cf7bs_acceptance_shortcode_handler( $tag ) {
$tag = new WPCF7_Shortcode( $tag );
$tag = new WPCF7_FormTag( $tag );

if ( empty( $tag->name ) ) {
return '';
Expand Down
11 changes: 8 additions & 3 deletions modules/checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,20 @@
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_checkbox' );

function cf7bs_add_shortcode_checkbox() {
wpcf7_add_shortcode( array(
$tags = array(
'checkbox',
'checkbox*',
'radio',
), 'cf7bs_checkbox_shortcode_handler', true );
);
foreach ( $tags as $tag ) {
wpcf7_remove_form_tag( $tag );
}

wpcf7_add_form_tag( $tags, 'cf7bs_checkbox_shortcode_handler', true );
}

function cf7bs_checkbox_shortcode_handler( $tag ) {
$tag = new WPCF7_Shortcode( $tag );
$tag = new WPCF7_FormTag( $tag );

if ( empty( $tag->name ) ) {
return '';
Expand Down
11 changes: 9 additions & 2 deletions modules/count.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_count' );

function cf7bs_add_shortcode_count() {
wpcf7_add_shortcode( 'count', 'cf7bs_count_shortcode_handler', true );
$tags = array(
'count'
);
foreach ( $tags as $tag ) {
wpcf7_remove_form_tag( $tag );
}

wpcf7_add_form_tag( $tags, 'cf7bs_count_shortcode_handler', true );
}

function cf7bs_count_shortcode_handler( $tag ) {
$tag_obj = new WPCF7_Shortcode( $tag );
$tag_obj = new WPCF7_FormTag( $tag );

if ( empty( $tag_obj->name ) ) {
return '';
Expand Down
11 changes: 8 additions & 3 deletions modules/date.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_date' );

function cf7bs_add_shortcode_date() {
wpcf7_add_shortcode( array(
$tags = array(
'date',
'date*',
), 'cf7bs_date_shortcode_handler', true );
);
foreach ( $tags as $tag ) {
wpcf7_remove_form_tag( $tag );
}

wpcf7_add_form_tag( $tags, 'cf7bs_date_shortcode_handler', true );
}

function cf7bs_date_shortcode_handler( $tag ) {
$tag = new WPCF7_Shortcode( $tag );
$tag = new WPCF7_FormTag( $tag );

if ( empty( $tag->name ) ) {
return '';
Expand Down
11 changes: 8 additions & 3 deletions modules/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_file' );

function cf7bs_add_shortcode_file() {
wpcf7_add_shortcode( array(
$tags = array(
'file',
'file*',
), 'cf7bs_file_shortcode_handler', true );
);
foreach ( $tags as $tag ) {
wpcf7_remove_form_tag( $tag );
}

wpcf7_add_form_tag( $tags, 'cf7bs_file_shortcode_handler', true );
}

function cf7bs_file_shortcode_handler( $tag ) {
$tag = new WPCF7_Shortcode( $tag );
$tag = new WPCF7_FormTag( $tag );

if ( empty( $tag->name ) ) {
return '';
Expand Down
11 changes: 8 additions & 3 deletions modules/number.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,21 @@
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_number' );

function cf7bs_add_shortcode_number() {
wpcf7_add_shortcode( array(
$tags = array(
'number',
'number*',
'range',
'range*',
), 'cf7bs_number_shortcode_handler', true );
);
foreach ( $tags as $tag ) {
wpcf7_remove_form_tag( $tag );
}

wpcf7_add_form_tag( $tags, 'cf7bs_number_shortcode_handler', true );
}

function cf7bs_number_shortcode_handler( $tag ) {
$tag = new WPCF7_Shortcode( $tag );
$tag = new WPCF7_FormTag( $tag );

if ( empty( $tag->name ) ) {
return '';
Expand Down
11 changes: 9 additions & 2 deletions modules/quiz.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_quiz' );

function cf7bs_add_shortcode_quiz() {
wpcf7_add_shortcode( 'quiz', 'cf7bs_quiz_shortcode_handler', true );
$tags = array(
'quiz'
);
foreach ( $tags as $tag ) {
wpcf7_remove_form_tag( $tag );
}

wpcf7_add_form_tag( $tags, 'cf7bs_quiz_shortcode_handler', true );
}

function cf7bs_quiz_shortcode_handler( $tag ) {
$tag = new WPCF7_Shortcode( $tag );
$tag = new WPCF7_FormTag( $tag );

if ( empty( $tag->name ) ) {
return '';
Expand Down
13 changes: 9 additions & 4 deletions modules/really-simple-captcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_captcha' );

function cf7bs_add_shortcode_captcha() {
wpcf7_add_shortcode( array(
$tags = array(
'captchac',
'captchar',
), 'cf7bs_captcha_shortcode_handler', true );
);
foreach ( $tags as $tag ) {
wpcf7_remove_form_tag( $tag );
}

wpcf7_add_form_tag( $tags, 'cf7bs_captcha_shortcode_handler', true );
}

function cf7bs_captcha_shortcode_handler( $tag ) {
$tag_obj = new WPCF7_Shortcode( $tag );
$tag_obj = new WPCF7_FormTag( $tag );

if ( 'captchac' == $tag_obj->type && ! class_exists( 'ReallySimpleCaptcha' ) ) {
return '<em>' . __( 'To use CAPTCHA, you need <a href="http://wordpress.org/extend/plugins/really-simple-captcha/">Really Simple CAPTCHA</a> plugin installed.', 'bootstrap-for-contact-form-7' ) . '</em>';
Expand Down Expand Up @@ -149,7 +154,7 @@ function cf7bs_captcha_ajax_refill( $items ) {
return $items;
}

$fes = wpcf7_scan_shortcode( array( 'type' => 'captchar' ) );
$fes = wpcf7_scan_form_tags( array( 'type' => 'captchar' ) );

if ( empty( $fes ) ) {
return $items;
Expand Down
11 changes: 9 additions & 2 deletions modules/recaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,19 @@ function cf7bs_recaptcha_add_shortcode_recaptcha() {
$recaptcha = WPCF7_RECAPTCHA::get_instance();

if ( $recaptcha->is_active() ) {
wpcf7_add_shortcode( 'recaptcha', 'cf7bs_recaptcha_shortcode_handler' );
$tags = array(
'recaptcha'
);
foreach ( $tags as $tag ) {
wpcf7_remove_form_tag( $tag );
}

wpcf7_add_form_tag( $tags, 'cf7bs_recaptcha_shortcode_handler' );
}
}

function cf7bs_recaptcha_shortcode_handler( $tag ) {
$tag_obj = new WPCF7_Shortcode( $tag );
$tag_obj = new WPCF7_FormTag( $tag );

$field = new CF7BS_Form_Field( cf7bs_apply_field_args_filter( array(
'name' => wpcf7_recaptcha_shortcode_handler( $tag ),
Expand Down
11 changes: 8 additions & 3 deletions modules/select.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_select' );

function cf7bs_add_shortcode_select() {
wpcf7_add_shortcode( array(
$tags = array(
'select',
'select*',
), 'cf7bs_select_shortcode_handler', true );
);
foreach ( $tags as $tag ) {
wpcf7_remove_form_tag( $tag );
}

wpcf7_add_form_tag( $tags, 'cf7bs_select_shortcode_handler', true );
}

function cf7bs_select_shortcode_handler( $tag ) {
$tag = new WPCF7_Shortcode( $tag );
$tag = new WPCF7_FormTag( $tag );

if ( empty( $tag->name ) ) {
return '';
Expand Down
11 changes: 9 additions & 2 deletions modules/submit.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_submit' );

function cf7bs_add_shortcode_submit() {
wpcf7_add_shortcode( 'submit', 'cf7bs_submit_shortcode_handler' );
$tags = array(
'submit'
);
foreach ( $tags as $tag ) {
wpcf7_remove_form_tag( $tag );
}

wpcf7_add_form_tag( $tags, 'cf7bs_submit_shortcode_handler' );
}

function cf7bs_submit_shortcode_handler( $tag ) {
$tag = new WPCF7_Shortcode( $tag );
$tag = new WPCF7_FormTag( $tag );

$class = wpcf7_form_controls_class( $tag->type );

Expand Down
11 changes: 8 additions & 3 deletions modules/text.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_text' );

function cf7bs_add_shortcode_text() {
wpcf7_add_shortcode( array(
$tags = array(
'text',
'text*',
'email',
Expand All @@ -20,11 +20,16 @@ function cf7bs_add_shortcode_text() {
'url*',
'tel',
'tel*',
), 'cf7bs_text_shortcode_handler', true );
);
foreach ( $tags as $tag ) {
wpcf7_remove_form_tag( $tag );
}

wpcf7_add_form_tag( $tags, 'cf7bs_text_shortcode_handler', true );
}

function cf7bs_text_shortcode_handler( $tag ) {
$tag_obj = new WPCF7_Shortcode( $tag );
$tag_obj = new WPCF7_FormTag( $tag );

if ( empty( $tag_obj->name ) ) {
return '';
Expand Down
11 changes: 8 additions & 3 deletions modules/textarea.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@
add_action( 'wpcf7_init', 'cf7bs_add_shortcode_textarea' );

function cf7bs_add_shortcode_textarea() {
wpcf7_add_shortcode( array(
$tags = array(
'textarea',
'textarea*',
), 'cf7bs_textarea_shortcode_handler', true );
);
foreach ( $tags as $tag ) {
wpcf7_remove_form_tag( $tag );
}

wpcf7_add_form_tag( $tags, 'cf7bs_textarea_shortcode_handler', true );
}

function cf7bs_textarea_shortcode_handler( $tag ) {
$tag_obj = new WPCF7_Shortcode( $tag );
$tag_obj = new WPCF7_FormTag( $tag );

if ( empty( $tag_obj->name ) ) {
return '';
Expand Down

0 comments on commit c30bf26

Please sign in to comment.