-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfunctions.php
177 lines (145 loc) · 5.24 KB
/
functions.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
/**
* Ample functions related to defining constants, adding files and WordPress core functionality.
*
* @package ThemeGrill
* @subpackage Ample
* @since Ample 0.1
*/
/**
* Set the content width based on the theme's design and stylesheet.
*/
if ( ! isset( $content_width ) )
$content_width = 710; /* pixels */
/**
* $content_width global variable adjustment as per layout option.
*/
function ample_content_width() {
global $post;
global $content_width;
if( $post ) { $layout_meta = get_post_meta( $post->ID, 'ample_page_layout', true ); }
if( empty( $layout_meta ) || is_archive() || is_search() ) { $layout_meta = 'default_layout'; }
$ample_default_layout = ample_option( 'ample_default_layout', 'right_sidebar' );
if( $layout_meta == 'default_layout' ) {
if ( $ample_default_layout == 'no_sidebar_full_width' ) { $content_width = 1100; /* pixels */ }
elseif ( $ample_default_layout == 'both_sidebar' ) { $content_width = 500; /* pixels */ }
else { $content_width = 710; /* pixels */ }
}
elseif ( $layout_meta == 'no_sidebar_full_width' ) { $content_width = 1100; /* pixels */ }
elseif ( $layout_meta == 'both_sidebar' ) { $content_width = 500; /* pixels */ }
else { $content_width = 710; /* pixels */ }
}
add_action( 'template_redirect', 'ample_content_width' );
add_action( 'after_setup_theme', 'ample_setup' );
if ( ! function_exists( 'ample_setup' ) ) :
/**
* Sets up theme defaults and registers support for various WordPress features.
*
*/
function ample_setup() {
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
*/
load_theme_textdomain( 'ample', get_template_directory() . '/languages' );
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded <title> tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
// Gutenberg layout support.
add_theme_support( 'align-wide' );
// Gutenberg block layout support.
add_theme_support( 'wp-block-styles' );
// Gutenberg editor support.
add_theme_support( 'responsive-embeds' );
//Enable support for Post Thumbnails on posts and pages.
add_theme_support( 'post-thumbnails' );
// Added WooCommerce support.
add_theme_support( 'woocommerce' );
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
// Cropping the images to different sizes to be used in the theme
add_image_size( 'ample-featured-blog-large', 710, 300, true );
add_image_size( 'ample-featured-blog-small', 230, 230, true );
add_image_size( 'ample-portfolio-image', 330, 330, true );
// Registering navigation menus.
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'ample' ),
'footer' => __( 'Footer Menu', 'ample' ),
) );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form', 'comment-form', 'comment-list', 'gallery', 'caption',
) );
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'ample_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
) ) );
// Adding excerpt option box for pages as well
add_post_type_support( 'page', 'excerpt' );
// Adds the support for the Custom Logo introduced in WordPress 4.5
add_theme_support( 'custom-logo',
array(
'flex-width' => true,
'flex-height' => true,
)
);
// Support for selective refresh widgets in Customizer
add_theme_support( 'customize-selective-refresh-widgets' );
}
endif; // ample_setup
/**
* Register widget area.
*
*/
require get_template_directory() . '/inc/widgets/widgets.php';
/**
* Enqueue scripts and styles.
*/
require get_template_directory() . '/inc/functions.php';
/**
* Functions related to header.
*/
require get_template_directory() . '/inc/header-functions.php';
/**
* Implement the Custom Header feature.
*/
require get_template_directory() . '/inc/custom-header.php';
/**
* Add meta Box
*/
require get_template_directory() . '/inc/admin/meta-boxes.php';
/**
* Add Customizer
*/
require_once( get_template_directory() . '/inc/customizer.php' );
/**
* Detect plugin. For use on Front End only.
*/
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
/**
* Assign the Ample version to a variable.
*/
$ample_theme = wp_get_theme( 'ample' );
define( 'AMPLE_THEME_VERSION', $ample_theme->get( 'Version' ) );
/**
* Calling in the admin area for the Welcome Page as well as for the new theme notice too.
*/
if ( is_admin() ) {
require get_template_directory() . '/inc/admin/class-ample-admin.php';
require get_template_directory() . '/inc/admin/class-ample-dashboard.php';
require get_template_directory() . '/inc/admin/class-ample-notice.php';
require get_template_directory() . '/inc/admin/class-ample-welcome-notice.php';
require get_template_directory() . '/inc/admin/class-ample-upgrade-notice.php';
require get_template_directory() . '/inc/admin/class-ample-theme-review-notice.php';
}