Skip to content

Instantly share code, notes, and snippets.

View JiveDig's full-sized avatar

Mike Hemberger JiveDig

View GitHub Profile
@JiveDig
JiveDig / redirect_login.php
Created October 9, 2014 12:29
Redirect login and registration form to front end page
<?php
// Redirect wp-login.php to custom url
add_action( 'login_form_login', 'mwm_redirect_login' );
function mwm_redirect_login() {
wp_redirect( home_url() );
exit();
}
// Redirect wp-login.php?action=register to custom url
@JiveDig
JiveDig / stay_logged_in.php
Created October 9, 2014 16:34
// Stay logged in
<?php
// Stay logged in
add_filter( 'auth_cookie_expiration', 'mwm_keep_me_logged_in_for_4_weeks' );
function mwm_keep_me_logged_in_for_4_weeks( $expirein ) {
return 2419200; // 4 weeks in seconds
}
@JiveDig
JiveDig / disable_toolbar.php
Created October 9, 2014 16:38
Diable toolbar for non admins
<?php
//* Disable toolbar for non admins
add_action('after_setup_theme', 'mwm_remove_admin_bar');
function mwm_remove_admin_bar() {
if ( !current_user_can('administrator') && !is_admin() ) {
show_admin_bar(false);
}
}
@JiveDig
JiveDig / remove_toolbar.php
Created November 7, 2014 16:24
Remove toolbar from front end
<?php
//* Remove toolbar from frontend and remove CSS that bumps content down
add_filter( 'show_admin_bar', 'bhl_hide_admin_bar_from_front_end' );
function bhl_hide_admin_bar_from_front_end(){
if ( ! current_user_can('manage_options') ) {
return false;
// Remove CSS
remove_action( 'wp_head', '_admin_bar_bump_cb' );
@JiveDig
JiveDig / admin_columns.php
Last active August 29, 2015 14:09
Add custom admin sortable columns
<?php
add_filter( 'manage_edit-resident_columns', 'set_custom_edit_resident_columns' );
add_action( 'manage_resident_posts_custom_column' , 'custom_resident_column', 10, 2 );
function set_custom_edit_resident_columns($columns) {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => 'Title',
'display' => 'Display',
@JiveDig
JiveDig / comment_avatar_size.php
Last active August 29, 2015 14:10 — forked from GaryJones/functions.php
Change size of comment avatars in Genesis
<?php
/**
* Change size of comment avatars.
*/
add_filter( 'genesis_comment_list_args', 'childtheme_comment_list_args' );
function childtheme_comment_list_args( $args ) {
$args['avatar_size'] = 90;
return $args;
}
/* actions fired when listing/adding/editing posts or pages */
/* admin_head-(hookname) */
add_action( 'admin_head-post.php', 'admin_head_post_editing' );
add_action( 'admin_head-post-new.php', 'admin_head_post_new' );
add_action( 'admin_head-edit.php', 'admin_head_post_listing' );
function admin_head_post_editing() {
echo 'you are editing a post';
}
@JiveDig
JiveDig / sidr_edit_post.js
Created February 17, 2015 21:06
Front end post editing with Sidr
( function ( document, $, undefined ) {
'use strict';
// Initiate side menu
$( '#edit-toggle' ).sidr({
name: 'edit-post',
side: 'left',
renaming: false,
// displace: false,
onOpen: function() {
@JiveDig
JiveDig / acf-form-sidr.css
Last active August 29, 2015 14:15
CSS for Sidr with ACF front end form in it
.sidr {
display: none;
position: fixed;
top: 0;
height: 100%;
width: 100%;
max-width: 500px;
left: -500px;
right: auto;
background: #fff;
@JiveDig
JiveDig / sensible-script-enqueuing.php
Last active August 29, 2015 14:25
Sensible script enqueueing - http://mikejolley.com/2013/12/sensible-script-enqueuing-shortcodes/ - use wp_enqueue_script('script-name'); in your shortcode.
<?php // Put this code in functions.php or a custom plugin. Don't include opening php tag.
/**
* Register scripts to enqueue in our shortcode
* @author Mike Hemberger
* @link http://thestizmedia.com/shortcode-to-show-map-markers-of-child-pages-with-acf-pro/
*/
add_action('wp_enqueue_scripts', 'tsm_register_non_global_scripts');
function tsm_register_non_global_scripts() {
wp_register_script( 'google-map', 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false', array(), '3', true );