My question is: What do I need to add to the functions.php
file inside my Divi child theme.
I want to add a new Google font (Varela Round) to the "Font Selector" in Divi Builder.
I know how to do this. So this is not my problem.
1) Add "webfont" folder to Divi 2) In header.php, just before the closing head tag I need to put:
<link rel="stylesheet" href="<?php echo $template_directory_uri; ?>/webfonts/stylesheet.css" type="text/css" charset="utf-8">
Than I need to add in two files:
themes/Divi/includes/builder/core.php
themes/Divi/epanel/custom_functions.php
The following line:
$google_fonts = array(
'Varelda Round' => array(
'styles' => '400',
'character_set' => 'latin',
'type' => 'sans-serif',
),
When I do this in my Divi theme than I can select the "Varela Round" font from my Divi "Font selector"
Where I'm now stuck is translating all this to my Divi child theme.
In my Divi child theme I've added the "webfont" folder with my font in it.
In the Divi child theme I've created the two following structures.
includes/builder/core.php
epanel/custom_functions.php
I've deleted the core.php
and custom_functions.php
form my parent Divi Theme.
I know I need to still change something in my functions.php
from my child theme, but this is where I'm stuck. I can't figure it out what I need to put in the child themes functions.php
You can find the child theme functions.php
file below, as I've already put in some customization.
<?php
function enqueue_parent_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
//wp_enqueue_script( 'parent-script', get_template_directory_uri().'/js/main.js' );
}
add_action("wp_head","fun_head");
function fun_head()
{
if (is_user_logged_in()) {
global $current_user;
get_currentuserinfo();
$candi="none";
$comp="none";
if ( isset( $current_user->roles ) && is_array( $current_user->roles ) )
{
//check for admins
if ( in_array( 'candidate', $current_user->roles ) )
{
// redirect them to the default place
$candi="block";
}
elseif(in_array( 'employer', $current_user->roles ))
{
$comp="block";
}
}
?>
<style type="text/css">
#show_logut {
display: block;
}
#show_myaccountcandi
{
display: <?php echo $candi; ?>;
}
#show_myaccountcomp
{
display: <?php echo $comp; ?>;
}
#show_login {
display: none ;
}
#show_signup {
display: none ;
}
</style>
<?php }
else { get_template_part('ajax', 'auth');
//include('ajax-auth.php');
?>
<style type="text/css">
#show_logut {
display: none;
}
#show_myaccountcandi
{
display: none;
}
#show_myaccountcomp
{
display: none;
}
#show_login {
display: block;
}
#show_signup {
display: block ;
}
</style>
<?php }
}
require_once(WP_CONTENT_DIR. '/themes/divichild/custom-ajax-auth.php' );
add_action( 'template_redirect', 'wpse8170_activate_user' );
function wpse8170_activate_user() {
if ( is_page() && get_the_ID() == 25462 ) {
$user_id = filter_input( INPUT_GET, 'user', FILTER_VALIDATE_INT, array( 'options' => array( 'min_range' => 1 ) ) );
if ( $user_id ) {
// get user meta activation hash field
$code = get_user_meta( $user_id, 'has_to_be_activated', true );
if ( $code == filter_input( INPUT_GET, 'key' ) ) {
delete_user_meta( $user_id, 'has_to_be_activated' );
update_user_meta($user_id,"activated",1);
$user = get_user_by( 'id', $user_id );
if( $user ) {
wp_set_current_user( $user_id, $user->user_login );
wp_set_auth_cookie( $user_id );
do_action( 'wp_login', $user->user_login, $user);
echo "Please wait until process complete.";
//echo get_option("siteurl")."/mijn-account";
wp_redirect(get_option("siteurl")."/mijn-account");
exit();
}
}
}
echo "<strong>Activation Key is wrong or expired.</strong>";
die();
}
}
function my_login_redirect( $redirect_to, $request, $user ) {
//is there a user to check?
if ( isset( $user->roles ) && is_array( $user->roles ) )
{
//check for admins
if ( in_array( 'candidate', $user->roles ) )
{
// redirect them to the default place
return get_option("siteurl")."/candidate-dashboard";
}
elseif(in_array( 'employer', $user->roles ))
{
return get_option("siteurl")."/vacature-dashboard";
}
else
{
return home_url();
}
}
else
{
return $redirect_to;
}
}
add_filter( 'login_redirect', 'my_login_redirect', 10, 3 );
add_action('wp_logout','logout_redirect');
function logout_redirect(){
wp_redirect( home_url() );
exit;
}
?>