Skip to content

Instantly share code, notes, and snippets.

View smtir's full-sized avatar
🏠
Working from home

Tawhidul Islam smtir

🏠
Working from home
View GitHub Profile
@smtir
smtir / add_contact_form_7_custom_tag.php
Created April 21, 2022 03:04 — forked from eduardoarandah/add_contact_form_7_custom_tag.php
Adding A Custom Form-Tag to Contact Form 7 in Wordpress
<?php
/**
* Contact form 7
* custom tag: [posts show:12]
* show parameter is optional
*/
add_action('wpcf7_init', 'custom_add_form_tag_posts');
function custom_add_form_tag_posts()
{
@smtir
smtir / gist:246981d569ea57078ad1310f3f9f6128
Created October 28, 2021 17:16 — forked from mikejolley/gist:2044109
WooCommerce - Update number of items in cart and total after Ajax
<?php
// Ensure cart contents update when products are added to the cart via AJAX (place the following in functions.php)
add_filter( 'woocommerce_add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment' );
function woocommerce_header_add_to_cart_fragment( $fragments ) {
ob_start();
?>
<a class="cart-contents" href="<?php echo wc_get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>"><?php echo sprintf (_n( '%d item', '%d items', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?> - <?php echo WC()->cart->get_cart_total(); ?></a>
<?php
<?php
//save theme active time
function my_theme_activation_init() {
// Check if already saved the activation date & time
// to prevent over-writing if user deactive & active theme
// multiple time
if(!get_option('mytheme_activation_time', false)){
@smtir
smtir / loop-custom.php
Created January 19, 2019 17:16 — forked from kevinwhoffman/loop-custom.php
WordPress - Custom Post Type Loop
<?php
$loop = new WP_Query( array(
'post_type' => 'Property',
'posts_per_page' => -1
)
);
?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
@smtir
smtir / http to https
Last active May 1, 2020 01:56
Force http to https
# http to https
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
RewriteCond %{HTTPS} off
RewriteRule (.*)https://%{HTTP_HOST}%{REQUEST_URI}
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@smtir
smtir / email_validation
Created September 8, 2018 06:50
JS Email Validation
function validateEmail(email) {
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(String(email).toLowerCase());
}
@smtir
smtir / ampps-mysql-fix.md
Created August 10, 2018 14:02 — forked from irazasyed/ampps-mysql-fix.md
AMPPS MySQL not working, Solution!

AMPPS MySQL not working, Solution!

  1. Open Ampps Application -> MySQL Tab -> Configuration.

  2. In [mysqld] section, add the following line: innodb_force_recovery = 1

  3. Save the file and try starting MySQL

  4. Remove that line which you just added and Save.

<!doctype html>
<html lang=en>
<head>
<title>full screen video</title>
<style>
html, body {
width: 100%;
height: 100%;
padding: 0;
@smtir
smtir / change-digitis-unicode.php
Created April 19, 2018 19:14 — forked from hasinhayder/change-digitis-unicode.php
change digits from english to unicode locale
<?php
function changeDigitsEtoB( $digits ) {
$bangla = numfmt_format(numfmt_create( 'bn_BD', NumberFormatter::TYPE_DEFAULT ),$digits); //Bangla locale
return $bangla;
}
echo changeDigitsEtoB(1234); //output ১২৩৪
@smtir
smtir / white-space.css
Created March 4, 2018 17:17 — forked from Stanton/white-space.css
CSS white-space - Cross browser
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* IE 5.5+ */