Skip to content

Instantly share code, notes, and snippets.

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

Jasper Frumau jasperf

🏠
Working from home
View GitHub Profile
@jasperf
jasperf / events-cpt.php
Created November 1, 2021 03:09
Event Custom Post Type made with CPT UI
function cptui_register_my_cpts_event() {
/**
* Post Type: Events.
*/
$labels = [
"name" => __( "Events", "custom-post-type-ui" ),
"singular_name" => __( "Event", "custom-post-type-ui" ),
"menu_name" => __( "My Events", "custom-post-type-ui" ),
@jasperf
jasperf / dynamic-events-group.json
Created November 1, 2021 03:08
ACF Dynamic Fields Group
[
{
"key": "group_617a8b17d7b17",
"title": "Dynamic Event Block Fields",
"fields": [
{
"key": "field_617a8b25ff4c6",
"label": "Number of Events",
"name": "number_of_events",
"type": "range",
@jasperf
jasperf / block.php
Last active November 1, 2021 03:06
Loading Events CPT Posts as ACF Block
<?php
/**
* Events CPT Block
*
**/
// Create id attribute allowing for custom "anchor" value.
$id = 'pm-' . $block['id'];
if( !empty($block['anchor']) ) {
$id = $block['anchor'];
@jasperf
jasperf / functions.php
Last active October 24, 2021 02:15
Randomly load custom post type data- code by Piet Goosen to https://wordpress.stackexchange.com/a/218760/12260
<?php
/***
* Get the random custom post type ids and store them in a transient
*/
function get_random_id( $post_type = '' )
{
$q = [];
// Make sure we have a post type set, check if it exists and sanitize
@jasperf
jasperf / acf-image-banner.php
Last active October 21, 2021 00:05
Advanced Custom Field to load an image by attachment
$banner_img = get_field('banner_image', 'option');
$size = 'full'; // (thumbnail, medium, large, full or custom size)
echo wp_get_attachment_image( $banner_img, $size, '', ["class" => "banner-image"] );
echo '<a href="" class="wp-block-button__link outline" style="position:absolute; top:76%; right:3%;">hide</a>';
@jasperf
jasperf / bitbucket-pipelines.yml
Created October 19, 2021 05:00
Bitbucket pipeline WordPress Site
image: thenatives/ci-php-yarn:1.0
pipelines:
branches:
develop:
- step:
name: Deploy Development
deployment: test
caches:
@jasperf
jasperf / 1SyncOrderJob.php
Last active June 20, 2021 03:45
Exact Picquer PHP API Package Error on running Laravel Job: Could not acquire or refresh tokens [http 400]
<?php
namespace App\Jobs\Exact;
use App\Order;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
@jasperf
jasperf / elementor-swiper-slider.md
Last active October 27, 2023 07:53
Elementor Slider Pro with Swiper Slider issues using background images using CSS instead of HTML

See Swiper Slider Lazy Loading example. The Elementor Slider Widget Pro uses Swiper and basic setup uses background images with CSS [link]. They do not use HTML tags like <div> or <img> with src, data-src or srcset . To use lazy loading HTML markup has to be changed as shown in example.

With this HTML markup that we could also use Imagify to load webP images when possible using swapping with JavaScript. Unfortunately this is not possible with the current setup of Elementor Slider Pro.

@jasperf
jasperf / do-spaces-laravel-error.php
Last active April 25, 2021 01:11
Digital Ocean Spaces 503 Error using Laravel Backup
<?php
app/Jobs/ProjectExport.php:46 App\Jobs\ProjectExport::handle
$zip = \Zip::create(storage_path("app/projects/{$name}"));
// Clean files
$allFiles = \Storage::disk('do_backup')->allFiles($storagePath);
@jasperf
jasperf / phpmyadmin.sh
Last active April 23, 2021 23:55
PHPMyAdmin on PHP 7.4 with Homebrew on macOS
➜ ~ brew install phpmyadmin
Updating Homebrew...
==> Downloading https://files.phpmyadmin.net/phpMyAdmin/5.1.0/phpMyAdmin-5.1.0-all-
######################################################################## 100.0%
==> Caveats
To enable phpMyAdmin in Apache, add the following to httpd.conf and
restart Apache:
Alias /phpmyadmin /usr/local/share/phpmyadmin
<Directory /usr/local/share/phpmyadmin/>
Options Indexes FollowSymLinks MultiViews