Skip to content

Instantly share code, notes, and snippets.

@dan-westall
dan-westall / block.js
Created February 14, 2019 18:14
None deletable gutenberg blocks plugin
{
supports: {
deletable: false,
...
},
...
}
@dan-westall
dan-westall / plugin-slug.js
Last active January 21, 2016 20:46
Browser snippet to add a copy slug to clipboard link to wp plugin page. Handy for when working with dev sites and wp cli
( function($){
function copyToClipboard(text) {
const input = document.createElement('input');
input.style.position = 'fixed';
input.style.opacity = 0;
input.value = text;
document.body.appendChild(input);
input.select();
document.execCommand('Copy');
<div class="container" id="main">
<div class="row-fluid" style="
margin-bottom: 10px;">
<p class="span12">
<a href="#menu" class="side-menu-link btn btn-mini" title="Click for sub-menu">
<i class="icon-th"></i>
</a>
</p>
</div>
@dan-westall
dan-westall / Get Widget Location
Created July 28, 2013 15:34
Will return sidebar name when given widget id
function dw_get_widget_location($id){
global $wp_registered_sidebars, $wp_registered_widgets, $_wp_sidebars_widgets;
$widget_id = $id;
$widget = $wp_registered_widgets[$widget_id];
foreach($_wp_sidebars_widgets as $key => $value){
$sidebar = $key;
@dan-westall
dan-westall / wp_get_object_terms_exclude_filter.php
Last active August 9, 2017 01:23
Allowing wp_get_object_terms to exclude terms with a filter.
<?php
///////Example usage//////////
//get object terms for $post->ID with taxonomies categories and tags,
//args set as fields all and exclude term with id 1
$terms = wp_get_object_terms(
$post->ID,
array(