Skip to content

Instantly share code, notes, and snippets.

Avatar

Matt Watson mattwatsoncodes

View GitHub Profile
@mattwatsoncodes
mattwatsoncodes / functions.php
Created Nov 14, 2021
WP Owls - Owl Link Block Pattern
View functions.php
$block_pattern_content = '<!-- wp:group {"className":"owl-link"} -->
<div class="wp-block-group owl-link"><!-- wp:image {"id":121,"sizeSlug":"full","linkDestination":"none","className":"owl-link__image"} -->
<figure class="wp-block-image size-full owl-link__image"><img src="http://wholesome-plugins.test/wp-content/uploads/2021/08/fikret-tozak-Zk-Ydz2IAs-unsplash-scaled-208x270-c-center.jpg" alt="" class="wp-image-121"/></figure>
<!-- /wp:image -->
<!-- wp:group {"className":"owl-link__content"} -->
<div class="wp-block-group owl-link__content"><!-- wp:paragraph -->
<p><strong>Courtney Patubo Kranzke</strong>&nbsp;submitted a proposal for the Global Community Sponsorship program for 2022. As analog events are still up in the air, WordCamps are not included in the draft.</p>
<!-- /wp:paragraph -->
@mattwatsoncodes
mattwatsoncodes / .stylelintrc
Last active Aug 3, 2020
Extending the WordPress Create Block Script webpack Config with Bonus Extras
View .stylelintrc
{
"extends": "stylelint-config-standard",
"plugins": [
"stylelint-order"
],
"rules": {
"color-hex-length": "long",
"font-family-name-quotes": null,
"function-url-quotes": "always",
"indentation": "tab",
@mattwatsoncodes
mattwatsoncodes / package.json
Last active May 7, 2020
Extending the WordPress Create Block Script webpack Config with Polyfil's and Minification
View package.json
{
"name": "plugin-slug",
"version": "0.1.0",
"description": "Plugin Description",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
"main": "build/index.js",
"scripts": {
"build": "wp-scripts build",
"lint:css": "wp-scripts lint-style",
@mattwatsoncodes
mattwatsoncodes / package.json
Last active Jun 10, 2021
Extending the WordPress Create Block Script webpack Config
View package.json
{
"name": "plugin-slug",
"version": "0.1.0",
"description": "Plugin Description",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
"main": "build/index.js",
"scripts": {
"build": "wp-scripts build",
"lint:css": "wp-scripts lint-style",
@mattwatsoncodes
mattwatsoncodes / gf_prevent_data.php
Created Jun 26, 2018
Prevent Gravity Forms Storing Data
View gf_prevent_data.php
<?php
/**
* Prevent gravity forms storing data
**/
function mkdo_remove_form_entry( $entry ) {
if ( class_exists( 'GFAPI' ) ) {
GFAPI::delete_entry( $entry['id'] );
}
}
add_action( 'gform_after_submission', 'mkdo_remove_form_entry' );
@mattwatsoncodes
mattwatsoncodes / formats.php
Last active Oct 14, 2020
Custom TinyMCE Formatting in WordPress
View formats.php
<?php
/**
* TinyMCE Formatting
*
* Adds a pagraph around selected text with a class of .lead.
*
* @param array $settings Array of TinyMCE settings
* @return array Array of TinyMCE settings
*/
View github-labels.sh
#!/bin/bash
echo -n "GitHub User: "
read USER
echo -n "GitHub Password: "
read -s PASS
echo ""
echo -n "GitHub Repo (e.g. foo/bar): "
@mattwatsoncodes
mattwatsoncodes / step-1.conf
Last active Dec 4, 2017
How to add a SSL certificate to Salty WordPress
View step-1.conf
##
# Step 1
#
# Inside the Salty-WordPress folder that you have gotten from the Human Made
# repo (https://github.com/humanmade/Salty-WordPress), you will find the file
# /config/salt/config/nginx/nginx.conf
#
# That file looks something like this.
##
@mattwatsoncodes
mattwatsoncodes / geoip_langauge_code.php
Created Aug 8, 2017
Get the language code with a GEOIP service (this one uses WPEngine and freegeoipnet as a fallback.
View geoip_langauge_code.php
<?php
namespace mkdo\geoip_langauge_code;
/**
* Class LangaugeCode
*
* Gets the LanguageCode
*
* @package mkdo\geoip_langauge_code
*/
class LanguageCode {
@mattwatsoncodes
mattwatsoncodes / responsive-bg-images-example.php
Last active Jul 28, 2017
Responsive Background Images - The JavaScript
View responsive-bg-images-example.php
<?php
if ( has_post_thumbnail() ) {
$img_id = get_post_thumbnail_id( $post->ID );
$img_settings = array(
array(
'size' => 'featured-image-mobile',
'breakpoint' => '480',
),