functions.php ➔ bitsy_setup()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 88
Code Lines 33

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 33
nc 1
nop 0
dl 0
loc 88
rs 8.6012
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * bitsy functions and definitions.
4
 *
5
 * Set up the theme and provides some helper functions, which are used in the
6
 * theme as custom template tags. Others are attached to action and filter
7
 * hooks in WordPress to change core functionality.
8
 *
9
 * When using a child theme you can override certain functions (those wrapped
10
 * in a function_exists() call) by defining them first in your child theme's
11
 * functions.php file. The child theme's functions.php file is included before
12
 * the parent theme's file, so the child theme functions would be used.
13
 *
14
 * @link https://codex.wordpress.org/Theme_Development
15
 * @link https://codex.wordpress.org/Child_Themes
16
 *
17
 * Functions that are not pluggable (not wrapped in function_exists()) are
18
 * instead attached to a filter or action hook.
19
 *
20
 * For more information on hooks, actions, and filters,
21
 * {@link https://codex.wordpress.org/Plugin_API}
22
 *
23
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
24
 *
25
 * @package bitsy
26
 */
27
28
if ( ! function_exists( 'bitsy_setup' ) ) {
29
	/**
30
	 * Sets up theme defaults and registers support for various WordPress features.
31
	 *
32
	 * Note that this function is hooked into the after_setup_theme hook, which
33
	 * runs before the init hook. The init hook is too late for some features, such
34
	 * as indicating support for post thumbnails.
35
	 */
36
	function bitsy_setup() {
37
		/*
38
		 * Make theme available for translation.
39
		 * Translations can be filed in the /languages/ directory.
40
		 * If you're building a theme based on bitsy, use a find and replace
41
		 * to change 'bitsy' to the name of your theme in all the template files.
42
		 */
43
		load_theme_textdomain( 'bitsy', get_template_directory() . '/languages' );
44
45
		// Add default posts and comments RSS feed links to head.
46
		add_theme_support( 'automatic-feed-links' );
47
48
		/*
49
		 * Let WordPress manage the document title.
50
		 * By adding theme support, we declare that this theme does not use a
51
		 * hard-coded <title> tag in the document head, and expect WordPress to
52
		 * provide it for us.
53
		 */
54
		add_theme_support( 'title-tag' );
55
56
		/*
57
		 * Enable support for Post Thumbnails on posts and pages.
58
		 *
59
		 * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
60
		 */
61
		add_theme_support( 'post-thumbnails' );
62
63
		// This theme uses wp_nav_menu() in one location.
64
		register_nav_menus( array(
65
			'primary' => esc_html__( 'Primary', 'bitsy' ),
66
			'social'  => __( 'Social Links Menu', 'bitsy' )
67
		) );
68
69
		/*
70
		 * Switch default core markup for search form, comment form, and comments
71
		 * to output valid HTML5.
72
		 */
73
		add_theme_support( 'html5', array(
74
			'search-form',
75
			'comment-form',
76
			'comment-list',
77
			'gallery',
78
			'caption',
79
		) );
80
81
		// Set up the WordPress core custom background feature.
82
		add_theme_support( 'custom-background', apply_filters( 'bitsy_custom_background_args', array(
83
			'default-color' => 'ffffff',
84
			'default-image' => '',
85
		) ) );
86
87
		/*
88
		 * Enable support for Post Formats.
89
		 *
90
		 * See: https://codex.wordpress.org/Post_Formats
91
		 */
92
		add_theme_support( 'post-formats', array(
93
			'aside',
94
			'image',
95
			'video',
96
			'quote',
97
			'link',
98
			'gallery',
99
			'status',
100
			'audio',
101
			'chat',
102
		) );
103
		/*
104
		 * This theme styles the visual editor to resemble the theme style,
105
		 * specifically font, colors, icons, and column width.
106
		 */
107
		//add_editor_style( array( 'css/editor-style.css', bitsy_fonts_url() ) );
108
109
		// Add theme support for selective refresh for widgets.
110
		add_theme_support( 'customize-selective-refresh-widgets' );
111
112
		/**
113
		 * Add support for core custom logo.
114
		 *
115
		 * @link https://codex.wordpress.org/Theme_Logo
116
		 */
117
		add_theme_support( 'custom-logo', array(
118
			'height'      => 250,
119
			'width'       => 250,
120
			'flex-width'  => true,
121
			'flex-height' => true,
122
		) );
123
	}
124
} // bitsy_setup
125
126
add_action( 'after_setup_theme', 'bitsy_setup' );
127
128
/**
129
 * Register widget area.
130
 *
131
 * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
132
 */
133
require get_template_directory() . '/inc/widgets.php';
134
135
/**
136
 * Enqueue scripts and styles.
137
 */
138
require get_template_directory() . '/inc/enqueue.php';
139
140
/**
141
 * Load the theme wrapper.
142
 */
143
require get_template_directory() . '/inc/theme-wrapper.php';
144
145
/**
146
 * Implement the Custom Header feature.
147
 */
148
require get_template_directory() . '/inc/custom-header.php';
149
150
/**
151
 * Custom template tags for this theme.
152
 */
153
require get_template_directory() . '/inc/template-tags.php';
154
155
/**
156
 * Custom functions that act independently of the theme templates.
157
 */
158
require get_template_directory() . '/inc/extras.php';
159
160
/**
161
 * Customizer additions.
162
 */
163
require get_template_directory() . '/inc/customizer.php';
164
165
/**
166
 * Load Jetpack compatibility file.
167
 */
168
if ( defined( 'JETPACK__VERSION' ) ) {
169
	require get_template_directory() . '/inc/jetpack.php';
170
}
171
172
/**
173
 * Load WooCommerce compatibility file.
174
 */
175
if ( class_exists( 'WooCommerce' ) ) {
176
	require get_template_directory() . '/inc/woocommerce.php';
177
}
178