wordpress 自定义

tech2023-01-22  62

wordpress 自定义

WordPress is one of the web’s most popular Content Management Systems. The appeal is obvious: it’s flexible, it’s easy to create custom templates, it offers a huge quantity of plugins, hundreds of themes are available, the application is open source and it’s free. It’s also relatively simple for clients to understand — that’s one of the main reasons I use it.I recently posted the article Do Your Clients Use Their CMS? I concluded that many CMSs can be daunting, appear technical, use jargon, or offer too many superfluous options. WordPress may be one of easier systems but it could be simplified further. Fortunately, we can address many issues with a little PHP magic.In this series of articles we’ll implement several options to make WordPress easier for your clients. You can probably find plugins to achieve the same thing, but this code is easy, flexible, and won’t need to be updated (unless you want to make updates yourself).

WordPress是网络上最流行的内容管理系统之一。 吸引力显而易见:它灵活,创建自定义模板容易,提供大量插件,数百个主题可用,应用程序是开源的且免费。 对于客户而言,它也相对容易理解-这是我使用它的主要原因之一。我最近发布了文章“您的客户使用他们的CMS吗? 我得出的结论是,许多CMS可能令人生畏,出现技术问题,使用行话或提供太多多余的选择。 WordPress可能是更简单的系统之一,但可以进一步简化。 幸运的是,我们可以通过一点PHP魔术来解决许多问题。在本系列文章中,我们将实现几个选项,以使WordPress更易于您的客户使用。 您可能可以找到实现相同功能的插件,但是此代码简单,灵活,不需要更新(除非您想自己进行更新)。

functions.php (functions.php)

The following WordPress modifications change your theme’s functions.php file. This file is optional and it’s automatically loaded when you view an administration page or the website itself. The file is normally used to define regularly-used template functions, but it can also implement plugin-like behavior.Since functions.php is activated with your theme, it’s easy to distribute between WordPress installations without having to download, enable or update plugins. If your current theme does not contain a functions.php file, simply create one and add PHP delimiters:

以下WordPress修改更改了主题的functions.php文件。 该文件是可选的,在您查看管理页面或网站本身时会自动加载。 该文件通常用于定义常规使用的模板功能,但它也可以实现类似插件的行为。由于functions.php是用您的主题激活的,因此可以轻松地在WordPress安装之间分发,而无需下载,启用或更新插件。 如果您当前的主题不包含functions.php文件,则只需创建一个并添加PHP分隔符即可:

<?php// code will go here?> tip: PHP delimiters 提示: PHP分隔符

The closing “?>” isn’t strictly necessary and many PHP developers will tell you that it shouldn’t be used — but that’s a topic for another article!

并不是必须要以“?>”结尾,许多PHP开发人员会告诉您不应使用它-但这是另一篇文章的主题!

更改WordPress登录徽标 (Changing the WordPress login logo)

There’s nothing wrong with the WordPress logo, but few clients will care what CMS they’re using. Why not use their logo or branding?The logo file is /wp-admin/images/logo-login.gif. Although you can remove or change that file, it will reappear whenever you update WordPress. Here’s a better solution:1. Create/obtain your client’s logoIt’s best to resize the image so it’s no larger than 326 x 82 pixels. Copy the image file to your theme folder — in the following code, we’ll assume it’s named logo.png.2. Update your theme’s function.php filePlace the following code in function.php to change the default logo. Remember to modify the logo.png file reference if you named it differently.

WordPress徽标没有错,但是很少有客户会关心他们使用的CMS。 为什么不使用其徽标或商标?徽标文件为/wp-admin/images/logo-login.gif。 尽管您可以删除或更改该文件,但是只要您更新WordPress,它就会重新出现。 以下是一个更好的解决方案: 1.创建/获取客户的徽标最好调整图像大小,使其不大于326 x 82像素。 将图像文件复制到您的主题文件夹中-在以下代码中,我们假设其名为logo.png 。 2.更新主题的function.php文件将以下代码放在function.php中,以更改默认徽标。 如果命名不同,请记住修改logo.png文件引用。

// login page logofunction custom_login_logo() { echo '<style type="text/css">h1 a { background: url('.get_bloginfo('template_directory').'/logo.png) 50% 50% no-repeat !important; }</style>';}add_action('login_head', 'custom_login_logo');

删除WordPress更新通知 (Removing WordPress update notifications)

The WordPress administration panels inform you when a new version is available. Unfortunately, it tells everyone — including your clients. That could lead to unnecessary concern or persuade them contact you every half an hour until the update is applied.Add the following code to your theme’s functions.php file to disable the update notification for everyone except WordPress administrators:

当有新版本可用时,WordPress管理面板会通知您。 不幸的是,它告诉所有人-包括您的客户。 这可能导致不必要的担忧,或者说服他们每半小时与您联系,直到应用更新为止。将以下代码添加到主题的functions.php文件中,以禁用除WordPress管理员以外的所有用户的更新通知:

// remove upgrade notificationfunction no_update_notification() { remove_action('admin_notices', 'update_nag', 3);}if (!current_user_can('edit_users')) add_action('admin_notices', 'no_update_notification', 1);

I hope you found those two examples useful. Further WordPress simplification ideas are available now…

希望您发现这两个示例有用。 进一步的WordPress简化想法现在可用…

翻译自: https://www.sitepoint.com/make-wordpress-easier-for-clients-branding/

wordpress 自定义

最新回复(0)