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
@Garconis
Garconis / .htaccess
Created August 24, 2019 05:33
Cloudways | .htaccess rewrite URL to HTTPS with WWW
# Cloudways force HTTPS with WWW
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301,NC]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
@smartrashed
smartrashed / Simple Ajax Login Form.php
Created November 7, 2019 07:49 — forked from cristianstan/Simple Ajax Login Form.php
Wordpress: Simple Ajax Login Form
<?php
//Simple Ajax Login Form
//Source: http://natko.com/wordpress-ajax-login-without-a-plugin-the-right-way/
//html
<form id="login" action="login" method="post">
<h1>Site Login</h1>
<p class="status"></p>
<label for="username">Username</label>
<input id="username" type="text" name="username">
@peterfabian
peterfabian / rest_api_errors.txt
Created July 2, 2020 13:40
WP errors from the WooCommerce REST API directory
return new WP_Error( "woocommerce_rest_invalid_{$this->post_type}_id", __( 'Invalid ID.', 'woocommerce' ), array( 'status' => 404 ) );
return new WP_Error( "woocommerce_rest_invalid_{$this->post_type}_id", __( 'To manipulate product variations you should use the /products/&lt;product_id&gt;/variations/&lt;id&gt; endpoint.', 'woocommerce' ), array( 'status' => 404 ) );
return new WP_Error( "woocommerce_rest_user_cannot_delete_{$this->post_type}", sprintf( __( 'Sorry, you are not allowed to delete %s.', 'woocommerce' ), $this->post_type ), array( 'status' => rest_authorization_required_code() ) );
return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce' ), $this->post_type ), array( 'status' => 400 ) );
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_delivery_url", __( 'Webhook delivery URL must be a valid URL starting with http
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocom
@Rahmon
Rahmon / get_post_categories.php
Last active June 21, 2023 11:43
Get the post categories preserving the hierarchical order (WordPress)
<?php
/**
* Get the post categories preserving the hierarchical order
*
* This function returns an array with the following structure
*
* [
* [parent_term_id] => [
* [children] => [
* [child_term_id] => [
@adrianhajdin
adrianhajdin / StateContext.js
Last active March 21, 2025 22:38
Build and Deploy a Modern Full Stack ECommerce Application with Stripe
import React, { createContext, useContext, useState, useEffect } from 'react';
import { toast } from 'react-hot-toast';
const Context = createContext();
export const StateContext = ({ children }) => {
const getLocalStorage = (name) => {
if (typeof window !== 'undefined') {
const storage = localStorage.getItem(name);