Skip to content

Instantly share code, notes, and snippets.

View jsakhil's full-sized avatar
🎯
Focusing

Js Akhil jsakhil

🎯
Focusing
View GitHub Profile
@jsakhil
jsakhil / colors.scss
Created November 9, 2020 14:08
Color loop in Scss
$colors: ("blue", #0000ff, "green", #008000, "orange", #fca644);
@for $index from 1 through length($colors){
div:nth-child(#{length($colors)}n + #{$index}) {
color: unquote(nth($colors, $index));
}
}
@jsakhil
jsakhil / my_pmpro_email_data.php
Created October 30, 2020 14:50 — forked from strangerstudios/my_pmpro_email_data.php
Add a !!todaysdate!! variable for use in Paid Memberships Pro email templates. Add this to your active theme's functions.php or a custom plugin and then include !!todaysdate!! in your email templates.
/*
Adds !!todaysdate!! as an available variable for use in Paid Memberships Pro emails.
Notice the array key does not include the !!s
*/
function my_pmpro_email_data($data, $email)
{
$data['todaysdate'] = date(get_option("date_format"));
return $data;
@jsakhil
jsakhil / wc_ajax_add_to_cart.php
Created July 8, 2020 09:41
Woocommerce Ajax Add To Cart Button
<?php
//AJAX ADD TO CART BUTTON
$product_id = 143;
if( !my_custom_cart_contains( $product_id ) ) {
?>
<button class="my-custom-add-to-cart-button" data-product-id="<?php echo $product_id; ?>">add to cart</button>
<?php
} else {
?>
@jsakhil
jsakhil / waMessageBlast.js
Last active March 4, 2021 19:11
WhatsApp web message Blast
// 𝔹𝕃𝔸𝕊𝕋
// Run the following code manually through browser console with an opened conversation in WhatsApp (Web Version)
// STEP #1
function sendMessageJs(message, count) {
for(var i = 0; i <= count; i++){
window.InputEvent = window.Event || window.InputEvent;
var event = new InputEvent('input', {
bubbles: true
});
@jsakhil
jsakhil / toggle.js
Last active November 13, 2020 10:01
Simple View More/ View Less Toggle for Content
$('.toggle').on('click', function(e){
e.preventDefault();
// Do Something
$(this).text($(this).text() == 'View More' ? 'View Less' : 'View More');
})
## Add class to body based on the URL – jQuery
var urlPath = window.location.pathname;
@jsakhil
jsakhil / metal-widget.js
Created April 22, 2020 15:53
Gold & Silver Rate Widget
$.ajax({
url: 'https://data-asg.goldprice.org/dbXRates/USD',
dataType: 'text',
success: function(response) {
var prices = JSON.parse(response).items[0];
var goldp = prices.xauPrice;
var goldx = prices.chgXau;
var golds = (prices.xauPrice > prices.xauClose) ? 'up' : 'down';
var silverp = prices.xagPrice;
var silverx = prices.chgXag;
@jsakhil
jsakhil / .htaccess
Created April 2, 2020 11:48 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@jsakhil
jsakhil / insta.js
Last active July 26, 2021 14:06
Live Instagram Feed - Instagram API that fetches User Profile, Followers, Following, Images, Posts, Likes , Shares
$(document).ready(function(){
$.ajax({
url:"https://www.instagram.com/{username}/channel/?__a=1",
type:'get',
success:function(response){
posts = response.graphql.user.edge_owner_to_timeline_media.edges;
posts_html = '';
for(var i=0;i<8;i++){
url = posts[i].node.display_url;
post_shortcode = posts[i].node.shortcode;
@jsakhil
jsakhil / ie.js
Created March 19, 2020 09:55
IE Background Image Fix when scrolling
if(navigator.userAgent.match(/Trident\/7\./)) {
document.body.addEventListener("mousewheel", function() {
event.preventDefault();
var wd = event.wheelDelta;
var csp = window.pageYOffset;
window.scrollTo(0, csp - wd);
});
}
<?php
/**
* @license MIT
* @author Ruben Decleyn mukke@tbs-dev.co.uk>
* @created 12/02/2017
*/
namespace App\TwigExtensions;