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%;
}
@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 / jquery-replace-characters.js
Created January 8, 2020 15:11
Replace characters in jQuery
jQuery("h1, h2, h3, h4, h5, h6").each(function() {
jQuery(this).html(function(index, text) {
return text.replace( /([',.;:?!])/g, '<span class="special">$1</span>' );
});
});
@yankiara
yankiara / gutenberg-columns-gap.css
Created April 13, 2020 10:55
Custom Gutenberg columns gap
:root {
--columns-gap: 1rem;
}
@media (min-width:782px) {
.wp-block-column:not(:first-child) {
margin-left: var(--columns-gap);
}
}
@media (min-width:600px) and (max-width:781px) {
@yankiara
yankiara / remove-oxygen-imported-alt-text.php
Last active May 17, 2020 11:18
Remove imported alt text from Oxygen builder images in all posts/templates
<?php
/* WARNING: Advanced SQL table modifications, USE AT YOUR OWN RISKS */
/* IMPORTANT: You need to RESIGN SHORTCODES after executing this script */
global $wpdb;
$sql = 'SELECT meta_id, meta_value
FROM ' . $wpdb->postmeta . '
WHERE meta_key = "ct_builder_shortcodes"';
@yankiara
yankiara / oxygen-media-breakpoints-buttons.css
Last active January 28, 2021 20:53
Direct access to Oxygen's media breakpoints
.oxygen-media-query-box-wrapper {
position: static;
}
.oxygen-sidebar-currently-editing {
position: relative;
padding-bottom: 48px;
}
.oxygen-media-query-box {
display: none;
}