Completed
Push — master ( bf1080...d99bb1 )
by Md. Mozahidur
04:04
created

functions.php (3 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 18 and the first side effect is on line 100.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * Lighthouse functions and definitions.
4
 *
5
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
6
 *
7
 * @package Lighthouse
8
 */
9
10
if ( ! function_exists( 'lighthouse_setup' ) ) :
11
/**
12
 * Sets up theme defaults and registers support for various WordPress features.
13
 *
14
 * Note that this function is hooked into the after_setup_theme hook, which
15
 * runs before the init hook. The init hook is too late for some features, such
16
 * as indicating support for post thumbnails.
17
 */
18
function lighthouse_setup() {
19
    // This theme styles the visual editor to resemble the theme style.
20
	$font_url = 'https://fonts.googleapis.com/css?family=Questrial';
21
	add_editor_style( 
22
		array( 
23
			'style.css', str_replace( ',', '%2C', $font_url )
24
			) 
25
		);
26
	/*
27
	 * Make theme available for translation.
28
	 * Translations can be filed in the /languages/ directory.
29
	 * If you're building a theme based on Lighthouse, use a find and replace
30
	 * to change 'lighthouse' to the name of your theme in all the template files.
31
	 */
32
	load_theme_textdomain( 'lighthouse', get_template_directory() . '/languages' );
33
34
	// Add default posts and comments RSS feed links to head.
35
	add_theme_support( 'automatic-feed-links' );
36
37
	/*
38
	 * Let WordPress manage the document title.
39
	 * By adding theme support, we declare that this theme does not use a
40
	 * hard-coded <title> tag in the document head, and expect WordPress to
41
	 * provide it for us.
42
	 */
43
	add_theme_support( 'title-tag' );
44
45
	/*
46
	 * Enable support for Post Thumbnails on posts and pages.
47
	 *
48
	 * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
49
	 */
50
	add_theme_support( 'post-thumbnails' );
51
52
	add_image_size( 'lighthouse_feature_img', 1000, 310, array( 'center', 'center' ) );
53
54
	add_image_size( 'lighthouse_blog_listing', 714, 274, array( 'center', 'center' ) );
55
56
	add_image_size( 'lighthouse_related_post', 475, 280, array( 'center', 'center' ) );
57
58
	/*
59
	 * Default HTML5 Form
60
	 *
61
	 * @link https://codex.wordpress.org/Function_Reference/get_search_form
62
	 */
63
	add_theme_support( 'html5', array( 'search-form' ) ); 
64
65
	// This theme uses wp_nav_menu() in one location.
66
	register_nav_menus( array(
67
		'primary' => esc_html__( 'Primary', 'lighthouse' ),
68
		) );
69
70
	/*
71
	 * Switch default core markup for search form, comment form, and comments
72
	 * to output valid HTML5.
73
	 */
74
	add_theme_support( 'html5', array(
75
		'search-form',
76
		'comment-form',
77
		'comment-list',
78
		'gallery',
79
		'caption',
80
		) );
81
82
	/*
83
	 * Enable support for Post Formats.
84
	 * See https://developer.wordpress.org/themes/functionality/post-formats/
85
	 */
86
	add_theme_support( 'post-formats', array(
87
		'aside',
88
		'image',
89
		'video',
90
		'quote',
91
		'link',
92
		) );
93
94
	// Set up the WordPress core custom background feature.
95
	add_theme_support( 'custom-background', apply_filters( 'lighthouse_custom_background_args', array(
96
		'default-color' => 'ffffff',
97
		'default-image' => '',
98
		) ) );
99
}
100
endif;
101
add_action( 'after_setup_theme', 'lighthouse_setup' );
102
103
/**
104
 * Set the content width in pixels, based on the theme's design and stylesheet.
105
 *
106
 * Priority 0 to make it available to lower priority callbacks.
107
 *
108
 * @global int $content_width
109
 */
110
function lighthouse_content_width() {
0 ignored issues
show
lighthouse_content_width uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
111
	$GLOBALS['content_width'] = apply_filters( 'lighthouse_content_width', 640 );
112
}
113
add_action( 'after_setup_theme', 'lighthouse_content_width', 0 );
114
115
/**
116
 * Enqueue scripts and styles.
117
 */
118
function lighthouse_scripts() {
119
120
	wp_enqueue_style( 'lighthouse-style', get_stylesheet_uri() );
121
122
	wp_enqueue_style('lighthouse-google-fonts', 'https://fonts.googleapis.com/css?family=Questrial');
123
124
	//wp_enqueue_style('lighthouse-owl-carousel-css', get_template_directory_uri() . '/css/owl.carousel.css');
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
125
126
	wp_enqueue_script( 'lighthouse-classList-js', 'https://cdnjs.cloudflare.com/ajax/libs/classlist/2014.01.31/classList.min.js', array('jquery'), '');
127
128
	wp_enqueue_script( 'lighthouse-bootstrap-js', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), '', true );
129
130
	wp_enqueue_script( 'lighthouse-material-menu-js', get_template_directory_uri() . '/js/materialMenu.js', array('jquery'), '', true );
131
132
	wp_enqueue_script( 'lighthouse-owl-carousel-js', get_template_directory_uri() . '/js/owl-carousel.js', array('jquery'), '', true );
133
134
	wp_enqueue_script( 'lighthouse-match-height-js', get_template_directory_uri() . '/js/jquery.matchHeight-min.js', array('jquery'), '', true );
135
136
	wp_enqueue_script( 'lighthouse-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20120206', true );
137
138
	wp_enqueue_script( 'lighthouse-settings-js', get_template_directory_uri() . '/js/lighthouse-settings.js', array('jquery'), '', true );
139
140
	wp_enqueue_script( 'lighthouse-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true );
141
142
	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
143
		wp_enqueue_script( 'comment-reply' );
144
	}
145
}
146
add_action( 'wp_enqueue_scripts', 'lighthouse_scripts' );
147
148
149
/**
150
 * Implement the Custom Header feature.
151
 */
152
require get_template_directory() . '/inc/custom-header.php';
153
154
/**
155
 * Custom template tags for this theme.
156
 */
157
require get_template_directory() . '/inc/template-tags.php';
158
159
/**
160
 * Custom functions that act independently of the theme templates.
161
 */
162
require get_template_directory() . '/inc/extras.php';
163
164
/**
165
 * Customizer additions.
166
 */
167
require get_template_directory() . '/inc/customizer.php';
168
169
/**
170
 * Load Jetpack compatibility file.
171
 */
172
require get_template_directory() . '/inc/jetpack.php';
173
174
175
176
/**
177
 * Custom Include files
178
 */
179
180
// ACF
181
include_once( get_stylesheet_directory() . '/includes/acf/acf.php' );
182
183
// ACF Settings
184
include_once( get_stylesheet_directory() . '/includes/acf-settings.php' );
185
186
// Widgets
187
include_once( get_stylesheet_directory() . '/includes/widgets.php' );
188
189
// Menus
190
include_once( get_stylesheet_directory() . '/includes/menus.php' );
191
192
// Theme Settings
193
include_once( get_stylesheet_directory() . '/includes/theme-settings.php' );
194
195
// Shortcodes
196
include_once( get_stylesheet_directory() . '/includes/shortcodes.php' );
197