PluginProbe
Machete / 5.1
Machete v5.1
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.1, at machete.php

103 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.1
7 * Requires at least: 4.6
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.0' );
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 disabled modules.
61 $machete_disabled_modules = get_option( 'machete_disabled_modules', array() );
62 foreach ( $machete_disabled_modules as $machete_module ) {
63 if (
64 isset( $machete->modules[ $machete_module ] ) &&
65 $machete->modules[ $machete_module ]->params['can_be_disabled']
66 ) {
67 $machete->modules[ $machete_module ]->params['is_active'] = false;
68 }
69 }
70
71 // Main init.
72 add_action(
73 'init',
74 function () {
75 global $machete;
76
77 load_plugin_textdomain( 'machete', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
78
79 // Manage of external modules.
80 if ( defined( 'MACHETE_POWERTOOLS_INIT' ) ) {
81 $machete->modules['powertools']->params['is_active'] = true;
82 $machete->modules['powertools']->params['description'] = __( 'Machete PowerTools are now active! Enjoy your new toy!', 'machete' );
83 }
84
85 // Disable WooCommerce module if WooCommece is active.
86 if ( ! function_exists( 'is_woocommerce' ) ) {
87 $machete->modules['woocommerce']->params['is_active'] = false;
88 $machete->modules['woocommerce']->params['can_be_enabled'] = false;
89 $machete->modules['woocommerce']->params['description'] .= ' ' . __( 'You have to install and activate WooCommerce to use this module.', 'machete' );
90 }
91
92 if ( defined( 'WP_CLI' ) && WP_CLI ) {
93 define( 'MACHETE_CLI_INIT', true );
94 } elseif ( ! is_admin() ) {
95 define( 'MACHETE_FRONT_INIT', true );
96 require_once 'machete-frontend.php';
97 } else {
98 define( 'MACHETE_ADMIN_INIT', true );
99 require_once 'machete-admin.php';
100 }
101 }
102 );
103