Repository navigation
Expand file tree
/
Copy pathcortext.php
More file actions
65 lines (59 loc) · 2.22 KB
/
Copy pathcortext.php
File metadata and controls
65 lines (59 loc) · 2.22 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
<?php
/**
* Plugin Name: Cortext
* Plugin URI: https://github.com/Automattic/cortext
* Description: Build a WordPress-native knowledge base with pages, typed collections, views, and public publishing.
* Version: 0.2.0
* Requires at least: 7.1
* Requires PHP: 8.1
* Author: Héctor Prieto, Miguel Fonseca
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: cortext
*
* @package Cortext
*/
defined( 'ABSPATH' ) || exit;
define( 'CORTEXT_VERSION', '0.2.0' );
define( 'CORTEXT_PATH', plugin_dir_path( __FILE__ ) );
define( 'CORTEXT_URL', plugin_dir_url( __FILE__ ) );
$cortext_autoload = CORTEXT_PATH . 'vendor/autoload.php';
if ( ! file_exists( $cortext_autoload ) ) {
add_action(
'admin_notices',
static function () {
echo '<div class="notice notice-error"><p>';
echo esc_html__( 'Cortext: Composer dependencies are missing. Run "composer install" in the plugin directory.', 'cortext' );
echo '</p></div>';
}
);
return;
}
require $cortext_autoload;
add_action(
'plugins_loaded',
static function () {
\Cortext\Plugin::instance()->boot();
}
);
register_activation_hook(
__FILE__,
static function () {
// Register the document CPT and its trait taxonomy explicitly so
// `flush_rewrite_rules()` below sees Cortext's rewrite rules. The
// same registration runs again on `init` during normal boot via
// `Plugin::boot()`.
( new \Cortext\PostType\Document() )->register_post_type();
( new \Cortext\Taxonomy\TraitTaxonomy() )->register_taxonomy();
( new \Cortext\FieldValues\FieldValueIndex() )->activate();
flush_rewrite_rules();
}
);
if ( defined( 'WP_CLI' ) && WP_CLI ) {
\WP_CLI::add_command( 'cortext seed', \Cortext\CLI\SeedDummyCollections::class );
\WP_CLI::add_command( 'cortext field-values', \Cortext\CLI\FieldValues::class );
\WP_CLI::add_command( 'cortext perf-seed', array( \Cortext\CLI\PerfBench::class, 'seed' ) );
\WP_CLI::add_command( 'cortext perf-bench', array( \Cortext\CLI\PerfBench::class, 'bench' ) );
\WP_CLI::add_command( 'cortext backfill-media', \Cortext\CLI\BackfillMedia::class );
\WP_CLI::add_command( 'cortext backfill-mentions', \Cortext\CLI\BackfillMentions::class );
}