Skip to content

Instantly share code, notes, and snippets.

Simon Prosser Pross

Block or report user

Report or block Pross

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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;
});
View gist:e4f82af63755e455b28ed4c021c933ab
add_action( 'pre_get_posts', function( $query ) {
if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
$query->set( 'post_status', array( 'private', 'publish' ) );
}
});
@Pross
Pross / js.js
Created Jan 21, 2019
How to paste random jQuery from the internet.
View js.js
(function($){
$(document).ready(function(){
// This runs on ready function
// Add Copy+Pasta here
});
})(jQuery);
View gist:0956bee3feb78d1f8faf48dffe4d56da
composer config --global repositories.beaver-builder composer https://composer.wpbeaverbuilder.com/KEY
@Pross
Pross / fl-builder-layout.js
Created Sep 4, 2019
bb-plugin/js/fl-builder-layout.js
View fl-builder-layout.js
(function($){
if(typeof FLBuilderLayout != 'undefined') {
return;
}
/**
* Helper class with generic logic for a builder layout.
*
* @class FLBuilderLayout
@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;
@Pross
Pross / css.css
Created Jun 24, 2019
Disable row shapes in ie11
View css.css
body.fl-builder-ie-11 div.fl-builder-shape-layer {
display:none;
}
View functions.php
<?php // added for syntax highlighting.
add_shortcode( 'coauthors', 'coauthors_func' );
function coauthors_func( $atts ) {
$atts = shortcode_atts( array(
'between' => null,
'betweenLast' => null,
'before' => null,
'after' => null,
), $atts, 'coauthors' );
View functions.php
<?php // ignore this line, its only to make highlighting work
add_filter( 'fl_builder_render_module_content', function( $out, $module ) {
if ( 'heading' === $module->slug ) {
$string = $out;
$find = ' ';
$replace = '&nbsp;';
$out = strrev( preg_replace( strrev( "/$find/" ), strrev( $replace ), strrev( $string ), 1 ) );
}
return $out;
}, 10, 2);
View wpcli.diff
From b7f4b3d6aca25bd21495a35e620b642931af0e21 Mon Sep 17 00:00:00 2001
From: Simon Prosser <pross@pross.org.uk>
Date: Thu, 11 Apr 2019 17:30:38 +0100
Subject: [PATCH] Fix wp-cli in PHP 5.4 and below.
list is a protected function even though we are in a class.
---
classes/class-fl-builder-wpcli-command.php | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
You can’t perform that action at this time.