Skip to content

Instantly share code, notes, and snippets.

View coder618's full-sized avatar
🎯
Focusing

Ahadul Islam coder618

🎯
Focusing
View GitHub Profile
@coder618
coder618 / gist:46734a58c0cc587e9dd24761f7df20fd
Created September 8, 2021 07:40
WooCommerce Order email object
<?php
/*
This function will return easy to use email object which can be use in
any email template by giving the order id only
*/
function coder618_get_email_obj($order_id){
$email_obj = ['order_id' => $order_id];
@coder618
coder618 / out-of-stock.php
Created April 14, 2021 13:32
woocommerce out of stock check
$has_stock = false;
// echo $product->get_type();
if( $product->get_type() == 'variable' ){
$available_variations = $product->get_available_variations();
foreach( $available_variations as $item ){
if($item['is_in_stock']== true){
$has_stock = true;
}
}
@coder618
coder618 / Text to speech Amazon poly - Dutch (php)
Created April 2, 2021 11:04
Amazon polly API with Dutch Language (PHP)
<?php
// require_once 'app/aws/aws-autoloader.php';
require 'vendor/autoload.php';
$awsAccessKeyId = '-----';
$awsSecretKey = '-----';
$credentials = new \Aws\Credentials\Credentials($awsAccessKeyId, $awsSecretKey);
$client = new \Aws\Polly\PollyClient([
'version' => '2016-06-10',
'credentials' => $credentials,
'region' => 'us-east-1',
@coder618
coder618 / jQuery Accordion
Created October 17, 2020 07:28
jQuery Accordion snippet
<ul class="accordion">
<?php for($i=0; $i< 5; $i++): ?>
<li>
<a class="toggle" href="javascript:void(0);">Item 1 <i class="far fa-chevron-down"></i></a>
<div class="inner">
some inner textttttttt
</div>
</li>
<?php endfor; ?>
</ul>
@coder618
coder618 / Assessment
Last active December 3, 2020 07:10
Notionhive Assessment
Q1: Suppose this array come from back-end. data of this array can be dynamic.
You have to make a Dynamic HTML Output (using ul tag) based on this array,
where each item will fall under its parent id.
output will look something like this.
Bangladesh
Dhaka
Uttara
Khilgaon
@coder618
coder618 / Form Data To JSON
Created September 5, 2020 11:06
Convert Form Data into JSON formate
/**
Return Form Data in json formate.
require jQuery Form Selector
*/
function returnFormJson(fromSelector) {
var output = [];
var f_Data = $(fromSelector).serializeArray();
@coder618
coder618 / Wordpress Remove all unnecessary tags from head
Created August 3, 2020 12:36
this pieces of code will remove all unnecessary tags from which generated between <head></head> by WordPress. Use with caution
add_action( 'after_setup_theme', 'prefix_remove_unnecessary_tags' );
function prefix_remove_unnecessary_tags(){
// REMOVE WP EMOJI
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
@coder618
coder618 / return pagination index
Created July 10, 2020 10:28
Return pagination index for array
function returnIndex() {
var postsPerPage = 12;
console.log('return start endindex ', page, postsPerPage);
let startIndex = postsPerPage * page;
let endIndex = startIndex + postsPerPage;
return [ startIndex, endIndex ];
}
@coder618
coder618 / VS Code essential spinet
Last active November 7, 2020 10:29
vs code spinet
HTML, PHP
{
"php tag": {
"prefix": "php",
"body": ["<?php $1 ?>"],
"description": "php"
},
"coder618_print": {
"prefix": "coder618_print_markup",
"body": ["<?php coder618_print_markup($1) ?>"],
@coder618
coder618 / Gutenberg Sample Block form carbon field
Created June 18, 2020 07:08
Gutenberg Sample Block form carbon field wordpress plugin
<?php
use Carbon_Fields\Container;
use Carbon_Fields\Field;
use Carbon_Fields\Block;
add_action( 'carbon_fields_register_fields', 'dd' );
function dd(){
// var_dump( WP_Block_Type_Registry::get_instance()->get_all_registered() );
Block::make( __( 'My Shiny Gutenberg Block' ) )