Simplify: Refactor functions to just include one function that adds the 3 required filters/actions

This commit is contained in:
Enej Bajgoric 2020-12-16 11:33:53 -08:00 committed by Maggie Cabrera
parent 5fc14b6351
commit ca1ba9919f
8 changed files with 32 additions and 91 deletions

View file

@ -103,19 +103,9 @@ if ( ! function_exists( 'alves_setup' ) ) :
) )
); );
// Add .mobile-nav-side body class. // Setup nav on side toggle support.
if ( function_exists( 'varia_mobile_nav_on_side' ) ) { if ( function_exists( 'varia_mobile_nav_on_side_setup' ) ) {
add_filter( 'body_class', 'varia_mobile_nav_on_side' ); varia_mobile_nav_on_side_setup();
}
// Enable the mobile nav on side on theme switch.
if ( function_exists( 'varia_enable_mobile_nav_on_side' ) ) {
add_action( 'after_switch_theme', 'varia_enable_mobile_nav_on_side' );
}
// Enable the customizer control toggle for the mobile nav on the side.
if ( function_exists( 'varia_register_mobile_nav_on_side_customizer_control' ) ) {
add_action( 'customize_register' , 'varia_register_mobile_nav_on_side_customizer_control' );
} }
} }
endif; endif;

View file

@ -103,19 +103,9 @@ if ( ! function_exists( 'barnsbury_setup' ) ) :
) )
); );
// Add .mobile-nav-side body class. // Setup nav on side toggle support.
if ( function_exists( 'varia_mobile_nav_on_side' ) ) { if ( function_exists( 'varia_mobile_nav_on_side_setup' ) ) {
add_filter( 'body_class', 'varia_mobile_nav_on_side' ); varia_mobile_nav_on_side_setup();
}
// Enable the mobile nav on side on theme switch.
if ( function_exists( 'varia_enable_mobile_nav_on_side' ) ) {
add_action( 'after_switch_theme', 'varia_enable_mobile_nav_on_side' );
}
// Enable the customizer control toggle for the mobile nav on the side.
if ( function_exists( 'varia_register_mobile_nav_on_side_customizer_control' ) ) {
add_action( 'customize_register' , 'varia_register_mobile_nav_on_side_customizer_control' );
} }
} }
endif; endif;

View file

@ -120,19 +120,9 @@ if ( ! function_exists( 'dalston_setup' ) ) :
) )
); );
// Add .mobile-nav-side body class. // Setup nav on side toggle support.
if ( function_exists( 'varia_mobile_nav_on_side' ) ) { if ( function_exists( 'varia_mobile_nav_on_side_setup' ) ) {
add_filter( 'body_class', 'varia_mobile_nav_on_side' ); varia_mobile_nav_on_side_setup();
}
// Enable the mobile nav on side on theme switch.
if ( function_exists( 'varia_enable_mobile_nav_on_side' ) ) {
add_action( 'after_switch_theme', 'varia_enable_mobile_nav_on_side' );
}
// Enable the customizer control toggle for the mobile nav on the side.
if ( function_exists( 'varia_register_mobile_nav_on_side_customizer_control' ) ) {
add_action( 'customize_register' , 'varia_register_mobile_nav_on_side_customizer_control' );
} }
} }
endif; endif;

View file

@ -100,19 +100,9 @@ if ( ! function_exists( 'hever_setup' ) ) :
) )
); );
// Add .mobile-nav-side body class. // Setup nav on side toggle support.
if ( function_exists( 'varia_mobile_nav_on_side' ) ) { if ( function_exists( 'varia_mobile_nav_on_side_setup' ) ) {
add_filter( 'body_class', 'varia_mobile_nav_on_side' ); varia_mobile_nav_on_side_setup();
}
// Enable the mobile nav on side on theme switch.
if ( function_exists( 'varia_enable_mobile_nav_on_side' ) ) {
add_action( 'after_switch_theme', 'varia_enable_mobile_nav_on_side' );
}
// Enable the customizer control toggle for the mobile nav on the side.
if ( function_exists( 'varia_register_mobile_nav_on_side_customizer_control' ) ) {
add_action( 'customize_register' , 'varia_register_mobile_nav_on_side_customizer_control' );
} }
} }
endif; endif;

