{"id":16381038,"url":"https://github.com/widoz/wordpress-nonce","last_synced_at":"2026-05-06T01:33:43.866Z","repository":{"id":57075736,"uuid":"109476458","full_name":"widoz/wordpress-nonce","owner":"widoz","description":"An OOP wrapper for the WordPress nonce","archived":false,"fork":false,"pushed_at":"2017-11-07T17:39:00.000Z","size":53,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"dev","last_synced_at":"2025-10-31T03:53:55.828Z","etag":null,"topics":["composer","nonce","psr-4","unit-testing","unprefix","wordpress"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/widoz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-04T07:40:18.000Z","updated_at":"2018-08-04T14:28:17.000Z","dependencies_parsed_at":"2022-08-24T14:55:46.152Z","dependency_job_id":null,"html_url":"https://github.com/widoz/wordpress-nonce","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/widoz/wordpress-nonce","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/widoz%2Fwordpress-nonce","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/widoz%2Fwordpress-nonce/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/widoz%2Fwordpress-nonce/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/widoz%2Fwordpress-nonce/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/widoz","download_url":"https://codeload.github.com/widoz/wordpress-nonce/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/widoz%2Fwordpress-nonce/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281925792,"owners_count":26584821,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-31T02:00:07.401Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["composer","nonce","psr-4","unit-testing","unprefix","wordpress"],"created_at":"2024-10-11T03:53:13.183Z","updated_at":"2025-10-31T03:53:58.466Z","avatar_url":"https://github.com/widoz.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/widoz/unprefix-nonce.svg?branch=dev)](https://travis-ci.org/widoz/unprefix-nonce)\n[![codecov](https://codecov.io/gh/widoz/unprefix-nonce/branch/dev/graph/badge.svg)](https://codecov.io/gh/widoz/unprefix-nonce)\n\n\n# Unprefix Nonce\n\nA WordPress package that wrap the nonce logic in a OOP way.\n\n# Requirements\n\n- PHP 5.6+\n- WordPress 4.8+\n- [Slugify ^3.0](https://github.com/cocur/slugify)\n- [Unprefix Template Loader ^3.0](https://github.com/widoz/template-loader)\n\n# Installation\n\nUse [composer](https://getcomposer.org/) \n\n`composer require unprefix/nonce`\n\n# License\n\nThe package is open source and released under GPL-2 license.\nSee LICENSE for more info.\n\n# Issues\n\nYou can submit issues via [github issues](https://github.com/widoz/unprefix-nonce/issues).\n\n# Documentation\n\n## Create a basic Nonce\n\n```php\nuse Unprefix\\Nonce\\Nonce;\n\n// This create a new nonce instance.\n$nonce = new Nonce('action_name');\n\n// To retrieve the nonce just do this.\n$nonce-\u003enonce();\n\n// To retrieve the nonce action.\n$nonce-\u003eaction();\n```\n\n### Create a basic Nonce with helper\n\n```php\nuse Unprefix\\Nonce\\Nonce;\n\n// This will generate the nonce and return the nonce string, all at once.\n$nonce = Nonce::create('nonce_action');\n```\n\n## Create a URL Nonce\n\nThe constructor for `NonceUrl` take three parameters, a `Nonce` instance, a nonce **name** and an **url** in which add the nonce.\n\n```php\nuse Unprefix\\Nonce\\NonceUrl;\n\n$nonceUrl = new NonceUrl(\n    new Nonce('nonce_action'),\n    'nonce_name',\n    'http://www.mycustomurl.com'\n);\n\n// Retrieve the url.\n$nonceUrl-\u003eurl();\n\n// To retrieve the name.\n$nonceUrl-\u003ename();\n```\n\n### Create a nonce url with helper\n\nYou don't need to pass an `Nonce` instance when using the helper function, just pass the action name as first \nparameter.\n\n```php\nuse Unprefix\\Nonce\\NonceUrl;\n\n// Retrieve the nonce url string at once.\n$nonceUrl = NonceUrl::create('action_name', 'nonce_name', 'http://www.mycustomurl.com');\n```\n\n## Create a nonce Field\n\nLike `NonceUrl` to create a `NonceField` you must pass a `Nonce` instance along with the **name** and the **referrer** parameter.\n\nThe referrer parameter is optional, you can ignore it if you don't want to include the referrer input field.\n\n```php\nuse Unprefix\\Nonce\\NonceField;\n\n$nonceField = new NonceField(\n    new Nonce('nonce_action'),\n    'nonce_name',\n    true\n);\n\n// Show the nonce field.\n$nonceField-\u003etmpl(\n    $nonceField-\u003edata()\n);\n```\n\nThe `NonceField` class implements Unprefix\\TemplateInterface from [unprefix/unprefix-templateloader](https://github.com/widoz/template-loader) to print the markup of the field.\n\nThe file is searched within the `views` directory two level up of the `src/` directory.\n\nIt is possible to filter the template path by hooking into `tmploader_template_file_path` filter as you can see in [Loader.php](https://github.com/widoz/template-loader/blob/master/src/Loader.php#L256)\n\nAlso, like other classes you can use an helper function to print the field at once.\n\n```php\nuse Unprefix\\Nonce\\NonceField;\n\nNonceField::field('nonce_action', 'nonce_name', true);\n```\n\n## Verify Nonce\n\nTo verify a nonce it is possible to use the `NonceVerification` class.\n\nThe class provide a single method with which is possible to verify nonces, admin referrer and ajax referrer.\n\n```php\nuse Unprefix\\Nonce\\NonceValidation;\n\n// Create the instance\n$nonceVerify = new NonceVerification(\n    new Nonce('nonce_action'),\n    'name_action',\n    'POST', // But can be GET, REQUEST\n    false\n);\n\n$nonceVerify-\u003everify();\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwidoz%2Fwordpress-nonce","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwidoz%2Fwordpress-nonce","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwidoz%2Fwordpress-nonce/lists"}