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
Jany-M / vc-mu_loop.php
Last active Aug 14, 2019
[WP] Visual Composer custom query loop block / module, for WordPress Multisite
View vc-mu_loop.php
<?php
if( class_exists( 'WPBakeryShortCode' ) && !class_exists( 'vcMUloop' ) ) {
class vcMUloop extends WPBakeryShortCode {
function __construct() {
add_action( 'init', array( $this, 'vc_multisite_mapping' ) );
add_shortcode( 'vc_mu_posts', array( $this, 'vc_multisite_widget' ) );
}
@Jany-M
Jany-M / wp_ics.php
Last active Aug 11, 2019 — forked from jakebellacera/ICS.php
[WP] Generate a downloadable .ics file from any WordPress post or custom post type
View wp_ics.php
<?php
// Add a custom endpoint "calendar"
function add_calendar_feed(){
add_feed('calendar', 'export_ics');
// Only uncomment these 2 lines the first time you load this script, to update WP rewrite rules
/*global $wp_rewrite;
$wp_rewrite->flush_rules( false );*/
}
add_action('init', 'add_calendar_feed');
@Jany-M
Jany-M / wc-custom_attributes.php
Created Mar 20, 2018
[WP][WooCommerce] Customize attributes & Edit "Variation Swatches" plugin
View wc-custom_attributes.php
<?php
/* ------------------------------------------------------------------------------------------------
*
* METHOD 1
*
-------------------------------------------------------------------------------------------------- */
// Customize WooCommerce Attributes (method 1 - no swatches/plugins)
function wc_custom_attr( $product ) {
@Jany-M
Jany-M / wp_select_comuni.php
Last active May 22, 2019
[WP] Select con Comuni per x Regione italiana, in Ajax
View wp_select_comuni.php
<?php
// Richiede la creazione ed il popolamente delle tabelle https://gist.github.com/Jany-M/7b75ac99f46aaf13ef04587e5e9dd882
// Richiede la libreria JS Bootstrap Select https://github.com/silviomoreto/bootstrap-select
/* --------------------------------------------------------------------------------
*
* functions.php
*
-------------------------------------------------------------------------------- */
@Jany-M
Jany-M / wp_rename_upload_files.php
Created Apr 19, 2017
[WP] Rename files in custom upload folder
View wp_rename_upload_files.php
<?php
/* ----------------------------------------------------------------------------------------------------------------------------
* PREFACE for this script
*
* A frontend custom form, allowing registered users to create a custom post type + upload images to ACF Gallery custom field,
* in a custom uploads folder, had a bug where it would replace any symbol with -,
* including replacing the file extensions (eg. .jpg and .png, in -jpg and -png).
* That resulted in various issues, even though browsers could still read the file as image.
* After fixing the form itself, this script was made, to fix all the uploads that had already been uploaded and their path.
@Jany-M
Jany-M / wp_add_body_classes.php
Last active May 22, 2019
[WP] Add custom body classes for better CSS customization
View wp_add_body_classes.php
<?php
function add_classes_to_body($classes) {
global $post;
// User Role
$user_info = get_currentuserinfo();
$classes[] = implode(' ', $user_info->roles);
// WPML
if ( function_exists('icl_object_id') ) {
@Jany-M
Jany-M / wp_wc_filter_by_featured_product.php
Last active May 22, 2019
[WP][WooCommerce] Add featured products filter
View wp_wc_filter_by_featured_product.php
@Jany-M
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
<?php
/* --------------------------------------------------------------------------------
*
* JS stand-alone (CSS not included - Get it here https://pastebin.com/uNKPdMVj)
*
-------------------------------------------------------------------------------- */
?>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
@Jany-M
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
<?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
Jany-M / woocommerce_custom.php
Created Mar 24, 2019
[WordPress][WooCommerce] Add SKU next to Variation ID in Admin Metabox
View woocommerce_custom.php
<?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) {
You can’t perform that action at this time.