Skip to content

Instantly share code, notes, and snippets.

View tuanbbhero's full-sized avatar

Tuan Phan tuanbbhero

View GitHub Profile
@tuanbbhero
tuanbbhero / Excerpt-Extra
Created June 13, 2018 04:10
Insert TinyMCE to Excerpt WordPress
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')){
add_action( 'wp_enqueue_scripts', function() {
wp_enqueue_style( 'font-awesome-5' );
} );
<?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 October 26, 2018 15:16
Create and Amin Account in WordPress with functions.php
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 January 26, 2019 03:32
Change Out of Stock Text in WooCommerce
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 January 26, 2019 03:36
Change Add to Cart Text in WooCommerce Product Page. Insert into Appearance > Editor > functions.php or use Code Snippets Plugin
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 January 27, 2019 23:17
Styling WooCommerce Add to Cart Button: text color, background color, font style, radius,... Created by Tuan (Beaverhero.com)
/* 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 January 27, 2019 23:59
Add "Free Shipping On All Orders" before Header in GeneratePress Theme. Created by BeaverHero.com
/* 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 January 28, 2019 03:44
Turn Off WP Mail SMTP by WPForms Notifications in WP-Admin. Insert into Functions.php or use Code Snippets Plugin. Created by BeaverHero.com
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 January 28, 2019 09:17
Hide/Customize MH Magazine Lite Theme Copyright. Created by Tuan (BeaverHero.com)