Browse Source

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

Enej Bajgoric 4 years ago
parent
commit
ca1ba9919f

+ 3 - 13
alves/functions.php

@@ -103,19 +103,9 @@ if ( ! function_exists( 'alves_setup' ) ) :
 			)
 		);
 
-		// Add .mobile-nav-side body class.
-		if ( function_exists( 'varia_mobile_nav_on_side' ) ) {
-			add_filter( 'body_class', 'varia_mobile_nav_on_side' );
-		}
-
-		// 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' );
+		// Setup nav on side toggle support.
+		if ( function_exists( 'varia_mobile_nav_on_side_setup' ) ) {
+			varia_mobile_nav_on_side_setup();
 		}
 	}
 endif;

+ 3 - 13
barnsbury/functions.php

@@ -103,19 +103,9 @@ if ( ! function_exists( 'barnsbury_setup' ) ) :
 			)
 		);
 
-		// Add .mobile-nav-side body class.
-		if ( function_exists( 'varia_mobile_nav_on_side' ) ) {
-			add_filter( 'body_class', 'varia_mobile_nav_on_side' );
-		}
-
-		// 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' );
+		// Setup nav on side toggle support.
+		if ( function_exists( 'varia_mobile_nav_on_side_setup' ) ) {
+			varia_mobile_nav_on_side_setup();
 		}
 	}
 endif;

+ 3 - 13
dalston/functions.php

@@ -120,19 +120,9 @@ if ( ! function_exists( 'dalston_setup' ) ) :
 			)
 		);
 
-		// Add .mobile-nav-side body class.
-		if ( function_exists( 'varia_mobile_nav_on_side' ) ) {
-			add_filter( 'body_class', 'varia_mobile_nav_on_side' );
-		}
-
-		// 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' );
+		// Setup nav on side toggle support.
+		if ( function_exists( 'varia_mobile_nav_on_side_setup' ) ) {
+			varia_mobile_nav_on_side_setup();
 		}
 	}
 endif;

+ 3 - 13
hever/functions.php

@@ -100,19 +100,9 @@ if ( ! function_exists( 'hever_setup' ) ) :
 			)
 		);
 
-		// Add .mobile-nav-side body class.
-		if ( function_exists( 'varia_mobile_nav_on_side' ) ) {
-			add_filter( 'body_class', 'varia_mobile_nav_on_side' );
-		}
-
-		// 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' );
+		// Setup nav on side toggle support.
+		if ( function_exists( 'varia_mobile_nav_on_side_setup' ) ) {
+			varia_mobile_nav_on_side_setup();
 		}
 	}
 endif;

+ 3 - 13
mayland/functions.php

@@ -103,19 +103,9 @@ if ( ! function_exists( 'mayland_setup' ) ) :
 			)
 		);
 
-		// Add .mobile-nav-side body class.
-		if ( function_exists( 'varia_mobile_nav_on_side' ) ) {
-			add_filter( 'body_class', 'varia_mobile_nav_on_side' );
-		}
-
-		// 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' );
+		// Setup nav on side toggle support.
+		if ( function_exists( 'varia_mobile_nav_on_side_setup' ) ) {
+			varia_mobile_nav_on_side_setup();
 		}
 	}
 endif;

+ 3 - 13
morden/functions.php

@@ -100,19 +100,9 @@ if ( ! function_exists( 'morden_setup' ) ) :
 			)
 		);
 
-		// Add .mobile-nav-side body class.
-		if ( function_exists( 'varia_mobile_nav_on_side' ) ) {
-			add_filter( 'body_class', 'varia_mobile_nav_on_side' );
-		}
-
-		// 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' );
+		// Setup nav on side toggle support.
+		if ( function_exists( 'varia_mobile_nav_on_side_setup' ) ) {
+			varia_mobile_nav_on_side_setup();
 		}
 	}
 endif;

+ 3 - 13
rivington/functions.php

@@ -112,19 +112,9 @@ if ( ! function_exists( 'rivington_setup' ) ) :
 		// Remove footer menu
 		unregister_nav_menu( 'menu-2' );
 
-		// Add .mobile-nav-side body class.
-		if ( function_exists( 'varia_mobile_nav_on_side' ) ) {
-			add_filter( 'body_class', 'varia_mobile_nav_on_side' );
-		}
-
-		// 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' );
+		// Setup nav on side toggle support.
+		if ( function_exists( 'varia_mobile_nav_on_side_setup' ) ) {
+			varia_mobile_nav_on_side_setup();
 		}
 	}
 endif;

+ 11 - 0
varia/functions.php

@@ -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.
  */