-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathvoicewp.php
122 lines (101 loc) · 3.11 KB
/
voicewp.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
<?php
/**
* Plugin Name: VoiceWP
* Description: Create Alexa skills using your WordPress site
* Plugin URI: https://github.com/tomharrigan/
* Author: TomHarrigan
* Author URI: https://voicewp.com
* Version: 1.0.0
* Text Domain: voicewp
* License: MIT
*/
define( 'VOICEWP_PATH', dirname( __FILE__ ) );
register_activation_hook( __FILE__, 'voicewp_activate' );
function voicewp_activate() {
Voicewp::get_instance();
flush_rewrite_rules();
}
register_deactivation_hook( __FILE__, 'voicewp_deactivate' );
function voicewp_deactivate() {
flush_rewrite_rules();
}
/**
* Compatibility requirements.
*/
require_once( VOICEWP_PATH . '/inc/compat.php' );
/**
* Post Type Base Class
*/
require_once( VOICEWP_PATH . '/inc/post-types/class-voicewp-post-type.php' );
/**
* Skill Post Type
*/
require_once( VOICEWP_PATH . '/inc/post-types/class-voicewp-post-type-skill.php' );
/**
* Flash Briefing Post Type
*/
require_once( VOICEWP_PATH . '/inc/post-types/class-voicewp-post-type-briefing.php' );
/**
* Taxonomy Base Class
*/
require_once( VOICEWP_PATH . '/inc/taxonomies/class-voicewp-taxonomy.php' );
/**
* Briefing Category Taxonomy
*/
require_once( VOICEWP_PATH . '/inc/taxonomies/class-voicewp-briefing-category.php' );
/**
* Fieldmanager custom fields
*/
function voicewp_load_fieldmanager_fields() {
if ( defined( 'FM_VERSION' ) ) {
require_once( VOICEWP_PATH . '/inc/voicewp-fieldmanager-content-textarea.php' );
require_once( VOICEWP_PATH . '/inc/fields.php' );
}
}
add_action( 'init', 'voicewp_load_fieldmanager_fields' );
require_once( VOICEWP_PATH . '/inc/class-voicewp-setup.php' );
require_once( VOICEWP_PATH . '/inc/class-voicewp.php' );
add_action( 'init', array( 'Voicewp', 'get_instance' ), 0 );
/**
* Load a class from within the plugin based on a class name.
*
* @param string $classname Class name to load.
*/
function voicewp_autoload_function( $classname ) {
if ( class_exists( $classname ) || 0 !== strpos( $classname, 'Alexa' ) ) {
return;
}
$class = str_replace( '\\', DIRECTORY_SEPARATOR, str_replace( '_', '-', strtolower( $classname ) ) );
// create the actual filepath
$file_path = VOICEWP_PATH . DIRECTORY_SEPARATOR . $class . '.php';
// check if the file exists
if ( file_exists( $file_path ) ) {
// require once on the file
require_once $file_path;
}
}
/**
* Get the post types whose content is included in the bundled News skill.
*
* @return array Post type names.
*/
function voicewp_news_post_types() {
/**
* Filters the post types whose content is included in the bundled News skill.
*
* @param array $post_types Post type names.
*/
return apply_filters( 'voicewp_post_types', array( 'post' ) );
}
/**
* Get the taxonomies whose terms can be specified by users invoking the News skill.
*
* @return array Taxonomy names.
*/
function voicewp_news_taxonomies() {
$option = get_option( 'voicewp-settings' );
$taxonomies = ( empty( $option['latest_taxonomies'] ) ) ? array() : $option['latest_taxonomies'];
// Nonexistant taxonomies can shortcircuit get_terms().
return array_filter( $taxonomies, 'taxonomy_exists' );
}
spl_autoload_register( 'voicewp_autoload_function' );