Skip to content

Instantly share code, notes, and snippets.

View slaFFik's full-sized avatar
🚀

Slava Abakumov slaFFik

🚀
View GitHub Profile
@slaFFik
slaFFik / fix_bp_nextgen.php
Created June 13, 2014 13:54
Fix for BuddyPress and NextGen Gallery
<?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 August 29, 2015 14:05
Do not display Recent Posts in Activity widget in WordPress Dashboard
<?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 October 9, 2015 10:47
Redirect users from a home page to any page if logged in [WordPress]
<?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 August 29, 2017 09:01
WPForms: Split the first Name field to display only First Name in notification text
<?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 / pvar.php
Last active December 7, 2017 15:59
Nicely display the var content
<?php
/**
* Nicely display the var content.
*
* @param mixed $var
* @param bool $die
*/
function pvar( $var = '', $die = false ) {
echo '<pre>' . PHP_EOL;
@slaFFik
slaFFik / wpforms-reformat-payment-fields-values-in-emails.php
Created October 8, 2018 17:59
WPForms: Make "$40.00 - Second Choice" instead of "Second Choice - $40.00" for different payment fields.
<?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-change-country-code.php
Created June 3, 2019 18:26
WPForms: change the key of a country from country code to country name
<?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 / wpforms-export-change-separator.php
Last active January 31, 2020 18:19
WPForms: change the export CSV file separator.
<?php
// For WPForms < v1.5.5, but should work with the latest version as well.
add_filter(
'wpforms_csv_export_separator',
function( $sep ) {
return ';';
}
);
@slaFFik
slaFFik / bp-prevent-duplicate-group-names.php
Last active February 3, 2020 11:23 — forked from shanebp/bp-prevent-duplicate-group-names.php
BuddyPress prevent duplicate Group Names
<?php
function pp_check_group_name( $group_new ) {
if ( 'group-details' == bp_get_groups_current_create_step() ) {
$args = array(
'per_page' => null,
'populate_extras' => false,
'update_meta_cache' => false
);
@slaFFik
slaFFik / blocklisted_emails.txt
Created March 24, 2016 08:15
List of domains (or their parts) that are blocked on my site
*@a3.mobile*
*@a3.accounting*
*@a3.news*
*@spambog.ru
*@get30daychange.com
*@qaqmail.com
*@mailcatch.com
*@discardmail.com
*@price*
*@baby.upheast*