PluginProbe
Machete / 5.3
Machete v5.3
5.3 trunk 3.5.1 4.0 4.0.1 4.0.2 4.0.3 5.0 5.0.1 5.1 5.2
machete / machete.php

machete.php in Machete 5.3, at machete.php

110 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Machete
4 * Plugin URI: https://machetewp.com
5 * Description: Machete is a lean and simple suite of tools that makes WordPress development easier: cookie bar, tracking codes, custom code editor, header cleanup, post and page cloner
6 * Version: 5.3
7 * Requires at least: 5.9
8 * Requires PHP: 7.4
9 * Author: Nilo Velez
10 * Author URI: https://www.nilovelez.com
11 * License: WTFPL
12 * License URI: http://www.wtfpl.net/txt/copying/
13
14 * Text Domain: machete
15 * Domain Path: /languages
16
17 * @package WordPress
18 * @subpackage Machete
19 */
20
21 if ( ! defined( 'ABSPATH' ) ) {
22 exit;
23 }
24
25 define( 'MACHETE_VERSION', '5.3' );
26
27 $machete_get_upload_dir = wp_upload_dir();
28 define( 'MACHETE_BASE_PATH', plugin_dir_path( __FILE__ ) );
29 define( 'MACHETE_RELATIVE_BASE_PATH', substr( MACHETE_BASE_PATH, strlen( ABSPATH ) - 1 ) );
30 define( 'MACHETE_BASE_URL', plugin_dir_url( __FILE__ ) );
31
32 define( 'MACHETE_DATA_PATH', $machete_get_upload_dir['basedir'] . '/machete/' );
33 define( 'MACHETE_RELATIVE_DATA_PATH', substr( MACHETE_DATA_PATH, strlen( ABSPATH ) - 1 ) );
34 define( 'MACHETE_DATA_URL', $machete_get_upload_dir['baseurl'] . '/machete/' );
35
36 register_activation_hook(
37 __FILE__,
38 function () {
39 add_option( 'machete_activation_welcome', 'pending' );
40 }
41 );
42
43 // Include main Machete classes.
44 require MACHETE_BASE_PATH . 'inc/class-machete.php';
45 require MACHETE_BASE_PATH . 'inc/class-machete-module.php';
46
47 // Include Machete modules.
48 global $machete;
49 $machete = new MACHETE();
50 require MACHETE_BASE_PATH . 'inc/about/class-machete-about-module.php';
51 require MACHETE_BASE_PATH . 'inc/cleanup/class-machete-cleanup-module.php';
52 require MACHETE_BASE_PATH . 'inc/cookies/class-machete-cookies-module.php';
53 require MACHETE_BASE_PATH . 'inc/utils/class-machete-utils-module.php';
54 require MACHETE_BASE_PATH . 'inc/maintenance/class-machete-maintenance-module.php';
55 require MACHETE_BASE_PATH . 'inc/clone/class-machete-clone-module.php';
56 require MACHETE_BASE_PATH . 'inc/social/class-machete-social-module.php';
57 require MACHETE_BASE_PATH . 'inc/woocommerce/class-machete-woocommerce-module.php';
58 require MACHETE_BASE_PATH . 'inc/powertools/class-machete-powertools-module.php';
59
60 // Management of enabled modules.
61 if ( null === get_option( 'machete_enabled_modules', null ) ) {
62 $machete_enabled_modules = array();
63 foreach ( $machete->modules as $machete_module ) {
64 if ( ! $machete_module->params['can_be_disabled'] ) {
65 continue;
66 }
67 if ( $machete_module->params['is_active_default'] ) {
68 $machete_enabled_modules[] = $machete_module->params['slug'];
69 }
70 }
71 add_option( 'machete_enabled_modules', $machete_enabled_modules );
72 }
73
74 $machete_enabled_modules = get_option( 'machete_enabled_modules', array() );
75 foreach ( $machete->modules as $machete_module ) {
76 if ( ! $machete_module->params['can_be_disabled'] ) {
77 continue;
78 }
79 $machete_module->params['is_active'] = in_array(
80 $machete_module->params['slug'],
81 $machete_enabled_modules,
82 true
83 );
84 }
85
86 // Main init.
87 add_action(
88 'init',
89 function () {
90 global $machete;
91
92 // Disable WooCommerce module if WooCommece is active.
93 if ( ! function_exists( 'is_woocommerce' ) ) {
94 $machete->modules['woocommerce']->params['is_active'] = false;
95 $machete->modules['woocommerce']->params['can_be_enabled'] = false;
96 $machete->modules['woocommerce']->params['description'] .= ' ' . __( 'You have to install and activate WooCommerce to use this module.', 'machete' );
97 }
98
99 if ( defined( 'WP_CLI' ) && WP_CLI ) {
100 define( 'MACHETE_CLI_INIT', true );
101 } elseif ( ! is_admin() ) {
102 define( 'MACHETE_FRONT_INIT', true );
103 require_once 'machete-frontend.php';
104 } else {
105 define( 'MACHETE_ADMIN_INIT', true );
106 require_once 'machete-admin.php';
107 }
108 }
109 );
110