Skip to content

Instantly share code, notes, and snippets.

View markhowellsmead's full-sized avatar

Mark Howells-Mead markhowellsmead

View GitHub Profile
@markhowellsmead
markhowellsmead / alignment-options.js
Created February 17, 2022 10:52 — forked from wpmark/alignment-options.js
Add alignment options for WordPress core blocks.
// set alignment options for cover, video, and paragraph blocks.
wp.hooks.addFilter(
'blocks.registerBlockType',
'hd-theme/hd-theme',
function( settings, name ) {
if ( name === 'core/cover' || name === 'core/video' || name === 'core/paragraph' || name === 'core/list' ) {
return lodash.assign( {}, settings, {
supports: lodash.assign( {}, settings.supports, {
// allow support for full and wide alignment.
align: ['full', 'wide'],
@markhowellsmead
markhowellsmead / iframe.js
Created September 30, 2021 08:13 — forked from wlarch/iframe.js
Overwrite/bypass <iframe></iframe> height limit imposed by Wordpress
/**
* Overwrite/bypass <iframe></iframe> height limit imposed by Wordpress
* Original idea from bypass-iframe-height-limit plugin by Justin Carboneau
* Adapted from original /wp-includes/js/wp-embed.js
*/
(function(window, document) {
'use strict';
var supportedBrowser = false;
@markhowellsmead
markhowellsmead / wp-config.php
Created June 17, 2021 16:50 — forked from MikeNGarrett/wp-config.php
All those damned wp-config constants you can never remember.
<?php
// PHP memory limit for this site
define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' ); // Increase admin-side memory limit.
// Database
define( 'WP_ALLOW_REPAIR', true ); // Allow WordPress to automatically repair your database.
define( 'DO_NOT_UPGRADE_GLOBAL_TABLES', true ); // Don't make database upgrades on global tables (like users)
// Explicitely setting url
@markhowellsmead
markhowellsmead / exif-gist.php
Created February 10, 2021 09:40 — forked from black-forever/exif-gist.php
EXIF 01 - Get EXIF-Information from wp_get_attachment_image_attributes
<?php
/**
* *****************************************************************************
* GIST - EXIF 01 - Get EXIF-Information from wp_get_attachment_image_attributes
* *****************************************************************************
*/
if ( is_attachment() ) {
$imgmeta = wp_get_attachment_metadata( $id );
@markhowellsmead
markhowellsmead / full-codes.js
Created January 16, 2021 15:51 — forked from phpbits/full-codes.js
Extend core Gutenberg blocks with custom attributes and settings. View full tutorials here : https://jeffreycarandang.com/extending-gutenberg-core-blocks-with-custom-attributes-and-controls/
/**
* External Dependencies
*/
import classnames from 'classnames';
/**
* WordPress Dependencies
*/
const { __ } = wp.i18n;
const { addFilter } = wp.hooks;
@markhowellsmead
markhowellsmead / add-wordpress-settings-page.php
Created October 3, 2019 14:20 — forked from DavidWells/add-wordpress-settings-page.php
WordPress :: Add Settings Page with All Fields
<?php
/*
Plugin Name: Homepage Settings for BigBang
Plugin URI: http://www.inboundnow.com/
Description: Adds additional functionality to the big bang theme.
Author: David Wells
Author URI: http://www.inboundnow.com
*/
// Specify Hooks/Filters
@markhowellsmead
markhowellsmead / set-filter-by-tax.php
Last active July 14, 2021 14:24 — forked from marushu/set-filter-by-tax.php
Supports multiple filters.
<?php
add_action('restrict_manage_posts', [$this, 'taxonomyFilter']);
add_filter('parse_query', [$this, 'filterByTaxonomy']);
public function taxonomyFilter()
{
global $typenow;
@markhowellsmead
markhowellsmead / mini-modernizr.html
Created July 4, 2018 06:49 — forked from tomblanchard/mini-modernizr.html
Mini Modernizr: I only ever use Modernizr mostly to check for JS and / or touch screen devices. This tiny piece of code will replace the classes which are on the `<html>` element `no-js` with `js` and `no-touch` with `touch`.
<script>!function(a,b){"use strict";b.documentElement.className=b.documentElement.className.replace("no-js","js"),("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)&&(document.documentElement.className=document.documentElement.className.replace("no-touch","touch"))}(window,document);</script>
@markhowellsmead
markhowellsmead / mark-parent-navigation-active.php Mark (highlight) post type parent as active item in Wordpress Navigation. When you visit a custom post type's single page, the parent menu item (the post type archive) isn't marked as active. This code solves it by comparing the slug of the current post type with the navigation items, and adds a class accordingly.
<?php
add_action('nav_menu_css_class', function ($classes, $item) {
// Getting the current post details
$post = get_queried_object();
if (isset($post->post_type)) {
if ($post->post_type == 'post') {
$current_post_type_slug = get_permalink(get_option('page_for_posts'));
@markhowellsmead
markhowellsmead / composer-wp-cli.md
Created April 29, 2018 09:32 — forked from neverything/comopser-wp-cli.md
Install composer and wp-cli on cyon.ch hostings with SSH access.

Cyon.ch/Hostpoint - Install composer & wp-cli

Composer

SSH into your server and stay in the home directory of the user.

Install composer using curl. Check if you have a bin directory in your user directory already, in case you do, omit the mkdir bin.

cd ~