{"id":155783,"date":"2022-04-12T05:12:25","date_gmt":"2022-04-12T05:12:25","guid":{"rendered":"https:\/\/wordpress.org\/plugins\/tori-ajax\/"},"modified":"2026-03-09T13:45:02","modified_gmt":"2026-03-09T13:45:02","slug":"tori-ajax","status":"publish","type":"plugin","link":"https:\/\/ml.wordpress.org\/plugins\/tori-ajax\/","author":20189349,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"2.0.3","stable_tag":"2.0.3","tested":"6.8.5","requires":"3.0.0","requires_php":"5.6.20","requires_plugins":null,"header_name":"Tori Ajax","header_author":"Alvin Muthui","header_description":"This is a short description of what the plugin does. It's displayed in the WordPress admin area.","assets_banners_color":"","last_updated":"2026-03-09 13:45:02","external_support_url":"","external_repository_url":"","donate_link":"https:\/\/www.buymeacoffee.com\/alvinmuthui","header_plugin_uri":"http:\/\/toriajax.com\/","header_author_uri":"https:\/\/profiles.wordpress.org\/alvinmuthui\/","rating":0,"author_block_rating":0,"active_installs":0,"downloads":1802,"num_ratings":0,"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":"alvinmuthui","date":"2022-04-12 05:28:22"},"1.0.1":{"tag":"1.0.1","author":"alvinmuthui","date":"2022-04-13 20:11:33"},"1.0.2":{"tag":"1.0.2","author":"alvinmuthui","date":"2022-04-26 22:00:09"},"1.0.3":{"tag":"1.0.3","author":"alvinmuthui","date":"2022-04-28 20:45:59"},"1.1.0":{"tag":"1.1.0","author":"alvinmuthui","date":"2022-05-26 22:16:28"},"1.2.0":{"tag":"1.2.0","author":"alvinmuthui","date":"2022-07-10 15:19:48"},"2.0.0":{"tag":"2.0.0","author":"alvinmuthui","date":"2022-12-29 22:01:25"},"2.0.1":{"tag":"2.0.1","author":"alvinmuthui","date":"2023-01-01 18:21:12"},"2.0.2":{"tag":"2.0.2","author":"alvinmuthui","date":"2023-04-22 12:12:01"},"2.0.3":{"tag":"2.0.3","author":"alvinmuthui","date":"2026-03-09 13:45:02"}},"upgrade_notice":{"2.0.2":"<ul>\n<li>Added plugin meta links in wp-admin\/plugins.php<\/li>\n<\/ul>","2.0.3":"<ul>\n<li>Tested with WordPress 6.8.3<\/li>\n<\/ul>"},"ratings":[],"assets_icons":{"icon-128x128.png":{"filename":"icon-128x128.png","revision":2737361,"resolution":"128x128","location":"assets","locale":"","width":128,"height":128},"icon-256x256.png":{"filename":"icon-256x256.png","revision":2737361,"resolution":"256x256","location":"assets","locale":"","width":256,"height":256},"icon.svg":{"filename":"icon.svg","revision":2737361,"resolution":false,"location":"assets","locale":false}},"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0.0","1.0.1","1.0.2","1.0.3","1.1.0","1.2.0","2.0.0","2.0.1","2.0.2","2.0.3"],"block_files":[],"assets_screenshots":{"screenshot-1.png":{"filename":"screenshot-1.png","revision":2708334,"resolution":"1","location":"assets","locale":"","width":633,"height":242},"screenshot-2.png":{"filename":"screenshot-2.png","revision":2708334,"resolution":"2","location":"assets","locale":"","width":538,"height":357},"screenshot-3.png":{"filename":"screenshot-3.png","revision":2708819,"resolution":"3","location":"assets","locale":"","width":652,"height":167},"screenshot-4.png":{"filename":"screenshot-4.png","revision":2708819,"resolution":"4","location":"assets","locale":"","width":640,"height":186},"screenshot-5.png":{"filename":"screenshot-5.png","revision":2708819,"resolution":"5","location":"assets","locale":"","width":664,"height":175}},"screenshots":{"1":"Sample theme functions PHP code","2":"Sample Javascript code","3":"Sample theme functions PHP code for authenticated and non-authenticated Ajax actions.","4":"Sample theme functions PHP code for authenticated Ajax actions.","5":"Sample theme functions PHP code for non-authenticated Ajax actions."},"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[221,229,209470,209469],"plugin_category":[44,54],"plugin_contributors":[209408],"plugin_business_model":[],"class_list":["post-155783","plugin","type-plugin","status-publish","hentry","plugin_tags-ajax","plugin_tags-javascript","plugin_tags-toria_add_ajax","plugin_tags-tori_ajax","plugin_category-discussion-and-community","plugin_category-security-and-spam-protection","plugin_contributors-alvinmuthui","plugin_committers-alvinmuthui"],"banners":[],"icons":{"svg":"https:\/\/ps.w.org\/tori-ajax\/assets\/icon.svg?rev=2737361","icon":"https:\/\/ps.w.org\/tori-ajax\/assets\/icon.svg?rev=2737361","icon_2x":false,"generated":false},"screenshots":[{"src":"https:\/\/ps.w.org\/tori-ajax\/assets\/screenshot-1.png?rev=2708334","caption":"Sample theme functions PHP code"},{"src":"https:\/\/ps.w.org\/tori-ajax\/assets\/screenshot-2.png?rev=2708334","caption":"Sample Javascript code"},{"src":"https:\/\/ps.w.org\/tori-ajax\/assets\/screenshot-3.png?rev=2708819","caption":"Sample theme functions PHP code for authenticated and non-authenticated Ajax actions."},{"src":"https:\/\/ps.w.org\/tori-ajax\/assets\/screenshot-4.png?rev=2708819","caption":"Sample theme functions PHP code for authenticated Ajax actions."},{"src":"https:\/\/ps.w.org\/tori-ajax\/assets\/screenshot-5.png?rev=2708819","caption":"Sample theme functions PHP code for non-authenticated Ajax actions."}],"raw_content":"<!--section=description-->\n<p>Add AJAX easily by passing an action name, PHP callback, and JavaScript file path to the toria_add_ajax() function with the Tori Ajax plugin.<\/p>\n\n<h3>Documentation<\/h3>\n\n<p>Please check out the <a href=\"https:\/\/toriajax.com\/documentation\">Tori Ajax plugin Documentation<\/a><\/p>\n\n<h3>About<\/h3>\n\n<p>This is an easy-to-use <strong>dev tool<\/strong> for adding Ajax in word press.<\/p>\n\n<!--section=installation-->\n<ol>\n<li>Upload <code>tori-ajax<\/code> folder to the <code>\/wp-content\/plugins\/<\/code> directory<\/li>\n<li>Activate the plugin through the 'Plugins' menu in WordPress<\/li>\n<li>Add custom code to add ajax in your theme functions or anywhere else desirable. For example:<\/li>\n<\/ol>\n\n<pre><code> function my_simple_ajax() {\n    \/\/ Magic happens here.\n    echo json_encode( 'Welcome to Tori Ajax' );\n}\n\nif ( function_exists( 'toria_add_ajax' ) ) {\n    toria_add_ajax(\n        'simple',\n        'my_simple_ajax',\n        get_stylesheet_directory_uri() . '\/inc\/my_custom_ajax\/toria_ajax.js'\n    );\n}\n<\/code><\/pre>\n\n<ol>\n<li>Create a javascript file in the <code>inc\/my_custom_ajax\/toria_ajax.js<\/code>.<\/li>\n<li>Add Javascript code. For example:<\/li>\n<\/ol>\n\n<pre><code>function tori_ajax() {\n    jQuery.ajax({\n        type: \"post\",\n        url: toria.ajax_url, \/\/ admin-ajax.php path,\n        data: {\n            action: toria.action, \/\/ action\n            nonce: toria.nonce,   \/\/ pass the nonce here\n        },\n        success: function (data) {\n            console.log(data.trim());\n            \/\/alert(data.trim());\n        },\n        error: function (errorThrown) {\n            console.log(errorThrown);\n        }\n    });\n}\ntori_ajax();\/\/ call the function.\n<\/code><\/pre>\n\n<!--section=faq-->\n<dl>\n<dt id=\"how%20to%20solve%20toria_add_ajax%28%29%20is%20undefined%3F\"><h3>How to solve toria_add_ajax() is undefined?<\/h3><\/dt>\n<dd><ul>\n<li>By ensuring the Tori Ajax plugin is installed. <\/li>\n<li>Use the if statement to check if the toria_add_ajax() exists first before using it. For example:\n~~~~\nif ( function_exists( 'toria_add_ajax' ) ) {\ntoria_add_ajax(\n    'simple',\n    'my_simple_ajax',\n    get_stylesheet_directory_uri() . '\/inc\/my_custom_ajax\/toria_ajax.js'\n);\n}\n~~~~<\/li>\n<\/ul><\/dd>\n<dt id=\"how%20to%20register%20action%20for%20both%20logged%20in%20and%20non%20logged%20in%20users%3F\"><h3>How to register action for both logged in and non logged in users?<\/h3><\/dt>\n<dd><p>You can use the fourth parameter to set the mode to <em>'both'<\/em>.\nBy default, the mode is set to <em>'private'<\/em> for authenticated Ajax actions for logged-in users.\nYou can also use <em>'public'<\/em> to expose the Ajax action to non-authenticated Ajax actions for logged-out users \n<strong>Summary<\/strong>\n<em>both<\/em> - For exposing the Ajax action to authenticated Ajax actions for logged-in users and non-authenticated Ajax actions for logged-out users.\nExample<\/p>\n\n<pre><code>if ( function_exists( 'toria_add_ajax' ) ) {\n    toria_add_ajax(\n        'simple',\n        'my_simple_ajax',\n        get_stylesheet_directory_uri() . '\/inc\/my_custom_ajax\/toria_ajax.js',\n        'both'\n    );\n}\n<\/code><\/pre>\n\n<p><em>private<\/em> - For exposing the Ajax action to authenticated Ajax actions for logged-in users.\nExample<\/p>\n\n<pre><code>if ( function_exists( 'toria_add_ajax' ) ) {\n    toria_add_ajax(\n        'simple',\n        'my_simple_ajax',\n        get_stylesheet_directory_uri() . '\/inc\/my_custom_ajax\/toria_ajax.js',\n        'private'\n    );\n}\n<\/code><\/pre>\n\n<p>Or<\/p>\n\n<pre><code>if ( function_exists( 'toria_add_ajax' ) ) {\n    toria_add_ajax(\n        'simple',\n        'my_simple_ajax',\n        get_stylesheet_directory_uri() . '\/inc\/my_custom_ajax\/toria_ajax.js'\n    );\n}\n<\/code><\/pre>\n\n<p><em>public<\/em> - For exposing the Ajax action to non-authenticated Ajax actions for logged-out users.\nExample<\/p>\n\n<pre><code>if ( function_exists( 'toria_add_ajax' ) ) {\n    toria_add_ajax(\n        'simple',\n        'my_simple_ajax',\n        get_stylesheet_directory_uri() . '\/inc\/my_custom_ajax\/toria_ajax.js',\n        'public'\n    );\n}\n<\/code><\/pre><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>1.0.0<\/h4>\n\n<ul>\n<li>The beginning of the Tori Ajax plugin.<\/li>\n<\/ul>\n\n<h4>1.0.1<\/h4>\n\n<ul>\n<li>Fixed: Uncaught ArgumentCountError during the nonce check.<\/li>\n<li>Added JSON output for nonce messages.<\/li>\n<\/ul>\n\n<h4>1.0.2<\/h4>\n\n<ul>\n<li><p>Added 3 optional arguments to <em>toria_add_ajax()<\/em> function:<\/p>\n\n<ol>\n<li><code>$script_depends<\/code> (string[]) (Optional) An array of registered script handles this script depends on. Default value: array().<\/li>\n<li><code>$script_version<\/code> (string|bool|null) (Optional) String specifying script version number, if it has one, which is added to the URL as a query string for cache busting purposes. If the version is set to false, a version number is automatically added equal to the current installed Tori Ajax version. If set to null, no version is added. Default value: false.<\/li>\n<li><code>$script_in_footer<\/code> (bool) (Optional) Whether to enqueue the script before  instead of in the . Default 'false'.<\/li>\n<\/ol><\/li>\n<li><p>Added support for PHP version 5.6.20 and above<\/p><\/li>\n<li>Added compatibility of WordPress Version 3.0 and above<\/li>\n<\/ul>\n\n<h4>1.0.3<\/h4>\n\n<ul>\n<li>Fixed: PHP Notice undefined variable: allowed_html<\/li>\n<\/ul>\n\n<h4>1.1.0<\/h4>\n\n<ul>\n<li>Compatible with WordPress 6.0.<\/li>\n<li>Added filters:\napply_filters( 'toria\/ajax\/action', $action );\napply_filters( 'toria\/ajax\/php_callback', $php_callback, $action );\napply_filters( 'toria\/ajax\/script_path', $script_path, $action, $php_callback );\napply_filters( 'toria\/ajax\/mode', $mode, $action, $php_callback, $script_path );\napply_filters( 'toria\/ajax\/nonce', $nonce, $action, $php_callback, $script_path, $mode );\napply_filters( 'toria\/ajax\/ajax_object', $ajax_object, $action, $php_callback, $script_path, $mode );\napply_filters( 'toria\/ajax\/ajax_handle', $ajax_handle, $action, $php_callback, $script_path, $mode );\napply_filters( 'toria\/ajax\/script_depends', $script_depends, $action, $php_callback, $script_path, $mode );\napply_filters( 'toria\/ajax\/script_version', $script_version, $action, $php_callback, $script_path, $mode );\napply_filters( 'toria\/ajax\/script_in_footer', $script_in_footer, $action, $php_callback, $script_path, $mode );\napply_filters( 'toria\/ajax\/ajax_variables', $ajax_variables, $action, $php_callback, $script_path, $mode );<\/li>\n<\/ul>\n\n<h4>1.2.0<\/h4>\n\n<p>*Added more parameters to some filters.\n*The affected filters are:\n    apply_filters( 'toria\/ajax\/ajax_object', $ajax_object, $action, $php_callback, $script_path, $mode, $nonce );\n    apply_filters( 'toria\/ajax\/ajax_handle', $ajax_handle, $action, $php_callback, $script_path, $mode, $nonce, $ajax_object );\n    apply_filters( 'toria\/ajax\/script_depends', $script_depends, $action, $php_callback, $script_path, $mode, $nonce, $ajax_object, $ajax_handle );\n    apply_filters( 'toria\/ajax\/script_version', $script_version, $action, $php_callback, $script_path, $mode, $nonce, $ajax_object, $ajax_handle, $script_depends );\n    apply_filters( 'toria\/ajax\/script_in_footer', $script_in_footer, $action, $php_callback, $script_path, $mode, $nonce, $ajax_object, $ajax_handle, $script_depends, $script_version );\n    apply_filters( 'toria\/ajax\/ajax_variables', $ajax_variables, $action, $php_callback, $script_path, $mode, $nonce, $ajax_object, $ajax_handle, $script_depends, $script_version, $script_in_footer );<\/p>\n\n<h4>2.0.0<\/h4>\n\n<ul>\n<li>Compatible with WordPress 6.1.1.<\/li>\n<li>Fix: Ajax in <strong>private<\/strong> mode is only accessible by signed-in users and those in <strong>public<\/strong> are only accessible by signed-out users.<\/li>\n<li>Pro version available.<\/li>\n<\/ul>\n\n<h4>2.0.1<\/h4>\n\n<ul>\n<li>Fixed a PHP Deprecated notice.<\/li>\n<\/ul>\n\n<h4>2.0.2<\/h4>\n\n<ul>\n<li>Added plugin meta links in wp-admin\/plugins.php<\/li>\n<\/ul>","raw_excerpt":"Adds Ajax in WordPress with a few lines of code. Adding Ajax is now simple as calling toria_add_ajax($action_name, $php_callback, $js_script_path) fun &hellip;","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ml.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/155783","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ml.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/ml.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/ml.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=155783"}],"author":[{"embeddable":true,"href":"https:\/\/ml.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/alvinmuthui"}],"wp:attachment":[{"href":"https:\/\/ml.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=155783"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/ml.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=155783"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/ml.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=155783"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/ml.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=155783"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/ml.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=155783"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/ml.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=155783"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}