PHPackages                             varunsridharan/wp-ajaxer - 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. varunsridharan/wp-ajaxer

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

varunsridharan/wp-ajaxer
========================

Simple Lightweight Ajax Handler For WP Theme/Plugin Developers.

1.8.2(6y ago)62.0k1[1 PRs](https://github.com/varunsridharan/wp-ajaxer/pulls)1GPL-3.0-or-laterPHP

Since Dec 17Pushed 5y ago2 watchersCompare

[ Source](https://github.com/varunsridharan/wp-ajaxer)[ Packagist](https://packagist.org/packages/varunsridharan/wp-ajaxer)[ RSS](/packages/varunsridharan-wp-ajaxer/feed)WikiDiscussions main Synced today

READMEChangelog (10)DependenciesVersions (13)Used By (1)

WP Ajaxer
=========

[](#wp-ajaxer)

Simple Lightweight Ajax Handler For WP Theme/Plugin Developers

[![Latest Stable Version](https://camo.githubusercontent.com/c49d70a757d8d114d61b54ad917a43ca02e127ebf381437488f972430c10b450/68747470733a2f2f706f7365722e707567782e6f72672f766172756e73726964686172616e2f77702d616a617865722f76657273696f6e)](https://packagist.org/packages/varunsridharan/wp-ajaxer)[![Total Downloads](https://camo.githubusercontent.com/d8bd41a5f2b3c90b76ec43a09efe23846ceb46edaab293ec4afcd297720ed4e3/68747470733a2f2f706f7365722e707567782e6f72672f766172756e73726964686172616e2f77702d616a617865722f646f776e6c6f616473)](https://packagist.org/packages/varunsridharan/wp-ajaxer)[![Latest Unstable Version](https://camo.githubusercontent.com/55781b24536b478b20366c8286a2337261b78c08afbd0445bba79a1c36944235/68747470733a2f2f706f7365722e707567782e6f72672f766172756e73726964686172616e2f77702d616a617865722f762f756e737461626c65)](//packagist.org/packages/varunsridharan/wp-ajaxer)[![License](https://camo.githubusercontent.com/aae23edb6272f8448904aee1db152cd6205306c89fc9fa06a46c5def23b34934/68747470733a2f2f706f7365722e707567782e6f72672f766172756e73726964686172616e2f77702d616a617865722f6c6963656e7365)](https://packagist.org/packages/varunsridharan/wp-ajaxer)[![composer.lock available](https://camo.githubusercontent.com/ef658bb33262a06835d853511010e8db4bc985062bf8de739b7e5c4af0a04951/68747470733a2f2f706f7365722e707567782e6f72672f766172756e73726964686172616e2f77702d616a617865722f636f6d706f7365726c6f636b)](https://packagist.org/packages/varunsridharan/wp-ajaxer)

Installation
------------

[](#installation)

The preferred way to install this extension is through [Composer](http://getcomposer.org/download/).

To install **WP\_Ajaxer library**, simply:

```
$ composer require Varunsridharan/WP_Ajaxer

```

The previous command will only install the necessary files, if you prefer to **download the entire source code** you can use:

```
$ composer require Varunsridharan/WP_Ajaxer --prefer-source

```

You can also **clone the complete repository** with Git:

```
$ git clone https://github.com/varunsridharan/wp-ajaxer.git

```

Or **install it manually**:

[Download WP\_Ajaxer.php](https://raw.githubusercontent.com/varunsridharan/wp-ajaxer/master/class-ajaxer.php):

```
$ wget https://raw.githubusercontent.com/varunsridharan/wp-ajaxer/master/class-ajaxer.php

```

Sample Usage
------------

[](#sample-usage)

```
class BoilerPlate_Ajax extends Varunsridharan\WordPress\Ajaxer {
	/**
	 * Ajax Action Prefix
	 *
	 * @example for wordpress_show_popup wordpress is the prefix
	 *
	 * @var string
	 */
	protected $action_prefix = 'bp';

	/**
	 * Ajax Action Surfix
	 *
	 * @example for wordpress_show_popup_data data is the surfix
	 *
	 * @var string
	 */
	protected $action_surfix = '';

	/**
	 * Action Name
	 * provide value if all ajax requests runs in a single action key.
	 *
	 * @var string
	 */
	protected $action = 'bp-plugin';

	/**
	 * Array of ajax actions
	 *
	 * @example array('ajax_action_1' => true,'ajax_action_2' => false)
	 *          if value set to true then it runs for both loggedout / logged in users
	 *          if value set to false then it runs only for the logged in user
	 *
	 * @var array
	 */
	protected $actions = array(
		'action1'   => false,
		'action-12' => false,
	);

	/**
	 * Set to true if plugin's ajax runs in a single action
	 *
	 * @example Single Ajax Action
	 *          admin-ajax.php?action=plugin-slug&plugin-slug-action=ajax-action&param1=value1&param2=value=2
	 *          Multiple Ajax Actions
	 *          admin-ajax.php?action=plugin-slug-ajax-action1&param1=value1=param2=value2
	 *
	 * @var bool
	 */
	protected $is_single = true;

	/**
	 * Provide a action key if $this->is_single is set to true
	 *
	 * @var string
	 */
	protected $single_ajax_key = '';

	public function __construct( ) {
		parent::__construct();
	}

	public function action1() {
		///do some action here
	}
}
```

Methods
-------

[](#methods)

- `is_get()` -&gt; Checks if current ajax is requested Via **GET** Method
- `is_post()` -&gt; Check if current ajax is requested Via **POST** Method
- `get($key,$default)` -&gt; Retrives Value of the given key from **$\_GET** Variable
- `post($key,$default)` -&gt; Retrives Value of the given key from **$\_POST** Variable
- `request($key,$default)` -&gt; Retrives Value of the given key from **$\_REQUEST** Variable
- `json_error($data,$status_code)` -&gt; Triggers `wp_send_json_error`
- `json_success($data,$status_code)` -&gt; Triggers `wp_send_json_success`
- `validate_post($key,$error)` -&gt; Checks if given key is exits in **$\_POST** if not send an error
- `validate_get($key,$error)` -&gt; Checks if given key is exits in **$\_GET** if not send an error

---

📝 Changelog
-----------

[](#-changelog)

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

[Checkout CHANGELOG.md](https://github.com/varunsridharan/wp-ajaxer/blob/main/CHANGELOG.md)

🤝 Contributing
--------------

[](#-contributing)

If you would like to help, please take a look at the list of [issues](https://github.com/varunsridharan/wp-ajaxer/issues/).

📜 License &amp; Conduct
-----------------------

[](#--license--conduct)

- [**GNU General Public License v3.0**](https://github.com/varunsridharan/wp-ajaxer/blob/main/LICENSE) © [Varun Sridharan](website)
- [Code of Conduct](https://github.com/varunsridharan/.github/blob/main/CODE_OF_CONDUCT.md)

📣 Feedback
----------

[](#-feedback)

- ⭐ This repository if this project helped you! 😉
- Create An [🔧 Issue](https://github.com/varunsridharan/wp-ajaxer/issues/) if you need help / found a bug

💰 Sponsor
---------

[](#-sponsor)

[I](https://sva.onl/twitter/) fell in love with open-source in 2013 and there has been no looking back since! You can read more about me [here](https://sva.onl/website/). If you, or your company, use any of my projects or like what I’m doing, kindly consider backing me. I'm in this for the long run.

- ☕ How about we get to know each other over coffee? Buy me a cup for just [**$9.99**](https://sva.onl/buymeacoffee)
- ☕️☕️ How about buying me just 2 cups of coffee each month? You can do that for as little as [**$9.99**](https://sva.onl/buymeacoffee)
- 🔰 We love bettering open-source projects. Support 1-hour of open-source maintenance for [**$24.99 one-time?**](https://sva.onl/paypal)
- 🚀 Love open-source tools? Me too! How about supporting one hour of open-source development for just [**$49.99 one-time ?**](https://sva.onl/paypal)

Connect &amp; Say 👋
-------------------

[](#connect--say-)

- **Follow** me on [👨‍💻 Github](https://sva.onl/github/) and stay updated on free and open-source software
- **Follow** me on [🐦 Twitter](https://sva.onl/twitter/) to get updates on my latest open source projects
- **Message** me on [📠 Telegram](https://sva.onl/telegram/)
- **Follow** my pet on [Instagram](https://www.instagram.com/sofythelabrador/) for some *dog-tastic* updates!

---

*Built With ♥ By [Varun Sridharan](https://sva.onl/twitter) [ ![](https://camo.githubusercontent.com/ac180da7a81f72a639abce09c4827e7bacfdd3b82586b657387a7f84430c7b7f/68747470733a2f2f63646e2e73766172756e2e6465762f666c61672d696e6469612e6a7067)](https://en.wikipedia.org/wiki/India)*

 [![](https://camo.githubusercontent.com/51991d58f40dac784a0c08b9c5c16c66c59ef5bdf083e3d49e4f617ef98e03ee/68747470733a2f2f63646e2e73766172756e2e6465762f636f64656973706f657472792e706e67)](https://camo.githubusercontent.com/51991d58f40dac784a0c08b9c5c16c66c59ef5bdf083e3d49e4f617ef98e03ee/68747470733a2f2f63646e2e73766172756e2e6465762f636f64656973706f657472792e706e67)

---

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~21 days

Total

11

Last Release

2486d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/522dc9d037e4b0517ee9b76cd63d75a6331b0e578afa9b27fee84b02863ace80?d=identicon)[varunsridharan](/maintainers/varunsridharan)

---

Top Contributors

[![varunsridharan](https://avatars.githubusercontent.com/u/1884287?v=4)](https://github.com/varunsridharan "varunsridharan (31 commits)")

---

Tags

ajaxajax-handlerajax-librarylibraryphpvsp-libsvsp-wp-ajaxerwordpresswordpress-ajaxwordpress-developmentwordpress-pluginwordpress-plugin-librarywordpress-themewordpress-theme-librarywp-ajaxwp-ajax-handlerwp-ajaxerwp-developerswp-librarywp-themephpwordpresslibraryajaxwordpress pluginwordpress-themewordpress-developmentwp themeajax-handlerwordpress-plugin-librarywordpress-theme-libraryvsp-libswp-librarywp-developerswp-ajax-handlerwordpress-ajaxajax-librarywp-ajaxvsp-wp-ajaxer

### Embed Badge

![Health badge](/badges/varunsridharan-wp-ajaxer/health.svg)

```
[![Health](https://phpackages.com/badges/varunsridharan-wp-ajaxer/health.svg)](https://phpackages.com/packages/varunsridharan-wp-ajaxer)
```

###  Alternatives

[varunsridharan/wp-dependencies

Provides Function To Check if a plugin is active/inactive &amp; function to compare versions.

1032.5k1](/packages/varunsridharan-wp-dependencies)[freemius/wordpress-sdk

Freemius WordPress SDK

303101.4k4](/packages/freemius-wordpress-sdk)[justcoded/wordpress-theme-boilerplate

WordPress theme boilerplate with better code structure and OOP support.

563.9k1](/packages/justcoded-wordpress-theme-boilerplate)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
