Skip to content

Instantly share code, notes, and snippets.

View elias1435's full-sized avatar
🕋
Working from home

Md. Elias elias1435

🕋
Working from home
View GitHub Profile
@elias1435
elias1435 / Read-More.txt
Created April 16, 2024 15:51
how to enable dark mood in chrome and css media query
# How to emulate/activate prefers-color-scheme on Chrome (Desktop):
1. Press F12 key (or Command+Shift+C on Mac)
2. Click on the tree dots symbol (customize and control DevTools)
3. Point your mouse on the more tools option, and then click in rendering option.
4. The option Emulate CSS media feature prefers-color-scheme near the end it's your destination !
# How to emulate/activate prefers-color-scheme on Chrome (Mobile):
1. Click on the tree dots symbol.
@elias1435
elias1435 / functions.php
Created April 10, 2024 09:24
Add tracking code only in woocommerce order received page
/**
* Add tracking code on Order received/thank you page.
*
* @return void
*/
function md_thankyou_page_tracking_code() {
if ( ! is_wc_endpoint_url( 'order-received' ) ) {
return;
}
?>
@elias1435
elias1435 / style.css
Created April 5, 2024 18:54
number input field increase and decrease handler always display with css only
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
opacity: 1
}
@elias1435
elias1435 / redirect.html
Last active March 13, 2024 19:01
Sometime we need to redirect a url directory. Use this index file to redirect the visitors
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0;url=https://www.exmaple1.com/pages/details/">
<title>Redirecting...</title>
</head>
<body>
<p>If you are not redirected automatically, <a href="https://www.exmaple.com/pages/details1/">click here</a>.</p>
</body>
@elias1435
elias1435 / functions.php
Created February 9, 2024 15:34
ACF data in order received page woocommerce. ACF field name is "course_date"
add_action ('woocommerce_order_details_after_order_table', 'action_order_details_after_order_table', 20 );
function action_order_details_after_order_table($order) {
foreach ( $order->get_items() as $item ) {
if ( $course_date = get_field('course_date', $item->get_product_id())) {
printf('<p class="course-date">%s: %s<p>', __("Course Date "), $course_date);
}
}
}
@elias1435
elias1435 / functions.php
Created February 9, 2024 11:22
WooCommerce: Only Allow 1 Product in the Cart. Place this code in functions.php
add_filter( 'woocommerce_add_to_cart_validation', 'product_only_one_in_cart', 9999 );
function product_only_one_in_cart( $passed ) {
wc_empty_cart();
return $passed;
}
@elias1435
elias1435 / gist:99fbfd4b6b2e3a676fbb0b68aa7180d7
Created January 22, 2024 15:02
Add SVG to allowed file uploads to WordPress
//add SVG to allowed file uploads
function add_file_types_to_uploads($file_types){
$new_filetypes = array();
$new_filetypes['svg'] = 'image/svg';
$file_types = array_merge($file_types, $new_filetypes );
return $file_types;
}
add_action('upload_mimes', 'add_file_types_to_uploads');
@elias1435
elias1435 / script.js
Created January 19, 2024 08:16
Match String and add selector by native js
<script>
document.addEventListener('DOMContentLoaded', function () {
// Get all elements with the specified class
var targetElements = document.querySelectorAll('.berocket_better_labels_position span.b_span_text');
// Loop through each element
targetElements.forEach(function (targetElement) {
// Get the number and convert it to a float
var number = parseFloat(targetElement.textContent);
// Check if the number is below 20%
if (number < 20) {
@elias1435
elias1435 / script.js
Created December 26, 2023 06:46
Remove characters with JS and wrap with the html element
// Get all elements with the selector '.variation-Option div'
const elements = document.querySelectorAll('.variation-Option div');
// Iterate through each element and remove "(", "+", and ")" excluding content inside <span>
elements.forEach(element => {
// Iterate through child nodes of the element
for (let i = 0; i < element.childNodes.length; i++) {
const node = element.childNodes[i];
// Check if the node is a text node and not inside a <span>
@elias1435
elias1435 / qr_code.liquid
Created December 14, 2023 17:26 — forked from hasinhayder/qr_code.liquid
QR Code Block
{% assign full_url = request.host | append: request.path %}
<div style="position: fixed; bottom: 0; right: 0">
{% comment %} {{ "thumbs-up.png" | asset_url | img_tag }} {% endcomment %}
<img width="150" height="150" src="https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl={{ full_url }}" alt=""/>
</div>
{% schema %}
{
"name": "App Embed",
"target": "body",
"settings": []