{"id":99790,"date":"2019-03-14T06:20:56","date_gmt":"2019-03-14T06:20:56","guid":{"rendered":"https:\/\/wordpress.org\/plugins\/cookie-tasting\/"},"modified":"2020-10-27T03:03:59","modified_gmt":"2020-10-27T03:03:59","slug":"cookie-tasting","status":"publish","type":"plugin","link":"https:\/\/test.wordpress.org\/plugins\/cookie-tasting\/","author":13589055,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.0.11","stable_tag":"1.0.11","tested":"5.5.18","requires":"5.0","requires_php":"7.0","requires_plugins":"","header_name":"Cookie Tasting","header_author":"Tarosky INC.","header_description":"User can","assets_banners_color":"b8b6bd","last_updated":"2020-10-27 03:03:59","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"https:\/\/wordpress.org\/plugins\/cookie-tasting\/","header_author_uri":"https:\/\/tarosky.co.jp","rating":5,"author_block_rating":0,"active_installs":10,"downloads":2185,"num_ratings":1,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":{"1.0.0":{"tag":"1.0.0","author":"Takahashi_Fumiki","date":"2019-03-14 06:20:44"},"1.0.1":{"tag":"1.0.1","author":"Takahashi_Fumiki","date":"2019-03-14 06:45:42"},"1.0.10":{"tag":"1.0.10","author":"Takahashi_Fumiki","date":"2019-04-25 09:41:59"},"1.0.11":{"tag":"1.0.11","author":"Takahashi_Fumiki","date":"2020-10-27 03:03:59"},"1.0.2":{"tag":"1.0.2","author":"Takahashi_Fumiki","date":"2019-03-15 03:25:06"},"1.0.3":{"tag":"1.0.3","author":"Takahashi_Fumiki","date":"2019-03-21 13:05:26"},"1.0.4":{"tag":"1.0.4","author":"Takahashi_Fumiki","date":"2019-04-11 12:44:52"},"1.0.5":{"tag":"1.0.5","author":"Takahashi_Fumiki","date":"2019-04-11 15:11:22"},"1.0.6":{"tag":"1.0.6","author":"Takahashi_Fumiki","date":"2019-04-11 15:32:04"},"1.0.7":{"tag":"1.0.7","author":"Takahashi_Fumiki","date":"2019-04-12 03:50:32"},"1.0.8":{"tag":"1.0.8","author":"Takahashi_Fumiki","date":"2019-04-12 14:07:47"},"1.0.9":{"tag":"1.0.9","author":"Takahashi_Fumiki","date":"2019-04-15 05:52:28"}},"upgrade_notice":[],"ratings":{"1":0,"2":0,"3":0,"4":0,"5":"1"},"assets_icons":{"icon-128x128.jpg":{"filename":"icon-128x128.jpg","revision":2050214,"resolution":"128x128","location":"assets","locale":""},"icon-256x256.jpg":{"filename":"icon-256x256.jpg","revision":2050214,"resolution":"256x256","location":"assets","locale":""}},"assets_banners":{"banner-1544x500.jpg":{"filename":"banner-1544x500.jpg","revision":2072383,"resolution":"1544x500","location":"assets","locale":""},"banner-772x250.jpg":{"filename":"banner-772x250.jpg","revision":2050214,"resolution":"772x250","location":"assets","locale":""}},"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0.0","1.0.1","1.0.10","1.0.11","1.0.2","1.0.3","1.0.4","1.0.5","1.0.6","1.0.7","1.0.8","1.0.9"],"block_files":[],"assets_screenshots":[],"screenshots":[],"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[146,388,1932],"plugin_category":[52,58],"plugin_contributors":[83237,142014],"plugin_business_model":[],"class_list":["post-99790","plugin","type-plugin","status-publish","hentry","plugin_tags-cache","plugin_tags-cookie","plugin_tags-membership","plugin_category-performance","plugin_category-user-management","plugin_contributors-takahashi_fumiki","plugin_contributors-tarosky","plugin_committers-kuno1","plugin_committers-marikomorimoto","plugin_committers-takahashi_fumiki","plugin_committers-tarosky","plugin_committers-toru"],"banners":{"banner":"https:\/\/ps.w.org\/cookie-tasting\/assets\/banner-772x250.jpg?rev=2050214","banner_2x":"https:\/\/ps.w.org\/cookie-tasting\/assets\/banner-1544x500.jpg?rev=2072383","banner_rtl":false,"banner_2x_rtl":false},"icons":{"svg":false,"icon":"https:\/\/ps.w.org\/cookie-tasting\/assets\/icon-128x128.jpg?rev=2050214","icon_2x":"https:\/\/ps.w.org\/cookie-tasting\/assets\/icon-256x256.jpg?rev=2050214","generated":false},"screenshots":[],"raw_content":"<!--section=description-->\n<p>This plugin sets user cookie when user is logged in.\nYou can use cookie as data store,\nso you can use it as UI resource.<\/p>\n\n<h4>Visibility<\/h4>\n\n<p>This plugin adds class to <code>html<\/code> element.<\/p>\n\n<ul>\n<li><code>ct-logged-in<\/code> The current user is logged in.<\/li>\n<li><code>ct-not-logged-in<\/code> The current user is anonymous.<\/li>\n<\/ul>\n\n<p>You can control elements visibility with CSS.<\/p>\n\n<pre>.some-element{\n  display: none;\n}\n.ct-logged-in .some-element{\n  display: block;\n}<\/pre>\n\n<h4>From JavaScript<\/h4>\n\n<p>You can use Global Object <code>CookieTasting<\/code> for utility.<\/p>\n\n<ul>\n<li><code>CookieTasting.userName()<\/code> Returns user name. If not logged in, returns 'Guest'.<\/li>\n<li><code>CookieTasting.lastUpdated()<\/code> Returns timestamp of last log in check. If this equals 0, it means that user is anonymous.<\/li>\n<\/ul>\n\n<p>Besides that, this plugin checks periodically log-in status.\nYou can handle it with jQuery.<\/p>\n\n<pre>jQuery( document ).on( 'cookie.tasting', function( event, response ) {\n  if ( response.login ) {\n    \/\/ User is logged in.\n    \/\/ If you use React...\n    setAttributes({ name: CookieTasting.userName() })\n  } else {\n    \/\/ User is not logged in.\n  }\n} );<\/pre>\n\n<p>If you use react or something, updated the status with <code>setState()<\/code>.<\/p>\n\n<h4>Check Before Action<\/h4>\n\n<p>If you manage cached WordPress and customizing your own theme,\nIt's a good idea to implement dynamic UI components with JavaScript.<\/p>\n\n<p>You can check user's credential just before important actions.<\/p>\n\n<pre>\/\/ Click action for button.\n$('.read-more').click( function( e ) {\n  e.preventDefault();\n  \/\/ Check cookie before do something.\n  CookieTasting.testBefore().then( function( response ) {\n    \/\/ Now user has fresh information.\n    \/\/ Load premium contents.\n    loadPremiumContents();\n  }).catch( function( response ) {\n    \/\/ This user is not logged in.\n    \/\/ Redirect them to login page.\n    window.locaion.href = '\/wp-login.php';\n  } );\n} );<\/pre>\n\n<p>Plese remember adding dependency for <code>cookie-tasting-heartbeat<\/code> to your script.<\/p>\n\n<h4>Handle UUID<\/h4>\n\n<p>By default, this plugin set UUID for each user. This will be...<\/p>\n\n<ul>\n<li>Unique for each logged in user and will be saved as user_meta.<\/li>\n<li>Also kept for anonymous user.<\/li>\n<\/ul>\n\n<p>So you can use it for Google Analytic's <a href=\"https:\/\/support.google.com\/analytics\/answer\/3123662\">User ID View<\/a>.<\/p>\n\n<pre>const uuid = CookieTasting.get( 'uuid' );\n\/\/ For Google Analytics.\nga( 'set', \"userId\", uid );<\/pre>\n\n<!--section=installation-->\n<ul>\n<li>Download zip file and unpack it.<\/li>\n<li>Upload the directory to <code>wp-content\/plugins<\/code>.<\/li>\n<li>Go to WordPress admin screen and activate this plugin.<\/li>\n<\/ul>\n\n<p><strong>Recommendation:<\/strong> Search on WordPress admin screen and install it.<\/p>\n\n<!--section=faq-->\n<dl>\n<dt><h3>How to Contribute<\/h3><\/dt>\n<dd><p>This plugin is hosted on <a href=\"https:\/\/github.com\/tarosky\/cookie-tasting\">Github<\/a>.\nPlease feel free to make issue or send pull requests.<\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>1.0.11<\/h4>\n\n<ul>\n<li>Display <code>console.log<\/code> only if <code>SCRIPT_DEBUG<\/code> is true.<\/li>\n<\/ul>\n\n<h4>1.0.10<\/h4>\n\n<ul>\n<li>Bugfix: Add polyfil for <code>Object.assign<\/code> in favor of lte IE11.\n(Props <a href=\"https:\/\/github.com\/kamataryo\">@Kamata Ryo<\/a>).<\/li>\n<\/ul>\n\n<h4>1.0.9<\/h4>\n\n<ul>\n<li>Bugfix nonce refreshing for cached page.<\/li>\n<\/ul>\n\n<h4>1.0.8<\/h4>\n\n<ul>\n<li>Add filter for Cookie check API. Now you can change error message.<\/li>\n<\/ul>\n\n<h4>1.0.7<\/h4>\n\n<ul>\n<li>Fix UUID logic.<\/li>\n<li>Add automatic refresh for rewrite rules.<\/li>\n<\/ul>\n\n<h4>1.0.6<\/h4>\n\n<ul>\n<li>Fix SSL bug.<\/li>\n<\/ul>\n\n<h4>1.0.5<\/h4>\n\n<ul>\n<li>Fix fatal error. <code>vendor<\/code> directory was missing.<\/li>\n<\/ul>\n\n<h4>1.0.4<\/h4>\n\n<ul>\n<li>Update nonce for <a href=\"https:\/\/wordpress.org\/gutenberg\/handbook\/designers-developers\/developers\/packages\/packages-api-fetch\/\">@wordpress\/wp-api-featch<\/a> and <code>wpApiSettings<\/code> of <a href=\"https:\/\/developer.wordpress.org\/rest-api\/using-the-rest-api\/backbone-javascript-client\/\">wp-api<\/a>.<\/li>\n<li>Change REST API endpoit because it requires COOKIES properly set. The endpoint <code>wp-json\/cookie\/v1\/nonce<\/code> is pseudo and it's not REST API actually, so you can refresh nonce with this endpoint. Normally, this refresh will be executed automatically, but if you get \"rest_cookie_invalid_nonce\", try updating permalink from \"Setting &gt; Permalink\". Just click \"Save\" and that's it.<\/li>\n<li>UUID will be set for current user. It's userful for tracking.<\/li>\n<\/ul>\n\n<h4>1.0.3<\/h4>\n\n<ul>\n<li>Add filter to cookie detection API.<\/li>\n<\/ul>\n\n<h4>1.0.2<\/h4>\n\n<ul>\n<li>Bugfix: if home url is not SSL, cookie <code>$secure<\/code> flag is now false.\nBut we sincerely recommend protecting your site under SSL.<\/li>\n<\/ul>\n\n<h4>1.0.0<\/h4>\n\n<ul>\n<li>Initial release.<\/li>\n<\/ul>","raw_excerpt":"Detect user login only with cookie. The best helper for cached WordPress sites.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/test.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/99790","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/test.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/test.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/test.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=99790"}],"author":[{"embeddable":true,"href":"https:\/\/test.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/tarosky"}],"wp:attachment":[{"href":"https:\/\/test.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=99790"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/test.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=99790"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/test.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=99790"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/test.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=99790"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/test.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=99790"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/test.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=99790"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}