5d4d783d |
1 | <?php |
2 | /* |
3 | Plugin Name: Site Plugin for danixland.net |
4 | Description: Site specific code changes for danixland.net |
5 | */ |
6 | |
7 | /** |
8 | * Disable admin bar sitewide |
9 | */ |
10 | show_admin_bar(__return_false()); |
11 | |
12 | /** |
13 | * Allow Shortcodes inside the html widget |
14 | */ |
0fcdb4ac |
15 | //add_filter( 'widget_text', 'do_shortcode' ); |
5d4d783d |
16 | |
17 | /** |
18 | * make sure the links menu in the admin is visible |
19 | */ |
20 | add_filter( 'pre_option_link_manager_enabled', '__return_true' ); |
21 | |
22 | /** |
23 | * The gravatar shortcode |
24 | * |
25 | * @param email $email email address used to retrieve the gravatar image |
26 | * @return string HTML the image tag which will display the gravatar image. |
27 | * |
28 | */ |
29 | function danix_gravatar( $atts ) { |
30 | extract(shortcode_atts(array( |
31 | 'email' => '', |
32 | 'size' => '200', |
33 | 'default' => '', |
34 | 'alt' => '' |
35 | ), $atts)); |
36 | |
37 | if( empty($email) ) |
38 | return ''; |
39 | |
40 | $output = get_avatar($email, $size, $default, $alt); |
41 | |
42 | return $output; |
43 | } |
44 | add_shortcode('gravatar', 'danix_gravatar'); |
45 | |
46 | /** |
47 | * The download button shortcode |
48 | * |
49 | * @param url $link link address. |
50 | * @param string $linkname text that will be displayed by the button. |
51 | * @return string HTML the link tag that will be rendered to the page. |
52 | * |
53 | */ |
54 | function danix_download_button( $atts ) { |
55 | extract(shortcode_atts(array( |
56 | 'link' => '', |
57 | 'linkname' => '' |
58 | ), $atts)); |
59 | |
60 | if ( empty($link) ) |
61 | return ''; |
62 | |
63 | $output = sprintf( |
64 | '<a href="%s" class="download_button">%s</a>', |
65 | $link, |
66 | $linkname |
67 | ); |
68 | |
69 | return $output; |
70 | } |
71 | add_shortcode('download', 'danix_download_button'); |
72 | |
73 | /** |
74 | * The google analytics code |
75 | * |
76 | */ |
77 | function danix_google_anal() {?> |
78 | <!-- Global site tag (gtag.js) - Google Analytics --> |
79 | <script async src="https://www.googletagmanager.com/gtag/js?id=UA-23882460-1"></script> |
80 | <script> |
81 | window.dataLayer = window.dataLayer || []; |
82 | function gtag(){dataLayer.push(arguments);} |
83 | gtag('js', new Date()); |
84 | |
85 | gtag('config', 'UA-23882460-1'); |
86 | </script> |
87 | <?php } |
88 | add_action('wp_head', 'danix_google_anal', 10); |
89 | |
90 | /** |
91 | * The googlemaps shortcode |
92 | * |
93 | * @param width the width of the returned map |
94 | * @param height the height of the returned map |
95 | * @param src the url of the map you want to display |
96 | * @return string HTML the map object |
97 | * @since 0.57 |
98 | * |
99 | */ |
100 | function danix_gmaps($atts, $content = null) { |
101 | extract(shortcode_atts(array( |
102 | "width" => '640', |
103 | "height" => '480', |
104 | "src" => '' |
105 | ), $atts)); |
106 | return '<iframe width="'.$width.'" height="'.$height.'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'.$src.'&output=embed" ></iframe>'; |
107 | } |
108 | add_shortcode("googlemaps", "danix_gmaps"); |
109 | |