Completed
Push — master ( d71a73...8db731 )
by Md. Mozahidur
03:18
created

functions.php (2 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 112.

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_Questrial = 'https://fonts.googleapis.com/css?family=Questrial';
21
22
	$font_url_Raleway = 'https://fonts.googleapis.com/css?family=Raleway:400,300,500,700,600,100';
23
24
	$font_url_Montserrat = 'https://fonts.googleapis.com/css?family=Montserrat:400,700';
25
26
	add_editor_style( 
27
		array( 
28
			'style.css', str_replace( ',', '%2C', $font_url_Questrial), str_replace( ',', '%2C', $font_url_Raleway), str_replace( ',', '%2C', $font_url_Montserrat)
29
			) 
30
		);
31
	/*
32
	 * Make theme available for translation.
33
	 * Translations can be filed in the /languages/ directory.
34
	 * If you're building a theme based on Lighthouse, use a find and replace
35
	 * to change 'lighthouse' to the name of your theme in all the template files.
36
	 */
37
	load_theme_textdomain( 'lighthouse', get_template_directory() . '/languages' );
38
39
	// Add default posts and comments RSS feed links to head.
40
	add_theme_support( 'automatic-feed-links' );
41
42
	/*
43
	 * Let WordPress manage the document title.
44
	 * By adding theme support, we declare that this theme does not use a
45
	 * hard-coded <title> tag in the document head, and expect WordPress to
46
	 * provide it for us.
47
	 */
48
	add_theme_support( 'title-tag' );
49
50
	/*
51
	 * Enable support for Post Thumbnails on posts and pages.
52
	 *
53
	 * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
54
	 */
55
	add_theme_support( 'post-thumbnails' );
56
57
	add_image_size( 'lighthouse_feature_img', 1000, 310, array( 'center', 'center' ) );
58
59
	add_image_size( 'lighthouse_blog_listing', 714, 274, array( 'center', 'center' ) );
60
61
	add_image_size( 'lighthouse_related_post', 475, 280, array( 'center', 'center' ) );
62
63
64
	/*
65
	 * Enable support for Shortcode in text widget
66
	 *
67
	 */
68
	add_filter('widget_text', 'do_shortcode');
69
	
70
	/*
71
	 * Default HTML5 Form
72
	 *
73
	 * @link https://codex.wordpress.org/Function_Reference/get_search_form
74
	 */
75
	add_theme_support( 'html5', array( 'search-form' ) ); 
76
77
	// This theme uses wp_nav_menu() in one location.
78
	register_nav_menus( array(
79
		'primary' => esc_html__( 'Primary', 'lighthouse' ),
80
		) );
81
82
	/*
83
	 * Switch default core markup for search form, comment form, and comments
84
	 * to output valid HTML5.
85
	 */
86
	add_theme_support( 'html5', array(
87
		'search-form',
88
		'comment-form',
89
		'comment-list',
90
		'gallery',
91
		'caption',
92
		) );
93
94
	/*
95
	 * Enable support for Post Formats.
96
	 * See https://developer.wordpress.org/themes/functionality/post-formats/
97
	 */
98
	add_theme_support( 'post-formats', array(
99
		'aside',
100
		'image',
101
		'video',
102
		'quote',
103
		'link',
104
		) );
105
106
	// Set up the WordPress core custom background feature.
107
	add_theme_support( 'custom-background', apply_filters( 'lighthouse_custom_background_args', array(
108
		'default-color' => 'ffffff',
109
		'default-image' => '',
110
		) ) );
111
}
112
endif;
113
add_action( 'after_setup_theme', 'lighthouse_setup' );
114
115
/**
116
 * Set the content width in pixels, based on the theme's design and stylesheet.
117
 *
118
 * Priority 0 to make it available to lower priority callbacks.
119
 *
120
 * @global int $content_width
121
 */
122
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...
123
	$GLOBALS['content_width'] = apply_filters( 'lighthouse_content_width', 640 );
124
}
125
add_action( 'after_setup_theme', 'lighthouse_content_width', 0 );
126
127
/**
128
 * Enqueue scripts and styles.
129
 */
130
function lighthouse_scripts() {
131
132
	wp_enqueue_style( 'lighthouse-style', get_stylesheet_uri() );
133
134
	wp_enqueue_style('lighthouse-google-fonts-questrial', 'https://fonts.googleapis.com/css?family=Questrial');
135
136
	wp_enqueue_style('lighthouse-google-fonts-raleway', 'https://fonts.googleapis.com/css?family=Raleway:400,300,500,700,600,100');
137
138
	wp_enqueue_style('lighthouse-google-fonts-montserrat', 'https://fonts.googleapis.com/css?family=Montserrat:400,700');
139
140
	wp_enqueue_script( 'lighthouse-classList-js', 'https://cdnjs.cloudflare.com/ajax/libs/classlist/2014.01.31/classList.min.js', array('jquery'), '');
141
142
	wp_enqueue_script( 'lighthouse-bootstrap-js', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), '', true );
143
144
	wp_enqueue_script( 'lighthouse-material-menu-js', get_template_directory_uri() . '/js/materialMenu.min.js', array('jquery'), '', true );
145
146
	wp_enqueue_script( 'lighthouse-owl-carousel-js', get_template_directory_uri() . '/js/owl-carousel.min.js', array('jquery'), '', true );
147
148
	wp_enqueue_script( 'lighthouse-match-height-js', get_template_directory_uri() . '/js/jquery.matchHeight-min.js', array('jquery'), '', true );
149
150
	wp_enqueue_script( 'lighthouse-navigation', get_template_directory_uri() . '/js/navigation.min.js', array(), '20120206', true );
151
152
	wp_enqueue_script( 'lighthouse-settings-js', get_template_directory_uri() . '/js/lighthouse-settings.min.js', array('jquery'), '20160220', true );
153
154
	wp_enqueue_script( 'lighthouse-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.min.js', array(), '20130115', true );
155
156
	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
157
		wp_enqueue_script( 'comment-reply' );
158
	}
159
}
160
add_action( 'wp_enqueue_scripts', 'lighthouse_scripts' );
161
162
163
/**
164
 * Implement the Custom Header feature.
165
 */
166
require get_template_directory() . '/inc/custom-header.php';
167
168
/**
169
 * Custom template tags for this theme.
170
 */
171
require get_template_directory() . '/inc/template-tags.php';
172
173
/**
174
 * Custom functions that act independently of the theme templates.
175
 */
176
require get_template_directory() . '/inc/extras.php';
177
178
/**
179
 * Customizer additions.
180
 */
181
require get_template_directory() . '/inc/customizer.php';
182
183
/**
184
 * Load Jetpack compatibility file.
185
 */
186
require get_template_directory() . '/inc/jetpack.php';
187
188
189
/**
190
 * Custom Include files
191
 */
192
193
// ACF
194
include_once( get_stylesheet_directory() . '/includes/acf/acf.php' );
195
196
// ACF Settings
197
include_once( get_stylesheet_directory() . '/includes/acf-settings.php' );
198
199
// Widgets
200
include_once( get_stylesheet_directory() . '/includes/widgets.php' );
201
202
// Menus
203
include_once( get_stylesheet_directory() . '/includes/menus.php' );
204
205
// Theme Settings
206
include_once( get_stylesheet_directory() . '/includes/theme-settings.php' );
207
208
// Shortcodes
209
include_once( get_stylesheet_directory() . '/includes/shortcodes.php' );
210