Skip to content

Instantly share code, notes, and snippets.

View Pross's full-sized avatar
💬

Simon Prosser Pross

💬
View GitHub Profile
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
Last active July 15, 2020 15:53
Replace Pagely urls in Beaver Builder with optional webp support
<?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
!function(t){var e={mode:"horizontal",slideSelector:"",infiniteLoop:!0,hideControlOnEnd:!1,speed:500,easing:null,slideMargin:0,startSlide:0,randomStart:!1,captions:!1,ticker:!1,tickerHover:!1,adaptiveHeight:!1,adaptiveHeightSpeed:500,video:!1,useCSS:!0,preloadImages:"visible",responsive:!0,slideZIndex:50,wrapperClass:"bx-wrapper",touchEnabled:!0,swipeThreshold:50,oneToOneTouch:!0,preventDefaultSwipeX:!0,preventDefaultSwipeY:!1,ariaLive:!0,ariaHidden:!0,keyboardEnabled:!1,pager:!0,pagerType:"full",pagerShortSeparator:" / ",pagerSelector:null,buildPager:null,pagerCustom:null,controls:!0,nextText:"Next",prevText:"Prev",nextSelector:null,prevSelector:null,autoControls:!1,startText:"Start",stopText:"Stop",autoControlsCombine:!1,autoControlsSelector:null,auto:!1,pause:4e3,autoStart:!0,autoDirection:"next",stopAutoOnClick:!1,autoHover:!1,autoDelay:0,autoSlideForOnePage:!1,minSlides:1,maxSlides:1,moveSlides:0,slideWidth:0,shrinkItems:!1,onSliderLoad:function(){return!0},onSlideBefore:function(){return!0},onSlideAfter
(function($) {
$(document).ready(function() {
var done = false;
$(window).on('scroll', function() {
if (done) {
return false;
}
if (isScrolledIntoView('.fl-module-post-grid')) {
done = true;
$(window).trigger('resize');
add_shortcode( 'something_unique', function() {
$now = strtotime( 'now' ); // The time now (in seconds).
$fixed_eot_time = strtotime( '31 August 2020' ); // Future time (in seconds).
$days_until_fixed_eot_time = round( ( $fixed_eot_time - $now ) / DAY_IN_SECONDS );
return do_shortcode( sprintf( '[s2Member-Pro-PayPal-Form level="1" ccaps="" desc="RIAPP Member / Professional Annual Membership" ps="paypal" lc="" cc="USD" dg="0" ns="1" custom="riapp.lenadev.com" ta="0" tp="0" tt="D" ra="0.01" rr="BN" rt="D" rp="%s" rrt="" rra="2" accept="paypal,visa,mastercard,amex,discover,maestro,solo" accept_via_paypal="paypal" coupon="" accept_coupons="0" default_country_code="" captcha="0" /]', $days_until_fixed_eot_time ) );
});
add_filter( 'fl_builder_get_cache_dir', function( $dirinfo ){
if ( 'icons' === basename( $dirinfo['path'] ) ) {
$dirinfo['path'] = trailingslashit( get_stylesheet_directory() ) . 'icons/';
$dirinfo['url'] = trailingslashit( get_stylesheet_directory_uri() ) . 'icons/';
}
return $dirinfo;
});
add_action(
'init',
function() {
if ( isset( $_GET['layout_nuke_js'] ) && is_numeric( $_GET['layout_nuke_js'] ) ) {
$data = get_post_meta( $_GET['layout_nuke_js'], '_fl_builder_data_settings', true );
$draft = get_post_meta( $_GET['layout_nuke_js'], '_fl_builder_draft_settings', true );
$data->js = '';
$draft->js = '';
update_post_meta( $_GET['layout_nuke_js'], '_fl_builder_data_settings', $data );
update_post_meta( $_GET['layout_nuke_js'], '_fl_builder_draft_settings', $draft );
<?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 December 19, 2019 19:39
10m challenge.. add to mu-plugins to show latest commits and branches in admin bar
<?php
add_action( 'admin_bar_menu', function() {
global $wp_admin_bar;
$menu_id = 'bb-git';
$wp_admin_bar->add_menu( array(
'id' => $menu_id,
'title' => __( 'BB - Git Helper' ),
) );
@Pross
Pross / functions.php
Last active January 11, 2021 09:39
Current user role shortcode.
<?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;
});