Title: SitePoint Random Hello Bar
Author: sitepointdevs
Published: <strong>2016 年 1 月 21 日</strong>
Last modified: 2016 年 1 月 22 日

---

搜索插件

![](https://ps.w.org/sp-random-hello-bar/assets/banner-772x250.png?rev=1333316)

**该插件尚未通过WordPress的最新3个主要版本进行测试**。 当与较新版本的WordPress一起
使用时，可能不再受到维护或支持，并且可能会存在兼容性问题。

![](https://ps.w.org/sp-random-hello-bar/assets/icon-256x256.png?rev=1333316)

# SitePoint Random Hello Bar

 作者：[sitepointdevs](https://profiles.wordpress.org/sitepointdevs/)

[下载](https://downloads.wordpress.org/plugin/sp-random-hello-bar.1.0.1.zip)

 * [详情](https://cn.wordpress.org/plugins/sp-random-hello-bar/#description)
 * [评价](https://cn.wordpress.org/plugins/sp-random-hello-bar/#reviews)
 *  [安装](https://cn.wordpress.org/plugins/sp-random-hello-bar/#installation)
 * [开发进展](https://cn.wordpress.org/plugins/sp-random-hello-bar/#developers)

 [支持](https://wordpress.org/support/plugin/sp-random-hello-bar/)

## 描述

As descibed in-depth on [SitePoint](http://www.sitepoint.com/sitepoint-random-hello-bar-wordpress-plugin/)
a hello bar is a thin bar of content that slides into view once the user scrolls
past a set point on a page.
 The message content is up to you, but is ideal for 
advertising, product annoncements or other messages.

This plugin provides an admin interface to create multiple hello bar messages that
can then be randomly displayed on user facing pages.

By setting weightings for each message you can determine how often each is displayed.
On each page load a message is randomly selected
 (respecting the weightings given).
A random number is generated client side before fetching the message content to 
ensure it is compatible with caching services such as W3 Total Cache.

All the required javascript and css is included in the plugin and can be set to 
enqueue via settings.
 Alternatively you can roll your own. To help with that the
core javascript has been extracted into the [sp-hello-bar](https://www.npmjs.com/package/sp-hello-bar)
npm module for you to include in your own scripts.

## 屏幕截图

[⌊Hello Bar in use - An example hello bar being displayed on the Twenty Fifteen 
theme.⌉⌊Hello Bar in use - An example hello bar being displayed on the Twenty Fifteen
theme.⌉[

**Hello Bar in use** – An example hello bar being displayed on the Twenty Fifteen
theme.

[⌊SP Random Hello Bar Submenu⌉⌊SP Random Hello Bar Submenu⌉[

**SP Random Hello Bar Submenu**

[⌊Settings - Quickly enable the hello bar feature and chose what js/css to enqueue.⌉⌊
Settings - Quickly enable the hello bar feature and chose what js/css to enqueue
.⌉[

**Settings** – Quickly enable the hello bar feature and chose what js/css to enqueue.

[⌊Content - Add as many hello bars as you wish.⌉⌊Content - Add as many hello bars
as you wish.⌉[

**Content** – Add as many hello bars as you wish.

## 安装

 1. Upload the entire `/sp-random-hello-bar/` folder to the `/wp-content/plugins/` 
    directory.
 2. 通过 WordPress 的“插件”菜单以激活本插件。
 3. Navigate to the **SP Random Hello Bar** section of the _Settings_ menu. At `example.
    com` this page would be found at `http://example.com/wp-admin/options-general.php?
    page=sp-random-hello-bar`.
 4. Enable the hello bar to display in pages.
 5. Select which javascript, if any, you would like to enqueue.
 6. Select if you would like to enqueue basic css styles fror the hello bar.
 7. Enter content for one or more hello bars and set a weighting.

## 常见问题

  Can I use the javascript module without npm?

Sure. The plugin contains the SpHelloBar source as an ES6 Module at `src/js/SpHelloBar.
js` and as a common.js module at `lib/SpHelloBar.js`.

  Does the javascript require other libraries such as jQuery to function?

The SpHelloBar module does not have any external dependencies but it would then 
be up to you to provide a throttle function and to load the hello bar content into
the page (usually via ajax).
 However the Basic and Basic with storage scripts assume
that jquery and underscore have been enqueued. Those two libraries are enqueued 
in the default setup of WordPress unless you have dequeued them.

  Can I customise the content?

Go for it. The basic scripts assume the default css class names are being used but
the only one that is required is `.SpHelloBar`.
 The javascript has been designed
to be as flexible as possible so see the [docs](https://github.com/sitepoint/sp-random-hello-bar#constructor)
for all the options that can be overridden when writing your own script.

  How did you build something so wonderful?

I’m glad you asked. You can read about how it was put together on [SitePoint](http://www.sitepoint.com/sitepoint-random-hello-bar-wordpress-plugin/).

## 评价

此插件暂无评价。

## 贡献者及开发者

「SitePoint Random Hello Bar」是开源软件。 以下人员对此插件做出了贡献。

贡献者

 *   [ sitepointdevs ](https://profiles.wordpress.org/sitepointdevs/)

[帮助将「SitePoint Random Hello Bar」翻译成简体中文。](https://translate.wordpress.org/projects/wp-plugins/sp-random-hello-bar)

### 对开发感兴趣吗?

您可以[浏览代码](https://plugins.trac.wordpress.org/browser/sp-random-hello-bar/)，
查看[SVN仓库](https://plugins.svn.wordpress.org/sp-random-hello-bar/)，或通过[RSS](https://plugins.trac.wordpress.org/log/sp-random-hello-bar/?limit=100&mode=stop_on_copy&format=rss)
订阅[开发日志](https://plugins.trac.wordpress.org/log/sp-random-hello-bar/)。

## 更新日志

#### 0.0.1

 * Submitted to WordPress for approval

#### 0.0.2

 * Added assets

#### 1.0.0

 * Ready for use

## 额外信息

 *  版本 **1.0.1**
 *  最后更新：**10 年前**
 *  活跃安装数量 **10+**
 *  WordPress 版本 ** 3.0 或更高版本 **
 *  已测试的最高版本为 **4.3.34**
 *  语言
 * [English (US)](https://wordpress.org/plugins/sp-random-hello-bar/)
 * 标签
 * [ads](https://cn.wordpress.org/plugins/tags/ads/)[advertising](https://cn.wordpress.org/plugins/tags/advertising/)
   [marketing](https://cn.wordpress.org/plugins/tags/marketing/)[products](https://cn.wordpress.org/plugins/tags/products/)
 *  [高级视图](https://cn.wordpress.org/plugins/sp-random-hello-bar/advanced/)

## 评级

尚未提交反馈。

[Your review](https://wordpress.org/support/plugin/sp-random-hello-bar/reviews/#new-post)

[查看全部评论](https://wordpress.org/support/plugin/sp-random-hello-bar/reviews/)

## 贡献者

 *   [ sitepointdevs ](https://profiles.wordpress.org/sitepointdevs/)

## 支持

有话要说吗？是否需要帮助？

 [查看支持论坛](https://wordpress.org/support/plugin/sp-random-hello-bar/)