3 Plugin Name: Site Plugin for danix.xyz
4 Description: Site specific code changes for danix.xyz
5 Plugin URI: https://danix.xyz
7 Author: Danilo 'danix' Macri
8 Author URI: https://danix.xyz
12 * Disable admin bar sitewide
14 show_admin_bar(__return_false());
17 * Allow Shortcodes inside the html widget
19 //add_filter( 'widget_text', 'do_shortcode' );
22 * make sure the links menu in the admin is visible
24 add_filter( 'pre_option_link_manager_enabled', '__return_true' );
27 * The gravatar shortcode
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.
33 function danix_gravatar( $atts ) {
34 extract(shortcode_atts(array(
44 $output = get_avatar($email, $size, $default, $alt);
48 add_shortcode('gravatar', 'danix_gravatar');
51 * The google analytics code
54 /*function danix_google_anal() {
55 if ( function_exists('cn_cookies_accepted') && cn_cookies_accepted() ) { ?>
56 <!-- Global site tag (gtag.js) - Google Analytics -->
57 <script async src="https://www.googletagmanager.com/gtag/js?id=UA-23882460-1"></script>
59 window.dataLayer = window.dataLayer || [];
60 function gtag(){dataLayer.push(arguments);}
61 gtag('js', new Date());
63 gtag('config', 'UA-23882460-1');
67 add_action('wp_head', 'danix_google_anal', 10);
70 * The googlemaps shortcode
72 * @param width the width of the returned map
73 * @param height the height of the returned map
74 * @param src the url of the map you want to display
75 * @return string HTML the map object
79 /*function danix_gmaps($atts, $content = null) {
80 extract(shortcode_atts(array(
85 return '<iframe width="'.$width.'" height="'.$height.'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'.$src.'&output=embed" ></iframe>';
87 add_shortcode("googlemaps", "danix_gmaps");
91 * Swap src with data-src inside img tags to use lazyload
93 function dagreynix_lazy_load($atts) {
94 $default = get_template_directory_uri() . '/img/standard-post-thumb.png';
95 if ( array_key_exists('src', $atts) ) {
96 $atts['data-src'] = $atts['src'];
97 $atts['src'] = $default;
101 // add_filter( 'wp_get_attachment_image_attributes', 'dagreynix_lazy_load', 10, 2 );
104 * Added baguette.js to display a lightbox for images and galleries
106 function baguette_register_assets() {
107 wp_register_script( 'baguettebox', plugin_dir_url( __FILE__
) . '/baguette/baguetteBox.min.js', [], '1.11.1', true );
108 wp_register_script( 'baguetteload', plugin_dir_url( __FILE__
) . '/baguette/baguetteLoad.js', [], '1.11.1', true );
109 wp_register_style( 'baguettebox-css', plugin_dir_url( __FILE__
) . '/baguette/baguetteBox.min.css', [], '1.11.1' );
111 add_action( 'wp_enqueue_scripts', 'baguette_register_assets' );
113 function baguette_enqueue_assets() {
114 if ( has_block( 'gallery' ) ||
has_block('image') ) {
115 wp_enqueue_script( 'baguettebox' );
116 wp_enqueue_script( 'baguetteload' );
117 wp_enqueue_style( 'baguettebox-css' );
120 add_action( 'wp_enqueue_scripts', 'baguette_enqueue_assets' );