Skip to content

Instantly share code, notes, and snippets.

View ckaklamanos's full-sized avatar

Haris Kaklamanos ckaklamanos

View GitHub Profile
@ckaklamanos
ckaklamanos / wordpress_hide_dashboard_menus.php
Created May 31, 2020 16:27
WordPress: Hide Dashboard Menus and ubmenus apart from Menu (for non- Administrators)
function fn_hide_dashbaord_menus_and_subemenus(){
//Posts
remove_menu_page( 'edit.php' );
//WoocOmmerce settings
remove_submenu_page('woocommerce', 'wc-settings');
remove_submenu_page('woocommerce', 'wc-addons');
remove_submenu_page('woocommerce', 'wc-status');
remove_menu_page('wc-admin&path=/marketing');
@ckaklamanos
ckaklamanos / woocommerce_remove_virtual_and_downloadable_checkboxes.php
Created March 8, 2020 14:53
WooCommerce - Remove Virtual and Downloadable Checkboxes from the Product Data Metabox
<?php
function fn_woocommerce_remove_virtual_and_downloadable_checkboxes( $options ) {
// remove "Virtual" checkbox
if( isset( $options[ 'virtual' ] ) ) {
unset( $options[ 'virtual' ] );
}
// remove "Downloadable" checkbox
@ckaklamanos
ckaklamanos / woocommerce_remove_product_type_options.php
Created March 8, 2020 14:42
WooCommerce - Remove "Product Type/Product Data" Dropdown Options (for non-Administrators)
<?php
function fn_woocommerce_remove_product_types( $types ){
unset( $types['grouped'] );
unset( $types['external'] );
//unset( $types['variable'] );
return $types;
}
@ckaklamanos
ckaklamanos / apache_htaccess_block_urls_by_regex.txt
Created March 7, 2020 07:59
Apache .htaccess - Block URLs by regex
RewriteEngine On
RewriteRule ^something(.*)$|^somethingelse(.*)$ - [F]
@ckaklamanos
ckaklamanos / wordpress_add_inline_script_to_footer_for_smooth_scroll_to_anchor_links.php
Created February 20, 2020 09:19
WordPress Add inline script for Javascript smooth scroll to anchor links
@ckaklamanos
ckaklamanos / wp_astra_remove_metabox_per_post_type.php
Created February 6, 2020 12:30
WP Astra Theme Remove Meta Box per Post Type (for non-Administrators)
<?php
function fn_remove_astra_metabox_per_post_type() {
$post_types = array(
//'page',
//'product',
//'post',
);
@ckaklamanos
ckaklamanos / woocommerce_remove_product_data_tabs.php
Created February 6, 2020 12:19
WooCommerce Remove Product Data Tabs (for non-Administrators)
<?php
function fn_remove_product_data_tabs($tabs) {
//unset($tabs['general']);
//unset($tabs['inventory']);
//unset($tabs['linked_product']);
//unset($tabs['shipping']);
//unset($tabs['attribute']);
//unset($tabs['variations']);
@ckaklamanos
ckaklamanos / wordpress_yoast_seo_remove_social_fields_and_hide_settings.php
Created January 27, 2020 09:09
Wordpress Yoast SEO - Remove user Social fields and Hide Yoast Profile settings (for non-Administrators)
<?php
if (!current_user_can('manage_options')) {
add_filter('user_contactmethods', 'fn_yoast_seo_remove_user_social_fields',99);
}
function fn_yoast_seo_remove_user_social_fields ( $contactmethods ) {
unset( $contactmethods['facebook'] );
unset( $contactmethods['instagram'] );
unset( $contactmethods['linkedin'] );
@ckaklamanos
ckaklamanos / wordpress_hide_personal_options_section_from_user_edit_screen.php
Last active January 25, 2020 14:04
WordPress: Hide "Personal Options" section from User Edit screen (for non-Administrators)
<?php
function fn_hide_personal_options_section_from_user_edit_screen(){
echo '<script>jQuery(document).ready(function($) {
$(".user-edit-php .user-admin-color-wrap").closest(".form-table").hide();
$(".user-edit-php .user-admin-color-wrap").closest(".form-table").prev("h2").hide();
} ); </script>';
}
if (!current_user_can('manage_options')) {
@ckaklamanos
ckaklamanos / uncheck_notify_register_on_new_user_form.php
Created January 25, 2020 13:41
Uncheck "Send the new user an email about their account." by default
add_action( 'user_new_form', 'fn_uncheck_notify_register_on_new_user_form' );
function fn_uncheck_notify_register_on_new_user_form() {
echo '<script>jQuery(document).ready(function($) {
$("#send_user_notification").removeAttr("checked");
} ); </script>';
}