Skip to content

Instantly share code, notes, and snippets.

✌️
What's happening?

Gregorio Galante gregogalante

✌️
What's happening?
Block or report user

Report or block gregogalante

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
@gregogalante
gregogalante / AnimatedCounter.js
Last active Feb 12, 2016
Animazione di sviluppo numeri di un contatore numerico.
View AnimatedCounter.js
var animateCounters = function(duration) {
var $count = $('.counter');
if($count.length) {
$count.each(function () {
$(this).prop('Counter',0).animate({
Counter: $(this).attr('count-number')
}, {
duration: duration,
easing: 'swing',
@gregogalante
gregogalante / WpPolylangCopyPosts.php
Last active Feb 12, 2016
Permette di copiare titolo e contenuto di un post da una lingua all'altra attraverso i comandi di duplicazione di Polylang. Codice da inserire nel function.php
View WpPolylangCopyPosts.php
<?php
// Make sure Polylang copies the content when creating a translation
function jb_editor_content( $content ) {
// Polylang sets the 'from_post' parameter
if ( isset( $_GET['from_post'] ) ) {
$my_post = get_post( $_GET['from_post'] );
if ( $my_post )
return $my_post->post_content;
}
@gregogalante
gregogalante / WpRemoveUpdates.php
Last active Feb 12, 2016
Disattivare gli aggiornamenti di Wordpress dal function.php.
View WpRemoveUpdates.php
<?php
// Rimozione aggiornamenti wp
add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );
// Rimozione aggiornamenti wp-plugin
add_filter( 'pre_site_transient_update_plugins', create_function( '$a', "return null;" ) );
?>
@gregogalante
gregogalante / WpRemoveMenu.php
Last active Feb 12, 2016
Codice per nascondere le voci del menu di Wordpress agli utenti.
View WpRemoveMenu.php
<?php
function remove_menus(){
// remove_menu_page( 'index.php' ); //Dashboard
remove_menu_page( 'edit.php' ); //Posts
remove_menu_page( 'upload.php' ); //Media
remove_menu_page( 'edit.php?post_type=page' ); //Pages
remove_menu_page( 'edit-comments.php' ); //Comments
remove_menu_page( 'themes.php' ); //Appearance
remove_menu_page( 'plugins.php' ); //Plugins
@gregogalante
gregogalante / SocialTags.html
Last active Feb 12, 2016
Metatags base per il supporto social da parte del sito web.
View SocialTags.html
<meta name="description" content="Page description. No longer than 155 characters." />
<!-- Twitter Card data -->
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@publisher_handle">
<meta name="twitter:title" content="Page Title">
<meta name="twitter:description" content="Page description less than 200 characters">
<meta name="twitter:creator" content="@author_handle">
<!-- Twitter Summary card images must be at least 120x120px -->
<meta name="twitter:image" content="http://www.example.com/image.jpg">
@gregogalante
gregogalante / ScrollEffect.js
Last active Feb 12, 2016
Effetto di comparsa elementi durante lo scrolling. Funzione dipendente dal plugin jquery-visible (https://github.com/customd/jquery-visible).
View ScrollEffect.js
// Funzione da richiamare nel document.ready
var scrollEffectsInit = function() {
if($(window).width() > 1024) {
$('.animate').css('opacity', '0');
$('.animate-left').css('left', '-100px');
$('.animate-right').css('right', '-100px');
$('.animate-top').css('top', '-100px');
$('.animate-bottom').css('bottom', '-100px');
}
}
@gregogalante
gregogalante / PaperclipDynamicStyle.rb
Created Feb 8, 2018
Set custom Paperclip attachments style based on specific attribute extra value.
View PaperclipDynamicStyle.rb
class Attachment < ApplicationRecord
has_attached_file :file,
styles: ->(a) { a.instance.paperclip_styles },
path: 'public/system/:class/:id/:style_:filename',
url: '/system/:class/:id/:style_:filename'
validates_attachment_presence :file
def paperclip_styles
@gregogalante
gregogalante / WoocommerceConditionalPaymentMethods.php
Last active Feb 19, 2018
Set conditional payments method based on shipping method select by the user.
View WoocommerceConditionalPaymentMethods.php
<?php
// Hide payment gateways based on shipping method
function payment_gateway_disable( $available_gateways ) {
global $woocommerce;
$chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
$chosen_shipping = $chosen_methods[0];
if( $chosen_shipping == 1479475819 ) {
unset($available_gateways['cod']);
}
@gregogalante
gregogalante / SnakeToCamelCase.js
Last active Mar 5, 2018 — forked from emcmanus/snakeToCamelCase.js
ES6 module to recursively convert snake case keys in an object to camel case using lodash.
View SnakeToCamelCase.js
export function camelCaseKeys(object) {
let camelCaseObject = _.cloneDeep(object)
if (_.isArray(camelCaseObject)) {
return _.map(camelCaseObject, camelCaseKeys)
}
if (_.isString(camelCaseObject)) {
return camelCaseObject
}
camelCaseObject = _.mapKeys(camelCaseObject, (value, key) => _.camelCase(key))
@gregogalante
gregogalante / SidebarSections.js
Last active Mar 5, 2018
A module to create a sidebar sections navigation based on content titles.
View SidebarSections.js
var SidebarSections = (function () {
var CONTENT_CONTAINER = 'YOUR CONTENT CONTAINER SELECTOR'
var SIDEBAR_CONTAINER = 'YOUR SIDEBAR CONTAINER SELECTOR'
var _titles = []
var _titlesGroup = []
// This function is used to initialize the module.
var init = function () {
You can’t perform that action at this time.