PHPackages                             objectivco/cgd\_eddsl\_magic - 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. objectivco/cgd\_eddsl\_magic

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

objectivco/cgd\_eddsl\_magic
============================

A drop-in class that magically manages Easy Digital Downloads Software Licensing for plugins and themes.

0.7.4(1y ago)136681GPL-3.0+PHPPHP &gt;=5.2.0

Since Apr 11Pushed 1y ago4 watchersCompare

[ Source](https://github.com/Objectivco/CGD_EDDSL_Magic)[ Packagist](https://packagist.org/packages/objectivco/cgd_eddsl_magic)[ RSS](/packages/objectivco-cgd-eddsl-magic/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (17)Used By (0)

CGD\_EDDSL\_Magic
=================

[](#cgd_eddsl_magic)

A drop-in class that magically manages your EDD SL plugin licensing.

What is magic and why do I need it?
===================================

[](#what-is-magic-and-why-do-i-need-it)

EDD's brilliant Software Licensing add-on is awesome, but its implementation examples are thin. Managing the various activation and licensing states takes a good amount of research and setup.

Once you have it setup, it can be a major pain in the tucus to manage across your various plugins.

For example, I have 8 plugins. Everytime I find a bug in my licensing code, I have to update 8 plugins that have 8 slightly different implementations. It's a major headache.

`CGD_EDDSL_Magic` fixes all of this. With as little as a single line of code, you can add a fully functioning licensing settings page to your plugin.

Installing
----------

[](#installing)

The best way to install is with composer: `composer require objectivco/cgd_eddsl_magic`

### Alternative method

[](#alternative-method)

1. Copy or clone CGD\_EDDSL\_Magic into your plugin project. Put it in a lib or inc folder.
2. At the top of your main plugin file, or wherever you do your includes, add some code like:

```
if ( ! class_exists( 'CGD_EDDSL_Magic' ) ) {
	// load our custom updater
	include( dirname( __FILE__ ) . '/lib/CGD_EDDSL_Magic/CGD_EDDSL_Magic.php' );
}
```

Instantiating
-------------

[](#instantiating)

In your plugin constructor (or in the main plugin file if you're not using classes for some reason), instantiate `CGD_EDDSL_Magic`.

```
$updater = new CGD_EDDSL_Magic($prefix, $menu_slug,  $host_url, $plugin_version, $plugin_name, $plugin_author, $plugin_file, $theme = false, $beta = false, $home_url = false);
```

**Note: The last parameter, `$plugin_file` is technically optional, but it's better to pass it in. This should be the main file for your plugin, the one with the plugin header. If you're in the main plugin file, use `__FILE__`, otherwise, define it as a constant in your main plugin file and pass it in when you instantiate the class.**

The parameters:
---------------

[](#the-parameters)

#### $prefix

[](#prefix)

This is a unique prefix for your instance. It's used for saving settings and hooking up various behaviors. Keep it short, and no spaces or weird symbols or other funny business. Example: myplugin

#### $menu\_slug

[](#menu_slug)

Assuming your plugin has a menu page, you would set the slug of that menu here so that `CGD_EDDSL_Magic` can add a submenu called "License" to this menu. If you'd rather control this yourself, set to `false`.

#### $host\_url

[](#host_url)

The URL of the site that hosts your plugins.

#### $plugin\_version

[](#plugin_version)

The version of the plugin.

#### $plugin\_name

[](#plugin_name)

The name of the plugin as setup in EDD.

#### $plugin\_author

[](#plugin_author)

The author of the plugin.

#### $plugin\_file

[](#plugin_file)

The main plugin file.

#### $theme

[](#theme)

Set to true for theme updates.

#### $beta

[](#beta)

Set to true to enable beta versions.

#### $home\_url

[](#home_url)

Defaults to false. If false, it uses home\_url() for activation checks. Otherwise, you can pass in a URL to check.

---

If you're using a class, it's probably a good idea to set a class variable called `updater` and then assign the new `CGD_EDDSL_Magic` instance to that. It will make it easier to access later.

**In a basic setup, you're done at this point. Your plugin will now have a fully functioning license settings page, added to whatever your parent menu is. For more advanced options, continue below.**

What about updating themes?
---------------------------

[](#what-about-updating-themes)

If your project is a theme, you simply need to set the `$theme` parameter above to true. This makes the `$plugin_file` parameter uneccessary, so you can simply set this parameter to `false`. Either way, it will not be used.

Advanced Implementation
=======================

[](#advanced-implementation)

Controlling the licensing settings page
---------------------------------------

[](#controlling-the-licensing-settings-page)

By default, a menu item called "License" is added to the parent menu of your choice. If you would like to have full control of where the license settings page is, that's actually really easy to do too.

Just set `$menu_slug` to false in your instantation, and then drop this line in your admin page, wherever you prefer:

```
$updater->admin_page();
```

Obviously, the exact syntax will vary depending on how you implement it. This is one reason I find it easier to set the updater instance as a class variable.

**One important note: Do not place this line in another HTML form. It will screw things up. Browsers hate nested forms. (and HTML standards do not permit them)**

Cronning license checks
-----------------------

[](#cronning-license-checks)

If you want it, `CGD_EDDSL_Magic` includes a way to force regular license checks. To do this, you'd add the following code to your activation or deactivation hooks:

### Activation hook

[](#activation-hook)

```
$this->updater->set_license_check_cron();
```

### Deactivation hook

[](#deactivation-hook)

```
$this->updater->unset_license_check_cron();
```

This will create daily checks that keep your key\_status variable up-to-date.

Really Advanced Implementation
==============================

[](#really-advanced-implementation)

If this does not satisfy you, and you want to add some type of nag to the plugin listing on the plugins page in WP admin, here's a quick example of how you might do that. This is just a starting point, so you'll have to parse through it to figure out how it works.

```
	add_action('admin_menu', 'add_key_nag', 11);
	function add_key_nag() {
		global $pagenow;

	    if( $pagenow == 'plugins.php' ) {
	        add_action( 'after_plugin_row_' . plugin_basename(__FILE__), 'after_plugin_row_message', 10, 2 );
	    }
	}

	function after_plugin_row_message() {
		$key_status = $this->updater->get_field_value('key_status');

		if ( empty($key_status) ) return;

		if ( $key_status != "valid" ) {
			$current = get_site_transient( 'update_plugins' );
			if ( isset( $current->response[ plugin_basename(__FILE__) ] ) ) return;

			if ( is_network_admin() || ! is_multisite() ) {
				$wp_list_table = _get_list_table('WP_Plugins_List_Table');
				echo '';
				echo keynag();
				echo '';
			}
		}
	}

	function keynag() {
		return "You're missing out on important updates because your license key is missing, invalid, or expired.";
	}
```

Changelog
=========

[](#changelog)

Version 0.5.3
-------------

[](#version-053)

- Change license key field to a password field.

Version 0.5.2
-------------

[](#version-052)

- Fixed bug with setting home url to passed in value.

Version 0.5.1
-------------

[](#version-051)

- Ok, that deprecated option was a bad idea. I'm removing it and instead providing the ability to pass in the URL you want to use for activation with a default to `home_url()`

Version 0.5.0
-------------

[](#version-050)

- Add deprecated\_url option and default to true. This tells the updater to check `home_url()` for site activation actions instead of `get_site_url()`. New projects should use `get_site_url()`.
- WP Coding Standards fixes.

Version 0.4.0
-------------

[](#version-040)

- Fix return types.
- Replace invalid reference to class EDD\_SL\_Theme\_Updater with EDD\_Theme\_Updater.

Version 0.3.2
-------------

[](#version-032)

- Composer package.
- Update EDD\_SL\_Plugin\_Updater.
- Add some utility functions that we use internally that you may find useful.

Version 0.3.1
-------------

[](#version-031)

- Add trailing slash to remote API url. Fixes odd bug with wp\_remote\_get().

Version 0.3
-----------

[](#version-03)

- Added theme update support!

Version 0.2
-----------

[](#version-02)

- Added url parameter to API requests for more reliable handling.

Version 0.1
-----------

[](#version-01)

- Initial release.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance45

Moderate activity, may be stable

Popularity21

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 63.5% 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 ~209 days

Recently: every ~302 days

Total

15

Last Release

427d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/85bbb15622b7f0e78a944ef64e996941480395283be13da5084344ed4b773d56?d=identicon)[clifgriffin](/maintainers/clifgriffin)

---

Top Contributors

[![clifgriffin](https://avatars.githubusercontent.com/u/682201?v=4)](https://github.com/clifgriffin "clifgriffin (40 commits)")[![EldonYoder](https://avatars.githubusercontent.com/u/3980380?v=4)](https://github.com/EldonYoder "EldonYoder (22 commits)")[![mjaschen](https://avatars.githubusercontent.com/u/328130?v=4)](https://github.com/mjaschen "mjaschen (1 commits)")

### Embed Badge

![Health badge](/badges/objectivco-cgd-eddsl-magic/health.svg)

```
[![Health](https://phpackages.com/badges/objectivco-cgd-eddsl-magic/health.svg)](https://phpackages.com/packages/objectivco-cgd-eddsl-magic)
```

###  Alternatives

[b13/justincase

With incoming URLs, it does not matter if they are upper/lowercase, they just work.

17230.9k](/packages/b13-justincase)

PHPackages © 2026

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