Skip to content

Instantly share code, notes, and snippets.

View joychetry's full-sized avatar
🏠
Working from home

Joy Chetry joychetry

🏠
Working from home
View GitHub Profile
@joychetry
joychetry / index.html
Created July 20, 2022 15:26
Dark Mode Switch
View index.html
<div class="toggle-switch">
<label for="darkSwitch">
<input type="checkbox" id="darkSwitch" />
<span class="toggle-slider"></span>
</label>
</div>
<script>
function initTheme(){var e=null!==localStorage.getItem("darkSwitch")&&"dark"===localStorage.getItem("darkSwitch");darkSwitch.checked=e,e?document.body.setAttribute("data-theme","dark"):document.body.removeAttribute("data-theme")}function resetTheme(){darkSwitch.checked?(document.body.setAttribute("data-theme","dark"),localStorage.setItem("darkSwitch","dark")):(document.body.removeAttribute("data-theme"),localStorage.removeItem("darkSwitch"))}var darkSwitch=document.getElementById("darkSwitch");window.addEventListener("load",function(){darkSwitch&&(initTheme(),darkSwitch.addEventListener("change",function(){resetTheme()}))});
</script>
@joychetry
joychetry / functions.php
Created March 2, 2022 20:22
jQuery Move Div on Mobile
View functions.php
(function($) {
var stickWidth = 768;
var win = $(window);
if (win.width() < stickWidth) {
$('#page-sidebar').insertAfter('#bottom-section');
}
win.resize(function () {
if (win.width() < stickWidth) {
@joychetry
joychetry / functions.php
Created October 27, 2021 14:52
Change WooCommerce Add To Cart Texts
View functions.php
<?php
add_filter( 'add_to_cart_text', 'woo_custom_single_add_to_cart_text' ); // < 2.1
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_single_add_to_cart_text' ); // 2.1 +
function woo_custom_single_add_to_cart_text() {
return __( 'My Button Text', 'woocommerce' );
}
@joychetry
joychetry / functions.php
Created October 1, 2021 06:31
Remove Plugin Update Notifications
View functions.php
// Remove plugin update notifications
function remove_update_notifications( $value ) {
if ( isset( $value ) && is_object( $value ) ) {
unset( $value->response[ 'plugin-folder/plugin.php' ] );
}
return $value;
}
add_filter( 'no_update_notifications', 'remove_update_notifications' );
@joychetry
joychetry / functions.php
Created October 1, 2021 06:19
Exclude Header Scripts Chat Form Different Pages
View functions.php
// Exclude Header Scripts Chat Form Different Pages
add_action('wp_head', 'joy_exclude_header');
function joy_exclude_header(){
if ( ! is_page( array(17896, 18006, 18040, 18749 ) ) ) { ?>
<script type="text/javascript">
// DA SCRIPT
</script>
@joychetry
joychetry / functions.php
Last active January 15, 2022 19:46
Insert Thumbnail Before First H2 and Insert Thumbnail After First Paragraph
View functions.php
<?php
//Insert Thumbnail After First Paragraph
add_filter( 'the_content', 'joy_insert_featured_image', 20 );
function insert_featured_image( $content ) {
$content = preg_replace( "/<\/p>/", "</p>" . get_the_post_thumbnail($post->ID, 'post-single'), $content, 1 );
return $content;
}
@joychetry
joychetry / popup-EleTemplate
Last active May 19, 2020 17:05
Remove 404 from Elementor Popups
View popup-EleTemplate
A Fix for now:
Remove the link from the button, icon or text
Add an ID to the element you want to trigger your pop-up with
Go to Pop-up settings > Advanced > Open By Selector
Fill in your selector (with an ID add # in front of it)
This will remove the tag to the trigger, so scrapers won't see an invalid link anymore.
@joychetry
joychetry / footer.php
Created May 13, 2020 14:25
Open External Links on New Tab
View footer.php
@joychetry
joychetry / media-query.css
Created April 26, 2020 06:53 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
View media-query.css
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
@joychetry
joychetry / elementor.css
Last active April 26, 2020 05:33
Consistent Image Size
View elementor.css
selector .elementor-image img {
border-radius: 10px 10px 10px 10px;
width: 400px;
height: 235px;
max-width: 100%;
object-fit: cover;
overflow: hidden;
}