Navigation arrows in Woocommerce 3.x product gallery slider - woocommerce

Has anyone been able to add navigation arrows for Next/Prev slides in the new woocommerce slider?
The thumbnail navigation particularly on mobile/table is great, but having arrows as well for desktop users would be a dream! Arrows on the main product image are preferred over the lightbox. You will understand why on our site:
http://52.56.199.58/collection/bedroom/giorgetti-syn-bedside-table/
Would seem an easy and obvious option that Woocommerce has forgotten. Any help or guidance would be much appreciated.
Cheers

You can update the Flexslider options in WooCommerce V3 by hooking into the 'woocommerce_single_product_carousel_options' filter. So specifically to enable the navigation arrows the 'directionNav' option should be set to 'true'.
Put this example function in your functions.php file and you should be good to go:
// Update WooCommerce Flexslider options
add_filter( 'woocommerce_single_product_carousel_options', 'ud_update_woo_flexslider_options' );
function ud_update_woo_flexslider_options( $options ) {
$options['directionNav'] = true;
return $options;
}

ul.flex-direction-nav {
position: absolute;
top: 30%;
z-index: 99999;
width: 100%;
left: 0;
margin: 0;
padding: 0px;
list-style: none;}
li.flex-nav-prev {float: left;}
li.flex-nav-next {float: right;}
a.flex-next {visibility:hidden;}
a.flex-prev {visibility:hidden;}
a.flex-next::after {visibility:visible;content: '\f105';
font-family: FontAwesome;margin-right: 10px;font-size: 70px; }
a.flex-prev::before {
visibility:visible;
content: '\f104';
font-family: FontAwesome; margin-left: 10px;font-size: 70px;}

Some more tested value with woocommerce 3.5.3
add_filter('woocommerce_single_product_carousel_options', 'ud_update_woo_flexslider_options');
function ud_update_woo_flexslider_options($options) {
// show arrows
$options['directionNav'] = true;
$options['animation'] = "slide";
// infinite loop
$options['animationLoop'] = true;
// autoplay (work with only slideshow too)
$options['slideshow'] = true;
//$options['autoplay'] = true;
// control par texte (boolean) ou bien par vignettes
// $options['controlNav'] = true;
//$options['controlNav'] = "thumbnails";
// $options['mousewheel'] = true;
return $options;
}

Related

Wordpress Gutenberg FSE Annoying Inline CSS

I'm trying to remove some CSS, which is added on the front-end by Wordpress. On last update Wordpress is adding class like this:
<main id="app" class="wp-container-620d4049355bb wp-block-group">
<div class="wp-container-620d404934f13 entry-content wp-block-post-content">
wp-container-620d4049355bb / wp-container-620d404934f13 for main blocks.
The problem is it's also adding some CSS:
.wp-site-blocks > * + * {
margin-top: var( --wp--style--block-gap );
}
.wp-site-blocks > * {
margin-top: 0;
margin-bottom: 0;
}
.wp-container-620d4049355bb > * {
margin-top: 0;
margin-bottom: 0;
}
.wp-container-620d404934f13 > * + * {
margin-top: var( --wp--style--block-gap );
margin-bottom: 0;
}
This CSS have a conflict with my blocks, where I'm adding single classes for setting margin.
Does anyone could help me how can I remove that css? Or remove that class? Funny fact is that wp-container-620d42ff1d800 is different every page refresh.
Thank you!
The blockGap feature, var( --wp--style--block-gap ); is not enabled by default. If you enabled blockGap or appearanceTools in theme.json, you can disable it again by setting it to null:
theme.json:
{
"version": 2,
"settings": {
"spacing": {
"blockGap": null
}
}
}
See the theme.json reference:
https://developer.wordpress.org/block-editor/reference-guides/theme-json-reference/theme-json-living/#spacing
If you want to remove the wp-container-random and the generated alignments, margins, and flex styles, you can disable the Layout feature.
Add this to your themes functions.php or similar:
remove_filter( 'render_block', 'wp_render_layout_support_flag', 10, 2 );
And if you have Gutenberg active:
remove_filter( 'render_block', 'gutenberg_render_layout_support_flag', 10, 2 );
Source for the wp_render_layout_support_flag: https://github.com/WordPress/WordPress/blob/master/wp-includes/block-supports/layout.php#L142

