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
namespace App;
/**
* Class NavWalker
*
* Bootstrap 4 walker with cleaner markup for wp_nav_menu()
* For use with Sage >= 8.5
*
@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
@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 / 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 / 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 / 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;
}
<?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
<?php
function acf_add_local_field_group($array) {
// put absolute path to theme in here
$themePath = $_SERVER["DOCUMENT_ROOT"].'/wp-content/uploads/';
$acfJsonPath = $themePath;
$output = json_encode($array);
echo '<p>Writing file to ' . $acfJsonPath . $array['key'] . '.json</p>';
$file = file_put_contents( $acfJsonPath . $array['key'] . '.json', $output );
<?php
$geo = Wpengine\Geoip::instance();
if($geo->country()=='RO') {
$country = 'Romania';
} elseif($geo->country()=='UK') {
$country = 'United Kingdom';
} elseif($geo->country()=='US') {
$country = 'United States';
}