Skip to content

Instantly share code, notes, and snippets.

View shahzaibkhan's full-sized avatar

Shahzaib Khan shahzaibkhan

View GitHub Profile
@shahzaibkhan
shahzaibkhan / functions.php
Created July 25, 2022 17:18
Add serial field to admin - WordPress
<?php
add_filter('manage_edit-shop_order_columns', 'edit_shop_order_columns');
function edit_shop_order_columns($columns)
{
$columns = array(
'cb' => '&lt;input type="checkbox" />',
'order_number' => __('Order') ,
'order_date' => __('Order Date') ,
'order_status' => __('Status') ,
@shahzaibkhan
shahzaibkhan / functions.php
Created July 21, 2022 15:28
compare_dates_post_draft
function test_single_page() {
$post_id = get_the_ID();
$closing_date = get_post_meta($post_id,'closing_date',true);
if($closing_date!='') {
$today = date("Y-m-d");
$expire = date("Y-m-d",strtotime($closing_date)) ;
$today_dt = new DateTime($today);
$expire_dt = new DateTime($expire);
@shahzaibkhan
shahzaibkhan / functions.php
Created July 21, 2022 11:25
prefix_custom_pre_get_posts_query
function prefix_custom_pre_get_posts_query( $q ) {
if( is_shop() || is_page('awards') ) { // set conditions here
$tax_query = (array) $q->get( 'tax_query' );
$tax_query[] = array(
'taxonomy' => 'product_cat',
'field' => 'slug',
@shahzaibkhan
shahzaibkhan / functions.php
Created July 21, 2022 11:23
get_subcategory_terms
<?php
function get_subcategory_terms( $terms, $taxonomies, $args ) {
$new_terms = array();
$hide_category = array( 300 ); // 300 is the category id, replace it with yours
// if a product category and on the shop page
if ( in_array( 'product_cat', $taxonomies ) && !is_admin() && is_shop() ) {
foreach ( $terms as $key => $term ) {
@shahzaibkhan
shahzaibkhan / themefile.php
Created July 18, 2022 13:44
featured_query_event_calendar
<?php
$featured_query = new WP_Query();
$featured_query->query(array(
'post_type' => 'tribe_events',
'posts_per_page' => '1',
'orderby' => 'rand',
'eventDisplay' => 'upcoming',
'tax_query' => array(
array(
'taxonomy' => 'tribe_events_cat',
@shahzaibkhan
shahzaibkhan / smoothscroll.js
Created July 15, 2022 05:48
smooth-scrolling
// Select all links with hashes
$('a[href*="#"]')
// Remove links that don't actually link to anything
.not('[href="#"]').
not('[href="#0"]').
click(function (event) {
// On-page links
if (
location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') &&
@shahzaibkhan
shahzaibkhan / style.css
Created July 13, 2022 09:48
Styling for Numeric Pagination
.navigation li a,
.navigation li a:hover,
.navigation li.active a,
.navigation li.disabled {
color: #fff;
text-decoration:none;
}
.navigation li {
display: inline;
@shahzaibkhan
shahzaibkhan / functions.php
Created July 13, 2022 09:48
numeric_posts_nav
function numeric_posts_nav() {
if( is_singular() )
return;
global $wp_query;
/** Stop execution if there's only 1 page */
if( $wp_query->max_num_pages <= 1 )
return;
from spellchecker import SpellChecker
spell = SpellChecker()
word = input("Enter your Word : ")
if word in spell:
print("Correct Spelling")
else:
print("Incorrect Spelling")
<?php
function callAPI($method, $url, $data){
$curl = curl_init();
switch ($method){
case "POST":
curl_setopt($curl, CURLOPT_POST, 1);
if ($data)
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
break;