-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmaera-recipes.php
104 lines (79 loc) · 2.91 KB
/
maera-recipes.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
<?php
/**
* Plugin Name: Maera Recipes
* Plugin URI: https://press.codes
* Version: 0.1.0
* Text Domain: maera-recipes
* Domain Path: /languages/
*/
define( 'MAERA_RECIPES_PATH', plugin_dir_path( __FILE__ ) );
define( 'MAERA_RECIPES_URL', plugins_url( '', __FILE__ ) );
function maera_recipes_include_acf() {
if ( ! class_exists( 'acf' ) ) {
require_once( MAERA_RECIPES_PATH . 'includes/advanced-custom-fields-pro/acf.php' );
}
}
add_action( 'plugins_loaded', 'maera_recipes_include_acf' );
require_once( MAERA_RECIPES_PATH . 'includes/post-type.php' );
require_once( MAERA_RECIPES_PATH . 'includes/taxonomies.php' );
require_once( MAERA_RECIPES_PATH . 'includes/fields-acf.php' );
require_once( MAERA_RECIPES_PATH . 'includes/class-maera-recipes.php' );
require_once( MAERA_RECIPES_PATH . 'includes/class-maera-recipes-admin-styles.php' );
require_once( MAERA_RECIPES_PATH . 'includes/reviews/class-maera-recipes-reviews.php' );
new Maera_Recipes_Reviews( 'recipe' );
require_once( MAERA_RECIPES_PATH . 'includes/scripts.php' );
require_once( MAERA_RECIPES_PATH . 'includes/customizer/customizer.php' );
require_once( MAERA_RECIPES_PATH . 'includes/customizer/styles.php' );
/**
* Instantiate the main plugin class
*/
function Maera_Recipes() {
$recipes = new Maera_Recipes();
$recipes->admin_styles = new Maera_Recipes_Admin_Styles();
}
Maera_Recipes();
function maera_recipes_get_template_part( $template ) {
if ( '' != locate_template( $template . '.php' ) ) {
$file = locate_template( $template . '.php' );
} else {
$file = MAERA_RECIPES_PATH . '/templates/' . $template . '.php';
}
if ( file_exists( $file ) ) {
load_template( $file );
}
}
function maera_recipes_single_recipe_content( $content ) {
global $post;
// Are we on a recipe?
// Does the user have a template file for content-recipe in their theme?
if ( ! is_singular( 'recipe' ) ) {
return $content;
}
maera_recipes_get_template_part( 'content-recipe' );
}
add_filter( 'the_content', 'maera_recipes_single_recipe_content' );
function maera_recipes_get_option( $option = '' ) {
if ( '' == $option ) {
return null;
}
$default_options = array(
'display_featured_image' => '1',
'display_description' => '1',
'display_rating' => '1',
'display_author' => '1',
'display_date' => '1',
);
$options = wp_parse_args( get_option( 'maera_recipes', array() ), $default_options );
if ( ! isset( $options[$option] ) ) {
return null;
}
return $options[$option];
}
function maera_recipes_recipe_excerpt( $excerpt ) {
global $post;
if ( 'recipe' != $post->post_type ) {
return $content;
}
maera_recipes_get_template_part( 'content-recipe-excerpt' );
}
add_filter( 'get_the_excerpt', 'maera_recipes_recipe_excerpt' );