-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfreemius.php
More file actions
88 lines (73 loc) · 1.93 KB
/
Copy pathfreemius.php
File metadata and controls
88 lines (73 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/**
* Plugin Name: Freemius for WordPress
* Description: Freemius Toolkit
* Requires at least: 6.6
* Requires PHP: 7.4
* Version: 0.4.2
* Author: Freemius
* Author URI: https://freemius.com
* License: MIT
*
* @package Freemius
*/
namespace Freemius;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
define( 'FREEMIUS_PLUGIN_DIR', __DIR__ );
define( 'FREEMIUS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
require_once __DIR__ . '/vendor/autoload.php';
// Autoload classes
spl_autoload_register(
function ( $class_name ) {
// Project-specific namespace prefix
$prefix = 'Freemius\\';
// Base directory for the namespace prefix
$base_dir = FREEMIUS_PLUGIN_DIR . '/includes/';
// Check if the class uses the namespace prefix
$len = strlen( $prefix );
if ( strncmp( $prefix, $class_name, $len ) !== 0 ) {
return;
}
// Get the relative class name
$relative_class = substr( $class_name, $len );
// Replace namespace separators with directory separators
$file = $base_dir . 'class-freemius-' . strtolower( str_replace( '_', '-', $relative_class ) ) . '.php';
// If the file exists, require it
if ( file_exists( $file ) ) {
require $file;
}
}
);
/**
* Bootstrap plugin components.
*
* @return void
*/
function init() {
Button::get_instance();
Scope::get_instance();
Settings::get_instance();
Api::get_instance();
Blocks::get_instance();
}
\add_action( 'plugins_loaded', __NAMESPACE__ . '\\init' );
/**
* Plugin activation hook
*
* @return void
*/
function activate() {
// Redirect on shutdown so plugin is actually loaded.
add_action( 'shutdown', array( Settings::get_instance(), 'activation_redirect' ) );
}
register_activation_hook( __FILE__, __NAMESPACE__ . '\\activate' );
/**
* Plugin deactivation hook
*
* @return void
*/
function deactivate() {
}
register_deactivation_hook( __FILE__, __NAMESPACE__ . '\\deactivate' );