Skip to content

Instantly share code, notes, and snippets.

@marcusig
marcusig / media-modal-data-sync.js
Last active Jan 26, 2018
wp.media listen to changes / sync when opening a media modal
View media-modal-data-sync.js
(function($,wp){
var handle_attachment_change = function(attachment){
console.log(attachment);
}
var media_modal = wp.media({
multiple: 'add',
library: {type: 'image'},
button: {
text: 'Select image'
}
@marcusig
marcusig / image-compression-filter.php
Created Dec 16, 2019
Custom image compression level with WP-Optimize
View image-compression-filter.php
<?php
add_filter( 'wpo_image_compression_single_image_options', 'my_prefix_change_image_compression_options', 20, 4 );
function my_prefix_change_image_compression_options( $options, $attachment_id, $file_path, $size ) {
// Set the quality to 80 for the full size images
if ( 'full' == $size ) {
$options['quality'] = 80;
}
// Set the quality to 51 for thumbnails.
if ( 'thumbnail' == $size ) {
$options['quality'] = 51;
@marcusig
marcusig / change-my-designs-label.php
Created Jul 30, 2020
How to change the "My designs" link in the Save my designs add-on
View change-my-designs-label.php
<?php
add_action( 'init', function () {
// Check that both plugins are active
if ( class_exists( 'MKL\PC\Plugin' ) && MKL\PC\Plugin::instance()->get_extension( 'save-your-design' ) ) {
// Remove the current text
remove_action( 'mkl_pc_frontend_configurator_footer_section_right_before', array( MKL\PC\Plugin::instance()->get_extension( 'save-your-design' )->product, 'add_configurator_button' ) );
// Replace it with the nex text
add_action( 'mkl_pc_frontend_configurator_footer_section_right_before', function() {
?>
<span class="save-your-design-modal-container"><a href="#" class="save-your-design"> (no icon) <span>Saved design</span></a></span>
@marcusig
marcusig / replace-cross-by-tick.css
Last active Sep 10, 2020
Product configurator, replace cross by a "tick"
View replace-cross-by-tick.css
.mkl_pc .mkl_pc_container .mkl_pc_toolbar section.choices .layer_choices li.layer-choices-title > span a.close::before,
.mkl_pc .mkl_pc_container .mkl_pc_toolbar section.choices .layer_choices li.layer-choices-title > span a.close:hover::before,
.mkl_pc .mkl_pc_container .mkl_pc_toolbar section.choices .layer_choices li.layer-choices-title > span a.close:focus::before {
width: 12px;
left: -7px;
transform: translateY(2px) rotate(45deg);
height: 3px;
transform-origin: 50%;
background-color: green;
@marcusig
marcusig / change-configuration-layout.css
Created Sep 11, 2020
Product configurator - put choices next to each other instead of stacked
View change-configuration-layout.css
.mkl_pc .mkl_pc_container .mkl_pc_viewer .mkl_pc_layers img {
transition: .2s all;
position: relative;
left: 0;
top: 0;
transform: none;
max-height: 100%;
height: auto;
width: 350px;
padding: 10px
@marcusig
marcusig / spinning-layer.css
Created Oct 5, 2020
Make a layer spin - e.g. a watch second hand
View spinning-layer.css
@keyframes rotate360 {
from {transform: translate(-50%, -50%) rotate(0deg);}
to {transform: translate(-50%, -50%) rotate(360deg);}
}
/*
"Evolvens_mp_mutato_" is the prefix of the file for the second hand
it is expected that all the choices requiring the animation have the same prefix.
*/
.mkl_pc .mkl_pc_container .mkl_pc_viewer .mkl_pc_layers img[src*="Evolvens_mp_mutato_"] {
View rotate-menu-and-full-width.css
@media (max-width: 600px) {
body.configurator_is_inline .mkl_pc .mkl_pc_container .angles-select {
transform-origin: 0 100%;
top 0;
left: 0;
transform: rotate(-90deg) translateX(-74%) translateY(46px);
}
body.configurator_is_inline .mkl_pc {
@marcusig
marcusig / float-dark-mode.css
Created Dec 19, 2020
Dark mode tweak for the Float theme
View float-dark-mode.css
.mkl_pc {
--toolbar_width: 500px;
--mkl_pc_color-primary: #e00706;
--mkl_pc_color-primary_rgb: 224, 7, 6;
}
.mkl_pc .mkl_pc_container .mkl_pc_bg {
background-image: none !important;
background-color: #313539;
}
View gamepcbestel-tweaks.css
.mkl_pc .mkl_pc_container .mkl_pc_toolbar section.choices .layers button.layer-item .description {
text-transform: initial;
}
.mkl_pc .mkl_pc_container .mkl_pc_toolbar section.choices .layers > li:not(.active) button.layer-item .description {
display: none;
}
.mkl_pc {
--mkl_pc_color-primary: #e80000;
View patrick-tweaks.css
.mkl_pc {
--mkl_pc_color-primary: #fe1a18;
--mkl_pc_color-primary_rgb: 254, 26, 24;
--mkl_pc_color-primary_hover: #fe1a18;
}
.mkl_pc .mkl_pc_container .mkl_pc_toolbar section.choices .layers button.layer-item {
color: var(--mkl_pc_color-primary_hover);
}