Skip to content

Instantly share code, notes, and snippets.

View HelloAlberuni's full-sized avatar
🏠
Working from home

Alberuni Azad HelloAlberuni

🏠
Working from home
View GitHub Profile
@HelloAlberuni
HelloAlberuni / GET ALL CATEGORIES IN WOOCOMMERCE
Created July 11, 2020 09:12 — forked from OneStep21/GET ALL CATEGORIES IN WOOCOMMERCE
HOW TO GET ALL CATEGORIES , SUB-CATEGORIES AND PRODUCTS IN WOOCOMMERCE WORDPRESS PLUGIN ( This will list all the top level categories and subcategories under them hierarchically. do not use the inner query if you just want to display the top level categories. Style it as you like. )
<?php
$taxonomy = 'product_cat';
$orderby = 'name';
$show_count = 0; // 1 for yes, 0 for no
$pad_counts = 0; // 1 for yes, 0 for no
$hierarchical = 1; // 1 for yes, 0 for no
$title = '';
$empty = 0;
@HelloAlberuni
HelloAlberuni / autotrack
Created April 3, 2020 18:20 — forked from adrianspeyer/autotrack
Automatic Tracking Of Outbound Links for gtags.js
<head>
<!--Need gtag.js code and jquery already in page -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
@HelloAlberuni
HelloAlberuni / trackoutboundlink-gtag.htm
Created April 2, 2020 22:35 — forked from coliff/trackoutboundlink-gtag.htm
Track outbound links with Google's gtag.js
@HelloAlberuni
HelloAlberuni / wporg_options.php
Last active December 21, 2019 09:48
Create custom option page as a submenu page under plugin menu
<?php
/**
* Sub Menu
*/
add_action( 'admin_menu', 'htpm_submenu' );
function htpm_submenu() {
add_submenu_page( 'plugins.php', 'Plugin Manager', 'Plugin Manager', 'manage_options', 'htpm-options', 'htpm_options_page_html' );
}
@HelloAlberuni
HelloAlberuni / functions.php
Last active November 14, 2019 06:17
Contact form 7 change email address before submit
// hook into wpcf7_before_send_mail
add_action( 'wpcf7_before_send_mail', function($contact_form){
// create new instance of WPCF7_Submission class
$submission = WPCF7_Submission::get_instance();
// email address you want to change
$toEmail = '[email protected]';
// set the email address to recipient
@HelloAlberuni
HelloAlberuni / App.js
Last active September 9, 2019 13:18
Reast: Submit form data to server
import React, { Component } from 'react'
import './App.css';
import PostForm from './PostForm'
class App extends Component{
render(){
return (
<div className="container">
<div className="col-md-10">
<PostForm />
@HelloAlberuni
HelloAlberuni / App.js
Created September 5, 2019 14:12
React: Form
import React, { Component } from 'react'
import './App.css';
import PostForm from './forms/PostForm';
class App extends Component{
render(){
return (
<div className="container">
<div className="col-md-10">
<PostForm />
@HelloAlberuni
HelloAlberuni / App.js
Created September 5, 2019 12:50
React fetch post by axios
import React, { Component } from 'react'
import './App.css';
import Books from './Books/Books';
import axios from 'axios'
class App extends Component{
state = {
posts: []
}
@HelloAlberuni
HelloAlberuni / Fetch A Post
Created August 28, 2019 09:46
WP Rest API
<?php
$response = wp_remote_get( 'https://ma.tt/wp-json/wp/v2/posts/49968' );
$data = json_decode( $response['body'] );
$content = $data->content->rendered;
echo $content;
?>
@HelloAlberuni
HelloAlberuni / React lifecycle.js
Created August 24, 2019 12:53
React component lifecycle
// constructor
// render
// call all lifecycle methods
// componentDidMount
// componentDidUpdate
// componentWillUnmount