[wordpress插件] Beta Flags … now with A/B Testing!Beta标志…现在具有A / B测试功能!

wordpress 插件 文章 2020-03-03 14:10 491 0 全屏看文

AI助手支持GPT4.0

评分
0
描述

Beta Flags allow developers to manage the release of new features.

测试版标志允许开发人员管理新功能的发布。

Instead of having code execute as soon as it is deployed to the production environment.

无需让代码在部署到生产环境后立即执行。

You can now wrap it in a beta flag conditional and activate it from the back end.

现在,您可以将其包装在有条件的beta标志中,然后从后端激活它。

A/B Testing works very similarly, except that instead of turning a code block on or off, they allow you to turn it on 50% of the time.

A / B测试的工作原理非常相似,除了可以打开或关闭代码块外,它们还可以让您50%的时间打开它。

This uses a slight variant on the URL used to display a post or term page, which can then be tracked in an analytics service (e.g. Adobe Omniture, Google 360).

这会在用于显示帖子或词条页面的URL上使用一个细微的变体,然后可以在分析服务(例如Adobe Omniture,Google 360​​)中对其进行跟踪。

The Basics of Beta Flags

Beta标志的基础

To create a new beta flag, open the configuration JSON file.

要创建新的beta标志,请打开配置JSON文件。

A copy of this file is provided with this plugin and is stored at data/beta-flags.json.

该插件提供了此文件的副本,并存储在 data / beta-flags.json 中。

You may prefer to create a copy in the root of your theme, the same folder that contains functions.php ([theme]/beta-flags.json).

您可能更愿意在主题的根目录中创建一个副本,该副本目录包含functions.php( [theme] /beta-flags.json )。

The JSON file follows the format below:
    

JSON文件遵循以下格式:
    

{
    

{
    

"flags": {
        

“ flags”:{
        

"sidebar_web": {
            

“ sidebar_web”:{
            

"title": "Beta Flags IN THEME",
            

“ title”:“主题中的测试版标志”,
            

"description": "Add a sidebar to the post page",
            

“ description”:“将侧边栏添加到帖子页面”,
            

"author": "Charles Jaimet"
        

“ author”:“ Charles Jaimet”
        

},
        

},
        

"library_admin": {
            

“ library_admin”:{
            

"title": "Beta Flags QA: Plugin Admin Test",
            

“ title”:“ Beta标志质量检查:插件管理测试”,
            

"description": "For Beta Flag testing in admin interface",
            

“ description”:“用于在管理界面中进行Beta Flag测试”,
            

"author": "Charles Jaimet"
        

“ author”:“ Charles Jaimet”
        

}
    

}
    

}

}

}

}

Each flag is defined by a key (e.g. sidebar_web, library_admin), representing an object with a title, description, and author.

每个标志均由键(例如sidebar_web,library_admin)定义,该键代表具有标题,描述和作者的对象。

The key must be unique, and is used throughout to identify the given flag.

密钥必须是唯一的,并且始终用于标识给定标志。

Once you have activated the plugin (there are no special instructions for this), navigate to Tools > Beta Flags in the admin interface (/wp-admin/tools.php?page=beta-flags

激活插件后(对此没有特殊说明),请在管理界面( /wp-admin/tools.php?page=beta-flags 中导航至“工具”>“ Beta标志”。

>).

>)。

Here you will find the flags from your JSON file if you have created it correctly.

如果正确创建了JSON文件,就会在这里找到标记。

A note about JSON, the easiest mistake to make is to put a comma after the last element in an array or object.

关于JSON的说明,最容易犯的错误是在数组或对象中的最后一个元素之后添加逗号。

This will break the JSON but is easy enough to fix when you know what to look for.

这将破坏JSON,但在知道要查找的内容时很容易修复。

Kinda like forgetting a semi-colon in PHP.

Kinda喜欢忘记PHP中的分号。

Stupid semi-colons…

愚蠢的分号…

When you first load the plugin, and any time after you update the JSON file, you should return to this admin screen.

首次加载插件时,以及更新JSON文件后的任何时间,都应返回此管理屏幕。

New flags are disabled by default, and can only be enabled here.

新标记默认情况下处于禁用状态,只能在此处启用。

Check the box in the Enabled column beside each flag you want to turn on.

选中要打开的每个标志旁边的“启用”列中的框。

Click Save Changes when done.

完成后,单击“保存更改”。

In your theme or other plugins, you can use these beta flag keys to control feature execution by wrapping a conditional around the relevant code.

在主题或其他插件中,可以通过在相关代码周围包装条件来使用这些beta标志键来控制功能的执行。

Try to group your wrapped code into a single function, method, or class to avoid littering your theme with beta flag conditionals.

