درج CSS و JS اختصاصی در قسمت wp-admin وردپرس
يكشنبه, ۲۴ مهر ۱۴۰۱، ۱۰:۵۸ ق.ظ
سلام
با تکه کد فوق می توان استایل های مد نظرمون را در بخش مدیریت وردپرس اعمال کرد:
add_action('admin_head', 'my_custom_fonts');
function my_custom_fonts() {
echo '<style>
body, td, textarea, input, select {
font-family: "Lucida Grande";
font-size: 12px;
}
</style>';
}
نمونه کد زیر چک میکند که اگر کاربر لاگین شده، نام کاربریش برابر بود با saeed، یکسری منوها و امکانات رو از طریق CSS مخفی کن:
global $current_user; get_currentuserinfo();
echo 'نام کاربری: ' . $current_user->user_login . "\n";
if ($current_user->user_login =="saeed"){
function my_custom_in_user_hide_elements() {
echo '<style>
tr.form-field.term-slug-wrap ,
tr.form-field.term-parent-wrap,
div#wp-html-tag-description-media-buttons,
tr.form-field.term-display-type-wrap,
tr.form-field.term-thumbnail-wrap,
.xts-options.xts-metaboxes,
li#menu-settings,
li#wp-admin-bar-elementor_edit_page ,
li#menu-posts-cms_block ,
a.wp-has-submenu.wp-not-current-submenu.menu-top.menu-icon-portfolio ,
li#toplevel_page_woocommerce ,
li#toplevel_page_elementor ,
li#toplevel_page_xtemos_options ,
#menu-tools ,
#menu-users ,
#menu-posts-woodmart_sidebar ,
.wp-menu-image.dashicons-before.dashicons-admin-appearance ,
#toplevel_page_woocommerce-marketing ,
#toplevel_page_wc-admin-path--analytics-overview ,
#menu-appearance ,
#menu-posts-woodmart_layout ,
#toplevel_page_wpcf7 ,
#menu-media ,
#menu-posts ,
#menu-pages ,
#menu-comments ,
#menu-posts-elementor_library ,
#menu-posts-portfolio ,
#menu-posts-woodmart_size_guide ,
#wp-admin-bar-new-content ,
#wp-admin-bar-comments ,
#setting-error-tgmpa ,
.notice.notice-error ,
.row-actions .delete ,
.row-actions span.inline.hide-if-no-js ,
.row-actions span.make_default ,
.form-wrap ,
li#menu-posts-product ul.wp-submenu.wp-submenu-wrap li:nth-child(2),
li#menu-posts-product ul.wp-submenu.wp-submenu-wrap li:nth-child(3),
li#menu-posts-product ul.wp-submenu.wp-submenu-wrap li:nth-child(5),
li#menu-posts-product ul.wp-submenu.wp-submenu-wrap li:nth-child(6),
li#menu-posts-product ul.wp-submenu.wp-submenu-wrap li:nth-child(7) ,
.edit-tag-actions #delete-link
{
display: none !important;
}
</style>';
}
add_action('admin_head', 'my_custom_in_user_hide_elements');
}
۰۱/۰۷/۲۴