Skip to content

Instantly share code, notes, and snippets.

View zarankumar's full-sized avatar

sarankumar zarankumar

View GitHub Profile
@zarankumar
zarankumar / all-angular-material-components-imports.txt
Created December 15, 2018 12:16 — forked from pimatco/all-angular-material-components-imports.txt
All Angular Material Components Imports from app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
//Angular Material Components
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {MatCheckboxModule} from '@angular/material';
import {MatButtonModule} from '@angular/material';
<?php
/**
* An email to ask the vendor to check availability of a booking.
*
* @extends \WC_Email
*
* Code copied from: https://www.skyverge.com/blog/how-to-add-a-custom-woocommerce-email/
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@zarankumar
zarankumar / PhpFireBaseNotificationSample.php
Created October 9, 2017 09:55 — forked from MohammadaliMirhamed/PhpFireBaseNotificationSample.php
Simple PHP FireBase (FCM) script showing how to send an Android push notification. Be sure to replace the SERVER_API_ACCESS_KEY with a proper one from the Google API's Console page. To use the script, just call http://sample.com/PhpFireBaseNotificationSample.php?id=THE_DEVICE_REGISTRATION_ID The main Code For GCM is https://gist.github.com/prime…
<?php
#API access key from Google API's Console
define( 'API_ACCESS_KEY', 'YOUR-SERVER-API-ACCESS-KEY-GOES-HERE' );
$registrationIds = $_GET['id'];
#prep the bundle
$msg = array
(
'body' => 'Body Of Notification',
//WP Query to get all bookable products of a vendor
$args = array(
'post_type' => 'product',
'author' => $vendor,
'meta_query' => array(
array(
'key' => '_wc_booking_availability',
'compare' => 'EXISTS',
),
@zarankumar
zarankumar / wc-bookings-availability-search.php
Created September 18, 2017 14:54 — forked from apintocr/wc-bookings-availability-search.php
WooCommerce Bookings Availability Search
<?php
/**
* WooCommerce Bookings Availability Search
*
* This is almost pseudo code, it only serves to explain the "how to do it" and does not attempt to be "The Way" to do it.
* NOTE: This NEEDS to be refined in order to work as expected.
*
* @author António Pinto <apinto@vanguardly.com>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
@zarankumar
zarankumar / Woocommerce Bookings Dropdown
Created July 22, 2017 07:30 — forked from LiamBailey/Woocommerce Bookings Dropdown
Changes out the Woocommerce Bookings date picker fields for a nice dropdown showing only available dates
<?php
/*
Plugin Name: Woocommerce Bookings Dropdown
Description: Swaps the date picker for a dropdown of dates
Version: 1.0.0
Author: Webby Scots
Author URI: http://webbyscots.com/
*/
$wswp_dates_built = false;
add_filter('booking_form_fields','wswp_booking_form_fields');
@zarankumar
zarankumar / file-upload-handler.php
Created July 10, 2017 13:15 — forked from daltonrooney/file-upload-handler.php
Multi-file WordPress uploads from the front-end
<?php /* This function attaches the image to the post in the database, add it to functions.php */
function insert_attachment($file_handler,$post_id,$setthumb='false') {
// check to make sure its a successful upload
if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) __return_false();
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
@zarankumar
zarankumar / create-image-id.php
Created July 9, 2017 08:54 — forked from joshuadavidnelson/create-image-id.php
Programmatically create the image attachment and return the new media upload id.
<?php
/**
* Create the image attachment and return the new media upload id.
*
* @author Joshua David Nelson, josh@joshuadnelson.com
*
* @since 03.29.2017 updated to a class, utilizing code from Takuro Hishikawa's gist linked below.
*
* @see https://gist.github.com/hissy/7352933
*
@zarankumar
zarankumar / add-woocommerce-product.php
Last active July 9, 2017 08:48 — forked from Yame-/add-woocommerce-product.php
Adding a WooCommerce product programmatically.
<?php
$args = array(
'post_author' => 1,
'post_content' => '',
'post_status' => "draft", // (Draft | Pending | Publish)
'post_title' => '',
'post_parent' => '',
'post_type' => "product"
);
@zarankumar
zarankumar / plugin-settings.php
Created April 23, 2017 15:53 — forked from annalinneajohansson/plugin-settings.php
A base for a WordPress plugin settings page, using the Settings API #add_options_page #add_action #admin_init #register_setting #add_settings_section
<?php
# http://kovshenin.com/2012/the-wordpress-settings-api/
# http://codex.wordpress.org/Settings_API
add_action( 'admin_menu', 'my_admin_menu' );
function my_admin_menu() {
add_options_page( __('My Plugin Options', 'textdomain' ), __('My Plugin Options', 'textdomain' ), 'manage_options', 'my-plugin', 'my_options_page' );
}
add_action( 'admin_init', 'my_admin_init' );