Repository navigation
Expand file tree
/
Copy pathplugin.php
More file actions
101 lines (88 loc) · 2.5 KB
/
Copy pathplugin.php
File metadata and controls
101 lines (88 loc) · 2.5 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
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
/**
* The plugin bootstrap file
*
* @link https://acf.wpi.pw
* @since 1.0.0
* @package ACF
*
* @wordpress-plugin
* Plugin Name: Advanced Custom Fields Wpi
* Plugin URI: https://acf.wpi.pw
* Description: A custom ACF plugin boilerplate
* Version: 1.0.0
* Author: Dima Minka
* Author URI: https://acf.wpi.pw
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: acf_wpi
* Domain Path: /
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
/**
* Helper function for prettying up errors
*
* @param string $message
* @param string $subtitle
* @param string $title
*/
$acf_error = function ( $message, $subtitle = '', $title = '' ) {
$title = $title ? $title : __( 'ACF › Error', 'acf_wpi' );
$footer = '<a href="https://acf.wpi.pw/">acf.wpi.pw</a>';
$message = "<h1>{$title}<br><small>{$subtitle}</small></h1><p>{$message}</p><p>{$footer}</p>";
wp_die( wp_kses_post( $message ), esc_attr( $title ) );
};
/**
* Ensure compatible version of PHP is used
*/
if ( version_compare( '7.1', phpversion(), '>=' ) ) {
$acf_error( __( 'You must be using PHP 7.1 or greater.', 'acf_wpi' ), __( 'Invalid PHP version', 'acf_wpi' ) );
}
/**
* Ensure dependencies are loaded
*/
if ( ! file_exists( dirname( __FILE__ ) . '/vendor/autoload.php' ) ) {
$acf_error(
__( 'You must run <code>composer install</code> from the ACF Wpi directory.', 'acf_wpi' )
);
} elseif ( file_exists( dirname( __FILE__ ) . '/vendor/autoload.php' ) ) {
require_once dirname( __FILE__ ) . '/vendor/autoload.php';
}
/**
* Displays a message that Advance Custom Fields/Ultimate Fields is needed for the theme.
*/
function acf_wpi_checker() {
if ( ! class_exists( 'acf' ) ) {
$message = __( 'Please install and activate Advanced Custom Fields', 'acf_wpi' );
printf( '<div class="notice notice-error"><p>%s</p></div>', esc_attr( $message ) );
}
}
add_action( 'admin_notices', 'acf_wpi_checker' );
/**
* The code that runs during plugin activation
*/
register_activation_hook(
__FILE__,
function () {
ACF\ACFWPI\Activate::activate();
}
);
/**
* The code that runs during plugin deactivation
*/
register_deactivation_hook(
__FILE__,
function () {
ACF\ACFWPI\Deactivate::deactivate();
}
);
/**
* Initialize all the core classes of the plugin
*/
if ( class_exists( 'ACF\\ACFWPI\\Init' ) ) {
$init = new ACF\ACFWPI\Init();
$init->run();
}