Skip to content

Instantly share code, notes, and snippets.

View mauriciogofas's full-sized avatar

Mauricio Gofas mauriciogofas

View GitHub Profile
<?php
function auto_send_invoice_after_creation( $invoice_id ) {
$invoice = SI_Invoice::get_instance( $invoice_id );
$client = $invoice->get_client();
$client_users = $client->get_associated_users();
if ( !empty( $client_users ) ) {
do_action( 'send_invoice', $invoice, $client_users );
}
}
@mauriciogofas
mauriciogofas / functions.php
Last active August 29, 2015 14:14
Import wp theme parent CSS
// Import parent CSS
add_action( 'wp_enqueue_scripts', 'child_enqueue_styles' );
function child_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
// End Import parent CSS
@mauriciogofas
mauriciogofas / gw-gravity-forms-map-fields-to-field.php
Last active August 29, 2015 14:14 — forked from spivurno/gw-gravity-forms-map-fields-to-field.php
Gravity Wiz // Gravity Forms // Map Submitted Field Values to Another Field
<?php
/**
* Gravity Wiz // Gravity Forms // Map Submitted Field Values to Another Field
*
* Preview your Gravity forms on the frontend of your website. Adds a "Live Preview" link to the Gravity Forms toolbar.
*
* Usage
*
* 1 - Enable "Allow field to be populated dynamically" option on field which should be populated.
* 2 - In the "Parameter Name" input, enter the merge tag (or merge tags) of the field whose value whould be populated into this field.
@mauriciogofas
mauriciogofas / functions.php
Created February 6, 2015 02:47
Replace user profile fields wp (não testado)
<?php
//fonte: https://wordpress.org/support/topic/incompatibility-with-custom-profile-fields
// Replace user profile fields
function add_twitter_contactmethod( $contactmethods ) {
// Add Twitter
if ( !isset( $contactmethods['twitter'] ) )
$contactmethods['twitter'] = 'Twitter url';
if ( !isset( $contactmethods['facebook url'] ) )
$contactmethods['facebook'] = 'Facebook url';
@mauriciogofas
mauriciogofas / functions.php
Last active August 29, 2015 14:14
Remove campos do perfil wp-admin
<?php
// Remove campos do perfil wp-admin
function remove_contactmethod( $contactmethods ) {
unset($contactmethods['aim']);
unset($contactmethods['jabber']);
unset($contactmethods['yim']);
return $contactmethods;
}
add_filter('user_contactmethods','remove_contactmethod',10,1);
// fim Remove coisas do perfil
@mauriciogofas
mauriciogofas / revoke-profile-access.php
Last active August 29, 2015 14:14 — forked from gmazzap/revoke-profile-access.php
Revoke WP Profile Access
<?php
/**
* Plugin Name: Revoke Profile Access
* Description: Allow administrators to revoke access to profile to some users
* Plugin URI: http://wordpress.stackexchange.com/q/141743/
* Author: G. M.
* Author URI: http://wordpress.stackexchange.com/users/35541/g-m
* License: GPLv2
*
*/
@mauriciogofas
mauriciogofas / functions.php
Last active August 29, 2015 14:14
Banir wp - Impedir usuário de editar perfil
<?php
// Banir usuário
// Crédito: https://gist.github.com/Giuseppe-Mazzapica/11070063
add_action( 'personal_options', 'rpa_profile_ban_field' );
add_action( 'edit_user_profile_update', 'rpa_profile_ban_field_save' );
function rpa_profile_ban_field( \WP_User $user ) {
$current = wp_get_current_user();
if ( ! is_admin() || $user->ID === $current->ID ) return;
if ( ! user_can( $current, 'edit_users' ) ) return;
$target = new WP_User( $user->ID );
@mauriciogofas
mauriciogofas / functions.php
Last active August 29, 2015 14:14
Oculta notificações de updates do wp-admin
<?php
// Remove notificação de Update
function remove_core_updates(){
global $wp_version;return(object) array('last_checked'=> time(),'version_checked'=> $wp_version,);
}
add_filter('pre_site_transient_update_core','remove_core_updates');
add_filter('pre_site_transient_update_plugins','remove_core_updates');
add_filter('pre_site_transient_update_themes','remove_core_updates');
function hideUpdateNag() {
@mauriciogofas
mauriciogofas / functions.php
Created February 6, 2015 02:12
Mostra adminbar apenas para admin
<?php
// Mostra adminbar apenas para admin
if ( get_current_user_id() != 1 ) {
add_filter( 'show_admin_bar', '__return_false' );
}
//Fim
@mauriciogofas
mauriciogofas / functions.php
Last active November 27, 2017 14:05
Notifica admin sobre post para revisão
<?php
// Notifica admin sobre post para revisão
function send_mail_post_pending( $post_id, $post ) {
$post_status = get_post_status( $post );
if( $post_status === 'pending' && ! wp_is_post_revision( $post ) ) {
$email = ( '[email protected]' );
$subject = 'Revisar novo post';
$message = 'Título do post: ' . get_the_title( $post ) . "\n\n";
$message .= 'Revisar o post: ' . admin_url( "post.php?post={$post_id}&action=edit" );
wp_mail( $email, $subject, $message );