Skip to content

Instantly share code, notes, and snippets.

@ofernandolopes
ofernandolopes / functions.php
Created May 12, 2020 22:53
WooCommerce set default city on checkout
/**
* @snippet WooCommerce Set Default City @ Checkout
* @how-to Get CustomizeWoo.com FREE
* @sourcecode https://businessbloomer.com/?p=21223
* @author Rodolfo Melogli
* @testedwith WooCommerce 3.4.6
*/
add_filter( 'woocommerce_checkout_fields', 'bbloomer_set_checkout_field_input_value_default' );
@ofernandolopes
ofernandolopes / functions.php
Created May 6, 2020 15:41
WooCommerce - Change add to cart text
// To change add to cart text on single product page
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woocommerce_custom_single_add_to_cart_text' );
function woocommerce_custom_single_add_to_cart_text() {
return __( 'Buy Now', 'woocommerce' );
}
// To change add to cart text on product archives(Collection) page
add_filter( 'woocommerce_product_add_to_cart_text', 'woocommerce_custom_product_add_to_cart_text' );
function woocommerce_custom_product_add_to_cart_text() {
return __( 'Buy Now', 'woocommerce' );
M500 ; reset EEPROM
G28 ; Home
M106 P0 S255 ; Set fan speed to 100%
M303 E0 S200 C8 U1 ; PID autotune extruder
M106 P0 S0 ; Turn off fan
M303 E-1 S50 C8 U1 ; PID autotune bed
M851 Z-1.0 ; Set z-offset
M503 ; Print current settings
M500 ; Save settings
@ofernandolopes
ofernandolopes / .htaccess
Created October 30, 2019 21:46
Enabling PHP 7.1 on Hostgator trough htaccess - Ativar PHP 7.1 no Hostgator usando o arquivo htaccess
# Habilitar o PHP 7.1
<IfModule mime_module>
AddHandler application/x-httpd-ea-php71 .php .php7 .phtml
</IfModule>
@ofernandolopes
ofernandolopes / functions.php
Created May 12, 2019 22:45
Sort products without stock WooCommerce
//Sort products without stock WooCommerce
class iWC_Orderby_Stock_Status
{
public function __construct()
{
// Check if WooCommerce is active
if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
add_filter('posts_clauses', array($this, 'order_by_stock_status'), 2000);
}
}
@ofernandolopes
ofernandolopes / functions.php
Created April 4, 2019 15:56 — forked from luiseduardobraschi/functions.php
Disable package splitting in Dokan Pro
<?php
remove_filter( 'woocommerce_cart_shipping_packages', 'dokan_custom_split_shipping_packages' );
remove_filter( 'woocommerce_shipping_package_name', 'dokan_change_shipping_pack_name' );
remove_action( 'woocommerce_checkout_create_order_shipping_item', 'dokan_add_shipping_pack_meta' );
add_filter( 'woocommerce_shipping_methods', function($methods){
unset( $methods['dokan_vendor_shipping'] );
return $methods;
}, 11 );
<?php
//FROM
//http://digwp.com/2010/03/wordpress-functions-php-template-custom-functions/
//http://webstractions.com/wordpress/remove-recent-comments-inline-styl/
//http://wpengineer.com/1438/wordpress-header/
//https://github.com/boldperspective/Whiteboard-Framework
//REMOVE ADMIN BAR
add_filter( 'show_admin_bar', '__return_false' );
@ofernandolopes
ofernandolopes / functions.php
Created February 25, 2019 12:04
Allow editors to edit WordPress menus
// Allow editors to edit WordPress menus
$role_object = get_role( 'editor' );
$role_object->add_cap( 'edit_theme_options' );
/////
function hide_menu() {
if (current_user_can('editor')) {
remove_submenu_page( 'themes.php', 'themes.php' ); // hide the theme selection submenu
@ofernandolopes
ofernandolopes / functions.php
Created February 17, 2019 00:58
Show values and add to cart only for users who have logged in to WooCommerce.
//
//Show values and add to cart only for users who have logged in to WooCommerce.
//
add_action( 'init', 'wc_hide_price_add_cart_not_logged_in' );
function wc_hide_price_add_cart_not_logged_in() {
if ( !is_user_logged_in() ) {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
@ofernandolopes
ofernandolopes / functions.php
Created February 3, 2019 10:53
Remove Personal Options in WordPress Admin Profile Page
//Remove Personal Options in WordPress Admin Profile Page
//https://isabelcastillo.com/hide-personal-options-wordpress-admin-profile
function remove_personal_options(){
echo '<script type="text/javascript">jQuery(document).ready(function($) {
$(\'form#your-profile > h2:first\').remove(); // remove the "Personal Options" title
$(\'form#your-profile tr.user-rich-editing-wrap\').remove(); // remove the "Visual Editor" field
$(\'form#your-profile tr.user-admin-color-wrap\').remove(); // remove the "Admin Color Scheme" field
$(\'form#your-profile tr.user-comment-shortcuts-wrap\').remove(); // remove the "Keyboard Shortcuts" field
$(\'form#your-profile tr.user-admin-bar-front-wrap\').remove(); // remove the "Toolbar" field