Skip to content

Instantly share code, notes, and snippets.

View denishvachhani's full-sized avatar
🏠
Working from home

Denish denishvachhani

🏠
Working from home
View GitHub Profile
@denishvachhani
denishvachhani / function.php
Last active December 18, 2015 08:48
Remove “Add New” link from custom post type
<?php
function remove_submenus() {
if(!current_user_can('activate_plugins')) {
global $submenu;
unset($submenu['edit.php?post_type=your_custom_post-type'][10]); // Removes 'Add New'.
}
}
add_action('admin_menu', 'remove_submenus');
function hide_that_stuff() {
@denishvachhani
denishvachhani / function.php
Last active December 18, 2015 08:49
Use Google font in Genesis Child Theme
<?php
//* Load Marmelad Google fonts
add_action( 'wp_enqueue_scripts', 'custom_load_google_fonts' );
function custom_load_google_fonts() {
wp_enqueue_style( 'google-font', 'http://fonts.googleapis.com/css?family=Marmelad', array(), PARENT_THEME_VERSION );
}
?>
@denishvachhani
denishvachhani / function.php
Created June 12, 2013 13:35
Disable/Hide Certain Payment method like ( cod, paypal, etc..) for certain country.
<?php
// Note for %payment-code%
// CashonDeliver = 'cod'
// PayPal = 'paypal'
// Basic Payment = 'bacs'
// Cheque payment = 'cheque'
// Mijireh Gatway = 'mijireh_checkout'
// Note for %countrycode%
// India = 'IN'
@denishvachhani
denishvachhani / template.php
Last active December 19, 2015 22:19
Get page content, at any place of theme/plugins
<?php
$id=47; // Id of your Page/Post/CustomPost type
$post = get_page($id);
$content = apply_filters('the_content', $post->post_content);
echo $content;
?>
@denishvachhani
denishvachhani / function.php
Last active December 20, 2015 08:49
Hide Dashboard for all except admin WITHOUT PLUGIN !
<?php
function remove_the_dashboard () {
if (current_user_can('level_10')) {
return;
} else {
global $menu, $submenu, $user_ID;
$the_user = new WP_User($user_ID);
reset($menu); $page = key($menu);
while ((__('Dashboard') != $menu[$page][0]) && next($menu))
$page = key($menu);
@denishvachhani
denishvachhani / function.php
Last active January 27, 2020 16:33
Remove Dashboard Widgets in Wordpress Backend
<?php
add_action('wp_dashboard_setup', 'remove_dashboard_widgets');
if( !function_exists('remove_dashboard_widgets') ) :
/**
*
*/
function remove_dashboard_widgets() {
remove_meta_box('dashboard_incoming_links', 'dashboard', 'normal'); // Incoming Links
remove_meta_box('dashboard_plugins', 'dashboard', 'normal'); // Plugins
@denishvachhani
denishvachhani / function.php
Last active December 20, 2015 08:49
Hide Admin Menus
<?php
add_action('admin_menu', 'remove_menu_items');
if( !function_exists('remove_menu_items') ) :
/**
*
*/
function remove_menu_items() {
global $menu;
$restricted = array(__('Links'), __('Comments'),
@denishvachhani
denishvachhani / cloudSettings
Last active May 29, 2021 15:20
Deactivate some menu, sub-menu or/and buttons of the admin bar
{"lastUpload":"2021-05-29T15:19:59.018Z","extensionVersion":"v3.4.3"}
@denishvachhani
denishvachhani / removeproduct.sql
Created March 26, 2014 06:23
How to remove all catalog products in Magento?
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE `catalog_product_bundle_option`;
TRUNCATE TABLE `catalog_product_bundle_option_value`;
TRUNCATE TABLE `catalog_product_bundle_selection`;
TRUNCATE TABLE `catalog_product_entity_datetime`;
TRUNCATE TABLE `catalog_product_entity_decimal`;
TRUNCATE TABLE `catalog_product_entity_gallery`;
TRUNCATE TABLE `catalog_product_entity_int`;
TRUNCATE TABLE `catalog_product_entity_media_gallery`;
TRUNCATE TABLE `catalog_product_entity_media_gallery_value`;
@denishvachhani
denishvachhani / mageissku.php
Last active August 29, 2015 13:57
Magento – How to Check if the SKU is Exist?
<?php
$sku = 'Your Product Sku';
$id = Mage::getModel('catalog/product')->getIdBySku($sku);
if ($id){
echo "SKU {$sku} exists";
}
else{
echo "SKU {$sku} does not exist";
}
?>