Skip to content

Instantly share code, notes, and snippets.

Jany Martelli Jany-M

Block or report user

Report or block Jany-M

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
Jany-M / mu_loop.php
Last active Nov 8, 2019
[WP] Custom shortcode for custom loops between different blogs - For WordPress Multisite MU
View mu_loop.php
// This is a work in progress, but it works fine
// Requires custom functions & libraries not present in the script (eg. Swiper)
// Adapted from my Visual Composer custom module (same purpose)
// Doesn't play well with WPML, for now
function shambix_shortcode_mu_posts($atts, $content = null ) {
// Let's compare parameters with defaults
Jany-M / vc-mu_loop.php
Last active Nov 8, 2019
[WP] Visual Composer custom query loop block / module, for WordPress Multisite
View vc-mu_loop.php
// There's also a standalone version, no Visual Composer required, purely as a shortcode here
if( class_exists( 'WPBakeryShortCode' ) && !class_exists( 'vcMUloop' ) ) {
class vcMUloop extends WPBakeryShortCode {
function __construct() {
add_action( 'init', array( $this, 'vc_multisite_mapping' ) );
Jany-M / woocommerce_custom.php
Created Mar 24, 2019
[WordPress][WooCommerce] Add SKU next to Variation ID in Admin Metabox
View woocommerce_custom.php
// Add SKU next to variation ID
function display_sku_next_to_var_ids() {
<script type="text/javascript">
jQuery(function($) {
"use strict";
$(document).on('woocommerce_variations_loaded', function(event) {
var id = -1;
$('.woocommerce_variation.wc-metabox').each( function(index, elem) {
Jany-M / manage_paragraphs.php
Last active Nov 14, 2019
[WP][PHP] Split first paragraph from main content, display it elsewhere
View manage_paragraphs.php
// Grab the first paragraph, show it where you need it, then take the rest of the content and remove the first paragraph and show it elsewhere
// The script uses WordPress functions/content but can be used in any PHP script, just replace the WP functions
// First Paragraph
global $post;
$p1 = wpautop( $post->post_content );
$p1 = substr( $p1, 0, strpos( $p1, '</p>' ) + 4 );
//$p1 = strip_tags($p1, '<a><strong><em><h3><h2><i>'); // in case you need to remove some tags, add the ones you want to KEEP here
Jany-M / random_masonry.js
Last active Nov 14, 2019
Masonry image size randomizer (with PHP, LESS and isotope.js)
View random_masonry.js
itemSelector: '.grid-item',
//percentPosition: true,
masonry: {
columnWidth: 100
Jany-M / wp_scripts.php
Created Aug 22, 2018
[WP] Add async, defer and origin attributes to WordPress scripts
View wp_scripts.php
// Place the handles somewhere convenient
global $scripts_to_defer, $scripts_to_async, $scripts_origin;
$scripts_to_defer = array('fancybox_js', 'bootstrap_js');
$scripts_to_async = array('fontawesome_js');
$scripts_origin = array('fontawesome_js');
// Put this in functions.php
function add_defer_attribute($tag, $handle) {
Jany-M / woo_remove_product_tags.php
Created Jul 24, 2018
[WP][WC] Remove / Hide WooCommerce product tags, the right way
View woo_remove_product_tags.php
// Overwrite product_tag taxonomy properties
add_action('init', function() {
register_taxonomy('product_tag', 'product', [
//'public' => false, // making it not public could throw errors in some themes / plugins
'show_ui' => false,
'show_admin_column' => false,
'show_in_nav_menus' => false,
'show_tagcloud' => false,
Jany-M / gdpr_scripts.php
Last active Apr 7, 2019
[GDPR] Scripts to ask / check for user consent (WordPress and JS examples)
View gdpr_scripts.php
/* --------------------------------------------------------------------------------
* JS stand-alone (CSS not included - Get it here
-------------------------------------------------------------------------------- */
<script src="" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
Jany-M / expires.conf
Last active Apr 5, 2018
[Apache] mod_expires conf
View expires.conf
# etc/httpd/conf.d/expires.conf
LoadModule expires_module modules/
ExpiresActive on
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
Jany-M / wc-custom_attributes.php
Created Mar 20, 2018
[WP][WooCommerce] Customize attributes & Edit "Variation Swatches" plugin
View wc-custom_attributes.php
/* ------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------- */
// Customize WooCommerce Attributes (method 1 - no swatches/plugins)
function wc_custom_attr( $product ) {
You can’t perform that action at this time.