[wordpress插件] Cookie Tasting饼干品尝

wordpress 插件 文章 2020-04-02 09:20 485 0 全屏看文

AI助手支持GPT4.0

评分
100
描述

This plugin sets user cookie when user is logged in.

此插件在用户登录时设置用户cookie。

You can use cookie as data store,

您可以将cookie用作数据存储,

so you can use it as UI resource.

因此您可以将其用作UI资源。

Visibility

可见度

This plugin adds class to html element.

此插件将类添加到 html 元素。

    • ct-logged-in The current user is logged in.
    • ct-logged-in 当前用户已登录。

    • ct-not-logged-in The current user is anonymous.
    • ct-not-logged-in 当前用户是匿名用户。

    You can control elements visibility with CSS.

    您可以使用CSS控制元素的可见性。

    .some-element{  

     .some-element {  

    display: none;

    显示:无;

    }

    }

    .ct-logged-in .some-element{  

    .ct-login .some-element {  

    display: block;

    显示:块;

    }

    }

    From JavaScript

    来自JavaScript

    You can use Global Object CookieTasting for utility.

    您可以将全局对象 CookieTasting 用于实用程序。

      • CookieTasting.userName() Returns user name.

      • CookieTasting.userName()返回用户名。

        If not logged in, returns ‘Guest’.

      • 如果尚未登录,则返回“访客”。

      • CookieTasting.lastUpdated() Returns timestamp of last log in check.

      • CookieTasting.lastUpdated()返回上次登录检查的时间戳。

        If this equals 0, it means that user is anonymous.

      • 如果该值等于0,则表示该用户是匿名用户。

      Besides that, this plugin checks periodically log-in status.

      此外,此插件会定期检查登录状态。

      You can handle it with jQuery.

      您可以使用jQuery处理它。

      jQuery( document ).on( 'cookie.tasting', function( event, response ) {  

       jQuery(document).on('cookie.tasting',function(event,response){  

      if ( response.login ) {    

      如果(response.login){    

      // User is logged in.    

      //用户已登录。    

      // If you use React...    

      //如果您使用React ...    

      setAttributes({ name: CookieTasting.userName() })  

      setAttributes({名称:CookieTasting.userName()})  

      } else {    

      }其他{    

      // User is not logged in.  

      //用户未登录。  

      }

      }

      } );

      });

      If you use react or something, updated the status with setState().

      如果您使用react或其他方法,请使用 setState()更新状态。

      Check Before Action

      操作前检查

      If you manage cached WordPress and customizing your own theme,

      如果您管理缓存的WordPress并自定义自己的主题,

      It’s a good idea to implement dynamic UI components with JavaScript.

      最好使用JavaScript来实现动态UI组件。

      You can check user’s credential just before important actions.

      您可以在执行重要操作之前检查用户的凭据。

      // Click action for button.

       //单击按钮的操作。

      $('.read-more').click( function( e ) {  

      $('。read-more')。click(function(e){  

      e.preventDefault();  

      e.preventDefault();  

      // Check cookie before do something.  

      //在做某事之前检查cookie。  

      CookieTasting.testBefore().then( function( response ) {    

      CookieTasting.testBefore()。then(function(response){    

      // Now user has fresh information.    

      //现在,用户有了新的信息。    

      // Load premium contents.    

      //加载高级内容。    

      loadPremiumContents();  

      loadPremiumContents();  

      }).catch( function( response ) {    

      })。catch(function(response){    

      // This user is not logged in.    

      //此用户尚未登录。    

      // Redirect them to login page.    

      //将他们重定向到登录页面。    

      window.locaion.href = '/wp-login.php';  

      window.locaion.href ='/wp-login.php';  

      } );

      });

      } );

      });

      Plese remember adding dependency for cookie-tasting-heartbeat to your script.

      请记住在脚本中添加 cookie-tasting-heartbeat 的依赖项。

      Handle UUID

      处理UUID

      By default, this plugin set UUID for each user.

      默认情况下,此插件为每个用户设置UUID。

      This will be…

      这将是...

        • Unique for each logged in user and will be saved as user_meta.
        • 每个登录用户的唯一身份,并将另存为user_meta。

        • Also kept for anonymous user.
        • 还保留给匿名用户。

        So you can use it for Google Analytic’s User ID View.

        因此,您可以将其用于Google Analytic(分析)的用户ID视图

        const uuid = CookieTasting.get( 'uuid' );

         const uuid = CookieTasting.get('uuid');

        // For Google Analytics.

        //对于Google Analytics(分析)。

        ga( 'set', "userId", uid );

        ga('set',“ userId”,uid);

安装步骤

    • Download zip file and unpack it.
    • 下载zip文件并解压缩。

    • Upload the directory to wp-content/plugins.
    • 将目录上传到 wp-content / plugins

    • Go to WordPress admin screen and activate this plugin.
    • 转到WordPress管理屏幕并激活此插件。

    Recommendation: Search on WordPress admin screen and install it.

    建议:在WordPress管理屏幕上搜索并安装。

下载地址
https://downloads.wordpress.org/plugin/cookie-tasting.1.0.10.zip
-EOF-

AI助手支持GPT4.0


国内超级便宜服务器

摸鱼人热门新闻聚合

钻级赞助商 我要加入

开发者在线工具

第三方支付技术请加QQ群

相关文章
[wordpress插件] Delete Post Revision删除帖子修订
[wordpress插件] Contact Form 7 Multi-step Forms (Add-on for CF7)联系表格7多步骤表格(CF7的附件)
[wordpress插件] Contact Form 7 Dynamic Text Extension联系表7动态文本扩展
[wordpress插件] Bx Carousel UltimateBx Carousel Ultimate
[wordpress插件] Cherry Socialize樱桃社交
随便看看
教育科技公司申请微信支付被拒绝? 3853
微信公众号免300认证教程 4951
小程序已经上线,作为管理员无法在小程序数据助手查看数据? 4067
小程序广告组件通过审核,但是小程序内没有显示广告? 4147
企业微信通讯录账号被管理员误/恶意删除,怎么办? 8012
问题? 7247
如何快速搭建抽奖助手小程序(无需代码知识) 5033
许涛 大哥在吗, 要解冻小程序的时候提示信息主体不一致, 能帮忙看下吗? 5985
小程序搜一搜全称搜索不显示 麻烦解决一下!谢谢 5505
我的小程序广告收款主体是个体工商户,每个月邮寄两次发票很是麻烦,我年底的时候打包邮寄一次可以么? 5201