surrounded google analytics code with cookie-notice code to block it if the user...
[danixland-site-plugin.git] / danixland-site-plugin.php
CommitLineData
5d4d783d 1<?php
2/*
bf61b3c6 3Plugin Name: Site Plugin for danix.xyz
4Description: Site specific code changes for danix.xyz
b4113a8e 5Plugin URI: https://danix.xyz
6Version: 0.7
7Author: Danilo 'danix' Macri
8Author URI: https://danix.xyz
5d4d783d 9*/
10
11/**
12 * Disable admin bar sitewide
13 */
14show_admin_bar(__return_false());
15
16/**
17 * Allow Shortcodes inside the html widget
18 */
0fcdb4ac 19//add_filter( 'widget_text', 'do_shortcode' );
5d4d783d 20
21/**
22 * make sure the links menu in the admin is visible
23 */
24add_filter( 'pre_option_link_manager_enabled', '__return_true' );
25
26/**
27 * The gravatar shortcode
28 *
29 * @param email $email email address used to retrieve the gravatar image
30 * @return string HTML the image tag which will display the gravatar image.
31 *
32 */
33function danix_gravatar( $atts ) {
34 extract(shortcode_atts(array(
35 'email' => '',
36 'size' => '200',
37 'default' => '',
38 'alt' => ''
39 ), $atts));
40
41 if( empty($email) )
42 return '';
43
44 $output = get_avatar($email, $size, $default, $alt);
45
46 return $output;
47}
48add_shortcode('gravatar', 'danix_gravatar');
49
50/**
51 * The download button shortcode
52 *
53 * @param url $link link address.
54 * @param string $linkname text that will be displayed by the button.
55 * @return string HTML the link tag that will be rendered to the page.
56 *
57 */
58function danix_download_button( $atts ) {
59 extract(shortcode_atts(array(
60 'link' => '',
61 'linkname' => ''
62 ), $atts));
63
64 if ( empty($link) )
65 return '';
66
67 $output = sprintf(
68 '<a href="%s" class="download_button">%s</a>',
69 $link,
70 $linkname
71 );
72
73 return $output;
74}
75add_shortcode('download', 'danix_download_button');
76
77/**
78 * The google analytics code
79 *
80 */
b4113a8e 81function danix_google_anal() {
82 if ( function_exists('cn_cookies_accepted') && cn_cookies_accepted() ) { ?>
5d4d783d 83<!-- Global site tag (gtag.js) - Google Analytics -->
84<script async src="https://www.googletagmanager.com/gtag/js?id=UA-23882460-1"></script>
85<script>
86 window.dataLayer = window.dataLayer || [];
87 function gtag(){dataLayer.push(arguments);}
88 gtag('js', new Date());
89
90 gtag('config', 'UA-23882460-1');
91</script>
92<?php }
b4113a8e 93}
5d4d783d 94add_action('wp_head', 'danix_google_anal', 10);
95
96/**
97 * The googlemaps shortcode
98 *
99 * @param width the width of the returned map
100 * @param height the height of the returned map
101 * @param src the url of the map you want to display
102 * @return string HTML the map object
103 * @since 0.57
104 *
105 */
106function danix_gmaps($atts, $content = null) {
107 extract(shortcode_atts(array(
108 "width" => '640',
109 "height" => '480',
110 "src" => ''
111 ), $atts));
112 return '<iframe width="'.$width.'" height="'.$height.'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'.$src.'&amp;output=embed" ></iframe>';
113}
114add_shortcode("googlemaps", "danix_gmaps");
0b37291c 115
116/**
117 * Add Next Page / Page Break button
118 * inside the WordPress Visual Editor
119 *
120 * @link https://shellcreeper.com/?p=889
121 * @since 0.9.7
122 *
123 */
124function danix_next_page_button( $buttons, $id ) {
125
126 /* only add this for content editor */
127 if ( 'content' != $id )
128 return $buttons;
129
130 /* add next page after more tag button */
131 array_splice( $buttons, 13, 0, 'wp_page' );
132
133 return $buttons;
134}
135 /* Add Next Page Button on the First Row */
136add_filter( 'mce_buttons', 'danix_next_page_button', 1, 2 ); // 1st row