Skip to content

Instantly share code, notes, and snippets.

@pingram3541
Last active November 6, 2023 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pingram3541/fb8e5a970dad64e6727a to your computer and use it in GitHub Desktop.
Save pingram3541/fb8e5a970dad64e6727a to your computer and use it in GitHub Desktop.
BeTheme Child Functions.php - Fix for proper loading of stylesheets & mfn_upload
<?php
/* ---------------------------------------------------------------------------
* Child Theme URI | DO NOT CHANGE
* --------------------------------------------------------------------------- */
define( 'CHILD_THEME_URI', get_stylesheet_directory_uri() );
/* ---------------------------------------------------------------------------
* Define | YOU CAN CHANGE THESE
* --------------------------------------------------------------------------- */
// White Label --------------------------------------------
define( 'WHITE_LABEL', false );
// Static CSS is placed in Child Theme directory ----------
define( 'STATIC_IN_CHILD', false );
/* ---------------------------------------------------------------------------
* Enqueue Style
* --------------------------------------------------------------------------- */
add_action( 'wp_enqueue_scripts', 'mfnch_enqueue_styles', 101 );
function mfnch_enqueue_styles() {
// Enqueue the parent stylesheet
//wp_enqueue_style( 'parent-style', get_template_directory_uri() .'/style.css' ); //we don't need this if it's empty
// Enqueue the parent rtl stylesheet
if ( is_rtl() ) {
wp_enqueue_style( 'mfn-rtl', get_template_directory_uri() . '/rtl.css' );
}
// Enqueue the child stylesheet
wp_dequeue_style( 'style' );
wp_enqueue_style( 'style', get_stylesheet_directory_uri() .'/style.css' );
}
/* ---------------------------------------------------------------------------
* Enqueue Admin Style/Script
* --------------------------------------------------------------------------- */
//add_action( 'admin_enqueue_scripts', 'mfnch_admin_enqueue', 101 );
function mfnch_admin_enqueue(){
if(defined('mfn_upload')){
//dequeue themes upload script and override for relative urls
wp_dequeue_script( 'mfn-opts-field-upload-js' );
wp_enqueue_script( 'mfn-opts-field-upload-js', get_stylesheet_directory_uri() .'/muffin-options/fields/upload/field_upload.js', array('jquery'), time(), true );
}
}
/* ---------------------------------------------------------------------------
* Load Textdomain
* --------------------------------------------------------------------------- */
add_action( 'after_setup_theme', 'mfnch_textdomain' );
function mfnch_textdomain() {
load_child_theme_textdomain( 'betheme', get_stylesheet_directory() . '/languages' );
load_child_theme_textdomain( 'mfn-opts', get_stylesheet_directory() . '/languages' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment