Skip to content

Instantly share code, notes, and snippets.

Avatar
🚀

Slava Abakumov slaFFik

🚀
View GitHub Profile
@slaFFik
slaFFik / fix_bp_nextgen.php
Created Jun 13, 2014
Fix for BuddyPress and NextGen Gallery
View fix_bp_nextgen.php
<?php
function ovi_kill_anonymous_hooks(){
ovi_remove_anonymous_object_filter(
'wp_footer',
'C_Photocrati_Resource_Manager',
'print_marker'
);
}
add_action('wp_footer', 'ovi_kill_anonymous_hooks', -2);
@slaFFik
slaFFik / dndrpawwd.php
Last active Aug 29, 2015
Do not display Recent Posts in Activity widget in WordPress Dashboard
View dndrpawwd.php
<?php
if ( strpos($_SERVER['SCRIPT_FILENAME'], 'wp-admin/index.php') && !defined('DOING_AJAX')) {
add_filter('the_posts', 'dndrpawwd', 10, 2);
}
function dndrpawwd($posts, $obj){
$trace = debug_backtrace();
foreach($trace as $item) {
if ($item['function'] == 'wp_dashboard_recent_posts' ) {
@slaFFik
slaFFik / gist:3491627
Last active Oct 9, 2015
Redirect users from a home page to any page if logged in [WordPress]
View gist:3491627
<?php
add_action( 'template_redirect', 'redirect_visitors' );
function redirect_visitors() {
if( is_user_logged_in() && (is_front_page() || is_home())) {
wp_redirect('http://ab.ovi/test2');
exit;
}
}
?>
@slaFFik
slaFFik / wpforms-split-name-smarttag-in-notifications.php
Last active Aug 29, 2017
WPForms: Split the first Name field to display only First Name in notification text
View wpforms-split-name-smarttag-in-notifications.php
<?php
add_filter( 'wpforms_process_smart_tags', function ( $message, $form_data, $fields = '', $entry_id = 0 ) {
// CHANGE THIS FORM ID TO YOURS:
if ( 157 != $form_data['id'] ) {
return $message;
}
// So we are not submitting the form.
if ( empty( $entry_id ) ) {
return $message;
@slaFFik
slaFFik / wpforms-change-js-validation-form-id.php
Last active Aug 29, 2017
WPForms: Change the JS validation strings based on a form ID (useful for multi-language sites)
View wpforms-change-js-validation-form-id.php
<?php
add_filter( 'wpforms_frontend_strings', function( $strings ) {
global $post;
if ( ! isset( $post->post_content ) ) {
return $strings;
}
preg_match( '~\[wpforms id=\"(\d+)\"~', $post->post_content, $matches );
@slaFFik
slaFFik / wpforms-hide-forms-on-mobile.php
Created Sep 25, 2017
WPForms: Hide forms on mobile
View wpforms-hide-forms-on-mobile.php
<?php
add_filter( 'wpforms_frontend_load', function( $load, $form_data, $var ) {
// Comment these lines if you need to hide a certain form only.
if ( wp_is_mobile() ) {
return false;
}
// Or check certain form only. Uncomment.
/*
@slaFFik
slaFFik / wp-mail-smtp-disable-smtpautotls.php
Created Nov 3, 2017
WP Mail SMTP: Disable SMTPAutoTLS
View wp-mail-smtp-disable-smtpautotls.php
<?php
add_filter('wp_mail_smtp_custom_options', function( $phpmailer ) {
$phpmailer->SMTPAutoTLS = false;
return $phpmailer;
} );
@slaFFik
slaFFik / pvar.php
Last active Dec 7, 2017
Nicely display the var content
View pvar.php
<?php
/**
* Nicely display the var content.
*
* @param mixed $var
* @param bool $die
*/
function pvar( $var = '', $die = false ) {
echo '<pre>' . PHP_EOL;
@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 / 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;
}
You can’t perform that action at this time.