Skip to content

Instantly share code, notes, and snippets.

View buiquangduc's full-sized avatar
🎯
Focusing

Bui Quang Duc buiquangduc

🎯
Focusing
View GitHub Profile
@buiquangduc
buiquangduc / functions.php
Created February 12, 2018 04:39
acf/settings/load_json filter
<?php
add_filter('acf/settings/load_json', 'my_acf_json_load_point');
function my_acf_json_load_point( $paths ) {
// remove original path (optional)
unset($paths[0]);
@buiquangduc
buiquangduc / functions.php
Created February 12, 2018 04:36
acf/settings/save_json filter
<?php
add_filter('acf/settings/save_json', 'my_acf_json_save_point');
function my_acf_json_save_point( $path ) {
// update path
$path = get_stylesheet_directory() . '/my-custom-folder';
@buiquangduc
buiquangduc / setup.php
Created January 25, 2018 06:59
Modify WooCommerce default override template path
/**
* Override folder that WooCommerce will check if there are any override WooCommerce's template files.
* WordPress initially detects theme in themes/sage/resources follow Sage's config.
* @see resources/functions.php:65
*/
add_filter( 'woocommerce_template_path', function($template_path) {
$template_path = 'views/woocommerce/';
return $template_path;
}, 10);
@buiquangduc
buiquangduc / frontpage.php
Created January 24, 2018 16:29
Protected function example
<?php
namespace App;
use Sober\Controller\Controller;
class FrontPage extends Controller
{
/**
* This function will be represented as $test_variable in single-product.blade.php file.
@buiquangduc
buiquangduc / front-page.php
Created January 24, 2018 16:14
Public static function example
<?php
namespace App;
use Sober\Controller\Controller;
class FrontPage extends Controller
{
/**
* This function will be called on front-page.blade.php by this way: FrontPage::custom_title().
@buiquangduc
buiquangduc / front-page.blade.php
Last active January 24, 2018 16:05
Front Page with custom title
@extends('layouts.app')
@section('content')
<h2>{{ $custom_title }}</h2>
@include('partials.page-header')
@if (!have_posts())
<div class="alert alert-warning">
{{ __('Sorry, no results were found.', 'sage') }}
</div>
@buiquangduc
buiquangduc / front-page.php
Last active January 24, 2018 16:01
Public scope example
<?php
namespace App;
use Sober\Controller\Controller;
class FrontPage extends Controller
{
/**
* This function will be represented as $custom_title variablr inside front-page.blade.php file.
@buiquangduc
buiquangduc / header.blade.php
Created January 24, 2018 10:28
Example of partial layout file
<header class="banner">
<div class="container">
<a class="brand" href="{{ home_url('/') }}">{{ get_bloginfo('name', 'display') }}</a>
<nav class="nav-primary">
Blade template header.
@if (has_nav_menu('primary_navigation'))
{!! wp_nav_menu(['theme_location' => 'primary_navigation', 'menu_class' => 'nav']) !!}
@endif
</nav>
</div>
@buiquangduc
buiquangduc / base.blade.php
Created January 24, 2018 09:54
Example of master layout file
<!doctype html>
<html @php(language_attributes())>
{{-- Meta include --}}
@include('partials.head')
<body @php(body_class())>
{{-- Header include --}}
@php(do_action('get_header'))
@include('partials.header')
<div class="wrap container" role="document">
<div class="content">
@buiquangduc
buiquangduc / archive.blade.php
Created January 24, 2018 09:28
Override archive page with Sage 9 template
@extends('layouts.app')
@section('content')
@include('partials.page-header')
This is a custom content for archive page.
@if (!have_posts())
<div class="alert alert-warning">
{{ __('Sorry, no results were found.', 'sage') }}
</div>
{!! get_search_form(false) !!}