This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Remove the 'all', 'publish', 'future', 'sticky', 'draft', 'pending', 'trash' views for non-admins | |
//https://wordpress.stackexchange.com/questions/224159/how-to-disable-or-remove-all-posts-published-and-trash-in-dashboard-posts | |
add_filter( 'views_edit-post', function( $views ) | |
{ | |
if( current_user_can( 'manage_options' ) ) | |
return $views; | |
$remove_views = [ 'all','publish','future','sticky','draft','pending','trash' ]; | |
foreach( (array) $remove_views as $view ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Hide all admin notices for everyone except admin users | |
//https://wordpress.stackexchange.com/questions/396302/how-can-i-programattically-hide-all-admin-notices-for-everyone-except-admin-user | |
add_action( | |
'admin_notices', | |
function() { | |
if ( ! current_user_can( 'manage_options' ) ) { | |
remove_all_actions( 'admin_notices' ); | |
} | |
}, | |
0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
//Tips on Customizing WooCommerce - https://plugintests.com/plugins/wporg/woocommerce/tips | |
// | |
//How to Hide WooCommerce Admin Menus | |
function plt_hide_woocommerce_menus() { | |
//Hide "Tools → Scheduled Actions". | |
remove_submenu_page('tools.php', 'action-scheduler'); | |
//Hide "WooCommerce". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Disable showing of WordPress post counts | |
//https://www.collectiveray.com/show-only-posts-media-owned-logged-in-wordpress-user | |
function fix_post_counts($views) { | |
global $current_user, $wp_query; | |
unset($views['mine']); | |
$types = array( | |
array( 'status' => NULL ), | |
array( 'status' => 'publish' ), | |
array( 'status' => 'draft' ), | |
array( 'status' => 'pending' ), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Restricting Authors to View Only Posts They Created | |
//https://www.isitwp.com/restricting-authors-to-view-only-posts-they-created/ | |
function posts_for_current_author($query) { | |
global $pagenow; | |
if( 'edit.php' != $pagenow || !$query->is_admin ) | |
return $query; | |
if( !current_user_can( 'manage_options' ) ) { | |
global $user_ID; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Removing links from the WordPress Toolbar | |
function webriti_remove_admin_bar_links() { | |
global $wp_admin_bar; | |
//Remove WordPress Logo Menu Items | |
$wp_admin_bar->remove_menu('wp-logo'); // Removes WP Logo and submenus completely, to remove individual items, use the below mentioned codes | |
$wp_admin_bar->remove_menu('about'); // 'About WordPress' | |
$wp_admin_bar->remove_menu('wporg'); // 'WordPress.org' | |
$wp_admin_bar->remove_menu('documentation'); // 'Documentation' | |
$wp_admin_bar->remove_menu('support-forums'); // 'Support Forums' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Removing wp admin bar nodes for non admin | |
function wpdocs_remove_nodes($wp_admin_bar) | |
{ | |
// Remove items from the menu bar. | |
if ( ! current_user_can('administrator')) { | |
$wp_admin_bar->remove_node('wp-logo'); | |
$wp_admin_bar->remove_node('comments'); | |
$wp_admin_bar->remove_node('new-content'); | |
$wp_admin_bar->remove_node('edit'); | |
$wp_admin_bar->remove_node('litespeed-menu'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Remove fields from WooCommerce checkout page. | |
add_filter( 'woocommerce_checkout_fields' , 'custom_remove_woo_checkout_fields' ); | |
function custom_remove_woo_checkout_fields( $fields ) { | |
// remove billing fields | |
unset($fields['billing']['billing_first_name']); | |
unset($fields['billing']['billing_last_name']); | |
unset($fields['billing']['billing_company']); | |
unset($fields['billing']['billing_address_1']); | |
unset($fields['billing']['billing_address_2']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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' ); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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' ); |
NewerOlder