Skip to content

Instantly share code, notes, and snippets.

View mattyza's full-sized avatar
Focused

Matty Cohen mattyza

Focused
View GitHub Profile
@claudiosanches
claudiosanches / custom-my-account-endpoint.php
Last active April 30, 2024 03:05
Example of custom My Account endpoint.
<?php
class My_Custom_My_Account_Endpoint {
/**
* Custom endpoint name.
*
* @var string
*/
public static $endpoint = 'my-custom-endpoint';
@btoone
btoone / curl.md
Last active April 2, 2024 20:18
A curl tutorial using GitHub's API

Introduction

An introduction to curl using GitHub's API.

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
@milo
milo / github-webhook-handler.php
Last active July 26, 2023 15:29
GitHub Webhook Handler
<?php
/**
* GitHub webhook handler template.
*
* @see https://docs.github.com/webhooks/
* @author Miloslav Hůla (https://github.com/milo)
*/
$hookSecret = 's.e.c.r.e.t'; # set NULL to disable check

Installation

To install, you need to have the WordPress i18n library on your computer. Check it out using SVN:

sudo svn co http://i18n.svn.wordpress.org/tools/trunk/ /usr/lib/wpi18n

You don't have to put the library in /usr/lib/wpi18n, but if you don't put it there, make sure to set the $WP_I18N_LIB environment variable in your .bashrc or .bash_profile file (with no trailing slash):

export WP_I18N_LIB="/path/to/i18n/lib"

@kloon
kloon / btc-eth-luno-buy.php
Last active July 23, 2022 12:37
Luno.com "Dollar Cost Avg" daily buy script for BTC & ETH
<?php
/**
* Buy BTC & ETH daily on Luno.com
* @author Gerhard Potgieter <potgieterg@gmail.com>
* @since 2017-12-07
* https://www.luno.com/invite/JN5Z4
*
* This script will do a daily purchase of BTC and ETH on Luno.com based on rand value (ZAR) set. Default to R100 each. Why daily? https://en.wikipedia.org/wiki/Dollar_cost_averaging
*
* Installation Instructions
@fdemiramon
fdemiramon / pre-commit
Created May 12, 2015 19:13
Pre-commit hook for git with phpcs and phpcbf (auto-correct obvious violations)
#!/bin/sh
PROJECT=`php -r "echo dirname(dirname(dirname(realpath('$0'))));"`
STAGED_FILES_CMD=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.php`
# Determine if a file list is passed
if [ "$#" -eq 1 ]
then
oIFS=$IFS
IFS='
@Fab1en
Fab1en / custom_media_menu.js
Created January 21, 2013 15:32
Draft plugin example to add a javascript menu into the WP3.5 Media Library popup. Answer to this Wordpress stackexchange question : http://wordpress.stackexchange.com/questions/76980/add-a-menu-item-to-wordpress-3-5-media-manager/
// for debug : trace every event
/*var originalTrigger = wp.media.view.MediaFrame.Post.prototype.trigger;
wp.media.view.MediaFrame.Post.prototype.trigger = function(){
console.log('Event Triggered:', arguments);
originalTrigger.apply(this, Array.prototype.slice.call(arguments));
}*/
// custom state : this controller contains your application logic
wp.media.controller.Custom = wp.media.controller.State.extend({
@gedex
gedex / phpcs.xml
Last active September 10, 2020 10:11
<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards">
<description>WooCommerce extension PHP_CodeSniffer ruleset.</description>
<!-- Exclude paths -->
<exclude-pattern>tests/</exclude-pattern>
<exclude-pattern>woo-includes/woo-functions.php</exclude-pattern>
<exclude-pattern>woo-includes/class-wc-dependencies.php</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
@georgestephanis
georgestephanis / limiter.php
Last active April 23, 2019 14:18
First, run `composer require google/apiclient:^2.0` on cli -- then get your credentials.json from the link in the file and drop this file in the folder. You WILL need to populate the two ID constants. They can be the same calendar if you really want, but I prefer to keep my blockers on a second hidden calendar to be tidier.
<?php
// credentials.json is gotten from https://developers.google.com/calendar/quickstart/php
define( 'EVENT_CALENDAR_ID', '' );
define( 'BLOCKER_CALENDAR_ID', '' );
define( 'WEEKS_TO_CHECK', 6 );
define( 'WEEKLY_LIMIT', 3 );
define( 'WEEK_IN_SECONDS', 7*24*60*60 );
define( 'TZ_P', substr_replace( trim( shell_exec( 'date +"%z"' ) ), ':', 3, 0 ) );
@johnpbloch
johnpbloch / README.md
Created August 23, 2012 13:55
A bash script to make .pot files for WordPress plugins

Installation

To install, you need to have the WordPress i18n library on your computer. Check it out using SVN:

sudo svn co http://i18n.svn.wordpress.org/tools/trunk/ /usr/lib/wpi18n

You don't have to put the library in /usr/lib/wpi18n, but if you don't put it there, make sure to set the $WP_I18N_LIB environment variable in your .bashrc file (with no trailing slash):

export WP_I18N_LIB="/path/to/i18n/lib"