Skip to content

Instantly share code, notes, and snippets.

View pdewouters's full-sized avatar
🌄
Working from home

Paul de Wouters pdewouters

🌄
Working from home
View GitHub Profile
@pdewouters
pdewouters / gist:2693274
Created May 14, 2012 10:52
featured posts loop with wp_reset_postdata
/**
* Filter the home page posts, and remove any featured post ID's from it. Hooked
* onto the 'pre_get_posts' action, this changes the parameters of the query
* before it gets any posts.
*
* @global array $featured_post_id
* @param WP_Query $query
* @return WP_Query Possibly modified WP_query
* http://developer.wordpress.com/2012/05/14/querying-posts-without-query_posts/
*/
@pdewouters
pdewouters / how-i-work-template.md
Last active February 4, 2019 13:26 — forked from jazzsequence/how-i-work-template.md
Template for How I Like to Work posts

How I work

This is my own interpretation of how I like to work, feedback welcome! Especially if my own view of how I think I like to work doesn't match your experience of how it seems I like to work!

When I work

Timezone: GMT I work 9 to 5 6-8 hours per day I don't work at the weekend I can be available after hours on occasion, if it's justified.

@pdewouters
pdewouters / gist:2794478
Created May 26, 2012 16:12
favicon bullet
function getDomain(url) {
return url.match(/:\/\/(.[^/]+)/)[1];
}
$("a[href^='http']").each(function() {
$(this).css({
background: "url(http://www.google.com/s2/u/0/favicons?domain=" + getDomain(this.href) +
") left center no-repeat",
"padding-left": "20px"
});
@pdewouters
pdewouters / select_dropdown_walker.php
Created November 28, 2011 18:59
select dropdown for WordPress custom menus
class Walker_Nav_Menu_Dropdown extends Walker_Nav_Menu{
var $to_depth = -1;
function start_lvl(&$output, $depth){
$output .= '</option>';
}
function end_lvl(&$output, $depth){
$indent = str_repeat("\t", $depth); // don't output children closing tag
}
@pdewouters
pdewouters / gist:4408200
Created December 29, 2012 17:29
Add parent class to top level terms that have children in wp_list_categories for a custom taxonomy using a custom Walker class.
<?php
class My_Walker_Category extends Walker_Category {
/**
* @see Walker::start_el()
* @since 2.1.0
*
* @param string $output Passed by reference. Used to append additional content.
* @param object $category Category data object.
* @param int $depth Depth of category in reference to parents.
# Task
Implement a recursive function that returns all of the unique dependencies, and sub-dependencies of a module, sorted alphabetically. Dependencies should be printed as dependency@version e.g. 'inflection@1.2.6'.
Multiple versions of the same module are allowed, but duplicates modules of the same version should be removed.
## Arguments:
* tree: A dependency tree. See below for an example of the structure.
{"features":[{"id":"5943b3abda50f","name":"Documents","type":"feature-about","icon":"35","sorting":"manual","sections":[{"id":"592","type":"about-section","title":"Despatch letters","content":"<p><a href=\"https:\/\/www.unison.org.uk\/content\/uploads\/2017\/05\/2017-NDC-first-despatch-letter.pdf\">First despatch letter<\/a><\/p>\n"},{"id":"589","type":"about-section","title":"Standing orders","content":"<p>Standing orders will appear here<\/p>\n"},{"id":"586","type":"about-section","title":"Key Documents","content":"<p><a href=\"https:\/\/www.unison.org.uk\/content\/uploads\/2017\/06\/24415.pdf\"><br \/>\nAbout conference<\/a><\/p>\n<p><a href=\"https:\/\/www.unison.org.uk\/content\/uploads\/2017\/06\/24394.pdf\">Conference document<\/a><\/p>\n<p><a href=\"https:\/\/www.unison.org.uk\/content\/uploads\/2017\/06\/2017-National-Delegate-Conference_Composite_Booklet_Final4.pdf\">Conference composite booklet<\/a><\/p>\n<p><a href=\"https:\/\/www.unison.org.uk\/content\/uploads\/2017\/05\/UNISONAnnual-Report-2017
{
"features": [
{
"id": "592fcb6e9243f",
"name": "Venue A-Z",
"type": "feature-about",
"icon": "36",
"sorting": "manual",
"sections": [
{
{
"features": [
{
"id": "1234",
"name": "about test",
"type": "feature-about",
"icon": "26",
"sorting": "manual",
"sections": [
{
@pdewouters
pdewouters / gist:4526457
Last active January 25, 2017 13:12
Remove the 'View' link from the admin bar for a custom post type
/**
* removes the 'view' link for CPT in the admin bar
*/
function pdw_admin_bar_render() {
global $wp_admin_bar;
if('client' == get_post_type()){
$wp_admin_bar->remove_menu('view');
}