Skip to content

Instantly share code, notes, and snippets.

Avatar
💬

Simon Prosser Pross

💬
View GitHub Profile
View whut.js
(function($){
$(document).ready(function(){
// This runs on ready function
// Add Copy+Pasta here
// assuming whut class is added to button group and we want the 2nd button
// if 3 buttons it would be 0,1,2 so we want child 1
$('.whut').find('a').children().eq(1)
.on('click',function(e){
@Pross
Pross / functions.php
Last active Jan 11, 2021
Current user role shortcode.
View functions.php
<?php // ADDED FOR CODE HIGHLIGHTING
add_shortcode( 'current_role', function() {
global $wp_roles;
$current_user = wp_get_current_user();
$role = array_shift( $current_user->roles );
return isset( $wp_roles->role_names[ $role ] ) ? translate_user_role( $wp_roles->role_names[ $role ] ) : false;
});
@Pross
Pross / sendy.php
Created Apr 26, 2016
Add to mu-plugins folder, auto add every new user to a sendy list. Works with default WordPress and Woocommerce registrations.
View sendy.php
<?php
add_action( 'user_register', 'add_user_to_sendy_list' );
function add_user_to_sendy_list( $user_id ) {
$list = 'SENDY_LIST_ID';
$url = 'http://SENDY_INSTALL_URL/subscribe';
$user = get_userdata( $user_id );
$email = $user->data->user_email;
$name = $user->data->user_nicename;
View bb-global-js-reset.php
<?php
/*
Plugin Name: Beaver Builder Global JS Reset
Description: Resets global JS and self deactivates.
Author: <Simon>
Version: 1.0
*/
class BB_Global_JS_Reset {
function __construct() {
include_once ABSPATH . '/wp-admin/includes/plugin.php';
@Pross
Pross / functions.php
Created Dec 7, 2020
Add Notes to all rows and columns
View functions.php
add_filter( 'fl_builder_register_settings_form', function( $form, $id ) {
if ( in_array( $id, array( 'row', 'col' ) ) ) {
$form['tabs']['notes'] = array(
'title' => 'Notes',
'sections' => array(
'notes' => array(
'title' => '',
'fields' => array(
'note' => array(
'title' => 'Note',
@Pross
Pross / gist:4cf9787acd67d5df512a788a0c620589
Created Oct 12, 2020
Enable quick edit for modules, saved rows etc
View gist:4cf9787acd67d5df512a788a0c620589
add_action( 'admin_init', function() {
remove_action( 'post_row_actions', 'FLBuilderUserTemplatesAdminList::row_actions' );
} );
@Pross
Pross / theme.patch
Created Sep 21, 2020
Filer to disable smoothscroll >> `add_filter( 'fl_theme_disable_smoothscroll', '__return_true' );`
View theme.patch
From 7485624b4814ccafb6edefc1358be7ca3f531478 Mon Sep 17 00:00:00 2001
From: Simon Prosser <pross@pross.org.uk>
Date: Mon, 21 Sep 2020 20:06:41 +0100
Subject: [PATCH] New filter fl_theme_disable_smoothscroll to disable
smoothscroll
add_filter( 'fl_theme_disable_smoothscroll', '__return_true' );
Fixes #148
---
classes/class-fl-theme.php | 6 +++++-
View gist:192abd46cde729109854409295596e60
add_shortcode( 'form1', function( $atts ) {
$rst = ( isset( $atts['rst'] ) ) ? $atts['rst'] : '9.00';
$msp = ( isset( $atts['msp'] ) ) ? $atts['msp'] : '16.00';
ob_start();
?>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular-route.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular-resource.js"></script>
<div id="rst_calc_main" ng-app="rstApp" ng-controller="rstCtrl">
<div class="table-responsive"></div>
@Pross
Pross / functions.php
Created Jul 17, 2018
Font Awesome Five.
View functions.php
add_action( 'wp_enqueue_scripts', function() {
wp_enqueue_style( 'font-awesome-5' );
} );
@Pross
Pross / functions.php
Last active Jul 15, 2020
Replace Pagely urls in Beaver Builder with optional webp support
View functions.php
<?php
/**
* Replace Pagely urls in Beaver Builder
* @author Simon Prosser
* @license MIT
*/
class PagelyCDNReplace {
static $site_url = 'https://example.com'; // Your site url
static $cdn_url = 'https://cdn.example.io'; // Your CDN url