Skip to content

Instantly share code, notes, and snippets.

@r-a-y
r-a-y / bp-disable-translation.php
Created February 15, 2015 18:40
Disable automatic translations by WordPress.org / GlotPress for BuddyPress.
<?php
/*
Plugin Name: BP Disable Auto Translation
Description: Disables automatic translations by WordPress.org / GlotPress for BuddyPress.
Author: r-a-y
License: GPLv2 or later
*/
/**
* Disables automatic translations for BuddyPress.
@r-a-y
r-a-y / README.md
Last active December 16, 2017 21:03 — forked from johnpbloch/README.md

Installation

To install, you need to have the WordPress i18n library on your computer. Check it out using SVN:

sudo svn co http://i18n.svn.wordpress.org/tools/trunk/ /usr/lib/wpi18n

You don't have to put the library in /usr/lib/wpi18n, but if you don't put it there, make sure to set the $WP_I18N_LIB environment variable in your .bashrc file (with no trailing slash):

export WP_I18N_LIB="/path/to/i18n/lib"

@r-a-y
r-a-y / gist:5209075
Created March 20, 2013 22:20
Lightweight, frontend version of admin-ajax.php for WordPress.
<?php
/**
* Lightweight, frontend version of admin-ajax.php.
*
* Only loads wp-load.php and sets up the headers and AJAX actions.
*/
// Setup 'DOING_AJAX' constant to be compatible with native WP functionality
define( 'DOING_AJAX', true );
@r-a-y
r-a-y / blogs.php
Last active March 15, 2017 20:28
Modify SQL query for BP's Sites Directory
<?php
/**
* Modify BP's site query for non-super-admins.
*/
add_action( 'bp_include', function() {
// If you're doing checks against More Privacy Options, make sure MPO is active.
if ( ! class_exists( 'ds_more_privacy_options' ) ) {
return;
}
@r-a-y
r-a-y / _bp_rbe_imap_object_cache.php
Last active July 28, 2016 22:21
BP Reply By Email - IMAP Object Cache extension. Replaces the default filesystem IMAP locking system in RBE with a persistent object cache.
<?php
/*
Plugin Name: BP Reply By Email - IMAP Object Cache extension
Description: Replaces the default filesystem IMAP locking system in RBE with a persistent object cache.
Author: r-a-y
Author URI: http://profiles.wordpress.org/r-a-y
License: GPLv2 or later
*/
/*
@r-a-y
r-a-y / wp-ms-login.php
Last active May 17, 2016 12:12
WordPress - Redirects login attempts from sub-sites to the main site to login. Supports mapped domains created by WPMU Domain Mapping.
<?php
/**
* Get login URL.
*
* If redirect URL is passed, this function attempts to see if the redirect
* is using a mapped domain. If so, we switch out the mapped domain with the
* original subdomain and force logins from the main site.
*
* @param string $redirect_to The redirect URL
@r-a-y
r-a-y / xmlrpc.php
Created May 13, 2016 23:19
Block all XMLRPC requests on WordPress
<?php
// Put this in /wp-content/mu-plugins/.
add_action( 'plugins_loaded', function() {
if ( 'POST' === $_SERVER['REQUEST_METHOD'] && false !== strpos( $_SERVER['SCRIPT_NAME'], '/xmlrpc.php' ) ) {
// Reject with 403.
header( 'HTTP/1.1 403 Forbidden' );
exit;
}
}, 0 );
@r-a-y
r-a-y / gestures.js
Last active February 20, 2016 22:14
Mouse gestures script for the Conkeror browser - http://conkeror.org
// Mouse Gestures for Conkeror by r-a-y.
//
// Modified from the Mouse Gestures By Sing Chu userscript:
// http://userscripts-mirror.org/scripts/show/162193
var BTN_RIGHT = 2;
var SENSITIVITY = 15; //Pixels moved until gesture is registered
var startX;
var startY;
var gesture = "";
@r-a-y
r-a-y / todo.md
Last active January 26, 2016 20:54
Stuff I want to work on
  • BP OStatus - Support OStatus for BuddyPress. Decentralization FTW! Will require a lot of integration (PubSubHubbub, ActivityStreams, Salmon, Portable Contacts, and Webfinger). See OStatus W3C draft spec for more info.
  • BP Mobile Theme - A mobile-optimized BuddyPress theme or template pack
  • BP History API - Fool around with HTML5's History API with BuddyPress - https://github.com/r-a-y/bp-pushstate
  • WP Community Blog - A lightweight blog for members based on a custom post type. Would not use multisite.
  • BP Webmentions - BP plugin supporting the Webmention API - http://webmention.org
  • WP Stream - A WP plugin supporting Stream - http://getstream.io; this would be an alternative to BuddyPress.
@r-a-y
r-a-y / bp17-compat.php
Last active December 14, 2015 16:59
Add BP 1.7 theme loading functions to your BP plugin. This is so you can use awesome functions like bp_get_template_part() and bp_locate_template(). Before including this file, do a check to see if v1.7 exists. You could do this with: if ( ! class_exists( 'BP_Theme_Compat' ) ) require( 'THIS GIST!' );
<?php
/**
* Backwards compatibililty functions for < BP 1.7.
*
* @author r-a-y
*/
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;