Skip to content

Instantly share code, notes, and snippets.

Nuno Morais Sarmento nfsarmento

Block or report user

Report or block nfsarmento

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nfsarmento
nfsarmento / functions.php
Created Oct 1, 2019
Allow SVG on wordpress without plugin
View functions.php
// Allow SVG without plugin
add_filter( 'wp_check_filetype_and_ext', function($data, $file, $filename, $mimes) {
global $wp_version;
if ( $wp_version !== '4.7.1' ) {
return $data;
}
$filetype = wp_check_filetype( $filename, $mimes );
@nfsarmento
nfsarmento / functions.php
Created Sep 20, 2019
Gravity Forms - product field "user defined" price max value
View functions.php
// Form product field validation - max price of £500
// gform_field_validation_3_9 the 3 is your form ID and the 9 is your field ID
add_filter( 'gform_field_validation_3_9', 'price_custom_validation', 10, 4 );
function price_custom_validation( $result, $value, $form, $field ) {
//change value for price field to just be numeric (strips off currency symbol, etc.) using Gravity Forms to_number function
//the second parameter to to_number is the currency code, ie "USD", if not specified USD is used
$number = GFCommon::to_number( $value, '' );
if ( $result['is_valid'] && intval( $number ) > 500 ) {
$result['is_valid'] = false;
@nfsarmento
nfsarmento / ns_social_sharing_buttons.php
Last active Sep 19, 2019
Social sharing shortcode buttons
View ns_social_sharing_buttons.php
function ns_social_sharing_buttons($content) {
// Get current page URL
$nsURL = urlencode(get_permalink());
// Get current page title
$nsTitle = htmlspecialchars(urlencode(html_entity_decode(get_the_title(), ENT_COMPAT, 'UTF-8')), ENT_COMPAT, 'UTF-8');
// Get Post Thumbnail for pinterest
$nsThumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
@nfsarmento
nfsarmento / get-isotope-items.php
Created Aug 6, 2019 — forked from mohandere/get-isotope-items.php
jQuery isotope plugin for wordpress posts filtering by category with pagination.
View get-isotope-items.php
<?php
function get_isotope_item( $query_args = array() ){
$defaults = array(
'post_type' => 'post',
'posts_per_page' => -1,
'post_status' => 'publish',
);
View smooth-jump.js
jQuery(function( $ ){
// Jump to home-arrow id
// or remove ID to select all links with hashes
$('a[href*="#home-jump"]')
.click(function(event) {
// On-page links
if (
location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') &&
location.hostname == this.hostname
@nfsarmento
nfsarmento / functions.php
Created Jun 7, 2019
Debug WordPress menu
View functions.php
/**
* Debug WordPress menu
*/
add_action( 'admin_init', 'ns_debug_admin_menu' );
function ns_debug_admin_menu() {
echo '<pre>' . print_r( $GLOBALS[ 'menu' ], TRUE) . '</pre>';
echo '<style> pre{margin-left: 240px;}</style>';
}
@nfsarmento
nfsarmento / functions.php
Created Jun 5, 2019
Allow skype URIs to be used
View functions.php
/**
* Allow skype URIs to be used
*/
if ( ! function_exists( ( 'ns_portfolio_minimal_allow_skype_protocol' ) ) ) {
function ns_portfolio_minimal_allow_skype_protocol( $protocols ) {
$protocols[] = 'skype';
return $protocols;
}
}
View functions.php
//Disable Gutenberg
add_filter( 'use_block_editor_for_post', '__return_false' );
remove_action( 'try_gutenberg_panel', 'wp_try_gutenberg_panel' );
@nfsarmento
nfsarmento / functions.php
Created May 29, 2019
How to Remove Visual Composer (WP Bakery Page Builder) meta generator
View functions.php
/**
* remove vc generator
*/
add_action('wp_head', 'ns_novcgen', 1);
function ns_novcgen() {
if ( class_exists( 'Vc_Base' ) ) {
remove_action('wp_head', array(visual_composer(), 'addMetaData'));
}
}
@nfsarmento
nfsarmento / functions.php
Created May 24, 2019 — forked from vicskf/functions.php
Event Tickets > Send a copy of the RSVP or ticket email to all event organizers that have a valid email address
View functions.php
<?php
/**
* BCC event organizers email on all Event Tickets' RSVP and commerce ticket emails so they get a copy of it too
*/
function bcc_all_event_organizers( $headers, $event_id, $order_id ) {
//check if has organizer
if ( !tribe_has_organizer( $event_id ) ) {
return $headers;
}
You can’t perform that action at this time.