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
@webgurus
webgurus / gulpfile.js
Created October 5, 2023 16:33 — forked from bhdd/gulpfile.js
Updated Sage 8.6.0 build files
// ## Globals
var argv = require('minimist')(process.argv.slice(2));
var autoprefixer = require('gulp-autoprefixer');
var browserSync = require('browser-sync').create();
var changed = require('gulp-changed');
var concat = require('gulp-concat');
var flatten = require('gulp-flatten');
var gulp = require('gulp');
var gulpif = require('gulp-if');
var imagemin = require('gulp-imagemin');
@webgurus
webgurus / ul_list_chunks.blade.php
Created August 31, 2023 20:17
Split list elements into chunks of 5 with Blade (e.g UL list columns)
@if($content['section_checkmarks'])
@php
// Transform array into collection
$checkmarks = collect($content['section_checkmarks']);
@endphp
{{-- Split elements into chunks of 5 --}}
@foreach($checkmarks->chunk(5) as $chunk)
<ul class="check list-smaller">
@foreach($chunk as $checkmark)
<li>{!! $checkmark['checkmark_text'] !!}</li>
@webgurus
webgurus / App.php
Last active September 27, 2022 09:39
<?php
/**
* Get 4 news item query
* @return array
*/
public static function blogPostsLoop($post_ids = array(), $post_type = 'post', $showposts = '4', $exclude_posts = array()) {
$blogposts_query = array(
'post_type' => $post_type,
'post_status' => 'publish',
'posts_per_page' => $showposts,
@webgurus
webgurus / oembed_add_attributes_to_iframe.php
Created August 9, 2022 12:52
Modify ACF oEmbed field to add attributes.
/**
* Add custom attributes to oEmbed iframe src
*
* @param string $iframe
* @return string
*/
public static function oEmbedIframe($iframe) {
// Use preg_match to find iframe src.
preg_match('/src="(.+?)"/', $iframe, $matches);
$src = $matches[1];
@webgurus
webgurus / estimated_reading_time.php
Last active July 18, 2022 11:06
Estimated post reading time (App.php) for Sage 9
/**
* Estimated Reading Time
*
* Use by adding {{ App::estimated_reading_time(get_the_ID()) }} to the Blade view where you want to use it.
*
* @return void
*/
public static function estimated_reading_time($post_id) {
$the_content = apply_filters( 'the_content', get_the_content(null, false, $post_id));
@webgurus
webgurus / excerpt_length_sage.php
Created July 18, 2022 10:30
Change Excerpt length on Sage 9
/**
* Filter the excerpt length to 39 words.
*
* @param int $length Excerpt length.
* @return int (Maybe) modified excerpt length.
*/
add_filter( 'excerpt_length', function( $length ) {
return 39;
} );
@webgurus
webgurus / filters.php
Created July 18, 2022 10:29
Add Wrapper to oEmbed to allow reframe.js to resize
/**
* Add wrapper to oEmbed
*/
add_filter('embed_oembed_html', function($html, $url, $attr) {
return $html!=='' ? '<div class="embed-container">'.$html.'</div>' : '';
}, 10, 3);
// 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
@webgurus
webgurus / segment-consent-analytics.blade.php
Created December 16, 2021 16:36
Segment Consent Manager in Sage9