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
Last active August 29, 2015 14:14 — forked from dancameron/functions.php
Redirect Away if not logged in and redirect back
<?php
function si_redirect_if_not_logged_in() {
$url = get_permalink( $invoice_id );
if ( !is_user_logged_in() ) {
wp_redirect( home_url() . '/login/?redirect_to=' . $url . '&reauth=1');
exit();
}
}
//
add_action( 'pre_si_invoice_view', 'si_redirect_if_not_logged_in' );
@mauriciogofas
mauriciogofas / functions.php
Last active August 29, 2015 14:14 — forked from dancameron/functions.php
Translating Strings in Sprout Invoices
<?php
/**
* Example filter will translate/change the string "Description".
* "Description" can be changed to whatever string you'd like to translate/change
* just make sure to change the function name so you don't have any conflicts.
*/
function l10n_description( $text ) {
return 'Beschrijving';
@mauriciogofas
mauriciogofas / functions.php
Last active August 29, 2015 14:14 — forked from dancameron/functions-original-and-slate-themes.php
Adds a print button to the top of estimates and invoices.
<?php
/**
* Adds a print button to the top of estimates and invoices.
* @return type
*/
function si_print_button() {
?>
<a href="javascript:window.print()" id="print_button" class="button print_button"><?php si_e('Imprimir') ?></a>
<?php
@mauriciogofas
mauriciogofas / functions.php
Last active August 29, 2015 14:14 — forked from dancameron/functions.php
Custom States and Countries for Sprout Invoices
<?php
/**
* This function file is loaded after the parent theme's function file. It's a great way to override functions, e.g. add_image_size sizes.
*
*
*/
function custom_states() {
return array(
@mauriciogofas
mauriciogofas / functions.php
Last active August 29, 2015 14:14 — forked from dancameron/functions.php
Default Money Formatting for the BR in Sprout Invoices
<?php
// Brazilian money simbol in Sprout Invoices
function set_br_reais_localeconv( $locale = array() ) {
$locale = array(
'decimal_point' => '.',
'thousands_sep' => '',
'int_curr_symbol' => 'BRL',
'currency_symbol' => 'R$',
'mon_decimal_point' => ',',
'mon_thousands_sep' => '.',
@mauriciogofas
mauriciogofas / functions.php
Last active August 29, 2015 14:14 — forked from dancameron/functions.php
Modify client dashboard date format in Sprout Invoices
<?php
function change_client_dash_date_format() {
return 'd/m/Y';
}
add_filter( 'si_client_dash_date_format', 'change_client_dash_date_format' );
@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 / 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.
<?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 / test.php
Last active August 29, 2015 14:15 — forked from raewrites/test.php
Display Post and Page IDs in the WordPress Admin
// fonte: http://premium.wpmudev.org/blog/display-wordpress-post-page-ids/
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;
}