How to hide a section and show another section in one click in elementor?

I want to hide a section and show another section in one click.... is there any way to do that in elementor.
I searched on google but I get the result that only hide a section and show it again on another click.
But I want to hide a section and show a hidden section in one click....
please, help me with the solution.
thank you.
make sure to set a classname/id for each of your sections and also for your button.
eg. let's say i have set .sc1 and .sc2 for sections and .btn for the button.
drag and drop HTML widget to your header template or the page/template you want the results in.
copy the following javascript code to your html, make sure to put it between script tag:
var btn = document.querySelector('.btn');
var sc1 = document.querySelector('.sc1');
var sc2 = document.querySelector('.sc2');
btn.addEventListener("click", function() {
if (sc1.style.display === "none") {
sc1.style.display = "block";
sc2.style.display = "none";
} else {
sc1.style.display = "none";
sc2.style.display = "block";
}
});
.sc1, .sc2 {
width: 50px;
height: 50px;
}
.sc1 {
background: #000;
display: block;
}
.sc2 {
background: #e2062c;
display: none;
}
<div>
<div class="sc1"></div>
<div class="sc2"></div>
</div>
<button class="btn">click</button>

Add a logo to the top of wordpress admin menu

I tried to add a logo to the admin menu as a menu item background image, but it seems not the best approach because when I try to add padding or margins to it, its position change and do not fit correctly, as shown in the image:
https://i.stack.imgur.com/ZpH3q.png
And I used the following code:
/********************************************************/
/* INSERT ADMIN LOGO
/********************************************************/
add_action('admin_menu', 'shomtek_admin_menu');
function shomtek_admin_menu() {
global $menu;
$url = 'https://google.com/';
$menu[0] = array( __('SHOMTek'), 'read', $url, 'shomtek-logo', 'shomtek-logo');
}
/*ADMIN LOGO STYLES*/
#adminmenu a.shomtek-logo{
display: block;
background: url(https://example.com/logo.svg) no-repeat center center;
background-size: 140px 40px;
width: 140px;
opacity: 1;
height: 40px;
margin: 0 auto;
padding-top: 20px;
}
Can you please recommend the best approach to add a logo to the top of wordpress admin menu?
Thanks
Follow these steps:
1- Create a menu on the top of the side menu:
add_action( 'admin_menu', 'register_my_custom_menu_page' );
function register_my_custom_menu_page() {
add_menu_page( 'Custom Menu Page Title', 'Custom Menu Page', 'manage_options', 'logo_based_menu', '', '', 1);
}
2- Add custom CSS code to print the logo inside that menu:
function admin_style() {
echo '<style>
#toplevel_page_logo_based_menu {
background-image: url('. get_field ("option", "logo_image") . ');
}
#toplevel_page_logo_based_menu > a, #toplevel_page_logo_based_menu > a > div.wp-menu-image {
display: none;
}
</style>';
}
add_action('admin_enqueue_scripts', 'admin_style');

How to run more than one css transition with a click on a button?

