regionhalland/region-halland-plugin-nps-form

在前端创建一个用于评估NPS的表单

安装次数: 4,138

依赖项: 2

建议者: 0

安全: 0

类型:wordpress-plugin

v1.7.0 2020-07-31 07:38 UTC

This package is auto-updated.

Last update: 2024-09-29 05:22:22 UTC


README

如何使用Region Hallands的RhNpsForm插件

以下是使用"RhNpsForm"插件的方法说明。

使用范围

此插件在管理界面创建一个表单来保存NPS数据

许可证模型

此插件使用许可证模型GPL-3.0。您可以通过随附文件了解更多关于此许可证模型的信息

LICENSE (https://regionhalland.visualstudio.com/public.RhWpPlugIns/_git/RhNpsForm?path=%2FLICENSE&version=GBmaster)

安装和激活

A) Hämta pluginen via Git eller läs in det med Composer
B) Installera Region Hallands plugin i Wordpress plugin folder
C) Aktivera pluginet inifrån Wordpress admin

通过Git下载插件

git clone https://regionhalland.visualstudio.com/public.RhWpPlugIns/_git/RhNpsForm

通过composer导入插件

这两个部分需要添加到您的composer文件中

Repositories = 存储插件的位置,在本例中为github

"repositories": [
  {
    "type": "vcs",
    "url": "https://regionhalland.visualstudio.com/public.RhWpPlugIns/_git/RhNpsForm"
  },
],

Require = 指定您想使用的插件版本,在本例中为1.0.0

注意!确保您获取的是最新版本。

"require": {
  "regionhalland/region-halland-nps-form": "1.0.0"
},

将表单添加到页面

{{-- NPS --}}
@include('partials.region-halland-nps-show-form')

显示表单的局部视图如下所示

@if(function_exists('show_region_halland_nps_form'))
	@php($myNpsShowForm = show_region_halland_nps_form())
	@if($myNpsShowForm == 1)
		<?php
			$myHasSubmittedNps = 0;
			if(isset($_POST["has-submitted-nps"])){
		        $myHasSubmittedNps = $_POST["has-submitted-nps"];
		    }
		?>
		@if($myHasSubmittedNps == 0)
			<form method="post" action="./">
				<h2>Hur bra var denna sidan</h2>
				<input type="hidden" name="has-submitted-nps" value="1">
				<input type="hidden" name="ID" value="{{$post->ID}}">
				<input type="radio" value="1" class="" name="my-nps-value">1
				<input type="radio" value="2" class="" name="my-nps-value">2
				<input type="radio" value="3" class="" name="my-nps-value">3
				<input type="radio" value="4" class="" name="my-nps-value">4
				<input type="radio" value="5" class="" name="my-nps-value">5
				<input type="radio" value="6" class="" name="my-nps-value">6
				<input type="radio" value="7" class="" name="my-nps-value">7
				<input type="radio" value="8" class="" name="my-nps-value">8
				<input type="radio" value="9" class="" name="my-nps-value">9
				<input type="radio" value="10" class="" name="my-nps-value">10<br><br>
				<textarea class="" name="my-nps-text"></textarea><br><br>
				<input type="submit" class="rh-button" value="SKICKA">
			</form>
		@else
			<p>Tack för din nps-kommentar!</p>
		@endif
	@endif
@endif

计算规则和保存表单数据

  • 注意!将其放入app.blade.php中,即在最顶部
@include('partials.region-halland-nps-form-save-form')

检查规则并提交数据的局部视图如下所示

  • 注意!这意味着

  • 函数"rules_region_halland_nps_form()"始终更新一个会话,包含用户访问的页面

  • 函数"region_halland_nps_form_save_form()"始终"嗅探"是否有表单数据被提交
@if(function_exists('rules_region_halland_nps_form'))
	@php(rules_region_halland_nps_form())
@endif
@if(function_exists('region_halland_nps_form_save_form'))
	@php(region_halland_nps_form_save_form())
@endif

保存数据的两个端点

  • 注意:npa-save-number返回一个uniqueID,该ID对于保存文本是必需的
http://[SITE-URL]]/app/plugins/region-halland-nps-form/endpoints/nps-save-number.php
http://[SITE-URL]/app/plugins/region-halland-nps-form/endpoints/nps-save-text.php

表单示例

  • 保存数字并创建帖子
<form method="post" action="http://[SITE-URL]/app/plugins/region-halland-nps-form/endpoints/nps-save-number.php">
<input type="hidden" name="has-submitted-nps-number" value="1">
<input type="hidden" name="ID" value="{{$post->ID}}">
<input type="radio" value="7" class="" name="my-nps-value">7
<input type="submit" class="rh-button" value="SKICKA">
</form>
  • 保存带有标识符的文本
<form method="post" action="http://[SITE-URL]/app/plugins/region-halland-nps-form/endpoints/nps-save-text.php">
<input type="hidden" name="has-submitted-nps-text" value="1">
<input type="hidden" name="ID" value="{{$post->ID}}">
<input type="hidden" name="my-nps-identifier" value="202060650420981910523">
<input type="text" value="Lorem ipsum" class="" name="my-nps-text">
<input type="submit" class="rh-button" value="SKICKA">
</form>

版本历史

1.7.0

  • 修复了仪表板上显示最差页面的错误

1.6.3

  • 修复了仪表板上最差页面的编号错误

1.6.2

  • 修复了管理界面中显示单个提交评分的错误

1.6.1

  • 添加了检查以确保帖子已设置,以便插件不会在例如404的情况下触发

1.6.0

  • 在页面级别NPS元框内添加了注释

1.5.0

  • 将cookie的名称从"cookie_nps_form"更改为"rh_cookie_nps_form"

1.4.1

  • 为大量文本添加了valign="top"以改善日期/注释的外观

1.4.0

  • 添加了一个显示所有注释的widget,按日期顺序排列,最新的是第一个

1.3.2

  • 截断了文本,长度为500个字符,并在所有数值字段上添加了intval()

1.3.1

  • 将端点中的return从eco更改为eco

1.3.0

  • 两个端点,一个用于保存数字,一个用于保存文本

1.2.3

  • 更新了两个错误的变量名

1.2.2

  • 修复了一个会话变量的错误名称

1.2.1

  • 修复了一个错误拼写

1.2.0

  • 添加了仪表板小部件
  • 在页面列表中添加了NPS数据列
  • 在编辑页面上添加了包含NPS数据的meta_box

1.1.0

  • 更新了规则和新功能

1.0.0

  • 第一个版本