wpdesk/wp-nps

显示插件中NPS的库。

1.3.0 2022-07-13 14:11 UTC

README

Latest Stable Version Total Downloads License

NPS

一个WordPress库,包含接口、抽象和基本实现,用于显示针对插件的Net Promoter Score调查表单。

要求

PHP 7.0或更高版本。

通过Composer安装

为了通过 Composer 安装绑定,请运行以下命令

composer reqiure wpdesk/wp-nps

示例用法

Flexible Shipping 运输方式设置屏幕上显示NPS

$user_meta_name = 'fs_nps';
$nps            = new \WPDesk\Nps\Nps(
    'fs_nps',
    'satismeter_write_key_here',
    'satismeter_campaign_id_here',
    'satismeter_feedback_id',
    new \WPDesk\Nps\UuidUserId(),
    $this->get_plugin_assets_url() . '../vendor_prefixed/wpdesk/wp-nps/assets/',
    $this->scripts_version,
    new \WPDesk\Nps\DisplayDecisions\DisplayNpsLocationsAndUserDecisions(
        [
            new \WPDesk\Nps\DisplayDecisions\ShippingMethodDisplayNpsDecision( 'flexible_shipping_single' ),
            new \WPDesk\Nps\DisplayDecisions\AdminPageDisplayNpsDecision( [
                'page'    => 'wc-settings',
                'tab'     => 'shipping',
                'section' => 'flexible_shipping_info',
            ] ),
        ],
        [
            new \WPDesk\Nps\DisplayDecisions\ShippingMethodDisplayNpsDecision( new \WPDesk\Nps\DisplayDecisions\UserDisplayNpsDecision( $user_meta_name ) ),
        ]
    ),
    $user_meta_name,
    admin_url( 'admin-ajax.php' )
);
$nps->set_question( __( 'Hey, we are curious how would you grade your first impression on Flexible Shipping so far?', 'flexible-shipping' ) );
$nps->set_best_label( __( 'Wow, it\'s awesome!', 'flexible-shipping' ) );
$nps->set_worst_label( __( 'Really poor', 'flexible-shipping' ) );
$nps->set_disclaimer(
    sprintf(
        __( 'By using the \'Send feedback\' button I hereby agree and consent to the terms of %1$sPrivacy Policy%2$s.', 'flexible-shipping' ),
        '<a target="_blank" href="https://octolize.com/terms-of-service/privacy-policy/">',
        '</a>'
    )
);

$nps->add_feedback_option( new FeedbackOption( __( 'More calculation conditions', 'flexible-shipping' ), __( 'What exactly should the conditions you need be based on?', 'flexible-shipping' ) ) )
    ->add_feedback_option( new FeedbackOption( __( 'More detailed documentation', 'flexible-shipping' ) ) )
    ->add_feedback_option( new FeedbackOption( __( 'Easier contact with support', 'flexible-shipping' ) ) )
    ->add_feedback_option( new FeedbackOption( __( 'More user-friendly interface', 'flexible-shipping' ) ) )
    ->add_feedback_option( new FeedbackOption( __( 'Less complicated settings', 'flexible-shipping' ) ) )
    ->add_feedback_option( new FeedbackOption( __( 'Too soon to say', 'flexible-shipping' ) ) )
    ->add_feedback_option( new FeedbackOption( __( 'Other', 'flexible-shipping' ), __( 'Please tell us what exactly can we do to improve our plugin?', 'flexible-shipping' ) ) );

$nps->hooks();

开发者

请记住,在提交之前执行:npm run prod