Skip to content

Instantly share code, notes, and snippets.

@gmazzap
gmazzap / loop.php
Last active August 29, 2015 14:07 — forked from tomjn/loop.php
<?php
array_walk($GLOBALS['wp_query']->posts, function($post, $i, $wp_query) {
$GLOBALS['post'] = $post;
$wp_query->the_post();
// loop code
the_title();
the_content();
@gmazzap
gmazzap / PointersManager.php
Last active January 13, 2017 19:06
Pointers Tour (WPSE 162794)
<?php namespace GM;
class PointersManager implements PointersManagerInterface {
private $pfile;
private $version;
private $prefix;
private $pointers = array();
public function __construct( $file, $version, $prefix ) {
@dnaber-de
dnaber-de / WP_Plugins_Unit_Tests.md
Last active November 9, 2016 13:55
Short description on how I prepared sucessfully a unit test for wordpress plugin.

Plugin UnitTest – How To

Assuming you have a separate WordPress installation for your project (eg. /var/www/my-project ) with your plugin you want to test in /var/www/my-project/wp-content/plugins/my-plugin. PHPUnit and SVN needs also to be installed on your system.

1. Get the WordPress test environment

Get the WordPress test environment as described here in step 1 and 2. You may want to use a separate directory for those stuff like ( ~/tmp/wordpress-test).

The repository looks like:

@norcross
norcross / email-address-login.php
Last active August 6, 2017 22:52
allow email address to be used as login name
<?php
add_filter ( 'authenticate', 'rkv_login_options', 20, 3 );
function rkv_login_options( $user, $username, $password ) {
if ( is_email( $username ) ) {
$user = get_user_by( 'email', $username );
}
if ( $user ) {
@domenic
domenic / .bashrc
Last active September 1, 2015 17:50
.bashrc with GitHub PR function
pr () {
git fetch origin refs/pull/$1/head:refs/remotes/origin/pr/$1 --force
git checkout -b pr/$1 origin/pr/$1
git rebase master
git checkout master
git merge pr/$1 --ff-only
}
@stephenharris
stephenharris / eo-theme-direct.php
Created September 11, 2013 19:01
Register a template location with Event Organiser for your theme
<?php
/**
* Registers the directory "[child-theme-dir]/event-organiser" as a template location for
* Event Organiser. EO will look there when looking for the plug-in template files (e.g. single-event.php, archive-event.php, etc )
*
*/
function mytheme_register_eventorganiser_stack( $stacks ){
//$stacks is an array of (absolute) directory paths. EO will look in the order
//in which they appear in the array
@markjaquith
markjaquith / gist:6225805
Last active February 21, 2024 23:56
WordPress multi-tenant directory structure sharing core files for opcode awesomeness, fast deployments, and low disk usage. With inspiration from @weskoop. "=>" indicates a symlink.
sites
|__ ms.dev
| |__ content
| |__ index.php
| |__ wp => ../../wordpress/stable
| |__ wp-config.php
|__ one.dev
| |__ content
| |__ index.php
| |__ wp => ../../wordpress/stable
@pento
pento / commercial-client.php
Created July 2, 2013 12:29
Sample Commercial Plugin update server and client
<?php
/*
* Plugin Name: Commercial Client
* Plugin URI: http://pento.net/
* Description: A sample client plugin for showing updates for non-WordPress.org plugins
* Author: pento
* Version: 0.1
* Author URI: http://pento.net/
* License: GPL2+
*/
@westonruter
westonruter / WordPress-Dependencies.md
Last active October 11, 2016 22:43
Gathering posts about the development of a core dependency system for WordPress.

I've been noticing that there seems to be a lot of interest and momentum lately surrounding plugn/theme dependencies. I am very excited about this. WordPress desperately needs a core dependency solution so that we can move the route of plugins being tiny interoperable building blocks, like what we've seen with NPM.

Here's a running list of the stuff I've been seeing lately about WordPress dependencies:

  • Strategies to implement selective loading of plugins on StackExchange
  • Nacin's suggestion that Dependencies be tackled for GSoC: > Dependencies. Allow plugins and themes to be dependent of one another. A theme could require a plugin or example, and WordPress would handle installing that plugin when you install that theme. Similar idea: Compatibility metrics. (Or: Can we be sure it is safe to upg
@shanselman
shanselman / gist:5422230
Last active March 28, 2024 10:33
Evil Blog Comment Spammer just exposed his template through some error and the whole thing showed up in my comments.
{
{I have|I've} been {surfing|browsing} online more than {three|3|2|4} hours today, yet I never found any interesting article like yours. {It's|It
is} pretty worth enough for me. {In my opinion|Personally|In my view}, if all {webmasters|site owners|website owners|web owners} and bloggers made good content as
you did, the {internet|net|web} will be {much more|a lot more}
useful than ever before.|
I {couldn't|could not} {resist|refrain from} commenting. {Very well|Perfectly|Well|Exceptionally well} written!|
{I will|I'll} {right away|immediately} {take hold of|grab|clutch|grasp|seize|snatch}
your {rss|rss feed} as I {can not|can't} {in finding|find|to find} your {email|e-mail} subscription {link|hyperlink} or {newsletter|e-newsletter} service. Do {you have|you've} any?
{Please|Kindly} {allow|permit|let} me {realize|recognize|understand|recognise|know} {so that|in order that} I {may just|may|could} subscribe.
Thanks.|