PluginProbe
Machete / 4.0.1
Machete v4.0.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 4.0.1, at machete.php

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