Skip to content

Instantly share code, notes, and snippets.

View sumonst21's full-sized avatar
💭
I may be slow to respond.

Md. Sumon Islam sumonst21

💭
I may be slow to respond.
View GitHub Profile
/*---------------------------------------------------------------------------
* Label + input display fix
* Put the input + text inside the label to make it works correctly
*--------------------------------------------------------------------------*/
label {
display: block;
padding-left: 15px;
text-indent: -15px;
}
@sumonst21
sumonst21 / add-to-cart.php
Created January 31, 2022 20:28 — forked from claudiosanches/add-to-cart.php
WooCommerce - Template add-to-cart.php with quantity and Ajax!
<?php
/**
* Custom Loop Add to Cart.
*
* Template with quantity and ajax.
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
global $product;
@sumonst21
sumonst21 / custom-validation.js
Created January 28, 2022 11:22 — forked from jaredatch/custom-validation.js
WPForms adding a custom validation rule
;(function($) {
var JA_Custom_Validation = {
/**
* Start the engine.
*
* @since 1.0.0
*/
init: function() {
@sumonst21
sumonst21 / wp-admin-modal-dialog.php
Created January 27, 2022 09:32 — forked from anttiviljami/wp-admin-modal-dialog.php
WordPress admin modal dialog example
<?php
// enqueue these scripts and styles before admin_head
wp_enqueue_script( 'jquery-ui-dialog' ); // jquery and jquery-ui should be dependencies, didn't check though...
wp_enqueue_style( 'wp-jquery-ui-dialog' );
?>
<!-- The modal / dialog box, hidden somewhere near the footer -->
<div id="my-dialog" class="hidden" style="max-width:800px">
<h3>Dialog content</h3>
<p>This is some terribly exciting content inside this dialog. Don't you agree?</p>
@sumonst21
sumonst21 / wp-admin-select2.php
Created January 27, 2022 03:19 — forked from yanknudtskov/wp-admin-select2.php
Add select2 to all select fields in WordPress Admin
<?php
function enqueue_select2_jquery() {
wp_register_style( 'select2css', '//cdnjs.cloudflare.com/ajax/libs/select2/3.4.8/select2.css', false, '1.0', 'all' );
wp_register_script( 'select2', '//cdnjs.cloudflare.com/ajax/libs/select2/3.4.8/select2.js', array( 'jquery' ), '1.0', true );
wp_enqueue_style( 'select2css' );
wp_enqueue_script( 'select2' );
}
add_action( 'admin_enqueue_scripts', 'enqueue_select2_jquery' );
@sumonst21
sumonst21 / my.cnf
Created January 20, 2022 01:36 — forked from fevangelou/my.cnf
Optimized my.cnf configuration for MySQL/MariaDB (on Ubuntu, CentOS, Almalinux etc. servers)
# === Optimized my.cnf configuration for MySQL/MariaDB (on Ubuntu, CentOS, Almalinux etc. servers) ===
#
# by Fotis Evangelou, developer of Engintron (engintron.com)
#
# ~ Updated December 2021 ~
#
#
# The settings provided below are a starting point for a 8-16 GB RAM server with 4-8 CPU cores.
# If you have different resources available you should adjust accordingly to save CPU, RAM & disk I/O usage.
#
@sumonst21
sumonst21 / .gitignore
Created January 12, 2022 15:55 — forked from SaltwaterC/.gitignore
php cache curl
/cache/
@sumonst21
sumonst21 / bitof.php
Created January 8, 2022 14:22 — forked from alanef/bitof.php
/* code to check if logged in to a different WP site example.com */
$logged_in_cookie = 'wordpress_logged_in_' . md5( 'https://example.com' );
if ( ! isset($_COOKIE[ $logged_in_cookie ]) ) {
// display adverts
}
@sumonst21
sumonst21 / terraform_digitalocean_dokku.tf
Created January 4, 2022 15:05 — forked from onnimonni/terraform_digitalocean_dokku.tf
Example terraform config for creating a digitalocean droplet with volume.
variable "digitalocean_token" {
description = "This is the Digitalocean API-token which is used to setup the machines."
}
variable "digitalocean_region" {
description = "For example: nyc1, nyc2, ams2, ams3, fra2"
default = "fra1"
}
variable "digitalocean_dokku_size" {
description = "Instance size: 512mb, 1gb, 2gb, 4gb ..."
default = "2gb"
@sumonst21
sumonst21 / current-week-dates.twig
Created January 3, 2022 02:21 — forked from bootsified/current-week-dates.twig
Get current week's range of dates (Craft/Twig)
{# CALCULATE THIS WEEK'S DATES #}
{% set todayNum = 'now' | date('w') %}
{% set startDate = 'now' | date_modify('-' ~ todayNum ~ ' day') %}
{% set endDate = startDate | date_modify('+6 day') %}
{% set endDateFormatted = '-' ~ endDate | date('j') %}
{% if startDate | date('M') != endDate | date('M') %}
{% set endDateFormatted = ' - ' ~ endDate | date('M j') %}
{% endif %}
<p>The Week of {{ startDate | date('M j') }}{{ endDateFormatted }}</p>