5d4d783d |
1 | <?php |
2 | /* |
bf61b3c6 |
3 | Plugin Name: Site Plugin for danix.xyz |
4 | Description: Site specific code changes for danix.xyz |
b4113a8e |
5 | Plugin URI: https://danix.xyz |
89b9676f |
6 | Version: 0.7.3 |
b4113a8e |
7 | Author: Danilo 'danix' Macri |
8 | Author URI: https://danix.xyz |
5d4d783d |
9 | */ |
10 | |
11 | /** |
12 | * Disable admin bar sitewide |
13 | */ |
89b9676f |
14 | show_admin_bar( __return_false() ); |
5d4d783d |
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 | */ |
24 | add_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 | */ |
33 | function danix_gravatar( $atts ) { |
89b9676f |
34 | extract( |
35 | shortcode_atts( |
36 | array( |
37 | 'email' => '', |
38 | 'size' => '200', |
39 | 'default' => '', |
40 | 'alt' => '', |
41 | ), |
42 | $atts |
43 | ) |
44 | ); |
5d4d783d |
45 | |
89b9676f |
46 | if ( empty( $email ) ) { |
47 | return ''; |
48 | } |
5d4d783d |
49 | |
89b9676f |
50 | $output = get_avatar( $email, $size, $default, $alt ); |
5d4d783d |
51 | |
89b9676f |
52 | return $output; |
5d4d783d |
53 | } |
89b9676f |
54 | add_shortcode( 'gravatar', 'danix_gravatar' ); |
2f370882 |
55 | |
56 | /** |
57 | * Added baguette.js to display a lightbox for images and galleries |
58 | */ |
59 | function baguette_register_assets() { |
89b9676f |
60 | wp_register_script( 'baguettebox', plugin_dir_url( __FILE__ ) . '/baguette/baguetteBox.min.js', array(), '1.11.1', true ); |
61 | wp_register_script( 'baguetteload', plugin_dir_url( __FILE__ ) . '/baguette/baguetteLoad.js', array(), '1.11.1', true ); |
62 | wp_register_style( 'baguettebox-css', plugin_dir_url( __FILE__ ) . '/baguette/baguetteBox.min.css', array(), '1.11.1' ); |
2f370882 |
63 | } |
64 | add_action( 'wp_enqueue_scripts', 'baguette_register_assets' ); |
65 | |
66 | function baguette_enqueue_assets() { |
89b9676f |
67 | if ( has_block( 'gallery' ) || has_block( 'image' ) ) { |
68 | wp_enqueue_script( 'baguettebox' ); |
69 | wp_enqueue_script( 'baguetteload' ); |
70 | wp_enqueue_style( 'baguettebox-css' ); |
71 | } |
2f370882 |
72 | } |
73 | add_action( 'wp_enqueue_scripts', 'baguette_enqueue_assets' ); |
89b9676f |
74 | |
75 | /* |
76 | * Do not translate smileys into emoticons. |
77 | */ |
78 | add_filter( 'option_use_smilies', '__return_false' ); |
5e0f7db7 |
79 | |
80 | /* |
81 | # Add matomo tracking js code to head |
82 | */ |
83 | if ( ! function_exists( 'matomo_tracking' ) ) : |
84 | function matomo_tracking() { |
85 | ?> |
86 | <!-- Matomo --> |
87 | <script type="text/javascript"> |
88 | var _paq = window._paq = window._paq || []; |
89 | /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ |
7812e449 |
90 | _paq.push(["setDocumentTitle", document.domain + "/" + document.title]); |
91 | _paq.push(["setCookieDomain", "*.danix.xyz"]); |
92 | _paq.push(["setDomains", ["*.danix.xyz"]]); |
5e0f7db7 |
93 | _paq.push(['trackPageView']); |
94 | _paq.push(['enableLinkTracking']); |
95 | (function() { |
96 | var u="//lucky.danix.xyz/"; |
97 | _paq.push(['setTrackerUrl', u+'matomo.php']); |
98 | _paq.push(['setSiteId', '1']); |
99 | var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; |
100 | g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); |
101 | })(); |
102 | </script> |
103 | <!-- End Matomo Code --> |
104 | <?php |
105 | } |
106 | endif; |
107 | add_action( 'wp_head', 'matomo_tracking' ); |