| 1 | <?php |
| 2 | /* |
| 3 | Plugin Name: Site Plugin for danix.xyz |
| 4 | Description: Site specific code changes for danix.xyz |
| 5 | Plugin URI: https://danix.xyz |
| 6 | Version: 0.7.3 |
| 7 | Author: Danilo 'danix' Macri |
| 8 | Author URI: https://danix.xyz |
| 9 | */ |
| 10 | |
| 11 | /** |
| 12 | * Disable admin bar sitewide |
| 13 | */ |
| 14 | show_admin_bar( __return_false() ); |
| 15 | |
| 16 | /** |
| 17 | * Allow Shortcodes inside the html widget |
| 18 | */ |
| 19 | //add_filter( 'widget_text', 'do_shortcode' ); |
| 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 ) { |
| 34 | extract( |
| 35 | shortcode_atts( |
| 36 | array( |
| 37 | 'email' => '', |
| 38 | 'size' => '200', |
| 39 | 'default' => '', |
| 40 | 'alt' => '', |
| 41 | ), |
| 42 | $atts |
| 43 | ) |
| 44 | ); |
| 45 | |
| 46 | if ( empty( $email ) ) { |
| 47 | return ''; |
| 48 | } |
| 49 | |
| 50 | $output = get_avatar( $email, $size, $default, $alt ); |
| 51 | |
| 52 | return $output; |
| 53 | } |
| 54 | add_shortcode( 'gravatar', 'danix_gravatar' ); |
| 55 | |
| 56 | /** |
| 57 | * Added baguette.js to display a lightbox for images and galleries |
| 58 | */ |
| 59 | function baguette_register_assets() { |
| 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' ); |
| 63 | } |
| 64 | add_action( 'wp_enqueue_scripts', 'baguette_register_assets' ); |
| 65 | |
| 66 | function baguette_enqueue_assets() { |
| 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 | } |
| 72 | } |
| 73 | add_action( 'wp_enqueue_scripts', 'baguette_enqueue_assets' ); |
| 74 | |
| 75 | /* |
| 76 | * Do not translate smileys into emoticons. |
| 77 | */ |
| 78 | add_filter( 'option_use_smilies', '__return_false' ); |
| 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" */ |
| 90 | _paq.push(['trackPageView']); |
| 91 | _paq.push(['enableLinkTracking']); |
| 92 | (function() { |
| 93 | var u="//lucky.danix.xyz/"; |
| 94 | _paq.push(['setTrackerUrl', u+'matomo.php']); |
| 95 | _paq.push(['setSiteId', '1']); |
| 96 | var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; |
| 97 | g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); |
| 98 | })(); |
| 99 | </script> |
| 100 | <!-- End Matomo Code --> |
| 101 | <?php |
| 102 | } |
| 103 | endif; |
| 104 | add_action( 'wp_head', 'matomo_tracking' ); |