Skip to content

Instantly share code, notes, and snippets.

Array
(
[0] => Array
(
[download_url] => http://wp-stats-v2.local/?download_file=11830&order=wc_order_fx1ehECxclOof&email=mrmolaei.ir%40gmail.com&key=404cab4a-2322-4c61-9d71-d4ff14f98db2
[download_id] => 404cab4a-2322-4c61-9d71-d4ff14f98db2
[product_id] => 11830
[product_name] => Advanced Widgets - Up To 5 Sites
[product_url] => http://wp-stats-v2.local/add-ons/advanced-widgets/?attribute_pa_license=5-sites
[download_name] => Advanced Widgets
@mrmolaei
mrmolaei / slider.js
Created February 5, 2023 02:52
Mouse wheel scroll on Flickity slider
// Include https://github.com/jquery/jquery-mousewheel
if (document.querySelector('.js-carousel')) {
const flickityElement = jQuery('.js-carousel').flickity({
prevNextButtons: false,
pageDots: false,
contain: true,
freeScroll: true,
cellAlign: 'left',
@mrmolaei
mrmolaei / hex_to_hsl.php
Last active December 31, 2022 16:39
Convert Hex to HSL in PHP
<?php
// To avoid the complexity, I use two separate functions.
function hexToHsl($hex)
{
// Convert hex to RGB
if (strlen($hex) == 7) {
$rgb = array_map('hexdec', str_split(ltrim($hex, '#'), 2));
} else {
$hex = '#' . implode( "", array_map( function($digit) {
@mrmolaei
mrmolaei / hex_to_rgb.php
Last active December 31, 2022 16:14
Convert Hex to RGB in PHP
<?php
function hexToRgb( $hex )
{
// Convert hex to RGB
if (strlen($hex) == 7) {
$rgb = array_map('hexdec', str_split(ltrim($hex, '#'), 2));
} else {
$hex = '#' . implode( "", array_map( function($digit) {
return str_repeat($digit, 2);
@mrmolaei
mrmolaei / breakWord.css
Last active December 14, 2022 16:24
How to break every word in a new line in CSS
.break-words {
width: min-intrinsic;
width: -moz-min-content;
width: min-content;
display: table-caption;
word-break: initial;
}
/*
Lorem ipsum dolor sit amet.
@mrmolaei
mrmolaei / clickedElement.js
Created December 2, 2022 18:53
Detect click outside an element with Vanilla JS
// Check if the user clicked outside of an element
document.addEventListener('click', function (e) {
if (!e.target.closest('.element')) {
// code...
}
})