Skip to content

Instantly share code, notes, and snippets.

View swissspidy's full-sized avatar

Pascal Birchler swissspidy

View GitHub Profile
#!/bin/bash
REV=$1
svn up --ignore-externals . > /dev/null
svn merge -c$REV ../../trunk .
LOG=$(svn log -r$REV ../../trunk | grep -v '\-------' | tail -n +3)
BRANCH=$(basename $(pwd))
echo -en "$LOG\n\nMerges [$REV] to the $BRANCH branch." | pbcopy
echo ""
pbpaste
<?php
/**
* Whitelist embedded links in the REST API responses
*
* This is often useful if you want to only get specified resources embedded along with the
* main resources, rather than the "all of nothing" approach of passing `?_embed` to the API request.
*
* You can either pass a comma seperated list of relationships or an array of string via the `_embed_include` query param.
*
<?php
/**
* Make an internal REST request
*
* @global WP_REST_Server $wp_rest_server ResponseHandler instance (usually WP_REST_Server).
* @param $request_or_method WP_REST_Request|string A WP_REST_Request object or a request method
* @param $path (optional) if the path is not specific in the rest request, specify it here
* @param $data (optional) option data for the request.
* @return WP_Error|mixed
You should really fix these slow tests (>250ms)...
1. 1601ms to run Tests_Basic:test_readme
2. 1384ms to run Tests_Canonical:test with data set #0
3. 1338ms to run Tests_WP_Site_Icon:test_insert_cropped_attachment
4. 1142ms to run Tests_XMLRPC_wp_uploadFile:test_valid_attachment
5. 1118ms to run Tests_Term_Cache:test_hierachy_invalidation
6. 1000ms to run Tests_Theme:test_get_themes_contents
7. 940ms to run Tests_XMLRPC_wp_newPost:test_post_format
8. 938ms to run Tests_WP_Site_Icon:test_create_attachment_object
9. 914ms to run Tests_XMLRPC_wp_getOptions:test_option_values_admin
@johnbillion
johnbillion / wp_mail.md
Last active June 3, 2024 13:31
WordPress Emails

WordPress Emails

This document lists all the situations where WordPress sends an email, along with how to filter or disable each email.

This documentation has moved here: https://github.com/johnbillion/wp_mail

@boonebgorges
boonebgorges / fix-changed-plugin-filename.php
Last active September 21, 2015 19:31
Fix changed plugin filename across a network
<?php
// Use: $ wp eval-file fix-changed-plugin-filename.php
global $wpdb;
$blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
$p = 'list-category-posts/list_cat_posts.php';
$new_p = 'list-category-posts/list-category-posts.php';
foreach ( $blog_ids as $blog_id ) {
@thomascharbit
thomascharbit / elasticpress-mlt.php
Created July 7, 2015 08:55
Find related posts with Elasticpress
<?php
add_filter('ep_formatted_args', 'my_ep_formatted_args', 10, 2 );
function my_ep_formatted_args( $formatted_args, $args ) {
// Handle more like this queries. WP_QUery arg formatting is: array( 'more_like' => $post_id )
if ( ! empty( $args['more_like'] ) ) {
$formatted_args['query'] = array(
'more_like_this' => array(
@bjork
bjork / h1-move-script-to-bottom.php
Last active August 29, 2015 14:19
Helper functions to move scripts enqueued by WordPress or plugins to bottom
<?php
/**
* Move script(s) to bottom
*
* @param string|array $script_handles Script handles to be moved to bottom
* @param array $args Additional arguments. Defaults to array( 'move_deps' => false ). Set to true to also move scripts dependencies.
*/
function h1_move_script_to_bottom( $script_handles, $args = array() ) {
$defaults = array(
@johnbillion
johnbillion / hierarchy.php
Last active June 22, 2023 23:05
ASCII WordPress Template Hierarchy
<?php
/*
WordPress Theme Template Hierarchy Last updated for WordPress 5.4
==================================
This diagram is partially simplified for legibility. To view the complete template hierarchy in use on your site see the
Template panel in the Query Monitor plugin.
@daddykotex
daddykotex / DummyAndroidTextUtilsMockTest.java
Last active April 20, 2017 10:51
Mock Android TextUtils static method
import android.text.TextUtils;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;