Skip to content

Instantly share code, notes, and snippets.

View philwonski's full-sized avatar

philwonski philwonski

View GitHub Profile
@philwonski
philwonski / extend-rest-api.php
Created November 28, 2022 16:40 — forked from mklasen/extend-rest-api.php
Update Custom Post Type Meta Fields with the WordPress REST API
<?php
register_meta('post', 'custom-field', [
'object_subtype' => 'custom-post-type',
'show_in_rest' => true
]);
@philwonski
philwonski / yoast_seo_sitemap_add_custom_type.php
Created January 27, 2022 19:50 — forked from amboutwe/yoast_seo_sitemap_add_custom_type.php
Filters and example code for Yoast SEO sitemaps
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Create Custom Yoast Sitemap
* Credit: Unknown
* Last Tested: Unknown
*********
* HOW TO USE
* Replace TYPE with your custom type
*/
@philwonski
philwonski / 1-promises.coffee
Created October 6, 2021 12:52 — forked from pketh/1-promises.coffee
Promises in Coffeescript
# Create a promise:
myCoolPromise = new Promise (resolve, reject) ->
# do a thing
success = true
if success
resolve 'stuff worked'
else
reject Error 'it broke'
@philwonski
philwonski / ArrayObjectDemo.coffee
Created September 19, 2021 21:15 — forked from frane/ArrayObjectDemo.coffee
Traversing arrays and objects in CoffeeScript
# Traversing arrays and objects in CoffeeScript
# The array and object we use for testing
arr = [1, 2, 3, 4, 5]
obj = {a: 1, b: 2, c: 3, d: 4, e: 5}
# 'in' has a different meaning in CoffeeScript than in JavaScript
# CS: element in array -> JS: array.indexOf(element) >= 0
console.log '5 in arr: ' + (5 in arr)
@philwonski
philwonski / request.coffee
Created September 19, 2021 00:01 — forked from wess/request.coffee
Basic and Simple to Use Request Class for CoffeeScript
#
# request.coffee
#
# Created by Wess Cope on 2012-01-30.
#
# Just a start. The basics in place and working
# to expand as elements are needed.
#
class Request
@philwonski
philwonski / app.coffee
Created September 18, 2021 23:40 — forked from seyhunak/app.coffee
Coffeescript - Ajax Request
$(document).ready ->
$.ajax '/items/get_list',
type: 'GET'
dataType: 'json'
beforeSend: ->
$('#loading').html "<img src='/assets/loading.gif' /> Now loading..."
error: (jqXHR, textStatus, errorThrown) ->
$('#items').html "Error: #{textStatus}"
success: (data, textStatus, jqXHR) ->