View gist:183466cf40d4d19a03dd86d222710178
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const queryString = window.location.search; | |
const urlParams = new URLSearchParams(queryString); | |
const param = urlParams.get('param'); | |
console.log(param ); |
View ajax-post-request-response.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$post_request = json_decode(file_get_contents('php://input')); | |
$requestArray = get_object_vars($post_request); | |
$data = $requestArray['data']; | |
?> |
View vanillaAjax.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sendForm = async function(form){ | |
let XHR = new XMLHttpRequest(); | |
let FD = new FormData(form); | |
window.location.reload(); | |
View redirect non logged users in wordpress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('template_redirect','my_non_logged_redirect'); | |
function my_non_logged_redirect() | |
{ | |
if(is_page('login') || is_page('my-account')){ | |
return; | |
} | |
if ( !is_user_logged_in() ){ | |
ob_clean(); |
View gist:14200bfbcf295b5f2db0ce10bda962c1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isMobile = window.matchMedia("only screen and (max-width: 768px)").matches; | |
if (isMobile) { | |
console.log("You are on mobile!"); | |
} |
View gist:0943a8abccf52b9407e56960acfdf403
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function runOnScroll() { | |
const header = document.getElementById("header"); | |
const bodyScroll = document.getElementsByTagName("body")[0].scrollTop; | |
// Chrome | |
const htmlScroll = document.getElementsByTagName("html")[0].scrollTop; | |
if ( bodyScroll >= 400 || htmlScroll >= 400) { | |
header.style.background = "#615e5d"; | |
} | |
else{ |