-
Notifications
You must be signed in to change notification settings - Fork 13
/
atlas-content-modeler.php
136 lines (121 loc) · 4.61 KB
/
atlas-content-modeler.php
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
/**
* Plugin Name: Atlas Content Modeler
* Plugin URI: https://developers.wpengine.com/
* Description: Model content for headless WordPress.
* Author: WP Engine
* Author URI: https://wpengine.com/
* Text Domain: atlas-content-modeler
* Domain Path: /languages
* Version: 0.26.2
* Requires at least: 5.7
* Requires PHP: 7.2
* License: GPLv2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Update URI: false
*
* @package AtlasContentModeler
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
define( 'ATLAS_CONTENT_MODELER_FILE', __FILE__ );
define( 'ATLAS_CONTENT_MODELER_INCLUDES_DIR', __DIR__ . '/includes/' );
define( 'ATLAS_CONTENT_MODELER_URL', plugin_dir_url( __FILE__ ) );
define( 'ATLAS_CONTENT_MODELER_PATH', plugin_basename( ATLAS_CONTENT_MODELER_FILE ) );
define( 'ATLAS_CONTENT_MODELER_SLUG', dirname( plugin_basename( ATLAS_CONTENT_MODELER_FILE ) ) );
add_action( 'plugins_loaded', 'atlas_content_modeler_loader' );
/**
* Bootstraps the plugin.
*/
function atlas_content_modeler_loader(): void {
$composer_autoloader = __DIR__ . '/vendor/autoload.php';
if ( file_exists( $composer_autoloader ) ) {
include_once $composer_autoloader;
}
load_plugin_textdomain( 'atlas_content_modeler', false, __DIR__ . '/languages' );
$plugin_files = array(
'publisher/lib/field-functions.php',
'shared-assets/wp_scripts/shared_assets.php',
'settings/settings-callbacks.php',
'content-registration/custom-post-types-registration.php',
'content-registration/register-taxonomies.php',
'content-registration/graphql-mutations.php',
'content-registration/class-wpe-rest-posts-controller.php',
'rest-api/init-rest-api.php',
'publisher/class-publisher-form-editing-experience.php',
'updates/version-updates.php',
'content-connect/autoload.php',
'blueprints/import.php',
'blueprints/fetch.php',
'blueprints/export.php',
'api/crud-functions.php',
'api/validation-functions.php',
'api/utility-functions.php',
'class-validation-exception.php',
'class-wp-error.php',
);
foreach ( $plugin_files as $file ) {
include_once ATLAS_CONTENT_MODELER_INCLUDES_DIR . $file;
}
if ( defined( 'WP_CLI' ) && WP_CLI ) {
include_once ATLAS_CONTENT_MODELER_INCLUDES_DIR . '/wp-cli/class-blueprint.php';
include_once ATLAS_CONTENT_MODELER_INCLUDES_DIR . '/wp-cli/class-reset.php';
include_once ATLAS_CONTENT_MODELER_INCLUDES_DIR . '/wp-cli/class-model.php';
\WP_CLI::add_command( 'acm blueprint', 'WPE\AtlasContentModeler\WP_CLI\Blueprint' );
\WP_CLI::add_command( 'acm reset', new WPE\AtlasContentModeler\WP_CLI\Reset() );
\WP_CLI::add_command( 'acm model', 'WPE\AtlasContentModeler\WP_CLI\Model' );
}
\WPE\AtlasContentModeler\VersionUpdater\update_plugin();
new \WPE\AtlasContentModeler\FormEditingExperience();
// Bootstrap relationships library.
acm_content_connect_autoloader();
\WPE\AtlasContentModeler\ContentConnect\Plugin::instance();
}
/**
* Determines if opt-in usage tracking is enabled.
*
* @return bool True if enabled, false if not.
*/
function acm_usage_tracking_enabled(): bool {
return (bool) get_option( 'atlas_content_modeler_usage_tracking', false );
}
add_action( 'admin_notices', 'acm_deprecation_notice' );
/**
* Displays the ACM deprecation admin notice.
*/
function acm_deprecation_notice(): void {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
?>
<div class="notice notice-warning">
<p>
<?php
echo wp_kses_post(
sprintf(
/* translators: %1$s: The plugin name. %2$s URL to deprecation documentation. */
__( 'The <strong>%1$s</strong> plugin is entering an end-of-life phase. It will be maintained for compatibility and security purposes through 2024. Read more about the deprecation plan and our recommended replacement <a aria-label="ACM Deprecation Documentation - link opens in a new tab" href="%2$s" target="_blank">here</a>.', 'atlas-content-modeler' ),
'Atlas Content Modeler',
'https://github.com/wpengine/atlas-content-modeler/blob/main/docs/end-of-life/index.md'
)
);
?>
</p>
</div>
<?php
}
/**
* Initialize the checking for plugin updates.
*/
function acm_check_for_updates() {
$properties = array(
// This must match the key in "https://wpe-plugin-updates.wpengine.com/plugins.json".
'plugin_slug' => 'atlas-content-modeler',
// This must be the result of calling plugin_basename( __FILE__ ) IN YOUR MAIN PLUGIN's FILE.
'plugin_basename' => ATLAS_CONTENT_MODELER_PATH,
);
require_once ATLAS_CONTENT_MODELER_INCLUDES_DIR . 'class-plugin-updater.php';
new \WPE\AtlasContentModeler\Updates\PluginUpdater( $properties );
}
add_action( 'admin_init', 'acm_check_for_updates' );