/home/techb158/public_html/wp-content/plugins/kirki/includes/Manager
Edit: /home/techb158/public_html/wp-content/plugins/kirki/includes/Manager/PluginInitEvents.php (6976B)
true ) );
add_filter( 'theme_page_templates', array( $this, 'add_page_template_to_dropdown' ) );
load_plugin_textdomain( 'kirki', false, KIRKI_PLUGIN_REL_URL . '/languages' );
}
/**
* Filter hook upload_mimes.
*
* @param array $mimes wp mimes.
* @return array
*/
public function cc_mime_types( $mimes ) {
$data = WpAdmin::get_common_data( true );
if ( isset( $data['json_upload'] ) && $data['json_upload'] === true ) {
$mimes['json'] = 'application/json';
}
if ( isset( $data['svg_upload'] ) && $data['svg_upload'] === true ) {
$mimes['svg'] = 'image/svg+xml';
}
return $mimes;
}
/**
* Fix JSON and SVG file type check for WordPress MIME sniffing.
*
* WordPress uses finfo to sniff the real MIME type of uploaded files.
* JSON files are detected as 'text/plain' by finfo, which causes WordPress
* to reject them even when 'application/json' is in the allowed mimes list.
* This filter overrides the sniffed type for .json files when json_upload is enabled.
*
* @param array $wp_check_filetype_and_ext Array with ext, type, proper_filename keys.
* @param string $file Full path to the file.
* @param string $filename The name of the file.
* @param string[] $mimes Array of mime types keyed by extension.
* @param string|false $real_mime The actual mime type or false if finfo is unavailable.
* @return array
*/
public function fix_filetype_check( $wp_check_filetype_and_ext, $file, $filename, $mimes, $real_mime ) {
$data = WpAdmin::get_common_data( true );
$ext = strtolower( pathinfo( $filename, PATHINFO_EXTENSION ) );
if ( 'json' === $ext && isset( $data['json_upload'] ) && $data['json_upload'] === true ) {
$wp_check_filetype_and_ext['ext'] = 'json';
$wp_check_filetype_and_ext['type'] = 'application/json';
}
if ( 'svg' === $ext && isset( $data['svg_upload'] ) && $data['svg_upload'] === true ) {
$wp_check_filetype_and_ext['ext'] = 'svg';
$wp_check_filetype_and_ext['type'] = 'image/svg+xml';
}
return $wp_check_filetype_and_ext;
}
/**
* Add rewrite rules for Kirki utility pages.
*
* @param array $rules The list of rewrite rules.
*
* @return array $rules The modified list of rewrite rules.
*/
public function kirki_utility_pages_rewrite_rules( $rules ) {
$utility_pages = Page::fetch_list('kirki_utility', true, array( 'publish' ) );
$new_rules = array();
foreach ( $utility_pages as $key => $page ) {
$slug = ! empty( $page['slug'] ) ? preg_quote( $page['slug'], '/' ) : '';
if ( empty( $slug ) ) {
continue;
}
if ( $page['utility_page_type'] !== '404' ) {
$new_rules[ "^$slug$" ] = "index.php?kirki_utility_page_type={$page['utility_page_type']}&kirki_utility_page_id={$page['id']}";
}
}
return $new_rules + ( is_array( $rules ) ? $rules : array() );
}
/**
* Add page templates.
*
* @param array $templates The list of page templates.
*
* @return array $templates The modified list of page templates.
*/
public function add_page_template_to_dropdown( $templates ) {
$templates[ HelperFunctions::get_kirki_full_canvas_template_path() ] = 'Kirki Full Canvas';
return $templates;
}
}