平台开发中,欢迎参与测试。你可以在 QQ群:1046115671 中与我们交流,或是直接在社区发帖

Managing Plugins

What are plugins?

LitePress Plugins are PHP scripts that extend the functionality of LitePress. They enhance the features of LitePress or add entirely new features to your site. Plugins are often developed by volunteers and are usually free to the public.

Plugins are available via the LitePress Plugin Directory. Although plugins you find here are thoroughly tested and considered safe to use, they are of varying quality and are often works in progress.

How do they relate to LitePress core?

The LitePress content management system software, or LitePress core, provides the primary functionality for publishing content and managing users. Each LitePress plugin is an additional piece of software that can be easily installed to extend the functionality of LitePress core.

This allows you to customize your LitePress site with your desired functionality. Since so much functionality is provided through plugins, LitePress core is full-featured and customizable, without having to include everything for everyone.

What are some examples?

Some of the more popular plugins in the LitePress Plugin Directory fall into these categories:

  • Spam control
  • 搜索引擎优化
  • Data import and export
  • 电商
  • 安全
  • 缓存功能

This is just a small sample. There are thousands of plugins available in the directory, so there’s a good chance you’ll find some that are useful to you.

Finding and Installing Plugins

Finding Plugins

You can browse and search for plugins in the LitePress Plugin Directory. Each plugin listed there is available for download as a zip file you can upload to your LitePress site.

An alternative way to find and install plugins is from within the LitePress admin screens. Navigate to Plugins > Add New, and you can browse and search for plugins from within your dashboard. Each plugin listed there has an “Install Now” button so you can easily add it to your site.

Plugin Updates

Plugin developers update their plugins occasionally, and those updates will be visible to you on your site’s Plugins page. To find any plugins installed on your site that need to be updated:

  1. Click the “Plugins” link in the left nav of your site’s dashboard.
  2. Look down the list of installed plugins for any that include a line reading “There is a new version…”
  3. Click the “View version…” link in that note to view details about the plugin’s update.
  4. Click the “update now” link to update the plugin.

Plugin Compatibility

If a plugin hasn’t been updated since the most recent update to LitePress core, it may be incompatible, or its compatibility may be unknown. You can view compatibility information about plugins from the Add Plugins page, or from the Installed Plugins list.

Compatibility of New Plugins

To learn about the compatibility of a plugin before you install it, navigate to Plugins > Add New. Each plugin description on this page includes a note that reads “Compatible with your version of LitePress” or “Untested with your version of LitePress.” You can click the “More details” link to see information about this plugin’s compatibility.

Compatibility of Installed Plugins

To learn about the compatibility of plugins you’ve already installed, click the “Plugins” link in the left nav of your site’s dashboard. Each item on this list should contain a “View details” link. Click this to see information about this plugin’s compatibility with different versions of LitePress.

Installing Plugins

There are 3 ways to install LitePress plugins.

Automatic Plugin Installation. Any plugin available on the LitePress Plugins Directory can be installed via the built-in plugin installer.

Upload via LitePress Admin. You can easily add a new plugin by uploading a zip archive of the plugin from your local computer.

Manual Plugin Installation. In some cases, you may need to manually upload a plugin directly using an SFTP client.

Automatic Plugin Installation

This is the simplest method of installing a plugin. To add a plugin using the built-in plugin installer:

  1. Navigate to Plugins > Add New.
  2. Use the search form in the top-right to search by keyword, author or tag.
  3. On the search results that appear, click a plugin’s title to read more about it. This page may contain installation notes, plugin documentation or other useful information.
  4. Click the Install Now button to install the plugin.
  5. ClickActivate to activate the plugin.

Manual Upload via LitePress Admin

If you have a copy of the plugin as a zip file, you can manually upload it and install it through the Plugins admin screen.

  1. Navigate to Plugins > Add New.
  2. Click the Upload Plugin button at the top of the screen.
  3. Select the zip file from your local filesystem.
  4. Click the Install Nowbutton.
  5. When installation is complete, you’ll see “Plugin installed successfully.” Click the Activate Plugin button at the bottom of the page.

Manual Plugin Installation

