This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Modify BuddyPress group search to work on a word-wise basis | |
*/ | |
function openlab_group_search_breakup( $sql, $s ) { | |
global $bp; | |
if ( ! empty( $s['search'] ) ) { | |
// Get the search terms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
command! WPCodingStandards call WPCodingStandards() | |
function! WPCodingStandards() | |
" Space after opening paren | |
execute '%s/(\([^\t) ]\)/( \1/ge' | |
" Space before closing paren | |
execute '%s/\([^\t( ]\))/\1 )/ge' | |
" No spaces when casting types | |
execute '%s/(\s*\(array\|int\|object\|string\|float\)\s*)/(\1)/ge' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Note that it uses trailingslashit(), a WP function. Write your own logic if not using WP | |
*/ | |
function sanitize_twitter_handle( $handle ) { | |
$parts = parse_url( $handle ); | |
$url = ''; | |
if ( empty( $parts['host'] ) ) { | |
// not a url | |
if ( 0 === strpos( $handle, '@' ) ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Recursive argument parsing | |
* | |
* This acts like a multi-dimensional version of wp_parse_args() (minus | |
* the querystring parsing - you must pass arrays). | |
* | |
* Values from $a override those from $b; keys in $b that don't exist | |
* in $a are passed through. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Plugin Name: Damn Vulnerable WordPress Plugin | |
* Description: Intentionally vulnerable plugin for plugin author education | |
* Version: 0.1 | |
* Plugin URI: http://make.wordpress.org/plugins/2013/04/09/intentionally-vulnerable-plugin/ | |
* Author: Jon Cave | |
* Author URI: http://joncave.co.uk | |
* License: GPLv2+ | |
* | |
* DO NOT RUN THIS PLUGIN ON AN INTERNET ACCESSIBLE SITE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Prevent specific plugins from being activated (or, in some cases, deactivated). | |
* | |
* Plugins that are to be deprecated should be added to the $disabled_plugins array. | |
* | |
* Plugins that should be un-deactivatable should be added to the $undeactivatable_plugins array | |
*/ | |
function cac_hide_plugins( $plugins ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function bbg_activity_subnav( $items, $menu, $args ) { | |
// Find the Activity item | |
$bp_pages = bp_core_get_directory_page_ids(); | |
if ( isset( $bp_pages['activity'] ) ) { | |
$activity_directory_page = $bp_pages['activity']; | |
} else { | |
return $items; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function qw_delete_spam_comments() { | |
$in_progress = (bool) get_site_option( 'qw_delete_in_progress' ); | |
if ( ! $in_progress ) { | |
global $wpdb; | |
update_site_option( 'qw_delete_in_progress', '1' ); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Are we looking at the WordPress admin? | |
* | |
* Because AJAX requests are sent to wp-admin/admin-ajax.php, WordPress's | |
* is_admin() function returns true when DOING_AJAX. This function contains | |
* logic to test whether AJAX requests are coming from the front end or from | |
* the Dashboard. | |
* | |
* @return bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Recommended usage: Don't use this at all. Setting widgets programatically is generally a bad idea. | |
* Let your users do it - that's what the UI is for. | |
* | |
* However, if you must use it: | |
* BBG_Widget_Setter::clear_sidebar( 'sidebar-1' ); | |
* to clear the widgets from the sidebar called 'sidebar-1' (they are moved to | |
* "Inactive Widgets".) And: |