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 / 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>
@joychetry
joychetry / functions.php
Last active January 15, 2022 19:46
Insert Thumbnail Before First H2 and Insert Thumbnail After First Paragraph
<?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
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.