Hide Admin Menu Items

function wpcode_custom_remove_admin_menus(){ // Replace “user_role” with the user role you want to target. if ( ! current_user_can( ‘user_role’) ) { return; } // Hide the comments page. remove_menu_page( ‘edit-comments.php’ ); // Hide WooCommerce page. remove_menu_page( ‘woocommerce’ ); // Hide the…Continue reading

Hide plugins from admin list of plugins

function wpcode_custom_hide_plugins() { // Replace “administrator” with the user role you want to target. if ( ! current_user_can( ‘administrator’ ) ) { return; } // Modify the array to match the plugins you want to hide. $plugins_to_hide = array( ‘plugin-slug/plugin-file.php’,…Continue reading

Limit Meta Description to 160 characters

add_filter( ‘aioseo_description’, ‘aioseo_filter_description’ ); function aioseo_filter_description( $description ) { if ( strlen($description) > 160 ) { $description = substr($description, 0, 159); } return $description; }Continue reading

Redirect Pages

function afwerx_redirect() { if (isset($_SERVER[‘HTTPS’]) && ($_SERVER[‘HTTPS’] == ‘on’ || $_SERVER[‘HTTPS’] == 1) || isset($_SERVER[‘HTTP_X_FORWARDED_PROTO’]) && $_SERVER[‘HTTP_X_FORWARDED_PROTO’] == ‘https’) { $protocol = ‘https://’; } else { $protocol = ‘http://’; } $currenturl = $protocol . $_SERVER[‘HTTP_HOST’] . $_SERVER[‘REQUEST_URI’]; $currenturl_relative = wp_make_link_relative($currenturl);…Continue reading

تغيير عمله

/** * Change a currency symbol */ add_filter(‘woocommerce_currency_symbol’, ‘change_existing_currency_symbol’, 10, 2); function change_existing_currency_symbol( $currency_symbol, $currency ) { switch( $currency ) { case ‘مصري’: $currency_symbol = ‘جنيه’; break; } return $currency_symbol; }Continue reading

Fix LearnPress conflict that hides AIOSEO tabs on settings pages

add_filter( ‘learnpress/admin/can-load-assets/lp-admin’, ‘aioseoDontLoadLearnPress’, 10, 2 ); add_filter( ‘learnpress/admin/can-load-assets/lp-admin-notice’, ‘aioseoDontLoadLearnPress’, 10, 2 ); function aioseoDontLoadLearnPress( $canLoad, $currentPage ) { if ( false === strpos( $currentPage, ‘aioseo’ ) ) { return $canLoad; } return false; }Continue reading

Noindex & Nofollow Posts

add_filter( ‘aioseo_robots_meta’, ‘aioseo_filter_robots_meta’ ); function aioseo_filter_robots_meta( $attributes ) { if ( is_singular() ) { $attributes[‘noindex’] = ‘index’; $attributes[‘nofollow’] = ‘nofollow’; } return $attributes; }Continue reading