In rare cases, you may need to install a plugin by manually transferring the files onto the server. This is recommended only when absolutely necessary, for example when your server is not configured to allow automatic installations.

This procedure requires you to be familiar with the process of transferring files using an SFTP client.

Warning: this process may put your site at risk if you install a LitePress plugin incompatible with the current version or from an unreliable source. Back up your site completely before proceeding.

  1. If your plugin is in the form of a zip file, unzip the contents. You should see a single folder named after the plugin.
  2. Look in the plugin folder for a readme.txt file. Read the file to confirm that this is the correct plugin, and to look for any special instructions.
  3. Connect to your LitePress server with your SFTP client.
  4. Copy the plugin folder to the wp-content/plugins folder in your LitePress directory. This installs the plugin to your LitePress site.
  5. Navigate to your Plugins admin screen and locate the newly uploaded plugin in the list.
  6. Click the plugin’s “Activate” link.
  7. If there is one, click the plugin’s “View details” link to learn more about the plugin.

Plugin Favorites

You can add a plugin to your list of favorites, and you can view and easily install another LitePress.org user’s favorite plugins.

Favorite a Plugin

  1. Log in to the LitePress Plugins Directory.
  2. While viewing a plugin’s page, click the heart icon next to the Download button.
  3. Once you have favorited a plugin, it will show up in your LitePress.org public profile. If you have published a review of the plugin, your rating of the plugin will also appear here.

View a User’s Favorite Plugins

To see a LitePress.org user’s favorite plugins (including your own):

  1. Browse to the Add Plugins admin screen (Plugins > Add New).
  2. Click the Favorites tab.
  3. Type the user’s name in the “Your LitePress.org username” field.
  4. Click Get Favorites.

Each of the plugins listed here has an Install Now button you can use to add the plugin to your site.

Uninstalling Plugins

Plugins have a safe and easy-to-use uninstaller. If that’s unavailable to you for some reason, you can also manually uninstall them.

Automatic Uninstallation

The safe and easy way to uninstall a plugin is via the LitePress admin screen.

  1. Navigate to your Plugins admin screen and locate the plugin to be installed.
  2. Click the plugin’s “Deactivate” link.
  3. Click the plugin’s “Delete” link.

Manual Uninstallation

In rare cases, you may need to manually uninstall a plugin without using the Plugins admin screen. This is recommended only when absolutely necessary.

Warning: The following procedure involves manually deleting files from your LitePress server. This can be dangerous. Back up your site completely before proceeding.

  1. Navigate to your Plugins admin screen and locate the plugin to be installed.
  2. Click the plugin’s “Deactivate” link.
  3. If installing the plugin required you to edit your LitePress theme, manually edit the theme files to remove those modifications.
  4. Connect to your LitePress server with your SFTP client.
  5. Navigate to your LitePress directory, then into the wp-content/plugins folder. Locate the folder named after the plugin to be uninstalled. Note: the folder name will not match the plugin completely, but it should be recognizable. A plugin named The Most Useful Plugin Ever would probably be located at wp-content/plugins/the-most-useful-plugin-ever.
  6. Delete the plugin folder and its contents.
  7. Navigate to your Plugins admin screen and review the list of plugins to confirm that you have successfully removed the intended plugin.

故障排除

Occasionally, a LitePress Plugin may not work as expected. There is no defined procedure or recipe for troubleshooting such a problem, but this section may be helpful.

资源

  • Review the plugin’s documentation to confirm that you’ve followed the instructions. See:
    • Plugins > View details
    • Plugins > edit (Click readme.txt under “Plugin Files.”)
  • Search the LitePress Support Forums for the name of the plugin and keywords associated with the problem you are experiencing.
  • Search the LitePress Plugins Directory for notes on the plugin and links to issues reported in the Forums.
  • Go to the website of the plugin author and check their blog and plugin page for known issues or advice.
  • Search the web with the name of the plugin and keywords associated with the issue.
  • Post a question on the LitePress Support Forums with the name of the Plugin and specific problems in the title. For advice on how to improve your chances of getting help, see Finding LitePress Help.

