-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
129 lines (100 loc) · 4.04 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
/*---------------------------------------------------------*/
/* Theme Initial Setup */
/*---------------------------------------------------------*/
if ( !function_exists('dimension_theme_setup') ) {
function dimension_theme_setup() {
/* REGISTER TEXT DOMAIN FOR TRANSLATION */
load_theme_textdomain('dimension');
/* GETTING RSS FEED LINKS */
add_theme_support('automatic-feed-links');
/* GETTING TITLE TAG */
add_theme_support('title-tag');
/* GETTING POST THUMBNAIL */
add_theme_support('post-thumbnails');
/* GETTING BACKGROUND OPTIONS */
add_theme_support('custom-background');
/* GETTING HEADER OPTIONS */
$defaults = array(
'default-image' => get_theme_file_uri('/images/bg.jpg'),
'header-text' => true,
'default-text-color' => '#fff'
);
add_theme_support('custom-header', $defaults);
}
}
add_action( 'after_setup_theme', 'dimension_theme_setup' );
/*---------------------------------------------------------*/
/* Register Page Sidebar */
/*---------------------------------------------------------*/
function dimension_page_sidebar() {
$args = array(
'name' => __( 'Page Sidebar', 'dimension' ),
'id' => 'page-sidebar',
'description' => __( 'Select your page widgets.', 'dimension' ),
);
register_sidebar($args);
}
add_action( 'widgets_init', 'dimension_page_sidebar' );
/*---------------------------------------------------------*/
/* Include Theme assets */
/*---------------------------------------------------------*/
function dimension_theme_assets() {
$var = '1.0';
/* FONTS */
wp_enqueue_style( 'dimension-font-awesome', get_theme_file_uri('/assets/css/font-awesome.min.css'), null, '4.7.0' );
wp_enqueue_style( 'dimension-Source-Sans-Pro', '//fonts.googleapis.com/css?family=Source+Sans+Pro:300italic,600italic,300,600', null, null );
/* CSS */
wp_enqueue_style( 'dimension-main-css', get_theme_file_uri('/assets/css/main.css'), array(), $var );
wp_enqueue_style( 'dimension-theme-css', get_stylesheet_uri(), array(), $var );
/* JavaScripts */
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'dimension-browser-min-js', get_theme_file_uri('/assets/js/browser.min.js'), array(), $var, true );
wp_enqueue_script( 'dimension-breakpoints-min-js', get_theme_file_uri('/assets/js/breakpoints.min.js'), array(), $var, true );
wp_enqueue_script( 'dimension-util-js', get_theme_file_uri('/assets/js/util.js'), array(), $var, true );
wp_enqueue_script( 'dimension-main-js', get_theme_file_uri('/assets/js/main.js'), array(), $var, true );
}
add_action( 'wp_enqueue_scripts', 'dimension_theme_assets' );
/* REQUIRE CUSTOM WIDGETS FILE */
require_once('inc/custom-widgets.php');
/* REQUIRE CUSTOMIZER FILE */
require_once('inc/customizer-api.php');
/*---------------------------------------------------------*/
/* Custom internal CSS add */
/*---------------------------------------------------------*/
function dimension_custom_internal_css() {
if ( current_theme_supports( 'custom-header' ) ) {
?>
<style>
#bg:after { background-image: url('<?php header_image(); ?>'); }
.inner h1, .inner p {
color: #<?php echo get_header_textcolor(); ?>;
<?php
if ( !display_header_text() ) {
echo 'display: none;';
}
?>
}
</style>
<?php
}
}
add_action( 'wp_head', 'dimension_custom_internal_css' );
/*---------------------------------------------------------*/
/* Remove default active widgets */
/*---------------------------------------------------------*/
if ( is_admin() && isset($_GET['activated'] ) && $pagenow == 'themes.php' ) {
add_action('admin_footer','removed_widgets');
}
function removed_widgets(){
//get all registered sidebars
global $wp_registered_sidebars;
//get saved widgets
$widgets = get_option('sidebars_widgets');
//loop over the sidebars and remove all widgets
foreach ($wp_registered_sidebars as $sidebar => $value) {
unset($widgets[$sidebar]);
}
//update with widgets removed
update_option('sidebars_widgets',$widgets);
}