Skip to content

Instantly share code, notes, and snippets.

View ashiishme's full-sized avatar
😷
COVID-19

Ashish Yadav ashiishme

😷
COVID-19
View GitHub Profile
@ashiishme
ashiishme / getEnv.ts
Last active March 21, 2022 12:24
GetEnv utility or helper function for TypeScript / JavaScript.
type WhenStringThenStringElseCustom<T, K> = T extends string ? string : K
type ProcessEnvValue = string | undefined
export const getEnv = <T extends string | undefined>(
key: string,
fallback?: T
): WhenStringThenStringElseCustom<T, ProcessEnvValue> => {
return (
process.env[key] ??
<?php
/**
* QuotesOfTheDay Uninstall
*
* @since 1.0.0
* @package QuotesOfTheDay
*/
// If not called by WordPress
/**
* QuotesOfTheDay Deactivation Hook
* @since 1.0.0
*/
function quotesoftheday_deactivation_hook() {
//wp_die("Deactivation Hook");
}
register_deactivation_hook(QUOTESOFTHEDAY_PLUGIN_FILE, 'quotesoftheday_deactivation_hook');
/**
* QuotesOfTheDay Activation Hook
* @since 1.0.0
*/
function quotesoftheday_activation_hook() {
//wp_die("Activation Hook");
}
register_activation_hook(QUOTESOFTHEDAY_PLUGIN_FILE, 'quotesoftheday_activation_hook');
<?php
/**
* Plugin Name: Quotes Of The Day
* Plugin URI: https://www.ashiish.me/
* Description: Everyday is a quote day, welcome your users with a quotes every time they visit your website.
* Version: 1.0.0
* Author: Ashish Yadav
* Author URI: https://www.ashiish.me
* License: GPLv2 or later
@ashiishme
ashiishme / hello-world.php
Created June 26, 2019 20:03
Hello World Plugin using class that executes function named congratulations.
<?php
/**
*
* @package hello-world
*
* Plugin Name: Hello World
* Plugin URI: https://www.ashiish.me/
* Description: A plugin to greet the visitors or just another test plugin to be honest.
* Version: 1.0.0
@ashiishme
ashiishme / encapsulation.php
Created June 26, 2019 19:48
Object Oriented Programming: Encapsulation
<?php
// Class in php
class MyClass {
// our private variable
private $name;
// MyClass Constructor
function __construct() {
@ashiishme
ashiishme / inheritance.php
Last active June 26, 2019 19:50
Object Oriented Programming: Inheritance
<?php
// Class in php
class Parents {
public function eye_color() {
echo "Black";
}
}
@ashiishme
ashiishme / oop-example.php
Created June 26, 2019 18:45
Object oriented programming example in PHP for wordpress plugin development.
<?php
// Class in php
class MyClass {
// MyClass Constructor
function __construct() {
// empty
}
@ashiishme
ashiishme / oop-example.php
Created June 26, 2019 18:11
Object oriented programming example in PHP for wordpress plugin development.
<?php
// Class in php
class MyClass {
// our data and methods goes here
}
?>