Skip to content

Instantly share code, notes, and snippets.

View gregoirenoyelle's full-sized avatar

Grégoire Noyelle gregoirenoyelle

View GitHub Profile
@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 ) ) {
@GaryJones
GaryJones / functions.php
Created February 12, 2012 04:01 — forked from billerickson/functions.php
Genesis Grid Loop Advanced
<?php
/**
* Possibly amend the loop.
*
* Specify the conditions under which the grid loop should be used.
*
* @author Bill Erickson
* @author Gary Jones
* @link http://code.garyjones.co.uk/genesis-grid-loop-advanced/
@Vheissu
Vheissu / functions.php
Created October 22, 2012 02:36
Bundling the Advanced Custom Fields plugin into a theme using the TGM Plugin Class
add_action( 'tgmpa_register', 'register_required_plugins' );
// This function is called from the above hook
function register_required_plugins()
{
// The plugins array allows us to define multiple plugins we want to include.
// The commented out example shows how we can include and activation a bundled
// plugin zip file in our theme.
$plugins = array(
/* array(
@salcode
salcode / gist:7164690
Last active May 12, 2017 22:12
Genesis WordPress Framework adding custom classes to markup This gist was originally created as an example of what I perceived to be an inconsistent behavior, my error was failing to attach my code to action `genesis_setup`. Corrected version now appears below. 20131027 - merged Gary Jones's fork with corrections and refactoring
<?php
/*
* Examples to add custom classes to Genesis WordPress Framework Markup when using HTML5 output
*/
add_action( 'genesis_setup', 'srf_add_cust_classes', 15 ); // Priority 15 ensures it runs after Genesis itself has setup.
function srf_add_cust_classes() {
add_filter( 'genesis_attr_site-inner', 'srf_attr_site_inner' );
add_filter( 'genesis_attr_content-sidebar-wrap', 'srf_attr_content_sidebar_wrap' );
add_filter( 'genesis_attr_content', 'srf_attr_content' );
add_filter( 'genesis_attr_sidebar-primary', 'srf_attr_sidebar_primary' );
@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
@gregoirenoyelle
gregoirenoyelle / wp-new-wp-query-light.php
Last active July 12, 2018 09:40
WordPress new WP Query
<?php
// article du codex: http://codex.wordpress.org/Class_Reference/WP_Query
// Query sur Catégories d'articles (ID) (inclure)
$ma_boucle = new WP_Query( 'cat=2,6,17,38' );
// Query sur Catégories d'articles (ID) (exclure)
$ma_boucle = new WP_Query( 'cat=-12,-34,-56' );
@billerickson
billerickson / genesis-custom-loop-pagination.php
Created July 31, 2012 15:59
Genesis custom loop with pagination
<?php
/* Template Name: Test */
/**
* Genesis custom loop
*/
function be_custom_loop() {
global $post;
// arguments, adjust as needed
@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;
} );