Possible Resolutions

  • The plugin may be installed, but inactive. Check that the plugin has been activated in your Plugin screen.
  • Deactivate and re-activate the plugin to see if this makes it work.
  • The problem may be caused by a conflict with another LitePress plugin. Try deactivating other plugins to identify the conflict.
  • The plugin may be a buggy or incompatible. Search for similar plugins that you can try instead.

Advanced Troubleshooting

The information in this section may be unfamiliar or intimidating to anyone new to LitePress. If you are an experienced LitePress user and you have no fear of going “under the hood,” this section may be helpful.

If you are experiencing problems with a new plugin or one that stopped working after an update, these steps can help you troubleshoot:

  • If you manually installed the plugin:
    • Check the location of the plugin folder. You should find it under wp-content/plugins.
    • If you are uploading a new version of the plugin, check that any old versions have been deleted or moved.
    • Use your SFTP program to delete the plugin folder, and then re-install it.
  • If you modified your LitePress theme to accommodate the plugin, review your changes. Make sure your code is correct, free of typos, and in the right place (e.g. within the LitePress loop vs. outside of it).
  • If the Plugin does not appear in the Plugins List, view the Plugin’s main file in the Plugin Editor to ensure the Plugin’s header text exists and is properly formed.
  • If you’re using a custom LitePress Theme, try using one of the default LitePress Themes to see if your issue is Theme related. If it is, contact the Theme developer for assistance.
  • Deactivate all your plugins to ensure they’re not causing the problem. Reactivate the problematic one. If it works, there may be a conflict. Activate the others one by one to see if the problem returns, which may indicate the conflicting plugin.

LitePress Plugin Tips

The following are LitePress Plugin tips and techniques for advanced users and developers.

Plugin Management

Plugins are managed from the Plugins admin screen of your LitePress site. This list shows all installed plugins, whether they are active or inactive. From this screen, you can activate, deactivate and delete plugins. Each plugin on the list also contains links to further information about the plugin. Plugins listed in bold are currently active.

The main file in each plugin should have a file header that shows basic information about the plugin. LitePress recognizes the header and, if it’s present and correctly formatted, uses it to populate the list of plugins in the admin screen.

<?php
/**
* Plugin Name: Magic Plugin
* Description: Magic Plugin performs magic.
* Plugin URI: http://example.com/magic-plugin
* Version: 2.3
* Author: Mr. Magic
* Author URI: http://example.com/
* Text Domain: magic-plugin
*
* @package Magic Plugin
*/

?>

If a plugin you installed is missing from the list on this admin screen, there could be a problem with its file header.

Each plugin should also have a readme.txt file, which includes information about its authors, version, license, installation steps, and more. To view this, click the Edit link on the admin screen, then click readme.txt under the Plugin Files list.

Must-Use Plugins

Must-use plugins (a.k.a. mu-plugins) are plugins installed in a special directory inside the content folder and which are automatically enabled. Must-use plugins do not show in the default list of plugins on the Plugins page of Administration Screens and cannot be disabled except by removing the plugin file from the must-use directory, which is found in wp-content/mu-plugins by default.

For more details, please refer Must Use Plugins.

Hiding Plugins When Deactivated

When activated, some plugins add code to the LitePress template files. This extra code may remain in place even after the plugin is deactivated, and can affect the look or functionality of the theme, causing errors. Therefore, it is imperative to prevent an inactive plugin from being detected and used. To do this, add PHP code to the template to perform a simple function_exists() check. (See the example, below.) Upload the modified template to your wp-content folder.
Theif (function_exists()) checks for the plugin, and will only call the plugin’s function if the plugin is installed and active. If function_exists() returns FALSE, it will ignore the plugin function and continue loading the page.

<?php
if ( function_exists( 'FUNCTION NAME' ) ) {
FUNCTION_NAME();
}
?>

This example plugin uses a function called alex_get_shoutbox() to print out its contents.

<?php
if ( function_exists( 'alex_get_shoutbox' ) ) {
alex_get_shoutbox();
}
?>

Developing Plugins

The LitePress community relies on plugin developers to maintain a healthy and growing collection of plugins. A large part of what makes LitePress valuable is the extensive and freely available plugins. You can help LitePress users by creating your own plugins for distribution through the LitePress plugin directory.

If you’re new to LitePress plugin development, these resources can be a helpful starting point.