css
1 month ago
data
2 years ago
github-updater
1 month ago
img
1 month ago
inc
1 year ago
js
2 years ago
tpl
1 year ago
LICENSE
1 month ago
changelog.md
1 month ago
readme.md
1 month ago
siteorigin-installer.php
1 month ago
siteorigin-installer.php
102 lines
| 1 | <?php |
| 2 | /* |
| 3 | Plugin Name: SiteOrigin Installer |
| 4 | Description: Streamline your WordPress setup with SiteOrigin's essential plugins and compatible themes in one go. |
| 5 | Version: 1.0.4 |
| 6 | Requires at least: 5.8 |
| 7 | Tested up to: 6.8 |
| 8 | Requires PHP: 7.0.0 |
| 9 | Author: SiteOrigin |
| 10 | Text Domain: siteorigin-installer-text-domain |
| 11 | Author URI: https://siteorigin.com |
| 12 | Plugin URI: https://siteorigin.com/installer/ |
| 13 | Update URI: https://github.com/siteorigin/siteorigin-installer/ |
| 14 | License: GPLv3 |
| 15 | License URI: https://www.gnu.org/licenses/gpl-3.0.html |
| 16 | */ |
| 17 | |
| 18 | if ( ! defined( 'SITEORIGIN_INSTALLER_VERSION' ) ) { |
| 19 | define( 'SITEORIGIN_INSTALLER_VERSION', '1.0.4' ); |
| 20 | define( 'SITEORIGIN_INSTALLER_DIR', plugin_dir_path( __FILE__ ) ); |
| 21 | define( 'SITEORIGIN_INSTALLER_URL', plugin_dir_url( __FILE__ ) ); |
| 22 | } |
| 23 | |
| 24 | if ( ! class_exists( 'SiteOrigin_Installer' ) ) { |
| 25 | class SiteOrigin_Installer { |
| 26 | public function __construct() { |
| 27 | add_filter( 'siteorigin_premium_affiliate_id', array( $this, 'affiliate_id' ) ); |
| 28 | add_filter( 'init', array( $this, 'setup' ) ); |
| 29 | add_filter( 'siteorigin_add_installer', array( $this, 'load_status' ) ); |
| 30 | add_action( 'wp_ajax_so_installer_status', array( $this, 'installer_status_ajax' ) ); |
| 31 | } |
| 32 | |
| 33 | public static function single() { |
| 34 | static $single; |
| 35 | |
| 36 | return empty( $single ) ? $single = new self() : $single; |
| 37 | } |
| 38 | |
| 39 | public static function user_has_permission() { |
| 40 | return ( |
| 41 | ! defined( 'DISALLOW_FILE_MODS' ) || |
| 42 | ! DISALLOW_FILE_MODS |
| 43 | ) && |
| 44 | current_user_can( 'install_plugins' ) && |
| 45 | current_user_can( 'install_themes' ) && |
| 46 | current_user_can( 'update_themes' ) && |
| 47 | current_user_can( 'update_plugins' ); |
| 48 | } |
| 49 | |
| 50 | public function setup() { |
| 51 | if ( |
| 52 | apply_filters( 'siteorigin_add_installer', true ) && |
| 53 | is_admin() && |
| 54 | self::user_has_permission() |
| 55 | ) { |
| 56 | /** |
| 57 | * Determine if the SiteOrigin Installer is a standalone plugin to conditionally load the updater. |
| 58 | * This prevents loading the updater when the Installer is bundled within another plugin. |
| 59 | */ |
| 60 | $plugin_basename = plugin_basename( __FILE__ ); |
| 61 | $is_standalone = ( |
| 62 | $plugin_basename === 'siteorigin-installer/siteorigin-installer.php' || |
| 63 | strpos( $plugin_basename, 'siteorigin-installer-' ) === 0 |
| 64 | ); |
| 65 | |
| 66 | if ( $is_standalone ) { |
| 67 | if ( file_exists( plugin_dir_path( __FILE__ ) . 'github-updater/updater.php' ) ) { |
| 68 | require_once plugin_dir_path( __FILE__ ) . 'github-updater/updater.php'; |
| 69 | new SiteOrigin_Updater( __FILE__, 'siteorigin-installer', 'siteorigin/siteorigin-installer' ); |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | require_once __DIR__ . '/inc/admin.php'; |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Get the Affiliate ID from the database. |
| 79 | * |
| 80 | * @return mixed|void |
| 81 | */ |
| 82 | public function affiliate_id( $id ) { |
| 83 | if ( get_option( 'siteorigin_premium_affiliate_id' ) ) { |
| 84 | $id = get_option( 'siteorigin_premium_affiliate_id' ); |
| 85 | } |
| 86 | |
| 87 | return $id; |
| 88 | } |
| 89 | |
| 90 | public function load_status() { |
| 91 | return (bool) get_option( 'siteorigin_installer', true ); |
| 92 | } |
| 93 | |
| 94 | public function installer_status_ajax () { |
| 95 | check_ajax_referer( 'siteorigin_installer_status', 'nonce' ); |
| 96 | update_option( 'siteorigin_installer', rest_sanitize_boolean( $_POST['status'] ) ); |
| 97 | die(); |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | SiteOrigin_Installer::single(); |
| 102 |