Skip to content

Instantly share code, notes, and snippets.

Avatar

Jane James genesis16

View GitHub Profile
View simple-likes-public.js
(function( $ ) {
'use strict';
$(document).on('click', '.sl-button', function() {
var button = $(this);
var post_id = button.attr('data-post-id');
var security = button.attr('data-nonce');
var iscomment = button.attr('data-iscomment');
var allbuttons;
if ( iscomment === '1' ) { /* Comments can have same id */
allbuttons = $('.sl-comment-button-'+post_id);
View gist:184494fad656fb55aa08216cf2232701
<?php
/*
Name: WordPress Post Like System
Description: A simple and efficient post like system for WordPress.
Version: 0.5.2
Author: Jon Masterson
Author URI: http://jonmasterson.com/
License:
Copyright (C) 2015 Jon Masterson
@genesis16
genesis16 / gist:4c13c5115d3d9eed6ddaa182f0bd4273
Created Sep 3, 2021
Disable admin bar from all non admins and editors
View gist:4c13c5115d3d9eed6ddaa182f0bd4273
// Disabled wordpress admin bar to all non admininstrators or editors - Jane James
function disable_admin_bar() {
if (current_user_can('administrator') || current_user_can('editor') ) {
// user can view admin bar
show_admin_bar(true); // this line isn't essentially needed by default...
} else {
// hide admin bar
show_admin_bar(false);
}
View wp forms blacklist
function wpf_blacklist_domains( $field_id, $field_submit, $form_data ) {
$domain = substr( strrchr( $field_submit, "@" ), 1 );
$blacklist = array( 'yahoo.com', 'hotmail.com' );
if( in_array( $domain, $blacklist ) ) {
wpforms()->process->errors[ $form_data['id'] ][ $field_id ] = esc_html__( 'We apologize for any inconvenience, we are unable to accept emails from this domain.', 'wpforms' );
return;
}
}
add_action('wpforms_process_validate_email', 'wpf_blacklist_domains', 10, 3 );
View Wp forms email whitelist
/*
* Whitelist email domains from your WPForms.
*
* @link https://wpforms.com/developers/how-to-restrict-email-domains/
*
*/
function wpf_whitelist_domains( $field_id, $field_submit, $form_data ) {
$domain = substr( strrchr( $field_submit, "@" ), 1 );
$whitelist = array( 'icloud.com', 'me.com' );
if( ! in_array( $domain, $whitelist ) ) {