-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathfunctions.php
More file actions
211 lines (194 loc) · 7.08 KB
/
functions.php
File metadata and controls
211 lines (194 loc) · 7.08 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
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<?php
/**
* Neve functions.php file
*
* Author: Andrei Baicus <andrei@themeisle.com>
* Created on: 17/08/2018
*
* @package Neve
*/
define( 'NEVE_VERSION', '4.2.2' );
define( 'NEVE_INC_DIR', trailingslashit( get_template_directory() ) . 'inc/' );
define( 'NEVE_ASSETS_URL', trailingslashit( get_template_directory_uri() ) . 'assets/' );
define( 'NEVE_MAIN_DIR', get_template_directory() . '/' );
define( 'NEVE_BASENAME', basename( NEVE_MAIN_DIR ) );
define( 'NEVE_PLUGINS_DIR', plugin_dir_path( dirname( __DIR__ ) ) . 'plugins/' );
if ( ! defined( 'NEVE_DEBUG' ) ) {
define( 'NEVE_DEBUG', false );
}
define( 'NEVE_NEW_DYNAMIC_STYLE', true );
/**
* Buffer which holds errors during theme inititalization.
*
* @var WP_Error $_neve_bootstrap_errors
*/
global $_neve_bootstrap_errors;
$_neve_bootstrap_errors = new WP_Error();
if ( version_compare( PHP_VERSION, '7.0' ) < 0 ) {
$_neve_bootstrap_errors->add(
'minimum_php_version',
sprintf(
/* translators: %s message to upgrade PHP to the latest version */
__( "Hey, we've noticed that you're running an outdated version of PHP which is no longer supported. Make sure your site is fast and secure, by %1\$s. Neve's minimal requirement is PHP%2\$s.", 'neve' ),
sprintf(
/* translators: %s message to upgrade PHP to the latest version */
'<a href="https://wordpress.org/support/upgrade-php/">%s</a>',
__( 'upgrading PHP to the latest version', 'neve' )
),
'7.0'
)
);
}
/**
* A list of files to check for existence before bootstrapping.
*
* @var non-falsy-string[] Files to check for existence.
*/
$_files_to_check = defined( 'NEVE_IGNORE_SOURCE_CHECK' ) ? [] : [
NEVE_MAIN_DIR . 'vendor/autoload.php',
NEVE_MAIN_DIR . 'style-main-new.css',
NEVE_MAIN_DIR . 'assets/js/build/modern/frontend.js',
NEVE_MAIN_DIR . 'assets/apps/dashboard/build/dashboard.js',
NEVE_MAIN_DIR . 'assets/apps/customizer-controls/build/controls.js',
];
foreach ( $_files_to_check as $_file_to_check ) {
if ( ! is_file( $_file_to_check ) ) {
$_neve_bootstrap_errors->add(
'build_missing',
sprintf(
/* translators: %s: commands to run the theme */
__( 'You appear to be running the Neve theme from source code. Please finish installation by running %s.', 'neve' ), // phpcs:ignore WordPress.Security.EscapeOutput
'<code>composer install --no-dev && yarn install --frozen-lockfile && yarn run build</code>'
)
);
break;
}
}
/**
* Adds notice bootstraping errors.
*
* @internal
* @global WP_Error $_neve_bootstrap_errors
*/
function _neve_bootstrap_errors() {
global $_neve_bootstrap_errors;
printf( '<div class="notice notice-error"><p>%1$s</p></div>', $_neve_bootstrap_errors->get_error_message() ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
if ( $_neve_bootstrap_errors->has_errors() ) {
/**
* Add notice for PHP upgrade.
*/
add_filter( 'template_include', '__return_null', 99 );
switch_theme( WP_DEFAULT_THEME );
unset( $_GET['activated'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
add_action( 'admin_notices', '_neve_bootstrap_errors' );
return;
}
/**
* Themeisle SDK filter.
*
* @param array $products products array.
*
* @return array
*/
function neve_filter_sdk( $products ) {
$products[] = get_template_directory() . '/style.css';
return $products;
}
add_filter( 'themeisle_sdk_products', 'neve_filter_sdk' );
add_filter(
'themeisle_sdk_compatibilities/' . NEVE_BASENAME,
function ( $compatibilities ) {
$compatibilities['NevePro'] = [
'basefile' => defined( 'NEVE_PRO_BASEFILE' ) ? NEVE_PRO_BASEFILE : '',
'required' => '2.9',
'tested_up' => '3.2',
];
return $compatibilities;
}
);
require_once 'globals/migrations.php';
require_once 'globals/utilities.php';
require_once 'globals/hooks.php';
require_once 'globals/sanitize-functions.php';
require_once get_template_directory() . '/start.php';
/**
* If the new widget editor is available,
* we re-assign the widgets to hfg_footer
*/
if ( neve_is_new_widget_editor() ) {
/**
* Re-assign the widgets to hfg_footer
*
* @param array $section_args The section arguments.
* @param string $section_id The section ID.
* @param string $sidebar_id The sidebar ID.
*
* @return mixed
*/
function neve_customizer_custom_widget_areas( $section_args, $section_id, $sidebar_id ) {
if ( strpos( $section_id, 'widgets-footer' ) ) {
$section_args['panel'] = 'hfg_footer';
}
return $section_args;
}
add_filter( 'customizer_widgets_section_args', 'neve_customizer_custom_widget_areas', 10, 3 );
}
require_once get_template_directory() . '/header-footer-grid/loader.php';
add_filter(
'neve_welcome_metadata',
function() {
return [
'is_enabled' => ! defined( 'NEVE_PRO_VERSION' ),
'pro_name' => 'Neve Pro Addon',
'logo' => get_template_directory_uri() . '/assets/img/dashboard/logo.svg',
'cta_link' => tsdk_translate_link( tsdk_utmify( 'https://themeisle.com/themes/neve/upgrade/?discount=LOYALUSER582&dvalue=50', 'neve-welcome', 'notice' ), 'query' ),
];
}
);
add_filter( 'themeisle_sdk_enable_telemetry', '__return_true' );
add_filter(
'themeisle_sdk_labels',
function ( $labels ) {
if ( isset( $labels['about_us'] ) ) {
$labels['about_us'] = array_merge(
$labels['about_us'],
array(
'title' => __( 'About Us', 'neve' ),
'heroHeader' => __( 'Our Story', 'neve' ),
)
);
}
if ( isset( $labels['dashboard_widget'] ) ) {
$labels['dashboard_widget'] = array_merge(
$labels['dashboard_widget'],
array(
'title' => __( 'WordPress Guides/Tutorials', 'neve' ),
/* translators: %s: product name */
'popular' => __( 'Popular %s', 'neve' ),
'install' => __( 'Install', 'neve' ),
/* translators: %s: product name */
'powered' => __( 'Powered by %s', 'neve' ),
)
);
}
if ( isset( $labels['compatibilities'] ) ) {
$labels['compatibilities'] = array_merge(
$labels['compatibilities'],
array(
/* translators: %s: product name, %s: requirement name %s: update link start, %s: update link end, %s: requirement name %s: requirement type(theme/plugin) */
'notice' => __( '%1$s requires a newer version of %2$s. Please %3$supdate%4$s %5$s %6$s to the latest version.', 'neve' ),
/* translators: %s: product name, %s: requirement name %s: update link start, %s: update link end, %s: requirement name %s: requirement type(theme/plugin) */
'notice2' => __( '%1$s update requires a newer version of %2$s. Please %3$supdate%4$s %5$s %6$s.', 'neve' ),
/* translators: $1: Bold start, $2: Bold end, $3: theme name, $4: plugin name */
'notice_theme' => __( '%1$sWarning:%2$s This theme has not been tested with your current version of %1$s%3$s%2$s. Please update %3$s plugin.', 'neve' ),
/* translators: $1: Bold start, $2: Bold end, $3: Product name, $4: product type(theme/plugin) */
'notice_plugin' => __( '%1$sWarning:%2$s This plugin has not been tested with your current version of %1$s%3$s%2$s. Please update %3$s %4$s.', 'neve' ),
'theme' => __( 'theme', 'neve' ),
'plugin' => __( 'plugin', 'neve' ),
)
);
}
return $labels;
}
);