Skip to content

Instantly share code, notes, and snippets.

View webgurus's full-sized avatar
🏠
Working from home

Gergely Márton webgurus

🏠
Working from home
View GitHub Profile
<?php
//BEGIN PROCESS THE FORM - NOTE $attributes global var is a merge of $_GET and $_POST - so the fields submitted in the form :);
if(empty($stripe_errors) && !empty($attributes['stripe_card_form_submitted'])){
$customer_args = array(
'card' => $attributes['stripeToken']
, 'description'=>trim($attributes['customer']['name']) . ';' . trim($attributes['customer']['email'])
, 'email'=>$attributes['customer']['email']
);
//create a new customer
//ALWAYS create the customer record in the root application - NOT using the stripe connect access_token
@webgurus
webgurus / acf-repeater-pagination.php
Created July 18, 2017 09:29
example on how to paginate an acf repeater image gallery
<?php
/*
* Paginate Advanced Custom Field repeater
*/
if( get_query_var('page') ) {
$page = get_query_var( 'page' );
} else {
$page = 1;
}
@webgurus
webgurus / loop_row.php
Last active January 23, 2018 11:19
Loop with row after each second item
<?php
$post = new WP_Query($args);
$counter = 0;
$start_el = '<div class="row">';
$end_el = '</div><!-- .row -->';
$item_per_row = 3;
if ( $post->have_posts() ) :
// Opening the first row
echo $start_el;
@webgurus
webgurus / photoswipe.js
Created November 25, 2020 17:49 — forked from panoply/photoswipe.js
Photoswipe.js ES6 Implementation
import PhotoSwipe from 'photoswipe';
import PhotoSwipeUI_Default from 'photoswipe/dist/photoswipe-ui-default';
export default (selector) => {
const parseThumbnailElements = (element) => {
let items = [];
const thumbs = element.parentNode.querySelectorAll('figure');
@webgurus
webgurus / App.php
Last active April 30, 2021 06:25
Sage9 - ACF Flexible page builder controller
<?php
namespace App\Controllers;
use Sober\Controller\Controller;
use WP_Query;
class App extends Controller
{
// Add all acf fields into the view
@webgurus
webgurus / content-flexible.blade.php
Last active October 22, 2021 07:05
The flexible content page builder content part
@if($page_builder)
@foreach ($page_builder as $block)
@include('partials/page-builder/'.$block->block_type)
@endforeach
@endif
<?php
namespace App;
/**
* Class NavWalker
*
* Bootstrap 4 walker with cleaner markup for wp_nav_menu()
* For use with Sage >= 8.5
*
@webgurus
webgurus / segment-consent-analytics.blade.php
Created December 16, 2021 16:36
Segment Consent Manager in Sage9
// Init Segment
!function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on"];analytics.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);e.unshift(t);analytics.push(e);return analytics}};for(var t=0;t<analytics.methods.length;t++){var e=analytics.methods[t];analytics[e]=analytics.factory(e)}analytics.load=function(t){var e=document.createElement("script");e.type="text/javascript";e.async=!0;e.src=("https:"===document.location.protocol?"https://":"http://")+"cdn.segment.com/analytics.js/v1/"+t+"/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(e,n)};analytics.SNIPPET_VERSION="4.0.0";
analytics.load("YOUR_WRITE_KEY");
ana