Skip to content

Instantly share code, notes, and snippets.

<?php
/*
* WordPress Breadcrumbs
* author: Dimox
* version: 2019.03.03
* license: MIT
*/
function dimox_breadcrumbs() {
/* === OPTIONS === */
@justintadlock
justintadlock / register-post-type.php
Last active October 22, 2023 05:55
Help file when registering post types.
<?php
# Register custom post types on the 'init' hook.
add_action( 'init', 'my_register_post_types' );
/**
* Registers post types needed by the plugin.
*
* @since 1.0.0
* @access public
@WebEndevSnippets
WebEndevSnippets / functions.php
Created March 3, 2014 19:50
Gravity Forms: Auto login to site after GF User Registration Form Submittal
add_action( 'gform_user_registered','we_autologin_gfregistration', 10, 4 );
/**
* Auto login to site after GF User Registration Form Submittal
*
*/
function we_autologin_gfregistration( $user_id, $config, $entry, $password ) {
wp_set_auth_cookie( $user_id, false, '' );
}
<?php
/**
* Generate the CSS in the <head> section using the Theme Customizer
* @since 0.1
*/
add_action('generate_head_css','generate_your_css');
if ( !function_exists( 'generate_your_css' ) ) :
function generate_advanced_css()
{
$your_option = get_option( 'your_saved_db_entry' );
@cfxd
cfxd / shortcode.css
Last active November 17, 2021 05:53
How to Make the WordPress Video Shortcode Responsive. See http://cfxdesign.com/how-to-make-the-wordpress-video-shortcode-responsive
.wp-video, video.wp-video-shortcode, .mejs-container, .mejs-overlay.load {
width: 100% !important;
height: 100% !important;
}
.mejs-container {
padding-top: 56.25%;
}
.wp-video, video.wp-video-shortcode {
max-width: 100% !important;
}
@devinsays
devinsays / authenticate-by-email.php
Last active January 4, 2016 01:14
Allows visitors to log in using e-mail address
<?php
/**
* Allows visitors to log in using e-mail address
*
* @param string username passed by reference
*/
function prefix_authenticate_by_email( &$username ) {
$user = get_user_by( 'email', $username );
@devinsays
devinsays / hide-admin-bar.php
Last active February 7, 2021 15:16
Disables the #wpadmin bar for users without "edit_posts" permissions.
<?php
/**
* Disables the #wpadmin bar for users without "edit_posts" permissions.
*/
function prefix_hide_admin_bar() {
if ( ! current_user_can( 'edit_posts' ) ) {
add_filter( 'show_admin_bar', '__return_false' );
}
}
add_action( 'after_setup_theme', 'prefix_hide_admin_bar' );
@devinsays
devinsays / redirect-admin.php
Last active May 14, 2022 15:54
Redirects subscribers back to the home page if they attempt to access the dashboard.
<?php
/**
* Redirects subscribers back to the home page if they attempt to access the dashboard.
*/
function prefix_redirect_admin() {
if ( ! current_user_can( 'edit_posts' ) && ! defined( 'DOING_AJAX' ) ) {
wp_safe_redirect( home_url() );
exit;
}
}
@devinsays
devinsays / tracking.js
Created December 21, 2015 17:01
Track JetPack Shares in Google Analytics
/**
* Javacript for loading custom Google Analytics events
*
* @since 1.0.0
*/
(function($) {
// GA Docs for Social Interactions:
// https://developers.google.com/analytics/devguides/collection/analyticsjs/social-interactions
@slushman
slushman / customizer-links.php
Last active September 23, 2023 13:03
How to link into the WordPress Customizer