-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
135 lines (114 loc) · 4.55 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
129
130
131
132
133
134
135
<?php
function my_assets() {
wp_enqueue_style( 'main', get_template_directory_uri() . '/css/style.css', false, filemtime(get_stylesheet_directory() . '/css/style.css'));
wp_enqueue_script( 'script', get_template_directory_uri() . '/js/scripts.js', array(), '1.521' , true);
if ( is_single() ) {
wp_enqueue_script( 'twitter', 'https://platform.twitter.com/widgets.js', array(), '1', true);
wp_enqueue_script( 'shed', get_template_directory_uri() . '/js/shed.js', array('jquery'), '2.2', true);
}else if ( is_page( 'babezine' ) || is_category() || is_archive() || is_search() ) {
wp_enqueue_script( 'grids', get_template_directory_uri() . '/js/grids.js', array(), '1.4' , true);
wp_enqueue_script( 'masonry', 'https://unpkg.com/masonry-layout@4/dist/masonry.pkgd.js', array('jquery'), null, true);
wp_enqueue_script( 'infinte', 'https://cdnjs.cloudflare.com/ajax/libs/jquery-infinitescroll/2.0b2.120519/jquery.infinitescroll.min.js', array( 'jquery' ), '1', true );
}
}
add_action( 'wp_enqueue_scripts', 'my_assets' );
//theme support
add_action( 'after_setup_theme', 'theme_functions' );
function theme_functions() {
add_theme_support( 'title-tag' );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'html5', array( 'search-form' ) );
}
// Remove p tags from images, scripts, and iframes.
function remove_some_ptags( $content ) {
if ( is_single() ){
$content = preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
$content = preg_replace('/<p>\s*(<script.*>*.<\/script>)\s*<\/p>/iU', '\1', $content);
$content = preg_replace('/<p>\s*(<iframe.*>*.<\/iframe>)\s*<\/p>/iU', '\1', $content);
$content = preg_replace('/<p style="text-align: center;">\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
$content = preg_replace('/<p style="text-align: center;">\s*(<script.*>*.<\/script>)\s*<\/p>/iU', '\1', $content);
$content = preg_replace('/<p style="text-align: center;">\s*(<iframe.*>*.<\/iframe>)\s*<\/p>/iU', '\1', $content);
}
// Returns the content.
return $content;
}
add_filter( 'the_content', 'remove_some_ptags' );
/**
* Filter the except length to 20 words.
*
* @param int $length Excerpt length.
* @return int (Maybe) modified excerpt length.
*/
function wpdocs_custom_excerpt_length( $length ) {
return 15;
}
add_filter( 'excerpt_length', 'wpdocs_custom_excerpt_length', 999 );
// Replaces the excerpt "Read More" text by a link
function new_excerpt_more($more) {
global $post;
return '<a class="moretag" href="'. get_permalink($post->ID) . '">...</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');
/**Set the content width based on the theme's design and stylesheet.*/
if ( ! isset( $content_width ) ) {
$content_width = 960;
}
/**
* Register our sidebars and widgetized areas.
*
*/
function mg_widgets_init() {
if ( function_exists('register_sidebar') ) {
register_sidebar( array(
'name' => 'Right sidebar',
'id' => 'right-sidebar',
'before_widget' => '<div>',
'after_widget' => '</div>',
'before_title' => '<h2 class="">',
'after_title' => '</h2>',
) );
register_sidebar( array(
'name' => 'social bar',
'id' => 'social-bar',
'before_widget' => '<div>',
'after_widget' => '</div>',
'before_title' => '<h2 class="">',
'after_title' => '</h2>',
) );
}
//Adding a custom menu location
register_nav_menus( array( 'top-menu' => 'Top primary menu') );
}
add_action( 'widgets_init', 'mg_widgets_init' );
/**
* Registers an editor stylesheet for the theme.
*/
function wpdocs_theme_add_editor_styles() {
add_editor_style( 'editor-style.css' );
}
add_action( 'admin_init', 'wpdocs_theme_add_editor_styles' );
//inlcude custom shortcodes, but not on admin
function product_short() {
if (!is_admin()) {
// comment out the next two lines to load the local copy of jQuery
include(WP_CONTENT_DIR . '/custom_shortcodes.php');
add_shortcode( 'product', 'product_func' );
} else {
//which can also remove
remove_shortcode( 'product' );
}
}
add_action('init', 'product_short');
/* Youtube Videos remove show info related etc */
// Hide Instagram Captions
function custom_instagram_settings($code){
if(strpos($code, 'instagr.am') !== false || strpos($code, 'instagram.com') !== false){ // if instagram embed
$return = preg_replace("@data-instgrm-captioned@", "", $code); // remove caption class
return $return;
}
return $code;
}
add_filter('embed_handler_html', 'custom_instagram_settings');
add_filter('embed_oembed_html', 'custom_instagram_settings');
?>