Coder Social home page Coder Social logo

capevace / wordpress-plugin-updater Goto Github PK

View Code? Open in Web Editor NEW
10.0 3.0 5.0 213 KB

Utility that makes it easy to implement update mechanisms in WordPress Plugins.

Home Page: https://codecanyon.net/item/wordpress-plugin-update-license-server-automatic-updates-for-your-own-plugins/21464774

License: MIT License

JavaScript 4.42% PHP 95.06% CSS 0.51%

wordpress-plugin-updater's Introduction

wordpress-plugin-updater

The WordPress Plugin Integration for the WordPress License Server.

Usage

There's two ways you can integrate this and enable automatic updates for your own plugin.

Using Composer

If you're already using Composer, you'll know what to do.

If not, you'll need to install Composer on your computer and run composer init. This will initialize composer in your packages root.

Once that is complete, run this:

composer require smoolabs/wordpress-plugin-updater

Composer will then install the integration into the vendor/ folder.

To include the plugin files now, simply include the vendor/autoload.php file.

<?php

require_once 'vendor/autoload.php';

Without Composer

Download this repository as a .zip file and extract it somewhere into your plugin files. Then just include the loader.php file.

<?php

require_once '/path/to/updater/loader.php';

Setup

There's only one thing you'll need to do, to enable the integration once you've included it into your project.

In your plugins main file, paste this code:

$client = \Smoolabs\WPU\V4\WPLSController::initClient('http://url-to-wpls.com', array(
    'name'      => 'Example Plugin Name',
    'version'   => '1.0.0',
    'path'      => __FILE__,
    'slug'      => 'example-plugin-slug'
));

Now, replace Example Plugin Name with your plugins name, http://update-server-url.com with the URL where you hosted the update server, my-example-plugin with your plugin slug (for example the plugin folders name) and 1.0.0 with your current plugins version.

That's all you have to do! The plugin will now receive automatic updates once you make them available on your server (of course, only if the user supplied a license)!

Disabling functionality until License is entered

You may want to stop your buyers from using your plugin until they have entered their licenses. You can easily disable functionality like this:

// Your Updater instance
$client = \Smoolabs\...;

if ($client->isActivated()) {
  /* 
   * The User has activated the plugin.
   * Add your plugin functionality here.
   */
} else {
  /* 
   * The User has *NOT* activated the plugin.
   * Add activation messages etc here, for example on your plugin settings page.
   */
}

Please make sure that this complies with Envato's rules on locking fieatures behind licenses! The plugin may not be accepted otherwise.

wordpress-plugin-updater's People

Contributors

capevace avatar mypablo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

wordpress-plugin-updater's Issues

Getting this error in admin

Hello, I'm getting this error:

It's in a plugin in develop state

Deprecated: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in /vendor/smoolabs/wordpress-plugin-updater/plugin-update-checker-4.4/Puc/v4p4/Plugin/UpdateChecker.php on line 641

Warning: The URL https://domain.com/api/v1/packages/wpspa/metadata?installed_version=1.5&php=7.3.1&locale=es_ES&checking_for_updates=1&site-meta={"url":"http:\/\/wpspa.loc","wp_version":"5.2.2","package_version":"1.5.0","php_version":"7.3.1"} does not point to a valid metadata file. WP HTTP Error: cURL error 28: Operation timed out after 10071 milliseconds with 0 bytes received in /wp-content/plugins/wpspa/vendor/smoolabs/wordpress-plugin-updater/plugin-update-checker-4.4/Puc/v4p4/UpdateChecker.php on line 334

Newer PHP Version Issue

On newer versions of PHP the following notice is being thrown

Deprecated: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in /wp-content/plugins/NAME_OF_YOU_PLUGIN/vendor/smoolabs/wordpress-plugin-updater/plugin-update-checker-4.4/Puc/v4p4/Plugin/UpdateChecker.php on line 641

Multisite Global license key and network plugin list screen

Hallo @Capevace !

Ich führe aktuell ein paar Beta-Tests meiner Plugins mit meinen Kunden durch. Einige davon benutzen eine Multisite-Installation (https://codex.wordpress.org/Create_A_Network). Wie ist dieser Update-Client kompatibel mit Multisite-Installationen? Aktuell ist es so, dass der Kunde für jeden Blog im Netzwerk den Purchase Code eingeben muss anstelle einer Netzwerk-weiten Lizenzverwaltung.

Lizenzschlüssel Speicherort

Der eingegebene Lizenzschlüssel wird via get_option gespeichert. Sollte hier nicht get_site_option verwendet werden? Analog zu delete_site_option, update_site_option. Die Multisite-Funktionen können auch für Single-Site Installationen verwendet werden - hier muss keine Unterscheidung implementiert werden.

Anzeige Netzwerk-Plugin Liste

In der Netzwerk-Plugin Liste gibt es für den Kunden keine Möglichkeit, einen Lizenzschlüssel einzugeben. Zusätzlich zu der Single-Site Hook plugin_action_links_{plugin_file} sollte noch network_admin_plugin_action_links_{$plugin_file} hinzugefügt werden:

add_action('admin_enqueue_scripts', array($this, 'adminEnqueueScriptsHook'), 99);
add_action('after_plugin_row_' . $pluginFile, array($this, 'afterPluginRowHook'), 10, 2);
add_filter('plugin_action_links_' . $pluginFile, array($this, 'addLicenseSettingsLink'));

// Multisite
add_filter('network_admin_plugin_action_links_' . $pluginFile, array($this, 'addLicenseSettingsLink'));

Issue Ziele:

  • Den Lizenzschlüssel global speichern?
  • Dem Kunden ermöglichen, egal in welcher Plugin-Liste er sich befindet, den Lizenzschlüssel einzugeben?

Beste Grüße,
Matthias :-)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.