| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Deployer for Git |
| 5 |
* |
| 6 |
* @link https://deployer-for-git.com |
| 7 |
* @since 1.0.0 |
| 8 |
* @package Deployer_For_Git |
| 9 |
* |
| 10 |
* @wordpress-plugin |
| 11 |
* Plugin Name: Deployer for Git |
| 12 |
* Plugin URI: https://wordpress.org/plugins/deployer-for-git/ |
| 13 |
* Description: This plugin can install and automatically update themes and plugins hosted on GitHub, Bitbucket, GitLab, or Gitea. |
| 14 |
* Version: 1.0.13 |
| 15 |
* Author: Alex Masliychuk |
| 16 |
* Author URI: https://alex-masliychuk.com/ |
| 17 |
* License: GPL-3.0 |
| 18 |
* License URI: http://www.gnu.org/licenses/gpl-3.0.txt |
| 19 |
* Text Domain: deployer_for_git |
| 20 |
* Domain Path: /languages |
| 21 |
* Requires PHP: 7.0 |
| 22 |
* Requires at least: 4.4 |
| 23 |
*/ |
| 24 |
// If this file is called directly, abort. |
| 25 |
if ( !defined( 'WPINC' ) ) { |
| 26 |
die; |
| 27 |
} |
| 28 |
if ( !defined( 'DFG_FILE' ) ) { |
| 29 |
define( 'DFG_FILE', __FILE__ ); |
| 30 |
} |
| 31 |
if ( !defined( 'DFG_PATH' ) ) { |
| 32 |
define( 'DFG_PATH', plugin_dir_path( __FILE__ ) ); |
| 33 |
} |
| 34 |
if ( !defined( 'DFG_URL' ) ) { |
| 35 |
define( 'DFG_URL', plugin_dir_url( __FILE__ ) ); |
| 36 |
} |
| 37 |
if ( !defined( 'DFG_SLUG' ) ) { |
| 38 |
define( 'DFG_SLUG', 'dfg' ); |
| 39 |
// = plugin slug (used for options) |
| 40 |
} |
| 41 |
if ( !defined( 'ABSPATH' ) ) { |
| 42 |
exit; |
| 43 |
} |
| 44 |
// Load Freemius SDK. |
| 45 |
if ( function_exists( 'dfg_fs' ) ) { |
| 46 |
dfg_fs()->set_basename( false, __FILE__ ); |
| 47 |
// phpcs:ignore Universal.ControlStructures.DisallowLonelyIf.Found |
| 48 |
} else { |
| 49 |
// DO NOT REMOVE THIS IF, IT IS ESSENTIAL FOR THE `function_exists` CALL ABOVE TO PROPERLY WORK. |
| 50 |
if ( !function_exists( 'dfg_fs' ) ) { |
| 51 |
/** |
| 52 |
* Create a helper function for easy SDK access. |
| 53 |
*/ |
| 54 |
function dfg_fs() { |
| 55 |
global $dfg_fs; |
| 56 |
if ( !isset( $dfg_fs ) ) { |
| 57 |
// Activate multisite network integration. |
| 58 |
if ( !defined( 'WP_FS__PRODUCT_13247_MULTISITE' ) ) { |
| 59 |
define( 'WP_FS__PRODUCT_13247_MULTISITE', true ); |
| 60 |
} |
| 61 |
// Include Freemius SDK. |
| 62 |
require_once __DIR__ . '/freemius/start.php'; |
| 63 |
$dfg_fs = fs_dynamic_init( array( |
| 64 |
'id' => '13247', |
| 65 |
'slug' => 'deployer-for-git', |
| 66 |
'premium_slug' => 'deployer-for-git-pro', |
| 67 |
'type' => 'plugin', |
| 68 |
'public_key' => 'pk_24e3f32d1fddcf86de310f6883552', |
| 69 |
'is_premium' => false, |
| 70 |
'premium_suffix' => '(Pro)', |
| 71 |
'has_addons' => false, |
| 72 |
'has_paid_plans' => true, |
| 73 |
'is_org_compliant' => true, |
| 74 |
'trial' => array( |
| 75 |
'days' => 14, |
| 76 |
'is_require_payment' => false, |
| 77 |
), |
| 78 |
'menu' => array( |
| 79 |
'slug' => 'deployer-for-git', |
| 80 |
'support' => false, |
| 81 |
'network' => true, |
| 82 |
), |
| 83 |
'is_live' => true, |
| 84 |
) ); |
| 85 |
} |
| 86 |
return $dfg_fs; |
| 87 |
} |
| 88 |
|
| 89 |
// Load Composer autoload. |
| 90 |
require __DIR__ . '/vendor/autoload.php'; |
| 91 |
// Init Freemius. |
| 92 |
dfg_fs(); |
| 93 |
dfg_fs()->add_filter( 'show_delegation_option', '__return_false' ); |
| 94 |
// Signal that SDK was initiated. |
| 95 |
do_action( 'dfg_fs_loaded' ); |
| 96 |
} |
| 97 |
} |
| 98 |
use DeployerForGit\Helper; |
| 99 |
use DeployerForGit\Admin; |
| 100 |
use DeployerForGit\ApiRequests\PackageUpdate; |
| 101 |
use DeployerForGit\CLI\DfgCommand; |
| 102 |
if ( !class_exists( 'DeployerForGitInit' ) ) { |
| 103 |
/** |
| 104 |
* Class DeployerForGitInit |
| 105 |
*/ |
| 106 |
class DeployerForGitInit { |
| 107 |
/** |
| 108 |
* DeployerForGitInit constructor. |
| 109 |
*/ |
| 110 |
public function __construct() { |
| 111 |
if ( is_admin() ) { |
| 112 |
add_action( 'plugins_loaded', array($this, 'admin_init') ); |
| 113 |
add_action( 'plugins_loaded', array($this, 'load_textdomain') ); |
| 114 |
} |
| 115 |
// Init api requests. |
| 116 |
add_action( 'plugins_loaded', array($this, 'api_requests_init') ); |
| 117 |
register_activation_hook( DFG_FILE, array($this, 'plugin_activation') ); |
| 118 |
} |
| 119 |
|
| 120 |
/** |
| 121 |
* Set default settings. |
| 122 |
* |
| 123 |
* @return void |
| 124 |
*/ |
| 125 |
public function plugin_activation() { |
| 126 |
if ( !Helper::get_api_secret() ) { |
| 127 |
Helper::generate_api_secret(); |
| 128 |
} |
| 129 |
flush_rewrite_rules(); |
| 130 |
// Flush rewrite rules to ensure the new endpoints are registered. |
| 131 |
} |
| 132 |
|
| 133 |
/** |
| 134 |
* Load and initialize wp-admin side classes |
| 135 |
*/ |
| 136 |
public function admin_init() { |
| 137 |
new Admin(); |
| 138 |
} |
| 139 |
|
| 140 |
/** |
| 141 |
* Load and initialize api requests classes |
| 142 |
*/ |
| 143 |
public function api_requests_init() { |
| 144 |
// init theme update webhook endpoint. |
| 145 |
new PackageUpdate(); |
| 146 |
} |
| 147 |
|
| 148 |
/** |
| 149 |
* Load plugin textdomain. |
| 150 |
* |
| 151 |
* @return void |
| 152 |
*/ |
| 153 |
public function load_textdomain() { |
| 154 |
load_plugin_textdomain( 'deployer-for-git', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); |
| 155 |
} |
| 156 |
|
| 157 |
} |
| 158 |
|
| 159 |
new DeployerForGitInit(); |
| 160 |
} |
| 161 |
// Register WP-CLI commands when running under WP-CLI. |
| 162 |
if ( defined( 'WP_CLI' ) && WP_CLI ) { |
| 163 |
WP_CLI::add_command( 'dfg', DfgCommand::class ); |
| 164 |
} |