css
2 years ago
data
2 years ago
img
2 years ago
inc
2 years ago
js
2 years ago
tpl
1 year ago
changelog.md
2 years ago
readme.md
2 years ago
siteorigin-installer.php
2 years ago
siteorigin-installer.php
86 lines
| 1 | <?php |
| 2 | /* |
| 3 | Plugin Name: SiteOrigin Installer |
| 4 | Plugin URI: https://siteorigin.com/installer/ |
| 5 | Description: This plugin installs all the SiteOrigin themes and plugins you need to get started with your new site. |
| 6 | Author: SiteOrigin |
| 7 | Author URI: https://siteorigin.com |
| 8 | Version: 1.0.3 |
| 9 | License: GNU General Public License v3.0 |
| 10 | License URI: http://www.opensource.org/licenses/gpl-license.php |
| 11 | */ |
| 12 | |
| 13 | if ( ! defined( 'SITEORIGIN_INSTALLER_VERSION' ) ) { |
| 14 | define( 'SITEORIGIN_INSTALLER_VERSION', '1.0.3' ); |
| 15 | define( 'SITEORIGIN_INSTALLER_DIR', plugin_dir_path( __FILE__ ) ); |
| 16 | define( 'SITEORIGIN_INSTALLER_URL', plugin_dir_url( __FILE__ ) ); |
| 17 | } |
| 18 | |
| 19 | if ( ! class_exists( 'SiteOrigin_Installer' ) ) { |
| 20 | class SiteOrigin_Installer { |
| 21 | public function __construct() { |
| 22 | add_filter( 'siteorigin_premium_affiliate_id', array( $this, 'affiliate_id' ) ); |
| 23 | add_filter( 'init', array( $this, 'setup' ) ); |
| 24 | add_filter( 'siteorigin_add_installer', array( $this, 'load_status' ) ); |
| 25 | add_action( 'wp_ajax_so_installer_status', array( $this, 'installer_status_ajax' ) ); |
| 26 | } |
| 27 | |
| 28 | public static function single() { |
| 29 | static $single; |
| 30 | |
| 31 | return empty( $single ) ? $single = new self() : $single; |
| 32 | } |
| 33 | |
| 34 | public static function user_has_permission() { |
| 35 | return ( |
| 36 | ! defined( 'DISALLOW_FILE_MODS' ) || |
| 37 | ! DISALLOW_FILE_MODS |
| 38 | ) && |
| 39 | current_user_can( 'install_plugins' ) && |
| 40 | current_user_can( 'install_themes' ) && |
| 41 | current_user_can( 'update_themes' ) && |
| 42 | current_user_can( 'update_plugins' ); |
| 43 | } |
| 44 | |
| 45 | public function setup() { |
| 46 | if ( |
| 47 | apply_filters( 'siteorigin_add_installer', true ) && |
| 48 | is_admin() && |
| 49 | self::user_has_permission() |
| 50 | ) { |
| 51 | // If the installer has been installed as a plugin (rather than bundled), setup the Github updater. |
| 52 | if ( basename( SITEORIGIN_INSTALLER_DIR ) == 'siteorigin-installer-develop' ) { |
| 53 | require_once SITEORIGIN_INSTALLER_DIR . '/inc/github-plugin-updater.php'; |
| 54 | new SiteOrigin_Installer_GitHub_Updater( __FILE__ ); |
| 55 | } |
| 56 | |
| 57 | require_once __DIR__ . '/inc/admin.php'; |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Get the Affiliate ID from the database. |
| 63 | * |
| 64 | * @return mixed|void |
| 65 | */ |
| 66 | public function affiliate_id( $id ) { |
| 67 | if ( get_option( 'siteorigin_premium_affiliate_id' ) ) { |
| 68 | $id = get_option( 'siteorigin_premium_affiliate_id' ); |
| 69 | } |
| 70 | |
| 71 | return $id; |
| 72 | } |
| 73 | |
| 74 | public function load_status() { |
| 75 | return (bool) get_option( 'siteorigin_installer', true ); |
| 76 | } |
| 77 | |
| 78 | public function installer_status_ajax () { |
| 79 | check_ajax_referer( 'siteorigin_installer_status', 'nonce' ); |
| 80 | update_option( 'siteorigin_installer', rest_sanitize_boolean( $_POST['status'] ) ); |
| 81 | die(); |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | SiteOrigin_Installer::single(); |
| 86 |