Skip to content

Instantly share code, notes, and snippets.

View nicooprat's full-sized avatar

Nico Prat nicooprat

View GitHub Profile
@nicooprat
nicooprat / config-1.json
Created July 14, 2017 13:44
1. Config without French | 2. With French
{
"version": 8,
"id": "osm-liberty",
"name": "OSM Liberty",
"metadata": {
"mapbox:type": "template"
},
"sources": {
"natural_earth_shaded_relief": {
"maxzoom": 6,
@nicooprat
nicooprat / blocks.php
Last active February 25, 2018 18:45
Simple PHP block yielding system
<?php
function block($slug, $params = array()) {
global $_SLUG_;
global $_PARAMS_;
$_SLUG_ = $slug;
$_PARAMS_ = $params;
ob_start();
@nicooprat
nicooprat / .gitignore
Created March 9, 2018 16:17
NPM scripts and environment variables
.npmrc
- pipeline: "Push staging"
trigger_mode: "ON_EVERY_PUSH"
ref_name: "dev"
ref_type: "BRANCH"
target_site_url: ""
actions:
- action: "Composer"
type: "BUILD"
working_directory: ""
docker_image_name: "library/php"
@nicooprat
nicooprat / **.tmTheme
Last active September 4, 2018 10:41
Highlight blocks of PHP in Sublime Text theme
<dict>
<key>name</key>
<string>Attributes</string>
<key>scope</key>
<string>meta.embedded.line.php, meta.embedded.block.php</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#FFFFFF0F</string>
</dict>
@nicooprat
nicooprat / register-custom-blocks.php
Created October 22, 2018 14:17
Registering Gutenberg blocks with ACF blocks
function my_acf_block_render_callback( $block ) {
$slug = str_replace('acf/', '', $block['name']);
$block['slug'] = $slug;
$block['classes'] = implode(' ', [$block['slug'], $block['className'], $block['align']]);
echo \App\template("blocks/${slug}", ['block' => $block]);
}
add_action('acf/init', function() {
if( function_exists('acf_register_block') ) {
// Look into views/blocks
@nicooprat
nicooprat / custom-callback.php
Last active October 22, 2018 16:42
Create an ACF block
function my_acf_block_render_callback( $block ) {
$slug = str_replace('acf/', '', $block['name']);
if( file_exists(STYLESHEETPATH . "/template-parts/block/content-{$slug}.php") ) {
include( STYLESHEETPATH . "/template-parts/block/content-{$slug}.php" );
}
}
@nicooprat
nicooprat / testimonial.php
Last active October 22, 2018 17:46
Custom Gutenberg bloc with bare PHP
<?php
/*
Title: Témoignage
Description: test
Category: formatting
Icon: admin-comments
Keywords: testimonial quote
*/
?>
@nicooprat
nicooprat / nuxt.config.js
Created December 18, 2018 12:07
Nuxt, Webpack & Bugsnag
const { BugsnagBuildReporterPlugin, BugsnagSourceMapUploaderPlugin } = require('webpack-bugsnag-plugins')
module.exports = {
...
build: {
extend (config, { isDev, isClient }) {
if (!isDev && isClient) {
config.devtool = '#source-map'
config.plugins.push(
new BugsnagBuildReporterPlugin({
@nicooprat
nicooprat / grid.less
Last active August 1, 2019 09:07
First try to port Unsemantic to LESS. (http://unsemantic.com/)
// http://unsemantic.com/
// -------------------
// Variables
// -------------------