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
@Pross
Pross / functions.php
Last active Oct 16, 2019
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;
});
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' ) );
}
});
View gist:0956bee3feb78d1f8faf48dffe4d56da
composer config --global repositories.beaver-builder composer https://composer.wpbeaverbuilder.com/KEY
View composer.json
{
"repositories": {
"beaver-builder": {
"type": "composer",
"url": "https://composer.wpbeaverbuilder.com/KEY"
}
},
"require": {
"beaver-builder/bb-plugin-pro": "*",
"beaver-builder/bb-theme": "*",
@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 / 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 // 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(-)
View functions.php
/**
* dequeue FA4
*/
add_action( 'wp_print_styles', function() {
wp_dequeue_style( 'font-awesome' );
} );
You can’t perform that action at this time.