Skip to content

Instantly share code, notes, and snippets.

Avatar

Fuxia Scholz thefuxia

View GitHub Profile
View 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 Jan 13, 2017
Pointers Tour (WPSE 162794)
View PointersManager.php
<?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 Nov 9, 2016
Short description on how I prepared sucessfully a unit test for wordpress plugin.
View WP_Plugins_Unit_Tests.md

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 Aug 6, 2017
allow email address to be used as login name
View email-address-login.php
<?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 Sep 1, 2015
.bashrc with GitHub PR function
View .bashrc
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 Sep 11, 2013
Register a template location with Event Organiser for your theme
View eo-theme-direct.php
<?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 Jul 22, 2020
WordPress multi-tenant directory structure sharing core files for opcode awesomeness, fast deployments, and low disk usage. With inspiration from @weskoop. "=>" indicates a symlink.
View gist:6225805
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 Jul 2, 2013
Sample Commercial Plugin update server and client
View commercial-client.php
<?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 Oct 11, 2016
Gathering posts about the development of a core dependency system for WordPress.
View WordPress-Dependencies.md

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:

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 Jan 27, 2021
Evil Blog Comment Spammer just exposed his template through some error and the whole thing showed up in my comments.
View gist:5422230
{
{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.|