Skip to content

Instantly share code, notes, and snippets.

Tuan Phan tuanbbhero

View GitHub Profile
@tuanbbhero
tuanbbhero / Excerpt-Extra
Created Jun 13, 2018
Insert TinyMCE to Excerpt WordPress
View Excerpt-Extra
class TinyMceExcerptCustomization{
const textdomain = '';
const custom_exceprt_slug = '_custom-excerpt';
var $contexts;
/**
* Set the feature up
* @param array $contexts a list of context where you want the wysiwyg editor in the excerpt field. Defatul array('post','page')
*/
function __construct($contexts=array('post', 'page')){
View FA5-BB
add_action( 'wp_enqueue_scripts', function() {
wp_enqueue_style( 'font-awesome-5' );
} );
View gist:86bb3a99c94ea5f7716a240ef5e72d88
<?php
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@tuanbbhero
tuanbbhero / How-to-create-Admin-Account
Created Oct 26, 2018
Create and Amin Account in WordPress with functions.php
View How-to-create-Admin-Account
function wpb_admin_account(){
$user = 'Username';
$pass = 'Password';
$email = 'email@domain.com';
if ( !username_exists( $user ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $user, $pass, $email );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
} }
add_action('init','wpb_admin_account');
@tuanbbhero
tuanbbhero / change out of stock text
Last active Jan 26, 2019
Change Out of Stock Text in WooCommerce
View change out of stock text
add_filter('woocommerce_get_availability', 'availability_filter_func');
function availability_filter_func($availability)
{
$availability['availability'] = str_ireplace('Out of stock', 'Tuan Phan!', $availability['availability']);
return $availability;
}
@tuanbbhero
tuanbbhero / change-add-to-cart-button-text
Last active Jan 26, 2019
Change Add to Cart Text in WooCommerce Product Page. Insert into Appearance > Editor > functions.php or use Code Snippets Plugin
View change-add-to-cart-button-text
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_single_add_to_cart_text' ); // 2.1 +
function woo_custom_single_add_to_cart_text() {
return __( 'Tuan Phan', 'woocommerce' );
}
@tuanbbhero
tuanbbhero / Styling WooCommerce Add to Cart Button
Last active Jan 27, 2019
Styling WooCommerce Add to Cart Button: text color, background color, font style, radius,... Created by Tuan (Beaverhero.com)
View Styling WooCommerce Add to Cart Button
/* Insert below css into Custom CSS or Addtional CSS, not insert style.css */
/* change background, color, font.... to what you want */
/* You can use Color Name or Color Code. Check color-hex.com to see over 500 Color Code */
.woocommerce button.button.alt {
background: red;
color: white;
font-size: 20px;
font-weight: 300;
font-family: "Helvetica", sans-serif;
border-radius: 10px;
@tuanbbhero
tuanbbhero / Add "Free Shipping On All Orders" before Header
Last active Jan 27, 2019
Add "Free Shipping On All Orders" before Header in GeneratePress Theme. Created by BeaverHero.com
View Add "Free Shipping On All Orders" before Header
/* Appearance - Elements - Add New - Hook */
/* Insert this HTML then select: Hook - Before Header */
<div class="kl-before-header">
Free Shipping On All Orders
</div>
/* This is CSS, insert into Custom CSS or Additional CSS */
.kl-before-header {
padding: 10px;
background: blue;
@tuanbbhero
tuanbbhero / Turn Off WP Mail SMTP Notifications
Last active Jan 28, 2019
Turn Off WP Mail SMTP by WPForms Notifications in WP-Admin. Insert into Functions.php or use Code Snippets Plugin. Created by BeaverHero.com
View Turn Off WP Mail SMTP Notifications
add_action('admin_head', 'kl_dismiss_notifications');
function kl_dismiss_notifications() {
echo '<style>
div#setting-error-tgmpa, #update-nag, .update-nag, .updated.caldera_forms {
display: none;
}
</style>';
}
@tuanbbhero
tuanbbhero / Customize MH Magazine Lite Copyright
Last active Jan 28, 2019
Hide/Customize MH Magazine Lite Theme Copyright. Created by Tuan (BeaverHero.com)
View Customize MH Magazine Lite Copyright
You can’t perform that action at this time.