Skip to content

Instantly share code, notes, and snippets.

View m-miller's full-sized avatar

Martin Miller m-miller

View GitHub Profile
@blacksaildivision
blacksaildivision / wp-head-clean.php
Last active April 19, 2023 11:12
Remove all unnecessary stuff from WordPress <head> tag
<?php
/**
* Alter dns-prefetch links in <head>
*/
add_filter('wp_resource_hints', function (array $urls, string $relation): array {
// If the relation is different than dns-prefetch, leave the URLs intact
if ($relation !== 'dns-prefetch') {
return $urls;
}
@m-miller
m-miller / .babelrc
Created August 3, 2018 00:57 — forked from igorbenic/.babelrc
Integrating Gutenberg Blocks in Existing WordPress Plugins | https://www.ibenic.com/integrating-gutenberg-blocks-in-plugins
{
"presets": [
[
"env",
{
"modules": false
}
]
],
"plugins": [
@m-miller
m-miller / conditional_metabox.js
Created September 26, 2017 06:09
Wordpress conditional metabox on checked category
jQuery(document).ready(function() {
function metabox_category() {
// conditional show/hide metaboxes on checked category
var label = null;
var onemeta = jQuery('#id_of_custommetabox.postbox');
// get checked checkboxes
var ischecked = jQuery('#taxonomy_name_categorychecklist input[type="checkbox"]:checked');
var label = ischecked.parent().text().trim();
//console.log(label);
//console.log(ischecked.length);
@m-miller
m-miller / google_search_console_daily.R
Created June 3, 2017 01:21 — forked from ryanpraski/google_search_console_daily.R
Download Google Search Console data (formerly webmaster tools) to R using searchConsoleR package. This script downloads data for the most recent day of search console data which is 3 days ago. Tutorial describing how to automate daily Google Search Console pulls using this script: http://www.ryanpraski.com/google-search-console-api-r-guide-to-ge…
## A script to download and archive Google search console analytics (formerly webmaster tools)
##
## searchConsoleR package created by Mark Edmondson (http://markedmondson.me)
##
## This script downloads and writes data to .csv for the most recent day of search console data (3 days ago)
## load the required libraries
## (Download them with install.packages("googleAuthR") and install.packages("searchConsoleR") if necessary
library(googleAuthR)
library(searchConsoleR)
@m-miller
m-miller / nav-menu-exporter-importer.php
Created January 25, 2017 04:17 — forked from hissy/nav-menu-exporter-importer.php
[WordPress Plugin] Nav Menu Exporter and Importer / Export and Import nav menus. Requires WordPress Importer plugin.
<?php
/*
Plugin Name: Nav Menu Exporter and Importer
Description: Export and Import nav menus. Requires WordPress Importer plugin
Author: hissy, megumi themes
Version: 0.1
Text Domain: nav-menu-exporter-importer
License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
@palanik
palanik / server.js
Created June 6, 2016 02:54
Using D3 on node.js
/*
* npm install d3 node-jsdom
*/
var d3 = require('d3');
var jsdom = require('node-jsdom');
var http = require('http');
function svgDOM(width, height) {
// Setup DOM
@m-miller
m-miller / soliloquy-remove-slideshow-button.php
Last active June 3, 2017 01:22
WordPress remove soliloquy slider button
<?php
/*
Plugin Name: Remove Soliloquy slider button from editor
* Plugin URI: http://soliloquywp.com
* Version: 1.0
* Author: Martin Miller
* Author URI: https://www.govdelivery.com
* Description: Remove the Add Slideshow button from all Visual Editors in WordPress
*/
@benfrain
benfrain / allowSVG.php
Created March 8, 2014 00:05
Allow SVG upload and preview to Media area of Wordpress (add this to functions.php)
function custom_mtypes( $m ){
$m['svg'] = 'image/svg+xml';
$m['svgz'] = 'image/svg+xml';
return $m;
}
add_filter( 'upload_mimes', 'custom_mtypes' );
@kosinix
kosinix / header.php
Last active October 11, 2021 08:43
WordPress basic CSS for styling nav menus with wp_page_menu taken into account. Supports sub-menus as dropdowns.
<?php
// Somewhere in your header.php add this. container_class and menu_class should match the CSS main class.
wp_nav_menu( array( 'theme_location' => 'primary', 'container_class' => 'nav-menu', 'menu_class' => 'nav-menu' ) );
@jasondavis
jasondavis / toc.php
Created June 24, 2012 01:50 — forked from livingstonef/toc.php
Adds a table of Content to Wordpress posts
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* video.php
*
* Requires PHP version 5.0 or more
*
* LICENSE: This source file is subject to version 3.01 of the GNU/GPL License