-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomponentizer.php
74 lines (60 loc) · 2.34 KB
/
componentizer.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
<?php
/*
Plugin Name: Componentizer
Description: A tiny MVC for WordPress components.
Version: 1.4.0
Author URI: http://davohynds.com
Author: Davo Hynds
*/
// we look for Composer files first in the plugins dir.
// then in the wp-content dir (site install).
// and finally in the current themes directories.
if ( file_exists( $composer_autoload = __DIR__ . '/vendor/autoload.php' ) /* check in self */
|| file_exists( $composer_autoload = WP_CONTENT_DIR.'/vendor/autoload.php') /* check in wp-content */
|| file_exists( $composer_autoload = plugin_dir_path( __FILE__ ).'vendor/autoload.php') /* check in plugin directory */
|| file_exists( $composer_autoload = get_stylesheet_directory().'/vendor/autoload.php') /* check in child theme */
|| file_exists( $composer_autoload = get_template_directory().'/vendor/autoload.php') /* check in parent theme */
) {
require_once $composer_autoload;
new \Componentizer\Componentizer;
}
// Require these files
/*$componenentizer_includes = array(
'FieldGroups.php',
'Components.php',
'Context.php',
'admin/Admin.php',
'admin/SettingsPage.php',
'admin/EditPage.php',
);
$plugin_directory = plugin_dir_path(__FILE__);
foreach ($componenentizer_includes as $file) {
$filepath = $plugin_directory.$file;
if (!file_exists($filepath)) {
trigger_error(sprintf(__('Error locating %s for inclusion', 'componentizer'), $filepath), E_USER_ERROR);
}
require_once $filepath;
}
unset($file, $filepath);*/
register_activation_hook( __FILE__, 'componentizer_activate' );
function componentizer_activate() {
$plugin_data = get_plugin_data(__FILE__);
add_option('componentizer_db_version',$plugin_data['Version']);
add_action('after_theme_setup', 'install');
$exclude_post_types = get_post_types(['public' => false]);
add_option('componentizer_advanced_settings',[
'json_path' => 'componentizer-json',
'component_path' => 'controllers',
'exclude_post_types' => $exclude_post_types,
]);
add_option('componentizer_fields',[]);
add_option('componentizer_visible_on_archive',[]);
add_option('componentizer_location_orders',[
'top'=>[],
'bottom'=>[]
]);
$db_version = get_option( "componentizer_db_version" );
if ( $db_version != $plugin_data['Version'] ) {
}
add_role( 'edit_componentizer_options', __('Componentizer Options','componentizer'), array( 'level_10' => true ) );
}