Skip to content

Instantly share code, notes, and snippets.

View samikeijonen's full-sized avatar
🏠
Working from home

Sami Keijonen samikeijonen

🏠
Working from home
View GitHub Profile
/**
* Set dataLayer for Piwik Pro.
*/
function dataLayer() {
window.dataLayer = window.dataLayer || [];
// Form field have been added as hidden field in the Gravity Form.
// It has class `js-datalayer-name`.
const formNameField = document.querySelector('.js-datalayer-name input');
if (formNameField) {
pipelines:
default:
- parallel:
- step:
image: composer:2.0
name: 'PHPCS'
script:
# Install Dependencies
- composer install
# Run PHPCS
@samikeijonen
samikeijonen / theme.json
Last active July 25, 2023 20:38
theme.json example for WP 5.9
{
"$schema": "https://schemas.wp.org/trunk/theme.json",
"version": 2,
"settings": {
"custom": {
"color": {
"primary": {
"100": "hsl(360, 100%, 97%)",
"200": "hsl(360, 82%, 89%)",
"300": "hsl(360, 77%, 78%)",
@samikeijonen
samikeijonen / block-variations.js
Last active May 17, 2020 12:29
Example Block Variations
// WordPress dependencies.
const { __ } = wp.i18n;
const { Path, SVG } = wp.components;
/**
* Block variants.
*/
wp.domReady(() => {
wp.blocks.unregisterBlockVariation('core/columns', 'two-columns-equal');
import debounce from 'lodash.debounce';
const { subscribe, dispatch, select, withSelect } = wp.data;
const { getEditedPostAttribute, isCurrentPostPublished, getCurrentPostType } = select( 'core/editor' );
const { isTyping } = select( 'core/block-editor' );
const { getMedia } = select( 'core' );
const { lockPostSaving, unlockPostSaving } = dispatch( 'core/editor' );
const { createNotice, removeNotice } = dispatch( 'core/notices' );
const { __ } = wp.i18n;
@samikeijonen
samikeijonen / settings.json
Last active February 19, 2019 13:52
VS Code workspace settings for PHPCS in 10up projects
{
"phpcs.executablePath": "/absolute-path-to/vendor/bin/phpcs",
"phpcs.standard": "10up-Default",
"phpcs.autoConfigSearch": false
}
@samikeijonen
samikeijonen / gutenberg-notes.md
Last active July 7, 2018 11:19
Gutenberg notes 7.7.2018

Gutenberg notes

Paragraph

  • In the editor I see inline styles when changing custom size.
  • Also editor styles should use is-small-text, is-larger-text classes so that they would match what theme wants.
@samikeijonen
samikeijonen / filter-pagination-markup.php
Created June 27, 2018 16:37
Filter pagination markup. And some wp_link_pages_link.
<?php
add_filter( 'navigation_markup_template', function( $template, $class ) {
// Set custom modifier classes.
$class = 'pagination' === $class ? 'posts' : 'comments';
// Modified template with custom classes.
$template = '
<nav class="pagination pagination--' . $class . '" role="navigation">
<h2 class="screen-reader-text">%2$s</h2>
<div class="pagination__items">%3$s</div>
@samikeijonen
samikeijonen / register-page-template.php
Last active June 6, 2018 07:12
Register page template in HC5
<?php
use function Hybrid\register_object_template;
add_action( 'hybrid/register_object_templates', function() {
register_object_template( 'example', [
'label' => __( 'Example' ),
'filename' => 'example.php'
] );
@samikeijonen
samikeijonen / align-full-wide.css
Created March 17, 2018 07:10
Align full and wide CSS example for WP editor
// Align full and wide.
.alignfull {
margin-left: calc(50% - 50vw);
margin-right: calc(50% - 50vw);
max-width: 1000%;
width: auto;
}
@media (min-width: $breakpoint-1) {