Skip to content

Instantly share code, notes, and snippets.

View mauriciogofas's full-sized avatar

Mauricio Gofas mauriciogofas

View GitHub Profile
@mauriciogofas
mauriciogofas / functions.php
Created September 25, 2015 13:36
Prevents subscribers access to wp-admin and redirects to specific page of the front end
<?php
/*
* Impede o acesso de assinantes ao wp-admin e os redireciona para página específica do front end
* Prevents subscribers access to wp-admin and redirects to specific page of the front end
*/
function gfs_restrict_admin_with_redirect() {
if ( ! current_user_can( 'edit_posts' /* edit_posts = minimum capacity required to access the dashboard */ ) && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
wp_redirect( site_url() . '/?p=322' ); // 322 = Page ID to redirect
exit;
@mauriciogofas
mauriciogofas / functions.php
Last active September 25, 2015 11:23
Custom Avatar via Advanced Custom Fields Image Upload and Front End Profile Image Upload
<?php
// Custom Avatar via Advanced Custom Fields Image Upload
add_filter( 'get_avatar' , 'gofas_custom_avatar', 1, 5 );
function gofas_custom_avatar( $avatar, $id_or_email, $size, $default, $alt ) {
$image_object = get_field('your_image_field_id', 'user_'.$id_or_email);
$image_size = 'thumbnail';
$acf_avatar = $image_object['sizes'][$image_size]; // Configure ACF Image to return Image Object
if ( $image_object ) {
$avatar = $acf_avatar; // ACF Avatar
$avatar = "<img alt='{$alt}' src='{$avatar}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";
@mauriciogofas
mauriciogofas / download.sh
Created September 23, 2015 01:06 — forked from yratof/download.sh
Download a website for Static use
wget -r -P / --user-agent="" -e robots=off --wait 1 -E http://website.com
@mauriciogofas
mauriciogofas / functions.php
Last active September 18, 2015 13:05
Custom WP Avatar via Gravity Forms Upload Field and Gravity Forms Users Registration Add-On
<?php
/*
Author: Mauricio Gofas
Author URL: https://www.gofas.com.br
*/
// Custom Avatar via Gravity forms upload field
add_filter( 'get_avatar' , 'gfca_custom_avatar' , 1 , 5 );
function gfca_custom_avatar( $avatar, $id_or_email, $size, $default, $alt ) {
$current_user = wp_get_current_user();
$gfca_avatar = $current_user->your_custom_profile_image;
@mauriciogofas
mauriciogofas / gettext-filter-multiple.php
Last active September 4, 2015 01:41 — forked from BFTrick/gettext-filter-multiple.php
Use the gettext WordPress filter to change any translatable string.
<?php
/**
* Change text strings
*
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
*/
function my_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Sale!' :
$translated_text = __( 'Clearance!', 'woocommerce' );
@mauriciogofas
mauriciogofas / gettext-filter.php
Last active September 4, 2015 01:39 — forked from BFTrick/gettext-filter.php
Use the gettext WordPress filter to change any translatable string.
<?php
/**
* Change text strings
*
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
*/
function my_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Related Products' :
$translated_text = __( 'Check out these related products', 'woocommerce' );
@mauriciogofas
mauriciogofas / functions.php
Created September 2, 2015 02:52
How to Get the Current URL in WordPress
global $wp;
$current_url = add_query_arg( $wp->query_string, '', home_url( $wp->request ) );
@mauriciogofas
mauriciogofas / gist:044472308947b7e18c0d
Last active August 29, 2015 14:27 — forked from jamiemarsland/gist:5e618baeda2dd5199d4a
Remove WooThemes credit in Storefront footer
add_action( 'init', 'custom_remove_footer_credit', 10 );
function custom_remove_footer_credit () {
remove_action( 'storefront_footer', 'storefront_credit', 20 );
add_action( 'storefront_footer', 'custom_storefront_credit', 20 );
}
function custom_storefront_credit() {
?>
<div class="site-info">
echo do_shortcode("[shortcode]");
@mauriciogofas
mauriciogofas / test.php
Last active August 29, 2015 14:23 — forked from raewrites/test.php
Add post ID to posts, pages admin columns
add_filter( 'manage_posts_columns', 'revealid_add_id_column', 5 );
add_action( 'manage_posts_custom_column', 'revealid_id_column_content', 5, 2 );
function revealid_add_id_column( $columns ) {
$columns['revealid_id'] = 'ID';
return $columns;
}
function revealid_id_column_content( $column, $id ) {