Skip to content

Instantly share code, notes, and snippets.

@yankiara
yankiara / tarteaucitron-analytics-GDPR.html
Last active May 28, 2018 11:51
Anonymise IP address and force SSL in Google Analytics with tarteaucitron (RGPD, GDPR)
<!-- Add before closing <body> tag -->
<script>
tarteaucitron.user.analyticsUa = 'UA-XXXXXXXX-XX';
tarteaucitron.user.analyticsMore = function () { ga('set', 'anonymizeIp', true); ga('set', 'forceSSL', true); };
(tarteaucitron.job = tarteaucitron.job || []).push('analytics');
</script>
@yankiara
yankiara / wordpress-javascript.php
Created May 30, 2018 18:00
Add javascript to WordPress
<?php
// Add inline javascript before </head>
add_action( 'wp_head', 'header_inline_script' );
function header_inline_script() {
?>
<script>
</script>
<?php
}
@yankiara
yankiara / jquery-scroll.js
Created May 30, 2018 18:04
JQuery scroll
// Scroll to top
jQuery('html, body').animate({ scrollTop: 0 }, 1000);
// Scroll to element
jQuery('html, body').animate({ scrollTop: jQuery('#element').offset().top }, 1000);
// Scroll and center element on screen
jQuery('html, body').animate({ scrollTop: jQuery('#element').offset().top - jQuery(window).height()/2 - 100 }, 1000);
@yankiara
yankiara / divi-mobile-menu.css
Created June 17, 2018 15:58
New Divi mobile menu styles
/* Menu mobile pleine largeur qui s'étend sous l'entête */
@media only screen and (max-width: 980px) {
.mobile_nav.opened .mobile_menu_bar:before {
content: "\4d";
}
#main-header .container.clearfix.et_menu_container {
width: 100%;
}
/**
* Add Oxygen's global colors to Gutenberg's backend editor palette
*/
function pavenum_gutenberg_oxygen_palette() {
$gutenberg_colors = [];
$oxy_colors = oxy_get_global_colors();
foreach( $oxy_colors['colors'] as $oxy_color) {
$gutenberg_colors[] = [ 'name' => $oxy_color['name'], 'slug' => 'color-' . $oxy_color['id'], 'color' => $oxy_color['value'] ];
@yankiara
yankiara / customization-plugin.php
Last active July 12, 2022 06:26
Oxygen Builder dummy theme used to increase plugins compatibility
/**
* Oxy-Dummy activation (thank you Sridhar Katakam)
* Paste this code snippet in your Oxygen's customization plugin
* or copy the file to /wp-content/plugins/customization-plugin/
*/
remove_filter( 'template', 'ct_oxygen_template_name' );
remove_filter( 'template_directory', 'ct_disable_theme_load', 1, 1 );
remove_filter( 'stylesheet_directory', 'ct_disable_theme_load', 1, 1 );
@yankiara
yankiara / fluid-fonts-and-icons.css
Last active July 10, 2021 04:31
Fluid fonts and icons in CSS
body {
--base: 20;
--scale-headings: 1.44;
--scale-mobile: 0.7;
--scale-mobile-headings: 0.4;
--scale-icons: 1.4;
--min-viewport: 480;
--max-viewport: 1600;
--max-size: var(--base);
}
@yankiara
yankiara / google-tag-manager-wordpress.php
Last active November 27, 2019 14:48
Add Google Tag Manager to Wordpress
add_action('wp_head','gtm_head', 20);
function gtm_head() {
?>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXX');</script>
<!-- End Google Tag Manager -->
@yankiara
yankiara / ouput-acf-checkbox-selected.php
Created December 31, 2019 11:27
Output ACF checkbox field seleted items
<?php
$items = get_field('FIELD_NAME');
if( $items ): ?>
<ul>
<?php foreach( $items as $item ): ?>
<li><?php echo $item; ?></li>
<?php endforeach; ?>
</ul>
@yankiara
yankiara / oxygen-repeater-dynamic-query.php
Last active September 6, 2023 19:25
Use dynamic queries with Oxygen's repeater
/* I'll put here different examples of dynamic query for Oxygen repeater :
* - Use one of the following repeater_dynamic_query definitions
* in code block just BEFORE the repeater
* - Set the repeater custom query settings : post type, number of posts, order...
* - Add the remove_action in a code block AFTER the repeater
*/
/****************************************************************************************************
* Display related posts for any CPT with taxonomy: