Skip to content

Instantly share code, notes, and snippets.

View junaidkbr's full-sized avatar
🔥

Junaid Ahmed junaidkbr

🔥
View GitHub Profile
@kaorukobo
kaorukobo / how-to-solve-wordpress-invalid-default-value.sql
Created March 12, 2020 03:13
How to solve the `invalid default value for 'post_date'` error on WordPress DB with MySQL when modifying the schema of wp_posts table
SET SQL_MODE = '';
ALTER TABLE `wp_posts` CHANGE `post_date` `post_date` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00';
ALTER TABLE `wp_posts` CHANGE `post_date_gmt` `post_date_gmt` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00';
ALTER TABLE `wp_posts` CHANGE `post_modified` `post_modified` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00';
ALTER TABLE `wp_posts` CHANGE `post_modified_gmt` `post_modified_gmt` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00';
@robertuniqid
robertuniqid / example.php
Created October 21, 2019 12:38
FilterHacks Trait
<?php
require_once( "trait.php" );
class Example {
use FilterHacks;
public function foo() {
$this->_filter_hack_deque( 'bar' );
@junaidkbr
junaidkbr / cookies.js
Last active November 19, 2019 05:58
Handling cookies with Javascript
/**
* Creates or Updates a cookie
*/
function setCookie(name, value, expiry /* in days */ ) {
var d = new Date()
d.setTime(d.getTime() + (expiry * 24 * 60 * 60 * 1000))
var expires = 'expires=' + d.toUTCString()
document.cookie = name + '=' + value + ';' + expires + ';path=/'
}
@Sudheer-Reddy
Sudheer-Reddy / webpack.config.js
Last active April 12, 2021 14:57
Copy static assets in Webpack
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
const PATHS = {
src: path.join(__dirname, 'src'), //absolute path to RepoDir/src
dist: path.join(__dirname, 'dist') //absolute path to RepoDir/dist
}
module.exports = {
entry: {
//Webpack will automatically resolve it to RepoDir/src/js/index.js (if file name is not specified)
<?php
/**
* Add meta fields support in rest API for post type `Post`
*
* This function will allow custom parameters within API request URL. Add post meta support for post type `Post`.
*
* > How to use?
* http://mysite.com/wp-json/wp/v2/posts?meta_key=<my_meta_key>&meta_value=<my_meta_value>
*
* > E.g. Get posts which post meta `already-visited` value is `true`.
@kevinwhoffman
kevinwhoffman / resources-web-developers-designers.md
Last active January 26, 2024 21:20
Resources for Web Developers and Designers

Resources for Web Developers and Designers

This is an incomplete list of resources including courses and individuals who publish content that has helped me grow as a web developer and designer. Many of these resources are WordPress-specific as that is my current area of specialization. This list will grow over time. If you've got something to add, send me a link @kevinwhoffman and I'll check it out!

Course Providers

@majick777
majick777 / wp-debug-session.php
Last active May 29, 2022 11:17
Enables setting WordPress Debug, Debug Logging and Debug Display via Querystring.
<?php
/* ================ */
/* WP Debug Session */
/* ---------------- */
/* . Version 1.04 . */
/* ================ */
// Home: https://gist.github.com/majick777/6c4e4074ce4a59fe09f7baa855732aee
// Author: DreamJester of http://wordquest.org/
@crittermike
crittermike / wget.sh
Last active March 26, 2024 22:49
Download an entire website with wget, along with assets.
# One liner
wget --recursive --page-requisites --adjust-extension --span-hosts --convert-links --restrict-file-names=windows --domains yoursite.com --no-parent yoursite.com
# Explained
wget \
--recursive \ # Download the whole site.
--page-requisites \ # Get all assets/elements (CSS/JS/images).
--adjust-extension \ # Save files with .html on the end.
--span-hosts \ # Include necessary assets from offsite as well.
--convert-links \ # Update links to still work in the static version.
@cwhittl
cwhittl / fetch_plugin.js
Created April 13, 2017 14:42
Using Fetch with Wordpress Plugins Ajax
fetch(ajax_url, {
method: 'POST',
credentials: 'same-origin',
headers: new Headers({'Content-Type': 'application/x-www-form-urlencoded'}),
body: 'action=zget_profile_user'
})
.then((resp) => resp.json())
.then(function(data) {
if(data.status == "success"){
_this.setState({loaded:true,user:data.user});
@corsonr
corsonr / create-woocommerce-order-dynamically.php
Created April 4, 2017 10:03
Create a WooCommerce Order Dynamically
<?php
/*
* Create order dynamically
*/
add_action( 'woocommerce_before_checkout_form', 'create_order' );
function create_order() {
global $woocommerce;