View file

@ -103,19 +103,9 @@ if ( ! function_exists( 'mayland_setup' ) ) :
) )
); );
// Add .mobile-nav-side body class. // Setup nav on side toggle support.
if ( function_exists( 'varia_mobile_nav_on_side' ) ) { if ( function_exists( 'varia_mobile_nav_on_side_setup' ) ) {
add_filter( 'body_class', 'varia_mobile_nav_on_side' ); varia_mobile_nav_on_side_setup();
}
// Enable the mobile nav on side on theme switch.
if ( function_exists( 'varia_enable_mobile_nav_on_side' ) ) {
add_action( 'after_switch_theme', 'varia_enable_mobile_nav_on_side' );
}
// Enable the customizer control toggle for the mobile nav on the side.
if ( function_exists( 'varia_register_mobile_nav_on_side_customizer_control' ) ) {
add_action( 'customize_register' , 'varia_register_mobile_nav_on_side_customizer_control' );
} }
} }
endif; endif;

View file

@ -100,19 +100,9 @@ if ( ! function_exists( 'morden_setup' ) ) :
) )
); );
// Add .mobile-nav-side body class. // Setup nav on side toggle support.
if ( function_exists( 'varia_mobile_nav_on_side' ) ) { if ( function_exists( 'varia_mobile_nav_on_side_setup' ) ) {
add_filter( 'body_class', 'varia_mobile_nav_on_side' ); varia_mobile_nav_on_side_setup();
}
// Enable the mobile nav on side on theme switch.
if ( function_exists( 'varia_enable_mobile_nav_on_side' ) ) {
add_action( 'after_switch_theme', 'varia_enable_mobile_nav_on_side' );
}
// Enable the customizer control toggle for the mobile nav on the side.
if ( function_exists( 'varia_register_mobile_nav_on_side_customizer_control' ) ) {
add_action( 'customize_register' , 'varia_register_mobile_nav_on_side_customizer_control' );
} }
} }
endif; endif;

View file

@ -112,19 +112,9 @@ if ( ! function_exists( 'rivington_setup' ) ) :
// Remove footer menu // Remove footer menu
unregister_nav_menu( 'menu-2' ); unregister_nav_menu( 'menu-2' );
// Add .mobile-nav-side body class. // Setup nav on side toggle support.
if ( function_exists( 'varia_mobile_nav_on_side' ) ) { if ( function_exists( 'varia_mobile_nav_on_side_setup' ) ) {
add_filter( 'body_class', 'varia_mobile_nav_on_side' ); varia_mobile_nav_on_side_setup();
}
// Enable the mobile nav on side on theme switch.
if ( function_exists( 'varia_enable_mobile_nav_on_side' ) ) {
add_action( 'after_switch_theme', 'varia_enable_mobile_nav_on_side' );
}
// Enable the customizer control toggle for the mobile nav on the side.
if ( function_exists( 'varia_register_mobile_nav_on_side_customizer_control' ) ) {
add_action( 'customize_register' , 'varia_register_mobile_nav_on_side_customizer_control' );
} }
} }
endif; endif;

View file

@ -336,6 +336,17 @@ if ( ! function_exists( 'varia_register_mobile_nav_on_side_customizer_control' )
} }
} }
function varia_mobile_nav_on_side_setup() {
// Add .mobile-nav-side body class.
add_filter( 'body_class', 'varia_mobile_nav_on_side' );
// Enable the mobile nav on side on theme switch.
add_action( 'after_switch_theme', 'varia_enable_mobile_nav_on_side' );
// Enable the customizer control toggle for the mobile nav on the side.
add_action( 'customize_register' , 'varia_register_mobile_nav_on_side_customizer_control' );
}
/** /**
* SVG Icons class. * SVG Icons class.
*/ */