Skip to content

Instantly share code, notes, and snippets.

View dp21369's full-sized avatar
Learning something new every moment

Devendra Pali dp21369

Learning something new every moment
View GitHub Profile
@dp21369
dp21369 / password-protected-post-form.php
Created August 22, 2024 07:47
Function to replace all the content of the password Protected post and show the password form only
function add_password_protection_script() {
if (post_password_required()) {
?>
<script>
document.addEventListener('DOMContentLoaded', function() {
var mainArea = document.getElementById('main-content');
if (mainArea) {
// Clear the existing content
mainArea.innerHTML = '';
@dp21369
dp21369 / remove-img-title.js
Last active July 18, 2024 10:57
Remove the title attribute on all images from a website on hover
$("img").hover(
function() {
// On mouse hover
$(this).data("title", $(this).attr("title")).removeAttr("title");
},
function() {
// On mouse leave
$(this).attr("title", $(this).data("title"));
}
);
add_action( 'wp', function() {
if ( ! function_exists( 'et_core_is_fb_enabled' ) ) return;
if ( et_core_is_fb_enabled() ) {
add_filter ( 'pum_popup_is_loadable', function($is_loadable) {
$is_loadable = false;
return $is_loadable;
} );
}
});
@dp21369
dp21369 / slick-slider-for-mobile-only.js
Last active April 3, 2024 04:23
Initialize slick slider for mobile when window is resized or refreshed
jQuerywindow = jQuery(window);
var jQuerymobile_slick_slider = jQuery('.mobile-post-slider section,.solutions-posts .fusion-posts-container,.members-block-container .fusion-builder-row');
settings = {
slidesToShow: 1,
slidesToScroll: 1,
arrows: false,
dots: true,
responsive: [
{
breakpoint: 9999,
@dp21369
dp21369 / hide-slick-dots.css
Created March 25, 2024 15:45
Hide dot navigation on Slick Slider when there are no more slides than the visible ones
.slick-dots li:only-child {
display: none;
}
@dp21369
dp21369 / emtpy-a-tag.css
Created March 11, 2024 11:17
CSS to target empty a tag: anchor tag having no links
.parent-class a:not([href]) {
display: none;
}
@dp21369
dp21369 / emtpy-image.css
Created March 11, 2024 11:15
CSS to target empty image with no source path
.megamenu-tab-content figure img[src=''] {
visibility: hidden;
display: none;
height: 0;
}
@dp21369
dp21369 / add-class-if-no-child-elements.js
Created March 7, 2024 06:17
Add class to parent div if there are no children elements
if ($("#product-overview").children().length == 0) {
$("#product-overview").addClass("empty-overview");
}
@dp21369
dp21369 / add-class-if-found.js
Last active March 7, 2024 06:18
Add class to div if it has certain class in it
if ($(".single-forklift-gallery .fusion-gallery").hasClass("fusion-columns-total-0")) {
$(".single-forklift-gallery").addClass("empty");
} else {
$(".single-forklift-gallery").addClass("not-empty");
};
@dp21369
dp21369 / disable-multi-update-check.php
Created February 23, 2024 11:41
Disable update check for multiple plugins
function disable_plugin_updates( $value ) {
$pluginsNotUpdatable = [
'filebird-pro/filebird.php',
'advanced-custom-fields-pro/acf.php'
];
if ( isset($value) && is_object($value) ) {
foreach ($pluginsNotUpdatable as $plugin) {
if ( isset( $value->response[$plugin] ) ) {
unset( $value->response[$plugin] );