سفارشی سازی مدیریت وردپرس (۲) – صفحه پیشخوان

16 اردیبهشت 1393 | آموزش وردپرس | 0 comments

در این قسمت می خواهیم صفحه پیشخوان رو برای مشتری سفارشی کنیم . اغلب کاربران در مواجهه با وردپرس برای مرتبه اول اون رو بسیار شلوغ و سخت می بینند . اما با انجام این تنظیمات شما می تونید این مشکل رو حل کنید .

برای این کار یک افزونه درست می کنیم تا در هر سایتی که خواستید استفاده کنید .

۱-ساخت افزونه :

یه فایل به نام wp-custom-dash.php درست کنید و کد زیر رو اولش بگذارید  این کد افزونه رو معرفی می کنه .

/*
Plugin Name: WPTutsPlus Customize the Admin Part 2 - The Dashboard
Plugin URI: http://rachelmccollin.co.uk
Description: This plugin supports the tutorial in WPTutsPlus. It customizes the WordPress dashboard.
Version: 1.0
Author: Rachel McCollin
Author URI: http://rachelmccollin.com
License: GPLv2
*/

 

۲-حذف اضافات

حالا در این مرحله می خواهیم متاباکس های اضافی رو حذف کنیم . پس کد زیر رو می گذاریم :

// remove unwanted dashboard widgets for relevant users
function wptutsplus_remove_dashboard_widgets() {
$user = wp_get_current_user();
if ( ! $user->has_cap( 'manage_options' ) ) {
remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' );
remove_meta_box( 'dashboard_primary', 'dashboard', 'side' );
remove_meta_box( 'dashboard_secondary', 'dashboard', 'side' );
}
}
add_action( 'wp_dashboard_setup', 'wptutsplus_remove_dashboard_widgets' );

پیشخوان خیلی خلوت شد نه ؟‌!!

۳- تنظیم چیدمان

خب حالا چیدمان باکس ها رو تغییر میدیم .
// Move the 'Right Now' dashboard widget to the right hand side
function wptutsplus_move_dashboard_widget() {
$user = wp_get_current_user();
if ( ! $user->has_cap( 'manage_options' ) ) {
global $wp_meta_boxes;
$widget = $wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now'];
unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now'] );
$wp_meta_boxes['dashboard']['side']['core']['dashboard_right_now'] = $widget;
}
}
add_action( 'wp_dashboard_setup', 'wptutsplus_move_dashboard_widget' );

 

۴-متاباکس جدید بسازیم

حالا یه متاباکس جدید ایجاد می کنیم تا مطالب مورد نظرمون رو توش بنویسیم . مثل آدرس سایتمون و شماره پشتیبانی و …
// add new dashboard widgets
function wptutsplus_add_dashboard_widgets() {
wp_add_dashboard_widget( 'wptutsplus_dashboard_welcome', 'Welcome', 'wptutsplus_add_welcome_widget' );
wp_add_dashboard_widget( 'wptutsplus_dashboard_links', 'Useful Links', 'wptutsplus_add_links_widget' );
}
function wptutsplus_add_welcome_widget(){ ?>This content management system lets you edit the pages and posts on your website.Your site consists of the following content, which you can access via the menu on the left:
<ul>
<li><strong>Pages</strong> - static pages which you can edit.</li>
<li><strong>Posts</strong> - news or blog articles - you can edit these and add more.</li>
<li><strong>Media</strong> - images and documents which you can upload via the Media menu on the left or within each post or page.</li>
</ul>

On each editing screen there are instructions to help you add and edit content.

<?php }

function wptutsplus_add_links_widget() { ?>

Some links to resources which will help you manage your site:

<ul>
<li><a href="http://wordpress.org">The WordPress Codex</a></li>
<li><a href="http://easywpguide.com">Easy WP Guide</a></li>
<li><a href="http://www.wpbeginner.com">WP Beginner</a></li>
</ul>
<?php }
add_action( 'wp_dashboard_setup', 'wptutsplus_add_dashboard_widgets' );

می تونید تمام این کدها رو به جز قسمت اول توی فایل function.php قالبتون کپی کنید . اما اگه تو سایتای مختلفی می خواید این کار رو انجام بدید پیشنهاد می کنم افزونشو برای خودتون درست کنید .
به همین سادگی ! چطور بود ؟

منبع

0
افکار شما را دوست داریم، لطفا نظر دهید.x