Skip to content

Instantly share code, notes, and snippets.

View danlapteacru's full-sized avatar
:electron:

Dan Lapteacru danlapteacru

:electron:
View GitHub Profile
@danlapteacru
danlapteacru / AcfMenuDepth.php
Created May 16, 2024 11:40
ACF Menu Depth Rule
<?php
declare(strict_types=1);
use WP_Screen;
/**
* Class MenuDepth
*
* This class is used to define a custom rule for Advanced Custom Fields (ACF) plugin.
@danlapteacru
danlapteacru / RadicleValetDriver.php
Created May 10, 2024 07:51
~/.config/valet/Drivers/RadicleValetDriver.php
<?php
namespace Valet\Drivers\Custom;
use Valet\Drivers\ValetDriver;
class RadicleValetDriver extends ValetDriver
{
/**
* Determine if the driver serves the request.
@danlapteacru
danlapteacru / filter_posts_by_taxonomy_terms_name.php
Created September 1, 2021 14:31
Order posts by taxonomy terms name
<?php
add_filter('posts_clauses', function (array $clauses, WP_Query $wp_query): array {
$wpdb = $GLOBALS['wpdb'];
$taxonomy = 'course_level';
if (! isset($wp_query->query['orderby']) || $taxonomy !== $wp_query->query['orderby']) {
return $clauses;
}
@danlapteacru
danlapteacru / LaravelMixAsset.php
Last active July 23, 2021 12:32
WordPress Laravel Mix Asset Class
<?php
declare(strict_types=1);
/**
* Class LaravelMixAsset
*/
class LaravelMixAsset
{
/**
@danlapteacru
danlapteacru / filter-posts-by-post-title-first-letter.php
Last active December 21, 2023 11:29
Filter posts by post title first letter in WordPress (PHP 7.x)
<?php
/**
* Filter posts by post title first letter in WordPress (PHP 7.x)
*/
add_filter('posts_where', function (string $where, WP_Query $query): string {
$wpdb = $GLOBALS['wpdb'];
$starts_with = esc_sql($query->get('title_starts_with'));
@danlapteacru
danlapteacru / MoodleValetDriver.php
Created May 21, 2021 05:22 — forked from sandeepgill/MoodleValetDriver.php
Laravel Valet Moodle driver
<?php
class MoodleValetDriver extends BasicValetDriver
{
protected $isStyleUri = false;
protected $baseUri = '';
protected $moodleStaticScripts = [
'styles.php',
'javascript.php',
'jquery.php',
@danlapteacru
danlapteacru / getLatLngCenter.php
Last active July 23, 2021 12:33
Calculate the center point of multiple latitude/longitude coordinates array
<?php
/**
* Get Lat/Lng center from an coords array
*
* @param array $coords
* @return float[]|int[]
*/
function getLatLngCenter(array $coords): array
{