admin管理员组文章数量:1384286
I've made a simple plugin to style the WP default backend.
<?php
/*
Plugin Name: Admin CSS
Description: Custom Admin style. Made by LOOT
Author: LOOT
Version: 1.2
Author URI:
*/
function admin_theme() {
wp_enqueue_style('admin_theme', plugins_url('adminstyle.css', __FILE__));
}
function topbarstyle() {
wp_enqueue_style('topbarstyle', plugins_url('topbarstyle.css', __FILE__));
}
add_action('admin_enqueue_scripts', 'admin_theme');
add_action('login_enqueue_scripts', 'admin_theme');
add_action('admin_enqueue_scripts', 'topbarstyle');
add_action('wp_head', 'topbarstyle' );
?>
Then I have a bunch of CSS files and some colours defined in the topbarstyle.css like this:
/* General Colours */
:root {
--color1: #f5f5f5;
--color2: #d8d7da;
--color-accent: #2748f3;
--color-dark: #23282d;
}
I'd want to implement a settings page where those colours can be modified. I'm a total newbie in PHP and I'm trying to find resources, but thought I'd ask this over here as well Thanks!
I've made a simple plugin to style the WP default backend.
<?php
/*
Plugin Name: Admin CSS
Description: Custom Admin style. Made by LOOT
Author: LOOT
Version: 1.2
Author URI: http://weareloot
*/
function admin_theme() {
wp_enqueue_style('admin_theme', plugins_url('adminstyle.css', __FILE__));
}
function topbarstyle() {
wp_enqueue_style('topbarstyle', plugins_url('topbarstyle.css', __FILE__));
}
add_action('admin_enqueue_scripts', 'admin_theme');
add_action('login_enqueue_scripts', 'admin_theme');
add_action('admin_enqueue_scripts', 'topbarstyle');
add_action('wp_head', 'topbarstyle' );
?>
Then I have a bunch of CSS files and some colours defined in the topbarstyle.css like this:
/* General Colours */
:root {
--color1: #f5f5f5;
--color2: #d8d7da;
--color-accent: #2748f3;
--color-dark: #23282d;
}
I'd want to implement a settings page where those colours can be modified. I'm a total newbie in PHP and I'm trying to find resources, but thought I'd ask this over here as well Thanks!
Share Improve this question asked Apr 30, 2020 at 17:50 StephSteph 1213 bronze badges1 Answer
Reset to default 0This should get you started. Once you're more confident in plugin design I recommend using plugin boiler-plates you can create for free here: https://wppb.me/ They'll look pretty scary at first but as you gain confidence and knowledge, you won't be able to live without them.
Note: this is me just typing, expect typos.
function My_Cool_Menu() {
$icon_url = plugin_dir_url(__FILE__) . 'images/MyMenuIcon.png';
add_menu_page('My Cool Page Title', 'My Cool Menu Title', 'edit_posts',
'MyPluginSlug', 'My_Cool_Plugin_main_menu', $icon_url);
}
function My_Cool_Plugin_main_menu() {
//create your html admin menus, buttons and such in this file
include_once( 'MyCoolAdminPage.php' );
}
add_action('admin_menu', 'My_Cool_Menu');
edit and be sure you learn all about nonces!
本文标签: How can I create a simple interface for my WP plugin
版权声明:本文标题:How can I create a simple interface for my WP plugin? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744516253a2610177.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论