尝试将包装的代码分组为单个函数,方法或类,以避免使用beta标志条件散乱主题。

The public function beta_flag_enabled( $key ) will return a true|false value if the beta flag is enabled.

如果启用了beta标志,则公共函数 beta_flag_enabled($ key)将返回true | false值。

Some examples:
    

一些例子:
    

if ( beta_flag_enabled( 'sidebar_web' ) ) {
    

if(beta_flag_enabled('sidebar_web')){
    

get_sidebar();

get_sidebar();

}
    

}
    

if ( beta_flag_enabled( 'new_design' ) ) {
    

if(beta_flag_enabled('new_design')){
    

wp_register_style( 'my_styles', '/assets/my_styles.css', array(), '1.0.0', false );
    

wp_register_style('my_styles','/assets/my_styles.css',array(),'1.0.0',false);
    

wp_enqueue_style( 'my_styles' );

wp_enqueue_style('my_styles');

}
    

}
    

if ( beta_flag_enabled( 'popup_offer' ) ) {
    

if(beta_flag_enabled('popup_offer')){
    

new PopupOffer( '10% Off', 0.1 );

new PopupOffer('10%Off',0.1);

}

}

I suggest using beta flag keys that make sense and convey their purpose.

我建议使用有意义的Beta标志键并传达其目的。

Adding a version number never hurt, either.

添加版本号也无妨。

There is no character limit, so go nuts.
    

没有字符数限制,请多加注意。
    

if ( beta_flag_enabled( 'revised_sticky_video_for_youtube_widgets_v.1.0.5' ) ) {
    

if(beta_flag_enabled('revised_sticky_video_for_youtube_widgets_v.1.0.5')){
    

get_sidebar();

get_sidebar();

}

}

A/B Testing

A / B测试

Now you have your beta flags and you’ve embedded them in your code.

现在,您有了Beta标志并将其嵌入到代码中。

The feature works as expected and you have it running on production.

该功能可以按预期工作,并且已在生产环境中运行。

Is it better than what it replaced?

比取代的更好吗?

Enter A/B testing.

进入A / B测试。

Check the A/B Test box beside the flag you want to test in the admin interface (see screen shot below), and check the “Enable beta testing” box at the bottom of the flag list, then click “Save Changes

在管理界面中选中要测试的标志旁边的A / B测试框(请参见下面的屏幕截图),然后在标志列表底部选中“启用beta测试”框,然后单击“保存更改”

”.

”。

Go to your website and refresh a few times.

转到您的网站并刷新几次。

You will start to see some term and post links appearing with ?ab=1 appended to their URLs.

您将开始看到一些术语,并在其URL后面附加?ab = 1 出现发布链接。

(e.g. http://local.wordpress.test/hello-world/?ab=1).

(例如 http://local.wordpress.test/hello-world/?ab = 1 )。

When a visitor follows one of these links they will see your page with the beta flag disabled.

当访问者访问这些链接之一时,他们会看到禁用了beta标志的页面。

When they follow the normal URL without the query string (e.g. http://local.wordpress.test/hello-world/) they will see the page with the beta flag enabled.

当他们遵循不带查询字符串的普通URL(例如 http://local.wordpress.test/hello-world/ )时,他们将看到启用了beta标志的页面。

The query string is randomly appended 50% of time, so two visitors may follow the same link in the sidebar or menu, and one will get the flag turned on and one will get it turned off.

查询字符串会随机附加50%的时间,因此,两个访问者可以点击侧边栏或菜单中的同一链接,一个访问者将打开该标志,而一个访问者将其关闭。

Because the URL matches the state of the beta flag, you will be able to see in your analytics service which experience visitors engaged with more.

由于URL与beta标志的状态匹配,您将能够在分析服务中看到吸引更多访问者的体验。

Implementing an effective A/B testing campaign is outside the scope of a README file but there are plenty of good reference books and sites.

实施有效的A / B测试活动不在README文件的范围内,但是有很多不错的参考书和网站。

As long as the “Enable beta testing” box is checked, post and term URLs on your site will get this query string treatment.

只要选中“启用beta测试”框,您网站上的帖子和术语网址将获得此查询字符串处理。

Only beta flags that have the A/B Test box checked will be affected.

仅选中“ A / B测试”框的beta标志会受到影响。

Those with it unchecked will be controlled strictly by their Enabled box.

那些未选中的对象将完全由其启用框控制。

Note also that checking A/B Test on a flag that is disabled will have no effect.

另请注意,在禁用的标志上检查A / B测试将无效。

Off is off.

关闭是关闭。

下载地址
https://downloads.wordpress.org/plugin/beta-flags.zip
-EOF-

AI助手支持GPT4.0