-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
run phpcs on sample-code-snippets/ too
- Loading branch information
1 parent
7ee776f
commit d41f882
Showing
111 changed files
with
1,075 additions
and
986 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 15 additions & 15 deletions
30
...le-code-snippets/add-ons/download-monitor/redirect-to-detailed-form-if-new-subscriber.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
<?php | ||
|
||
/** | ||
* The snippet below hooks into the form with ID 500 | ||
* The snippet below hooks into the form with ID 500 | ||
* | ||
* - If a subscriber was updated; it redirects straight to the download monitor download | ||
* - If a subscriber was newly added; it redirects to another page where you can show another more detailed form. Make sure to set the "redirect on success" setting of the detailed form to your download. | ||
*/ | ||
add_action( 'mc4wp_form_updated_subscriber', function( $form ) { | ||
if( $form->ID != 500 ) { | ||
return; | ||
} | ||
|
||
dlm_mailchimp_set_cookie( $form->data['EMAIL'] ); | ||
add_action('mc4wp_form_updated_subscriber', function ($form) { | ||
if ($form->ID != 500) { | ||
return; | ||
} | ||
|
||
dlm_mailchimp_set_cookie($form->data['EMAIL']); | ||
|
||
// form was used to update a subscriber; redirect to download | ||
wp_redirect( 'http://my-site.com/download-url' ); | ||
exit; | ||
wp_redirect('http://my-site.com/download-url'); | ||
exit; | ||
}); | ||
|
||
add_action( 'mc4wp_form_subscribed', function( $form ) { | ||
if( $form->ID != 500 ) { | ||
return; | ||
} | ||
add_action('mc4wp_form_subscribed', function ($form) { | ||
if ($form->ID != 500) { | ||
return; | ||
} | ||
|
||
// form was used to add a new subscriber; redirect to detailed form | ||
wp_redirect( 'http://my-site.com/page-with-detailed-form' ); | ||
exit; | ||
wp_redirect('http://my-site.com/page-with-detailed-form'); | ||
exit; | ||
}); | ||
|
6 changes: 3 additions & 3 deletions
6
sample-code-snippets/add-ons/top-bar/add-consent-checkbox.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?php | ||
<?php | ||
|
||
add_action( 'mctb_before_submit_button', function() { | ||
echo '<input name="AGREE_TO_TERMS" type="checkbox" value="1" required=""> I have read and agree to the terms & conditions'; | ||
add_action('mctb_before_submit_button', function () { | ||
echo '<input name="AGREE_TO_TERMS" type="checkbox" value="1" required=""> I have read and agree to the terms & conditions'; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 8 additions & 8 deletions
16
sample-code-snippets/add-ons/top-bar/add-to-interest-groups.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
<?php | ||
|
||
add_filter( 'mctb_data', function($data) { | ||
add_filter('mctb_data', function ($data) { | ||
|
||
// make sure we have an array to work with | ||
if( ! isset( $data['INTERESTS'] ) ) { | ||
$data['INTERESTS'] = array(); | ||
} | ||
// make sure we have an array to work with | ||
if (! isset($data['INTERESTS'])) { | ||
$data['INTERESTS'] = []; | ||
} | ||
|
||
// replace "interest-id" with the actual ID of your interest. | ||
$data['INTERESTS'][] = "interest-id"; | ||
// replace "interest-id" with the actual ID of your interest. | ||
$data['INTERESTS'][] = "interest-id"; | ||
|
||
return $data; | ||
return $data; | ||
}); |
4 changes: 2 additions & 2 deletions
4
sample-code-snippets/add-ons/top-bar/hide-for-post-in-specific-category.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<?php | ||
|
||
add_filter( 'mctb_show_bar', function() { | ||
add_filter('mctb_show_bar', function () { | ||
// don't show for posts with category "fruit" | ||
if (is_single() && has_category(array('fruit'))) { | ||
if (is_single() && has_category(['fruit'])) { | ||
return false; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 9 additions & 9 deletions
18
sample-code-snippets/add-ons/top-bar/javascript-event-callback.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
<?php | ||
|
||
add_action('wp_footer', function() { | ||
?> | ||
<script> | ||
document.querySelector('#mailchimp-top-bar form').addEventListener('submit', function() { | ||
// your code goes here | ||
}); | ||
</script> | ||
<?php | ||
}, 20 ); | ||
add_action('wp_footer', function () { | ||
?> | ||
<script> | ||
document.querySelector('#mailchimp-top-bar form').addEventListener('submit', function() { | ||
// your code goes here | ||
}); | ||
</script> | ||
<?php | ||
}, 20); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,19 +3,20 @@ | |
/** | ||
* Block certain email addresses from signing up through forms. | ||
*/ | ||
add_filter( 'mc4wp_form_errors', function( $errors, MC4WP_Form $form ) { | ||
|
||
add_filter('mc4wp_form_errors', function ($errors, MC4WP_Form $form) { | ||
$data = $form->get_data(); | ||
$email = strtolower( $data['EMAIL'] ); | ||
$email = strtolower($data['EMAIL']); | ||
|
||
// add your blocked email addresses here. | ||
$blocked_emails = array( | ||
$blocked_emails = [ | ||
'[email protected]', | ||
'[email protected]', | ||
); | ||
]; | ||
|
||
if( in_array( $email, $blocked_emails ) ) { | ||
if (in_array($email, $blocked_emails)) { | ||
$errors[] = 'spam'; | ||
} | ||
|
||
return $errors; | ||
}, 10, 2 ); | ||
}, 10, 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.