Skip to content

Instantly share code, notes, and snippets.

View gregoirenoyelle's full-sized avatar

Grégoire Noyelle gregoirenoyelle

View GitHub Profile
@mannieschumpert
mannieschumpert / gist:8886289
Last active August 2, 2020 13:15
Code Examples from Andrew Nacin's "Current User Can Watch This Talk"
<?php
// If you can edit pages, you can edit widgets
add_filter( 'user_has_cap',
function( $caps ) {
if ( ! empty( $caps['edit_pages'] ) )
$caps['edit_theme_options'] = true;
return $caps;
} );
@cdils
cdils / genesis-site-title.php
Last active June 13, 2018 02:56
Filter the Genesis SEO Title to output with a custom class.
// Filter the title with a custom function
add_filter('genesis_seo_title', 'wap_site_title' );
// Add additional custom style to site header
function wap_site_title( $title ) {
// Change $custom_title text as you wish
$custom_title = '<span class="custom-title">WA</span>Estate';
// Don't change the rest of this on down
@imath
imath / wp-idea-stream-custom.php
Created September 30, 2014 11:52
Example of actions and filters to use to customize the behavior of WP Idea Stream
<?php
/**
* WP Idea Stream Custom.
*
* Place here the function to customize Version 2.0+ of WP Idea Stream
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
@thierrypigot
thierrypigot / restrict.php
Created October 10, 2014 10:11
Redirect non admin to front
<?php
/**
* Redirect non admin to front
**/
add_action( 'admin_init', 'tp_demo_redirect_non_admin_users' );
function tp_demo_redirect_non_admin_users()
{
if ( ! current_user_can( 'manage_options' ) && '/wp-admin/admin-ajax.php' != $_SERVER['PHP_SELF'] ) {
wp_safe_redirect( home_url() );
exit;
@imath
imath / wp-idea-stream-custom.php
Created February 8, 2015 18:37
WP Idea Stream Custom : Replace the author avatar by the first image found in the idea content
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
/**
* Replace the author avatar by the first image found in the idea content
* if no image was found keep the avatar.
*/
function first_idea_image_as_avatar( $avatar_link, $author, $avatar, $idea ) {
if ( empty( $idea->post_content ) ) {