Skip to content

Instantly share code, notes, and snippets.

@ajvillegas
ajvillegas / 01-custom-block.js
Last active May 14, 2024 15:19
Sample custom WordPress editor block and sidebar controls using using ES5 JavaScript syntax.
/**
* Custom WordPress block boilerplate.
*
* @package My_Block_Package
* @author Alexis J. Villegas
* @link http://www.alexisvillegas.com
* @license GPL-2.0+
*/
( function( blocks, editor, element ) {
@pento
pento / php-block.js
Last active February 29, 2024 01:31
Converting a shortcode to a block: this method is fast to do, but a mediocre UX. You should only use this as a stopgap until you can implement a full block UI.
// License: GPLv2+
var el = wp.element.createElement,
registerBlockType = wp.blocks.registerBlockType,
ServerSideRender = wp.components.ServerSideRender,
TextControl = wp.components.TextControl,
InspectorControls = wp.editor.InspectorControls;
/*
* Here's where we register the block in JavaScript.
@luizcarraro
luizcarraro / open-external-link.js
Created July 27, 2017 11:37
ELECTRON: Open link in external default OS browser
@moufmouf
moufmouf / .gitlab-ci.yml
Created February 22, 2017 17:53
Files from "A practical guide to continuous integration in PHP"
image: tetraweb/php:7.0
services:
- mysql:5.6
variables:
MYSQL_ROOT_PASSWORD: root_password
MYSQL_DATABASE: my_db
before_script:
@octalmage
octalmage / roles.md
Last active May 14, 2023 17:43
Default WordPress user roles and capabilities.

WordPress v4.3.1

Admin wp_capabilities wp_user_level 10

a:1:{s:13:"administrator";b:1;}

Contributor wp_capabilities wp_user_level 1

@TBD
TBD / ikea_price_check.bookmarklet
Created August 29, 2015 19:31
IKEA price check
javascript:(function(){var request=new XMLHttpRequest();request.open("GET",window.location.href.replace(/ro\//g,'hu/'),false);request.send(null);var hidden=document.body.appendChild(document.createElement("div"));hidden.style.display="none";hidden.innerHTML=request.responseText;price=hidden.querySelector('#schemaProductPrice');if(price){price=parseInt(hidden.querySelector('#schemaProductPrice').textContent.replace(/\./gm,''));price=(price*1.41/100).toFixed(2)+" lei ( "+price+" HUF )";}else{price="N/A";}price_hu=document.createElement("div");price_hu.innerHTML=price;refNode=document.querySelector('#price1');refNode.parentNode.insertBefore(price_hu,refNode.nextSibbling);})()
@sareiodata
sareiodata / gist:0d70d54e6167cddd7c44
Last active August 29, 2015 14:06
hide default edit profile fields in the backend
/*
* Hide Default Edit Profile Fields in the backend
*/
function wppb_hide_personal_options(){
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('form#your-profile > h3:first').hide();
$('form#your-profile > table:first').hide();
@zackkatz
zackkatz / gf-validate-edd-license-key.php
Last active May 3, 2021 09:10
Validate Easy Digital Downloads License Key Field in a Gravity Forms Submission
/**
* Validate a Gravity Forms license submission against EDD remote validation
*
* In Gravity Forms, for the text field you want to use as the license key entry,
* go to Advanced tab, check the "Allow field to be populated dynamically" checkbox,
* then enter the value as `edd-{download_id}`, where {download_id} is the, you guessed
* it, EDD Download ID.
*
* @param array $is_valid_and_form_array Gravity Forms passes an array with two keys: `is_valid` (boolean) and `form` (Gravity Forms form array)
* @return array Same format as incoming.
@sareiodata
sareiodata / empty-wp-plugin.php
Created July 2, 2014 08:45
Empty WordPress plugin
<?php
/**
* Plugin Name: Name Of The Plugin
* Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
* Description: A brief description of the Plugin.
* Version: The Plugin's Version Number, e.g.: 1.0
* Author: Name Of The Plugin Author
* Author URI: http://URI_Of_The_Plugin_Author
* License: A "Slug" license name e.g. GPL2
*/
@ascottmccauley
ascottmccauley / gist:3c3ad4e1772059234be5
Created June 14, 2014 12:36
WordPress Honeypot Functions
/**
* Add a spam-trap to comment form and registration form
*
* Include a hidden field called name and set it to hidden. If it receives an input, we have a bot!
*/
function get_decoy_fields() {
$decoys = array( 'firstname', 'lastname', 'email2', 'address', 'address2', 'city', 'state', 'zipcode', 'telephone', 'phone');
return $decoys;
}
function get_dailyID() {