| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Admin login URL Change |
| 4 |
* Plugin URI: https://wordpress.org/plugins/admin-login-url-change/ |
| 5 |
* Description: Allows you to Change your WordPress WebSite Login URL. |
| 6 |
* Version: 1.2.2 |
| 7 |
* Requires at least: 4.7 |
| 8 |
* Tested up to: 7.1 |
| 9 |
* Requires PHP: 5.3 |
| 10 |
* Author: jahidcse |
| 11 |
* Author URI: https://profiles.wordpress.org/jahidcse/ |
| 12 |
* Text Domain: admin-login-url-change |
| 13 |
* License: GPLv2 or later |
| 14 |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 15 |
*/ |
| 16 |
|
| 17 |
if ( ! defined( 'ABSPATH' ) ) exit; |
| 18 |
|
| 19 |
/** |
| 20 |
* Main Plugin Class |
| 21 |
*/ |
| 22 |
final class ALUC_Plugin { |
| 23 |
|
| 24 |
const VERSION = '1.2.2'; |
| 25 |
const TEXT_DOMAIN = 'admin-login-url-change'; |
| 26 |
|
| 27 |
private static $instance = null; |
| 28 |
|
| 29 |
public static function instance() { |
| 30 |
if ( self::$instance === null ) { |
| 31 |
self::$instance = new self(); |
| 32 |
} |
| 33 |
return self::$instance; |
| 34 |
} |
| 35 |
|
| 36 |
private function __construct() { |
| 37 |
$this->define_constants(); |
| 38 |
$this->init_freemius(); |
| 39 |
$this->includes(); |
| 40 |
$this->init_hooks(); |
| 41 |
} |
| 42 |
|
| 43 |
private function define_constants() { |
| 44 |
define( 'VERSION', self::VERSION ); |
| 45 |
define( 'ALUC_PLUGIN_FILE', __FILE__ ); |
| 46 |
define( 'ALUC_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); |
| 47 |
define( 'ALUC_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
| 48 |
define( 'ALUC_PLUGIN_BASE', plugin_basename( __FILE__ ) ); |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* Initialize Freemius SDK. |
| 53 |
*/ |
| 54 |
public function init_freemius() { |
| 55 |
global $aluc_fs; |
| 56 |
if ( ! isset( $aluc_fs ) ) { |
| 57 |
// Activate multisite network integration. |
| 58 |
if ( ! defined( 'WP_FS__PRODUCT_30294_MULTISITE' ) ) { |
| 59 |
define( 'WP_FS__PRODUCT_30294_MULTISITE', true ); |
| 60 |
} |
| 61 |
// Include Freemius SDK. |
| 62 |
require_once dirname( __FILE__ ) . '/includes/vendor/start.php'; |
| 63 |
$aluc_fs = fs_dynamic_init( array( |
| 64 |
'id' => '30294', |
| 65 |
'slug' => 'admin-login-url-change', |
| 66 |
'type' => 'plugin', |
| 67 |
'public_key' => 'pk_2c94cff45c34767d817239ab7a965', |
| 68 |
'is_premium' => false, |
| 69 |
'has_addons' => false, |
| 70 |
'has_paid_plans' => true, |
| 71 |
'is_org_compliant' => true, |
| 72 |
'menu' => array( |
| 73 |
'slug' => 'admin-login-url-change', |
| 74 |
'support' => false, |
| 75 |
), |
| 76 |
'is_live' => true, |
| 77 |
) ); |
| 78 |
} |
| 79 |
return $aluc_fs; |
| 80 |
} |
| 81 |
|
| 82 |
private function includes() { |
| 83 |
require_once ALUC_PLUGIN_PATH . 'includes/class-aluc-login-handler.php'; |
| 84 |
} |
| 85 |
|
| 86 |
private function init_hooks() { |
| 87 |
add_action( 'plugins_loaded', [ 'ALUC_Login_Handler', 'init' ] ); |
| 88 |
add_action( 'activated_plugin', array($this, 'aluc_activated_callback')); |
| 89 |
} |
| 90 |
|
| 91 |
public function aluc_activated_callback($plugin){ |
| 92 |
if ( plugin_basename( __FILE__ ) == $plugin ) { |
| 93 |
wp_redirect( admin_url( 'admin.php?page=admin-login-url-change') ); |
| 94 |
die(); |
| 95 |
} |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
/** |
| 100 |
* Init plugin |
| 101 |
*/ |
| 102 |
function ALUC() { |
| 103 |
return ALUC_Plugin::instance(); |
| 104 |
} |
| 105 |
ALUC(); |
| 106 |
|
| 107 |
// Define easy access helper function if not defined already. |
| 108 |
if ( ! is_plugin_active( 'admin-login-url-change-pro/admin-login-url-change-pro.php' ) && ! function_exists( 'aluc_fs' ) ) { |
| 109 |
function aluc_fs() { |
| 110 |
return ALUC()->init_freemius(); |
| 111 |
} |
| 112 |
} |
| 113 |
|
| 114 |
// Signal that SDK was initiated. |
| 115 |
// Note: This action is triggered right after class instantiates Freemius. |
| 116 |
do_action( 'aluc_fs_loaded' ); |
| 117 |
|
| 118 |
/** |
| 119 |
* Activation / Deactivation hooks |
| 120 |
*/ |
| 121 |
register_activation_hook( __FILE__, function () { |
| 122 |
ALUC(); // load plugin |
| 123 |
flush_rewrite_rules(); |
| 124 |
}); |
| 125 |
|
| 126 |
register_deactivation_hook( __FILE__, function () { |
| 127 |
flush_rewrite_rules(); |
| 128 |
}); |
| 129 |
|