Skip to content

Instantly share code, notes, and snippets.

@brendonexus
brendonexus / functions.php
Last active April 7, 2022 11:20
Add css class to menu item. WordPress/ACF
function custom_css_class_on_menu_item( $items, $args ) {
// loop
foreach( $items as &$item ) {
// vars
$class = get_field('css_class', $item);
// append class
if( $class ) {
$item->classes[] = $class;
}
}
@brendonexus
brendonexus / AppServiceProvider.php
Created February 8, 2022 09:21
Pagination macro for Collections - Laravel 8
<?php
namespace App\Providers;
use Illuminate\Support\Collection;
use Illuminate\Pagination\LengthAwarePaginator;
class AppServiceProvider extends ServiceProvider
{
public function boot()
@brendonexus
brendonexus / _variables.scss
Last active November 10, 2021 13:06
Custom Bootstrap 4 variables
//
// Bootstrap variables (overrides)
// --------------------------------------------------
//
// Color system
//
$white: #fff !default;
@brendonexus
brendonexus / FutureSoftDeletesScope.php
Last active May 21, 2021 11:52
Laravel deleted_at traits
<?php
namespace App\Traits;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletingScope;
class FutureSoftDeletesScope extends SoftDeletingScope {
public function apply(Builder $builder, Model $model)
@brendonexus
brendonexus / _variables.scss
Last active June 8, 2021 09:28
Bootstrap 5 sizes in Bootstrap 4
$grid-columns: 12;
$grid-gutter-width: 24px;
$grid-breakpoints: (
xs: 0,
sm: 576px,
md: 768px,
lg: 992px,
xl: 1200px,
xxl: 1400px
@brendonexus
brendonexus / message.blade.php
Created January 12, 2021 10:15
Blade template for session/flash messages in Laravel 8 & BS5
@if(session('success'))
<div class="alert alert-success" role="alert">{{ session('success') }}</div>
@endif
@if(session('error'))
<div class="alert alert-danger" role="alert">{{ session('error') }}</div>
@endif
@if(session('warning'))
<div class="alert alert-warning" role="alert">{{ session('warning') }}</div>
@endif
@if(session('info'))
@brendonexus
brendonexus / style.scss
Created November 5, 2020 12:42
Turn checkboxes to clickable buttons with active styling
[type="radio"] {
+ {
span {
position: relative;
cursor: pointer;
background-color: #F7FBFF;
border: 2px solid #F7FBFF;
padding: 15px 30px;
border-radius: 100px;
display: inline-block;
@brendonexus
brendonexus / settings.json
Last active November 9, 2020 09:43
VSCode Deploy Reloaded FTP Setup
{
"deploy.reloaded": {
"packages": [
{
"name": "name",
"targets": ["serverName"],
"files": [
"**/*",
],
"exclude": [
@brendonexus
brendonexus / functions.php
Created March 5, 2020 16:13
Change Woocommerce Variations from Selects to Radio buttons
function variation_radio_buttons($html, $args)
{
$args = wp_parse_args(apply_filters('woocommerce_dropdown_variation_attribute_options_args', $args), array(
'options' => false,
'attribute' => false,
'product' => false,
'selected' => false,
'name' => '',
'id' => '',
'class' => '',
@brendonexus
brendonexus / functions.php
Created March 5, 2020 16:13
Remove rel="nofollow" from Woocommerce
add_filter( 'woocommerce_loop_add_to_cart_args', 'remove_rel', 10, 2 );
function remove_rel( $args, $product ) {
unset( $args['attributes']['rel'] );
return $args;
}