Skip to content

Instantly share code, notes, and snippets.

View moxet's full-sized avatar

Abdul Muqsit moxet

View GitHub Profile
@moxet
moxet / gist:c5e270b9de422d193f5a4aff463bb1a5
Created April 27, 2024 10:50
Jquery Code for REST API Pagination
<div id="pagin"></div>
<script>
jQuery(document).ready(function($) {
//Pagination
pageSize = 10;
incremSlide = 10;
startPage = 0;
numberPage = 0;
@moxet
moxet / auto-refresh.js
Created February 23, 2024 17:17
This JQuery allows you to refresh listing without page refresh, make sure to apply .mylisting class to your listing. The timeout function improve the UX by hiding success message after 3 seconds
<script>
jQuery(document).ready(function($) {
$('.jet-form-builder__submit').on('click', function() {
$('.mylistings').load(window.location.href + ' .mylistings');
setTimeout(function() {
$(".jet-form-builder-messages-wrap").fadeOut();
}, 3000);
});
});
@moxet
moxet / logout.php
Created January 25, 2024 08:28
Wordpress Logout without Confirmation
add_action('check_admin_referer', 'logout_without_confirm', 10, 2);
function logout_without_confirm($action, $result)
{
/**
* Allow logout without confirmation
*/
if ($action == "log-out" && !isset($_GET['_wpnonce'])) {
$redirect_to = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : 'https://yoursite.com';
$location = str_replace('&amp;', '&', wp_logout_url($redirect_to));
header("Location: $location");
@moxet
moxet / google-wp-rest-api
Created December 19, 2023 12:45
Google Apps Script for Inserting Google Sheet Data to Wordpress as CPT
function Sheet_WP(e) {
var sheet = e.source.getActiveSheet();
//replace CPT with your sheet name
if(sheet.getName() == 'CPT'){
var range = e.range;
var affectedRow = range.getRow();
var postId = sheet.getRange(affectedRow, 1).getValue();
@moxet
moxet / email.html
Created September 4, 2023 10:48
Transactional Email Template for JetFormBuilder
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body style="background-color: #f6f6f6;
font-family: arial;
-webkit-font-smoothing: antialiased;
font-size: 16px;
@moxet
moxet / read_receipt.js
Created August 25, 2023 12:59
Jquery Code to Read Notification
<script>
jQuery(document).ready(function($) {
$(document).on('click',".fa-check-circle",function () {
var cct_id = $(this).siblings('.jet-listing-dynamic-field__content').text();
jQuery.ajax({
type: "post",
dataType: "json",
@moxet
moxet / notify.php
Last active October 30, 2023 08:48
Send Notification via JetForm Builder / JetEngine
add_action( 'jet-form-builder/custom-action/send_notification', function( $request, $action_handler ) {
$cct_id = $request['inserted_cct_notifications'];
$email_notify = $request['email_notify'];
$notification_details = $request['notification_details'];
$users = get_users();
foreach ($users as $user) {
$user_id = $user->ID;
@moxet
moxet / gist:32e34740bec6c87e8ce35ac70202e660
Last active August 17, 2023 06:28
Return Flat Terms with Levels from Shortcode [jet_post_terms tax="your-taxonomy" lvl="2"]
add_shortcode( 'jet_post_terms', function( $atts = array() ) {
$atts = shortcode_atts( array(
'tax' => '',
'lvl' => ''
), $atts, 'jet_post_terms' );
$post_id = get_the_ID();
if ( empty( $atts['tax'] ) ) {
return;
@moxet
moxet / hidden_activation_code.php
Created July 1, 2023 15:51
Create Hidden Code & Send via Email
<script>
jQuery(document).ready(function($) {
var generatePassword = (
length = 20,
wishlist = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~!@-#$'
) =>
Array.from(crypto.getRandomValues(new Uint32Array(length)))
.map((x) => wishlist[x % wishlist.length])
.join('')
@moxet
moxet / reading_time.php
Created June 21, 2023 05:52
Calculate Reading Time & Store in Meta Field
function calculate_reading_time() {
if (is_single()) {
global $post;
// Adjust the words-per-minute rate according to your preference
$words_per_minute = 200;
// Get the post content
$content = get_post_field('post_content', $post->ID);