Skip to content

Instantly share code, notes, and snippets.

View softiconic's full-sized avatar

Softiconic softiconic

View GitHub Profile
@softiconic
softiconic / gist:7c4077231d95b4d7ed1c4761bf28b504
Last active December 2, 2023 18:50
Add a class on click.
$('#classorid').click(function() {
$('.classoridnew').addClass("class");
});
@softiconic
softiconic / gist:db77e81b63580bf51a6b7096ec36507b
Last active December 2, 2023 18:50
Display posts using the shortcode [news id='1,2,3'].
<?php
// news
add_shortcode( 'news', 'news_shortcode' );
function news_shortcode( $atts ) {
extract(shortcode_atts(array(
'id' => null
), $atts, 'news'));
$post_ids = explode(",", strval($id));
ob_start();
@softiconic
softiconic / gist:19b3790e39bfcf8bb19ee91bf7d08bb7
Last active December 2, 2023 18:49
Modify the image path for marker clustering on Google Maps.
//Cluster init
if (s.cluster) {
markerCluster = new MarkerClusterer(map, markers, {
maxZoom: 12,
gridSize: 40,
//add image path url
imagePath: "https://www.bitcoinatmnearme.com/wp-content/themes/findall/images/m",
});
}
@softiconic
softiconic / read.html
Last active December 2, 2023 18:49
Implement a "Read More" functionality for content using JavaScript.
<div class="sccontent">
<p>default text here</p>
<p class="moretext">
more text here
</p>
</div>
<a class="readmore" href="#">Read more</a>
<style>
.moretext {
tags: [<?php
foreach ( get_the_terms( get_the_ID(), 'listing-tag' ) as $tax ) {
echo '"' . __( $tax->slug ) . '",';
}
foreach ( get_the_terms( get_the_ID(), 'listing-amenity' ) as $tax ) {
echo '"' . __( $tax->slug ) . '",';
}
foreach ( get_the_terms( get_the_ID(), 'listing-category' ) as $tax ) {
echo '"' . __( $tax->slug ) . '",';
}
@softiconic
softiconic / function.php
Last active December 2, 2023 18:48
Disable updates for a specific plugin.
function filter_plugin_updates( $value ) {
unset( $value->response['elementor-pro/elementor-pro.php'] );
return $value;
}
add_filter( 'site_transient_update_plugins', 'filter_plugin_updates' );
@softiconic
softiconic / function.php
Last active December 2, 2023 18:48
WooCommerce default setting for stock in orders.
add_filter('posts_clauses', 'order_by_stock_status');
function order_by_stock_status($posts_clauses) {
global $wpdb;
if (is_woocommerce() && (is_shop() || is_product_category() || is_product_tag() || is_product_taxonomy())) {
$posts_clauses['join'] .= " INNER JOIN $wpdb->postmeta istockstatus ON ($wpdb->posts.ID = istockstatus.post_id) ";
$posts_clauses['orderby'] = " istockstatus.meta_value ASC, " . $posts_clauses['orderby'];
$posts_clauses['where'] = " AND istockstatus.meta_key = '_stock_status' AND istockstatus.meta_value <> '' " . $posts_clauses['where'];
}
return $posts_clauses;
}
@softiconic
softiconic / funciton.php
Last active December 2, 2023 18:48
The default setting for new products in WooCommerce.
add_filter('woocommerce_default_catalog_orderby', 'misha_default_catalog_orderby');
function misha_default_catalog_orderby($sort_by)
{
return 'date';
}
@softiconic
softiconic / function.php
Last active December 2, 2023 18:47
The quantity of products shown per page on the WooCommerce shop page.
/**
* Change number of products that are displayed per page (shop page)
*/
add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 );
function new_loop_shop_per_page( $cols ) {
// $cols contains the current number of products per page based on the value stored on Options –> Reading
// Return the number of products you wanna show per page.
$cols = 9;
return $cols;
@softiconic
softiconic / custom.js
Last active December 2, 2023 18:47
Hide an Elementor form after submission.
<script>
jQuery(document).ready(function($) {
$(document).on('submit_success', '#formsct', function() {
$submitted_form = $(this);
// $submitted_form.hide();
$(".elementor-form-fields-wrapper").hide();
$('.elementor-message-success').show(); // this is the sucess message that I created.
});