PHP code example of stellarwp / installer
1. Go to this page and download the library: Download stellarwp/installer library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
stellarwp / installer example snippets
namespace StellarWP\Installer\Config;
namespace StellarWP\Installer\Installer;
add_action( 'plugins_loaded', function () {
Config::set_hook_prefix( 'boomshakalaka' );
Installer::init();
} );
use StellarWP\Installer\Installer;
add_action( 'plugins_loaded', function () {
$installer = Installer::get();
$installer->register_plugin( 'event-tickets', 'Event Tickets' );
} );
use StellarWP\Installer\Installer;
add_action( 'plugins_loaded', function () {
$installer = Installer::get();
$installer->register_plugin( 'event-tickets', 'Event Tickets', 'https://example.com/event-tickets.zip' );
} );
use StellarWP\Installer\Installer;
add_action( 'plugins_loaded', function () {
$installer = Installer::get();
$installer->register_plugin( 'event-tickets', 'Event Tickets', null, 'event_tickets_plugin_loaded' );
} );
use StellarWP\Installer\Installer;
Installer::get()->render_plugin_button( 'event-tickets', 'install', 'Install Event Tickets' );
use StellarWP\Installer\Installer;
Installer::get()->get_plugin_button( 'event-tickets', 'install', 'Install Event Tickets' );
use StellarWP\Installer\Installer;
// Get it.
$button = Installer::get()->get_plugin_button( 'event-tickets', 'install', 'Install Event Tickets', $redirect_url );
// Or render it.
Installer::get()->render_plugin_button( 'event-tickets', 'install', 'Install Event Tickets', $redirect_url );
use StellarWP\Installer;
$hook_prefix = Installer\Config::get_hook_prefix();
add_filter( "stellarwp/installer/{$hook_prefix}/activated_label", function ( $label, $slug, $handler ) {
return 'Activated, yo.';
}, 10, 3 );
use StellarWP\Installer;
$hook_prefix = Installer\Config::get_hook_prefix();
add_filter( "stellarwp/installer/{$hook_prefix}/activating_label", function ( $label, $slug, $handler ) {
return 'BOOM! Activating...';
}, 10, 3 );
use StellarWP\Installer;
$hook_prefix = Installer\Config::get_hook_prefix();
add_filter( "stellarwp/installer/{$hook_prefix}/busy_class", function ( $class ) {
return 'is-very-busy';
} );
use StellarWP\Installer;
$hook_prefix = Installer\Config::get_hook_prefix();
add_filter( "stellarwp/installer/{$hook_prefix}/button_classes", function ( $classes, $slug, $handler ) {
$classes[] = 'is-primary';
$classes[] = 'some-other-class';
return $classes;
}, 10, 3 );
use StellarWP\Installer;
$hook_prefix = Installer\Config::get_hook_prefix();
add_filter( "stellarwp/installer/{$hook_prefix}/installed_label", function ( $label, $slug, $handler ) {
return 'Installed, yo.';
}, 10, 3 );
use StellarWP\Installer;
$hook_prefix = Installer\Config::get_hook_prefix();
add_filter( "stellarwp/installer/{$hook_prefix}/installing_label", function ( $label, $slug, $handler ) {
return 'YAY! Installing...';
}, 10, 3 );
js
wp.hooks.addAction( 'stellarwp_installer_HOOK_PREFIX_error', function( selector, slug, action, message, hookPrefix ) {
alert( message );
} );