Skip to content

Instantly share code, notes, and snippets.

Avatar
🚀

Slava Abakumov slaFFik

🚀
View GitHub Profile
@slaFFik
slaFFik / wpforms-new-smarttag-current-time.php
Last active Apr 9, 2020
WPForms: new smart tag - current date and time
View wpforms-new-smarttag-current-time.php
<?php
// Register the smart tag.
add_filter( 'wpforms_smart_tags', static function( $tags ) {
// Key is the tag, value is the tag name.
$tags['current_time'] = 'Current Date/Time';
return $tags;
} );
@slaFFik
slaFFik / wpforms-field-description-notification-emails.php
Last active Apr 9, 2020
WPForms: add field description in notification HTML and plain text emails
View wpforms-field-description-notification-emails.php
<?php
// HTML Email.
add_filter( 'wpforms_html_field_value', static function ( $field_val, $field, $form_data, $context ) {
if ( $context !== 'email-html' ) {
return $field_val;
}
if ( empty( $form_data['fields'][ $field['id'] ] ) ) {
@slaFFik
slaFFik / wpforms-new-smarttags-submitted-cpt.php
Last active Feb 14, 2020
WPForms: add several new smart tags for newly submitted CPT: ID, title and URL. Useful only for Post Submission addon.
View wpforms-new-smarttags-submitted-cpt.php
<?php
function wpf_dev_register_smarttag( $tags ) {
// Key is the tag, value is the tag name.
$tags['submitted_cpt_id'] = 'Submitted Post Type ID';
$tags['submitted_cpt_url'] = 'Submitted Post Type URL';
$tags['submitted_cpt_title'] = 'Submitted Post Type Title';
return $tags;
@slaFFik
slaFFik / wp-mail-smtp-authtype-login.php
Created Feb 5, 2020
WP Mail SMTP: specify an exact AuthType to connect to a Server.
View wp-mail-smtp-authtype-login.php
<?php
add_filter( 'wp_mail_smtp_custom_options', function( $phpmailer ) {
$phpmailer->AuthType = 'LOGIN';
return $phpmailer;
} );
@slaFFik
slaFFik / wpforms-merge-field-values.php
Created Jan 23, 2020
WPForms: merge values for 2 fields into a 3rd one
View wpforms-merge-field-values.php
<?php
add_filter( 'wpforms_entry_save_data', static function ( $fields, $entry, $form_data ) {
$value1 = '';
$value2 = '';
// These are field IDs to take data from, and to merge into.
$field1_id = 1;
$field2_id = 2;
@slaFFik
slaFFik / wpforms-change-country-code.php
Created Jun 3, 2019
WPForms: change the key of a country from country code to country name
View wpforms-change-country-code.php
<?php
add_filter( 'wpforms_countries', function ( $countries ) {
$key_from = 'CA';
if ( array_key_exists( $key_from, $countries ) ) {
$keys = array_keys( $countries );
$keys[ array_search( $key_from, $keys, true ) ] = 'Canada';
@slaFFik
slaFFik / phpdox.xml
Created May 17, 2019
Full content of an example phpdox.xml file
View phpdox.xml
<?xml version="1.0" encoding="utf-8" ?>
<!-- This is a skeleton phpDox config file - Check http://phpDox.de for latest version and more info -->
<phpdox xmlns="http://xml.phpdox.net/config" silent="false">
<!-- @silent: true | false to enable or disable visual output of progress -->
<!-- Additional bootstrap files to load for additional parsers, enrichers and/or engines -->
<!-- Place as many require nodes as you feel like in this container -->
<!-- syntax: <require file="/path/to/file.php" /> -->
<bootstrap />
@slaFFik
slaFFik / wpforms-reformat-payment-fields-values-in-emails.php
Created Oct 8, 2018
WPForms: Make "$40.00 - Second Choice" instead of "Second Choice - $40.00" for different payment fields.
View wpforms-reformat-payment-fields-values-in-emails.php
<?php
/**
* Make "$40.00 - Second Choice" instead of "Second Choice - $40.00"
* for different payment fields.
*/
add_filter( 'wpforms_html_field_value', function ( $value, $field, $form_data, $context ) {
if ( 'email-html' !== $context ) {
return $value;
}
@slaFFik
slaFFik / wpforms-custom-redirect.php
Last active Dec 25, 2017 — forked from jaredatch/functions.php
WPForms: Conditional form redirects based on field value.
View wpforms-custom-redirect.php
<?php
/**
* WPForms: Conditional form redirects based on field value.
*
* @param string $url URL form will redirect to
* @param int $form_id Form ID
* @param array $fields Submitted form fields
* @return string
*/
function wpf_custom_redirect( $url, $form_id, $fields ) {
@slaFFik
slaFFik / wpms-smtp-disable-ssl-verify.php
Last active Sep 26, 2020
WP Mail SMTP: when using SMTP mailer - disable SSL verify on PHP 5.6+
View wpms-smtp-disable-ssl-verify.php
<?php
add_filter('wp_mail_smtp_custom_options', function( $phpmailer ) {
$phpmailer->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
You can’t perform that action at this time.