Skip to content

Instantly share code, notes, and snippets.

View softiconic's full-sized avatar

Softiconic softiconic

View GitHub Profile
@softiconic
softiconic / hook-vc-grid.php
Last active December 2, 2023 18:41
How to resolve the error "Compilation failed: invalid range in character class at offset."
/wp-content/plugins/js_composer/include/autoload/hook-vc-grid.php
And edit line 86, from:
. '([\\w-_]+)' // 2: Shortcode name
to
. '([\\w\-_]+)' // 2: Shortcode name
@softiconic
softiconic / function.php
Last active December 2, 2023 18:41
Elementor not found - query.
add_action('elementor/query/query_results', function($query) {
$total = $query->found_posts;
if ($total == 0) {
echo '<p class="text-align-center">No items found.</p>';
}
});
@softiconic
softiconic / custom.html
Last active December 2, 2023 18:40
Page loader or customized preloader.
<div class="loader" style="display:block" ></div>
<style type='text/css'>
.loader{
display: none;
}
.loader {
position: fixed;
left: 0px;
top: 0px;
@softiconic
softiconic / single-custom.php
Last active December 2, 2023 18:40
Navigate through custom post types using next and previous functionality.
<?php if (is_singular('post_type_here')) { ?>
<div class="sc-nav">
<div class="sc_prev-next"><?php previous_post_link('%link', 'Previous') ?></div>
<div class="sc_prev-next"><?php next_post_link('%link', 'Next') ?></div>
</div><?php } ?>
@softiconic
softiconic / custom.php
Last active December 2, 2023 18:39
Detect if the user is on a laptop or mobile device using browser checks.
<?php
function getBrowser()
{
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$browser = "N/A";
$browsers = [
'/msie/i' => 'Internet explorer',
'/firefox/i' => 'Firefox',
'/safari/i' => 'Safari',
@softiconic
softiconic / custom.js
Last active December 2, 2023 18:39
Items in Isotope Masonry are overlapping.
$(window).on('load', function() {
var $container = $('.members_results');
$container.imagesLoaded( function() {
$container.isotope({
itemSelector : '.block-member',
layoutMode : 'masonry',
percentPosition: true
});
});
@softiconic
softiconic / gist:1b6b361760656dfcab937d3551f9cbae
Last active December 2, 2023 18:38
Create a loop moving up and down or left and right using CSS.
@-webkit-keyframes vertical-moveright{
0%{-webkit-transform:translateX(0);transform:translateX(0)}
100%{-webkit-transform:translateX(-100px);transform:translateX(-100px)}
}
@keyframes vertical-moveright{
0%{-webkit-transform:translateX(0);transform:translateX(0)}
100%{-webkit-transform:translateX(-100px);transform:translateX(-100px)}
}
@softiconic
softiconic / gist:7aa37bcde7f4d6755d3a44b54cfae27e
Last active December 2, 2023 18:38
Close an Elementor popup when a button or link is clicked.
jQuery(function($){
$(document).on('click','.elementor-location-popup a', function(event){
elementorProFrontend.modules.popup.closePopup( {}, event);
});
});
@softiconic
softiconic / gist:7230a5e599307365ff03a3f3baed9f47
Last active December 2, 2023 18:37
Animate the background of a button.
<button class="btn-l-r btn">Left to Right</button>
<button class="btn-r-l btn">Right to Left</button>
<button class="btn-t-b btn">Top to Bottom</button>
<button class="btn-b-t btn">Bottom to Top</button>
button {
display: inline-block;
@softiconic
softiconic / gist:f20c4cb67f978c06721a328f6b8135a1
Last active December 2, 2023 18:37
Apply a class to a specific section on a website as the user scrolls.
// Function to handle the intersection of the observed element
function handleIntersection(entries, observer) {
entries.forEach(entry => {
const targetSection = document.getElementById('tetosection'); // Replace 'tetosection' with your section's ID
if (entry.target === targetSection) {
if (entry.isIntersecting) {
targetSection.classList.add('highlightsc');
} else {
targetSection.classList.remove('highlightsc');