Skip to content

Instantly share code, notes, and snippets.

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

Quang Mai quangmai911

🏠
Working from home
View GitHub Profile
@joshp23
joshp23 / YWP_widget.php
Last active March 1, 2024 10:06
WordPress widget to fetch and display YOURLS shorturl
<?php
/*
Name: YOURLS WordPress Widget
Description: A WordPress widget to display a YOURLS shorturl and QR code
Code URI: https://gist.github.com/joshp23/3f990e6ec36e24ba53985968bbfa89f1
Author: Josh Panter
Author URI: https://unfettered.net
======================================================================
This widget will create &/or fetch the existing short URL for a WordPress post from YOURLS,
provide a button to copy the short url, and optionally display a qrcode.
@techjewel
techjewel / protect_login_for_admin_roles.php
Last active October 28, 2021 08:34
Code snippet to reject login for admin/authors from the regular login url
<?php
/*
* Code snippet to reject login for admin/authors from the regular login url
* In this example, people who have edit_posts permission is require special url string to login
* The URL need to be: https://yourdomain.com/wp-login.php?salt=your_random_url_string
* For normal users they can login without the special salt
* But If author or admin try to login it will reject the authentication
*
*/
@quangmai911
quangmai911 / blocksy-blog-filter.php
Created July 5, 2021 23:05 — forked from tdmrhn/blocksy-blog-filter.php
Blocksy Blog or CPT live jQuery filter
<script>
jQuery(document).ready(function($) {
$('.ct-filter').on( 'click', function(event){
var $type = $(this).data("filter");
if($type == "all"){
$('.entry-card').fadeOut(0);
$('.entry-card').fadeIn(500);
} else {
$('.entry-card').hide();
// For CPTs just change the category class to your CPTs slug for example: '.projects-'
<?php
add_action('admin_menu', function () {
global $menu;
foreach ($menu as $index => $menuItem) {
if(!empty($menuItem[2]) && $menuItem[2] == 'ninja_tables') {
$menu[$index][0] = 'My Tables';
}
}
}, 100);
<?php
add_filter( 'woocommerce_loop_add_to_cart_link', function ( $html, $product ) {
if ( is_user_logged_in() && is_shop() && $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) {
$html = '<form action="' . esc_url( $product->add_to_cart_url() ) . '" class="cart" method="post" enctype="multipart/form-data"><div class="ct-cart-actions">';
$html .= woocommerce_quantity_input( array(), $product, false );
$html .= '<button type="submit" class="single_add_to_cart_button button alt" name="add-to-cart" value="' . $product->get_id() . '">' . esc_html( $product->add_to_cart_text() ) . '</button>';
$html .= '</div></form>';
}
return $html;
}, 10, 2 );