Skip to content

Instantly share code, notes, and snippets.

View modemlooper's full-sized avatar
🏠
Working from home

modemlooper modemlooper

🏠
Working from home
View GitHub Profile
@modemlooper
modemlooper / gist:43f768fff1cfacad9cfa
Created July 6, 2015 14:34
Get url param javascript
function getURLParameter(name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null
}
@modemlooper
modemlooper / gist:a8c4579354df41ed3525
Created July 13, 2015 15:51
convert date to human readable ( 6 days ago )
sprintf( __( '%1$s ago', 'example' ), human_time_diff( strtotime( $post->post_date ), current_time('timestamp') ) );
@modemlooper
modemlooper / wptouch.php
Created July 23, 2015 17:22
AppPresser turn off wptouch
if( class_exists( 'AppPresser' ) && AppPresser::is_app() ) {
add_filter('wptouch_should_init_pro', '__return_false');
}
@modemlooper
modemlooper / .php
Created August 3, 2015 20:25
example of adding a dropdown filter to media library
class BP_MEDIA_LIBRARY_FILTER {
/**
* Defines media types
* @var array
*/
protected static $media_types = array();
/**
* Holds a singleton instance of this class
* @var null
@modemlooper
modemlooper / custom-notification.php
Last active April 2, 2024 18:18
BuddyPress add custom notification
<?php
// this is to add a fake component to BuddyPress. A registered component is needed to add notifications
function custom_filter_notifications_get_registered_components( $component_names = array() ) {
// Force $component_names to be an array
if ( ! is_array( $component_names ) ) {
$component_names = array();
}
// Add 'custom' component to registered components array
# -*- mode: ruby -*-
# vi: set ft=ruby :
vagrant_dir = File.expand_path(File.dirname(__FILE__))
Vagrant.configure("2") do |config|
# Store the current version of Vagrant for use in conditionals when dealing
# with possible backward compatible issues.
vagrant_version = Vagrant::VERSION.sub(/^v/, '')
@modemlooper
modemlooper / searchwp_results_substitute_post_for_attachment.php
Created September 28, 2015 16:14 — forked from rogerlos/searchwp_results_substitute_post_for_attachment.php
Wordpress SearchWP: Substitute Post for Attachment in Search Results
<?php
/**
* This function will see if a PDF or other "attachment" post-type returned by SearchWP
* is present in a custom field in a regular post, and will return that post instead. Note
* this will only process documents which are referenced via the "attachment" post type.
*
* For example, you may have a product specification PDF and would like it in the search
* results, but would rather people got to it by visiting the product page itself.
*
@modemlooper
modemlooper / gist:fe83273ce5458ae5adfe
Created October 1, 2015 13:49
remove editor on page builder custom template page
function page_builder_remove_editor_init() {
// If not in the admin, return.
if ( ! is_admin() ) {
return;
}
// Get the post ID on edit post with filter_input super global inspection.
$current_post_id = filter_input( INPUT_GET, 'post', FILTER_SANITIZE_NUMBER_INT );
// Get the post ID on update post with filter_input super global inspection.
$update_post_id = filter_input( INPUT_POST, 'post_ID', FILTER_SANITIZE_NUMBER_INT );
@modemlooper
modemlooper / cpt.php
Created October 7, 2015 14:34
add custom post type to WP-API
function wpsd_add_events_args() {
global $wp_post_types;
$wp_post_types['incsub_wiki']->show_in_rest = true;
$wp_post_types['incsub_wiki']->rest_base = 'wiki';
$wp_post_types['incsub_wiki']->rest_controller_class = 'WP_REST_Posts_Controller';
}
add_action( 'init', 'wpsd_add_events_args', 30 );
@modemlooper
modemlooper / gist:bebbed85b4cb7767acbc
Created October 9, 2015 19:51
remove bbp_setup_current_user nocite
function remove_bbp_setup_current_user_notice( $function, $message, $version ) {
if( 'bbp_setup_current_user' === $function ) {
return false;
}
}
add_action( 'doing_it_wrong_run', 'remove_bbp_setup_current_user_notice', 10, 3 );