This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Shortcode : [post-content-with-fallback-text-if-empty] | |
function empty_content($str) { | |
return trim(str_replace(' ','',strip_tags($str))) == ''; | |
} | |
function my_sc_content() { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'save_post', 'set_first_gallery_image_from_featured_image' ); | |
function set_first_gallery_image_from_featured_image() { | |
$post = get_post(); | |
$featured_image = get_the_post_thumbnail($post->ID); | |
$acf_gallery = get_field('images', false, false); // Change images to the name of the ACF gallery field you want to update | |
$attachments_ids = [ 0 => get_post_thumbnail_id($post->ID) ]; | |
if ( $featured_image && !$acf_gallery ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
If uploading new logo image and changing logo image aspect ratio | |
-> also change --logo-aspect-ratio variables below | |
Tried to calculate aspect ratio automatically with : | |
--logo-aspect-ratio: calc(var(--logo-width)/6); | |
But it does not work | |
*/ | |
@media screen and (max-width: 420px) { | |
.fusion-logo img { | |
--cumulated-containers-padding: 60px; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Hide empty categories in menus | |
add_filter( 'wp_get_nav_menu_items', 'nav_remove_empty_category_menu_item',10, 3 ); | |
function nav_remove_empty_category_menu_item ( $items, $menu, $args ) { | |
if ( ! is_admin() ) { | |
global $wpdb; | |
$nopost = $wpdb->get_col( "SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE count = 0" ); | |
foreach ( $items as $key => $item ) { | |
if ( ( 'taxonomy' == $item->type ) && ( in_array( $item->object_id, $nopost ) ) ) { | |
unset( $items[$key] ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Need enable Cloudways geolocation | |
// Displays a message "Delivery is free for orders of 6 items or more!" next to add to cart button when quantity goes over 1. Only for user who do not have a membership plan. Only for Europe | |
add_action( 'woocommerce_after_add_to_cart_button', 'suggest_box_when_qty_over_six' ); | |
function suggest_box_when_qty_over_six() { | |
if (!class_exists('WooCommerce')) return; | |
if (is_product()) { | |
$productId = get_the_ID(); | |
$product = wc_get_product( $productId ); | |
// If not in Europe -> abort |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Need enable geolocation in Woocomerce settings | |
// Check if user is in Europe | |
function get_user_geo_continent () { | |
$location = WC_Geolocation::geolocate_ip(); | |
$country = $location['country']; // Get the country code | |
$WC_Countries = new WC_Countries(); // Get WC_Countries instance object | |
$continent = $WC_Countries->get_continent_code_for_country( $country ); // Get continent | |
return $continent; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*************************/ | |
/* Custom admin notice */ | |
/*************************/ | |
// Add temporary dashboard message about plugin_name for team | |
function plugin_name_admin_notices() { | |
echo '<div class="notice notice-warning is-dismissible"><p><strong>/!\ @website team /!\</strong>: Please do not use plugin_name for the moment. It is not fully configurated yet. Thanks</p></div>'; | |
} | |
add_action('admin_notices', 'plugin_name_admin_notices'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Forbid free shipping for members on any Woocomerce membership plan plan | |
add_filter( 'woocommerce_package_rates', 'filter_woocommerce_package_rates', 10, 2 ); | |
function filter_woocommerce_package_rates( $rates, $package ) { | |
if ( function_exists( 'wc_memberships' ) ) { | |
if ( wc_memberships_is_user_member() ) { | |
foreach ( $rates as $rate_key => $rate ) { | |
if ( 'advanced_free_shipping' === $rate->method_id ) { | |
unset($rates[$rate_key]); | |
return $rates; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Modification of Drupal [Content Sync](https://www.drupal.org/project/content_sync) module. | |
* It replace the single item export tab. On which it is heavily based. When an an entity is | |
* selected, it can be exported as a tar file. Along with the entity's dependencies and attached | |
* medias saved as files (not base64) with extensions. Entity type and bundle/sub-type are | |
* hardcoded and are set to "node" and "poi_collection". Quick and dirty but does the job. | |
*/ | |
<?php |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// functions.php | |
// Add login/logout link to main menu | |
// Displays as : | |
// Bonjour username | |
// (not username ? Logout) | |
add_action( 'avada_after_header_wrapper', 'add_loginout_link_in_header' ); | |
function add_loginout_link_in_header( ) { | |
global $current_user; wp_get_current_user(); | |
$display_name = esc_html($current_user->display_name); |
NewerOlder