PHPackages                             anthonybudd/wp\_ajax - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. anthonybudd/wp\_ajax

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

anthonybudd/wp\_ajax
====================

v1.0.3(8y ago)4517.4k↑46.4%17[1 issues](https://github.com/anthonybudd/wp_ajax/issues)PHP

Since Feb 27Pushed 8y ago5 watchersCompare

[ Source](https://github.com/anthonybudd/wp_ajax)[ Packagist](https://packagist.org/packages/anthonybudd/wp_ajax)[ RSS](/packages/anthonybudd-wp-ajax/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (4)DependenciesVersions (5)Used By (0)

WP\_AJAX
========

[](#wp_ajax)

[![](https://camo.githubusercontent.com/fa1fd94124733ba1dbac1b962fbd924a8bc0044c18d772aa5af7187ff5819720/68747470733a2f2f69646565612e636f2e756b2f7374617469632f77705f616a61782e706e67)](https://camo.githubusercontent.com/fa1fd94124733ba1dbac1b962fbd924a8bc0044c18d772aa5af7187ff5819720/68747470733a2f2f69646565612e636f2e756b2f7374617469632f77705f616a61782e706e67)

### Simple Controllers for WordPress

[](#simple-controllers-for-wordpress)

WP\_AJAX is a class for interfacing with WordPress’s built in AJAX system. This class is designed to fully abstract the developer from the traditional hook based system to a clean controller style structure. Simply define the class, echo urls with url($params = \[\]) method and write what code you want to execute in the run() method.

Introduction: **[Medium Post](https://medium.com/@AnthonyBudd/wp-ajax-97d8f1d83e26)**
-------------------------------------------------------------------------------------

[](#introduction-medium-post)

```
Class ExampleAction extends WP_AJAX{

    protected $action = 'example-action';

    protected function run(){

    	// Your Code Here!

    	update_option('name', $this->get('name'));

    }
}
ExampleAction::listen();

ExampleAction::url() // http://example.com/wp-admin/admin-ajax.php?action=example-action
ExampleAction::url(['name' => 'Anthony Budd']) // http://example.com/wp-admin/admin-ajax.php?action=example-action&name=Anthony%20Budd
```

ExampleAction.php

### Font-end

[](#font-end)

```
