Skip to content

Instantly share code, notes, and snippets.

Avatar
🚀

Slava Abakumov slaFFik

🚀
View GitHub Profile
@slaFFik
slaFFik / wpforms-display-form-under-confirmation.php
Created Feb 22, 2021
WPForms: display a form under the confirmation message with or without user entered field values.
View wpforms-display-form-under-confirmation.php
<?php
add_action(
'wpforms_frontend_output_success',
static function ( $form_data, $fields, $entry_id ) {
unset(
$_GET['wpforms_return'],
$_POST['wpforms']['id']
);
@slaFFik
slaFFik / wpforms-remove-single-entry-page-sections.php
Last active Feb 10, 2021
WPForms: hide certain sections on a single entry page: notes, log, debug, meta, payment, actions, related, geolocation.
View wpforms-remove-single-entry-page-sections.php
<?php
/**
* This code removes all sections on a single entry page in the admin area.
* Methods names in the remove_action() function call are self explanatory.
* Comment out or remove those lines which sections you want to show.
*/
// Main content area.
add_action( 'wpforms_entry_details_content', static function ( $entry, $form_data, $single_entry ) {
@slaFFik
slaFFik / expose.php
Created Jan 31, 2021
Fix Expose by BeyondCode issues when working with the local WordPress site
View expose.php
<?php
// phpcs:ignoreFile
define( 'EXPOSED_DOMAIN', 'example.sharedwithexpose.com' );
// Load only if we are running under Expose.
if ( empty( $_SERVER['HTTP_X_ORIGINAL_HOST'] ) || $_SERVER['HTTP_X_ORIGINAL_HOST'] !== EXPOSED_DOMAIN ) {
return;
}
@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 Nov 23, 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 />