Skip to content

Instantly share code, notes, and snippets.

View MrImranJaved's full-sized avatar
🙂
Open For Opportunity

Imran Javed MrImranJaved

🙂
Open For Opportunity
View GitHub Profile
@rxnlabs
rxnlabs / js-gravityform-save-multistep.js
Last active July 7, 2022 12:29
WordPress - Save and submit a multistep form using Gravity Forms. Multistep forms don't allow you to submit the form if the user decides to leave before completing the form. This allows the user to submit the form at any step.
//clone the form submit button for the form
var save_btn = jQuery('#gform_submit_button_2').clone();
//change the label of the midway submit button
save_btn.val('Save and Submit');
//get the ID of the gravity form
var gravity_form = jQuery('#gform_submit_button_2').closest('form');
var gravity_form_id = gravity_form.attr('id');
gravity_form_id = gravity_form_id.split("_");
gravity_form_id = gravity_form_id[1];
//get the last page of the form
@vishalbasnet23
vishalbasnet23 / functions.php
Created October 31, 2014 08:57
User Registration Front End WordPress with Ajax
<?php
add_action('wp_ajax_register_user_front_end', 'register_user_front_end', 0);
add_action('wp_ajax_nopriv_register_user_front_end', 'register_user_front_end');
function register_user_front_end() {
$new_user_name = stripcslashes($_POST['new_user_name']);
$new_user_email = stripcslashes($_POST['new_user_email']);
$new_user_password = $_POST['new_user_password'];
$user_nice_name = strtolower($_POST['new_user_email']);
$user_data = array(
'user_login' => $new_user_name,
@kjbrum
kjbrum / wp_get_attachment_image_data.php
Last active April 21, 2022 09:10
Create an array of an attachment image's data.
<?php
/**
* Create an array of an attachment image's data.
*
* @param int $id The id of the attachment image
* @return array $image An array of all the image data
*/
function wp_get_attachment_image_data( $id=null ) {
$image = array();
@goranefbl
goranefbl / gist:6cfda8683069b16eaeb6
Created October 7, 2015 14:13
Woocommerce Shortcodes
<?php
/**
* Shortcodes init
*
* Init main shortcodes, and add a few others such as recent products.
*
* @author WooThemes
* @category Shortcodes
* @package WooCommerce/Shortcodes
* @version 1.6.4
@itzikbenh
itzikbenh / README.md
Last active January 14, 2022 13:42
WordPress - How to upload images from a frontend form via the rest-api.

Before you go over the snippets I will summarize which functions are being used.

media_handle_upload('image', 0);

That's it! one function that would insert the image into the DB, create four copies with different sizes, and upload to the uploads directory. Regarding the arguments:

'image' is what holds all the data about the image. It comes from the POST request. In the JS file you will see what I mean.

'0' This is the $post_id. I set it to zero, because i'm not asigning this image to any post at the moment. In order for this function to work we need to add above it:

@gdarko
gdarko / file-upload.css
Last active March 11, 2023 21:11
WordPress Custom Profile Image Ajax Upload
.upload-thumb {
display: inline-block;
width: 120px;
height: 120px;
overflow: hidden;
background: #e2e2e2;
border: 1px solid #cdcdcd;
line-height: 120px;
margin-bottom: 10px;
}
Step 1: Add Data in a Custom Session, on ‘Add to Cart’ Button Click
<?php
add_action('wp_ajax_wdm_add_user_custom_data_options', 'wdm_add_user_custom_data_options_callback');
add_action('wp_ajax_nopriv_wdm_add_user_custom_data_options', 'wdm_add_user_custom_data_options_callback');
function wdm_add_user_custom_data_options_callback()
{
//Custom data - Sent Via AJAX post method
$product_id = $_POST['id']; //This is product ID
$user_custom_data_values = $_POST['user_data']; //This is User custom value sent via AJAX
/*-------------------Default Styles------------------------*/
.oxy-woo-checkout {
width: 100%;
}
td.download-file a.button.alt {
width: 100%;
}
.woocommerce ul.order_details {
background: #f7f6f7;
padding: 20px;
-- phpMyAdmin SQL Dump
-- version 4.8.5
-- https://www.phpmyadmin.net/
--
-- Host: localhost:8889
-- Generation Time: Jun 07, 2019 at 07:58 AM
-- Server version: 5.7.25
-- PHP Version: 7.3.1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
<?php
$catTerms = get_terms('product_cat', array(
'hide_empty' => 0,
'orderby' => 'ASC',
'child_of'=>'30' // air sampling applications
));
echo '<ul>';
foreach($catTerms as $catTerm) {
echo '<li>
<a href="'. get_term_link($catTerm) .'" >' . $catTerm->name.'</a>