Skip to content

Instantly share code, notes, and snippets.

View vanaf1979's full-sized avatar

VA79 vanaf1979

View GitHub Profile
@vanaf1979
vanaf1979 / webpack-mix-new.js
Last active March 19, 2019 10:13
Gist for my "WordPress: Laravel Mix, Sass and ES6 Modules in theme development" tutorial at Medium http://bit.ly/wplaravelmixtut
const mix = require('laravel-mix');
mix.js('src/app.js', 'dist')
.sass('src/app.scss', 'dist')
.setPublicPath('dist');
@vanaf1979
vanaf1979 / after-setup-theme-hook.php
Last active April 21, 2019 12:21
after-setup-theme-hook.php
<?php
function theme_register_nav_menus() {
}
add_action( 'after_setup_theme', 'theme_register_nav_menus' );
?>
@vanaf1979
vanaf1979 / register-nav-menus.php
Last active April 21, 2019 12:21
register-nav-menus.php
<?php
function theme_register_nav_menus() {
register_nav_menus(
array(
'header-menu' => __( 'Header Menu' ),
'footer-menu' => __( 'Footer Menu' )
)
);
@vanaf1979
vanaf1979 / package.scripts.json
Last active April 29, 2019 14:41
Gist for my "WordPress: Laravel Mix, Sass and ES6 Modules in theme development" tutorial at Medium http://bit.ly/wplaravelmixtut
{
"name": "mix-tutorial",
"version": "1.0.0",
"description": "laravel mix tutorial",
"main": "index.js",
"keywords": [],
"author": {
"name": "Vanaf1979",
"email": "email@example.com",
<?php
/**
* Plugin Name: My Sidebar
* Plugin URI: https://example.com/
* Description: A Example Gutenberg sidebar plugin.
* Version: 1.0
* Author: Your name
* Author URI: https://example.com/
* Text Domain: my-sidebar
@vanaf1979
vanaf1979 / my-sidebar.php
Last active May 23, 2019 09:36
Register my sidebar plugin with WordPress
<?php
/**
* Plugin Name: My Sidebar
* Plugin URI: https://example.com/
* Description: A Example Gutenberg sidebar plugin.
* Version: 1.0
* Author: Your name
* Author URI: https://example.com/
* Text Domain: my-sidebar
* Domain Path: languages
<?php
private static $pluginslug;
private static $instance;
private $dependancies;
<?php
public function __construct() {
$this->pluginslug = 'my-sidebar';
$this->dependancies = array(
'wp-plugins',
'wp-edit-post',
'wp-element',
<?php
public static function instance() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof MySIdebar ) ) {
self::$instance = new MySidebar;
}
<?php
public function init() {
// Hook to load plugin textdomain.
add_action(
'plugins_loaded',
array( $this , 'load_textdomain' ),
99
);