I am building an animated hamburger menu with html css js. I now know how to start a css transition with javascript. See https://jsfiddle.net/ralphsmit/byaLfox5/. My problem now is that I need to run more than one transition with a click on my button. I've put my code here https://jsfiddle.net/ralphsmit/v980ouwj/16/.
A short explanation of my code. I have made a button (for the sake of clarity I made it green with a low opacity) and when that button is clicked, the background .dsgn-header-background will appear. Now I also want the two rectangle for the menu to animate into a cross and that the the .dsgn-header-menu-opened-menuitems also fade in.
My question is, how do I modify this js code, so that more than one transition will be started? So all transitions are a different element. You'll find the full code in the JS fiddle above (feel free to edit this).
Javascript:
const background = document.querySelector('.dsgn-header-background');
const button = document.querySelector('.dsgn-header-button');
let open = false;
button.addEventListener('click', onClickPlay);
function onClickPlay(){
if(background.classList.contains('on')){
background.classList.remove('on');
}else{
background.classList.add('on');
}
}
Check this out.
function onClickPlay(){
if(background.classList.contains('on')){
background.classList.remove('on');
element.classList.remove('anotherClassWithDifferentTransitions');
}else{
background.classList.add('on');
element.classList.add('anotherClassWithDifferentTransitions');
}
}
Cheers!
You can try this , The changes is i have added 2 more constant variable which adding on class when menu open and remove on class when menu closes.
const background = document.querySelector('.dsgn-header-background');
const button = document.querySelector('.dsgn-header-button');
const menu_up = document.querySelector('.dsgn-header-rectangle-up');
const menu_down = document.querySelector('.dsgn-header-rectangle-down');
let open = false;
button.addEventListener('click', onClickPlay);
function onClickPlay(){
if(background.classList.contains('on')){
background.classList.remove('on');
menu_up.classList.remove('on');
menu_down.classList.remove('on');
}else{
background.classList.add('on');
menu_up.classList.add('on');
menu_down.classList.add('on');
}
}
hope this will help you .
const content = document.querySelector('.content');
const button = document.querySelector('.dsgn-header-button');
function onClickPlay() {content.classList.toggle('on');}
button.addEventListener('click', onClickPlay);
fiddle: https://jsfiddle.net/s24mbakf/
Add the other elements to your onClickPlay function as you did with demo.
const demo = document.querySelector('.demo');
const demo2 = document.querySelector('.demo2');
const buttondemo = document.querySelector('.buttondemo');
let open = false;
buttondemo.addEventListener('click', onClickPlay);
function onClickPlay(){
if(demo.classList.contains('on')){
demo.classList.remove('on');
demo2.classList.remove('on');
} else {
demo.classList.add('on');
demo2.classList.add('on');
}
}
.demo {
width: 0;
height: 100vh;
background-color: black;
position: absolute;
right: 0;
transition: width 4s;
}
.demo.on {
width: 100vw;
}
.demo2 {
width: 0;
height: 50vh;
background-color: red;
position: absolute;
right: 0;
transition: width 8s;
}
.demo2.on {
width: 100vw;
background-color: yellow;
}
.buttondemo {
position: absolute;
top: 0px;
right: 0px;
width: 100px;
height: 100px;
background-color: green;
}
<div class="demo"><div>
<div class="demo2"><div>
<div class="buttondemo"><div>

CSS for printing is not applied to dynamically generated HTML

I am trying to print an HTML that comes from server-side. And the main issue that I face now is that css is not applied for some reason. See the fiddle. Is there something I am doing wrong ?
P.S. The JS with frames is used in order to open the print window in the same tab. Previously I ran into trouble that when new tab opened, the JS on the original tab stopped working till I closed the second tab with print content
https://jsfiddle.net/7L9onps1/
#media print {
body * {
visibility: hidden;
}
.test {
visibility: visible;
position: absolute;
left: 0;
top: 0;
background: red;
color: red;
-webkit-print-color-adjust: exact;
}
}
JS:
document.querySelector("#print").addEventListener("click", function() {
var html = '<div class="test">Test</div>';
print(html);
});
function print(html) {
// https://www.sitepoint.com/5-jquery-print-page-options/
document.innerHTML = html;
$('<iframe>', {
name: 'myiframe',
class: 'printFrame'
}).appendTo('body').contents().find('body').append(html);
window.frames['myiframe'].focus();
window.frames['myiframe'].print();
setTimeout(() => { $(".printFrame").remove(); }, 1000);
}
I´m using a libary to do that: https://github.com/DoersGuild/jQuery.print

Resources