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 / single.php
Created April 16, 2024 08:28
Prompt native sharing options inside a post page
<script>
document.addEventListener('DOMContentLoaded', function() {
// Click event listener for images with class 'shareLink'
const images = document.querySelectorAll('.shareLink');
images.forEach(function(image) {
image.addEventListener('click', function() {
const link = document.URL;
// Check if Web Share API is supported
if (navigator.share) {
@joychetry
joychetry / loop-page.php
Last active April 16, 2024 08:26
Prompt native sharing options inside a post loop
<script>
document.addEventListener('DOMContentLoaded', function() {
// Click event listener for images with class 'shareLink'
const images = document.querySelectorAll('.shareLink');
images.forEach(function(image) {
image.addEventListener('click', function() {
const link = this.getAttribute('data-link');
const postTitle = this.getAttribute('data-title'); // Assuming 'data-title' attribute contains the post title
// Check if Web Share API is supported
@joychetry
joychetry / function.php
Created April 2, 2024 08:30
Bricks Builder: Custom Query Option
<?php
/* Add new query type controls to query options */
add_filter( 'bricks/setup/control_options', 'bl_setup_query_controls');
function bl_setup_query_controls( $control_options ) {
/* Adding new options in the dropdown */
$control_options['queryTypes']['goodmonks_crp_query'] = esc_html__( 'GoodMonks: CRP' );
return $control_options;
@joychetry
joychetry / function.php
Created April 2, 2024 08:29
Bricks Builder: Remove URL From Comments
<?php
add_filter( 'comment_form_fields', 'c_customize_bricks_comment_form_fields' );
function c_customize_bricks_comment_form_fields($fields) {
if(isset($fields['url'])){
unset( $fields['url'] ); // remove Comment Author URL field
}
return $fields;
}
@joychetry
joychetry / functions.php
Created April 2, 2024 08:21
Bricks Builder: Avoid blank screen on inside editor.
<?php
//Your code wrapped inside this condition
if( !bricks_is_builder() && !current_user_can('administrator') ){
//Your code here
}
@joychetry
joychetry / index.html
Created July 20, 2022 15:26
Dark Mode Switch
<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
(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
<?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
// 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
// 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>