X-Git-Url: https://git.danix.xyz/?p=danixland-site-plugin.git;a=blobdiff_plain;f=danixland-site-plugin.php;h=a6859e50c088670171fbbd33a445086aa26c3a0d;hp=71af06e72dfa8a90c6a25f09e2ff1e147d670140;hb=5e0f7db7ea49194634075fb459ada53b26862333;hpb=5d4d783d93ce302dd0f73a36ffe3e66d3efb6ca0 diff --git a/danixland-site-plugin.php b/danixland-site-plugin.php index 71af06e..a6859e5 100644 --- a/danixland-site-plugin.php +++ b/danixland-site-plugin.php @@ -1,18 +1,22 @@ '', - 'size' => '200', - 'default' => '', - 'alt' => '' - ), $atts)); - - if( empty($email) ) - return ''; - - $output = get_avatar($email, $size, $default, $alt); - - return $output; + extract( + shortcode_atts( + array( + 'email' => '', + 'size' => '200', + 'default' => '', + 'alt' => '', + ), + $atts + ) + ); + + if ( empty( $email ) ) { + return ''; + } + + $output = get_avatar( $email, $size, $default, $alt ); + + return $output; } -add_shortcode('gravatar', 'danix_gravatar'); +add_shortcode( 'gravatar', 'danix_gravatar' ); /** - * The download button shortcode - * - * @param url $link link address. - * @param string $linkname text that will be displayed by the button. - * @return string HTML the link tag that will be rendered to the page. - * + * Added baguette.js to display a lightbox for images and galleries */ -function danix_download_button( $atts ) { - extract(shortcode_atts(array( - 'link' => '', - 'linkname' => '' - ), $atts)); - - if ( empty($link) ) - return ''; - - $output = sprintf( - '%s', - $link, - $linkname - ); - - return $output; +function baguette_register_assets() { + wp_register_script( 'baguettebox', plugin_dir_url( __FILE__ ) . '/baguette/baguetteBox.min.js', array(), '1.11.1', true ); + wp_register_script( 'baguetteload', plugin_dir_url( __FILE__ ) . '/baguette/baguetteLoad.js', array(), '1.11.1', true ); + wp_register_style( 'baguettebox-css', plugin_dir_url( __FILE__ ) . '/baguette/baguetteBox.min.css', array(), '1.11.1' ); } -add_shortcode('download', 'danix_download_button'); +add_action( 'wp_enqueue_scripts', 'baguette_register_assets' ); + +function baguette_enqueue_assets() { + if ( has_block( 'gallery' ) || has_block( 'image' ) ) { + wp_enqueue_script( 'baguettebox' ); + wp_enqueue_script( 'baguetteload' ); + wp_enqueue_style( 'baguettebox-css' ); + } +} +add_action( 'wp_enqueue_scripts', 'baguette_enqueue_assets' ); -/** - * The google analytics code - * +/* + * Do not translate smileys into emoticons. */ -function danix_google_anal() {?> - - - - '640', - "height" => '480', - "src" => '' - ), $atts)); - return ''; -} -add_shortcode("googlemaps", "danix_gmaps"); - -function danix_get_plugins_stats() { - $url = 'https://api.wordpress.org/plugins/info/1.0/'; - $fields = array( - 'downloaded' => true, - 'rating' => false, - 'description' => false, - 'short_description' => false, - 'donate_link' => false, - 'tags' => false, - 'sections' => false, - 'homepage' => false, - 'added' => false, - 'last_updated' => false, - 'compatibility' => false, - 'tested' => false, - 'requires' => false, - 'downloadlink' => false, - ); - $args = (object) array( 'author' => 'danixland', 'fields' => $fields ); - $request = array( 'action' => 'query_plugins', 'timeout' => 15, 'request' => serialize( $args) ); - $response = wp_remote_post( $url, array( 'body' => $request ) ); - $plugins_info = unserialize( $response['body'] ); - $result = array(); - $total_dl = ''; - if ( isset( $plugins_info ) ) { - # let's build our array of data to return - foreach ($plugins_info->plugins as $plugin) { - $pl_name = $plugin->slug; - $pl_dirlink = 'https://wordpress.org/plugins/' . $pl_name; - $pl_download = $plugin->download_link; - $pl_downloaded = $plugin->downloaded; - $pl_voters = $plugin->num_ratings; - $pl_stars = $plugin->ratings; - $avg_vote = ($pl_stars[1] + $pl_stars[2] * 2 + $pl_stars[3] * 3 + $pl_stars[4] * 4 + $pl_stars[5] * 5) / $pl_voters; - $pl_avg_vote = ( ! is_int($avg_vote) ? 0 : $avg_vote ); - $result[$pl_name] = array( - 'dir_link' => $pl_dirlink, - 'dl_link' => $pl_download, - 'downloaded' => $pl_downloaded, - 'voters' => $pl_voters, - 'avg_rating' => $pl_avg_vote - ); - $total_dl += $pl_downloaded; - } - $result['total_plugins'] = count($plugins_info->plugins); - $result['total_downloads'] = $total_dl; - return $result; - } - return array(); -} - -// Execute cron -function danix_save_plugins_stats() { - - $plugins = danix_get_plugins_stats(); - update_option( 'danix_plugins_stats', $plugins ); -} -add_action( 'danix_save_plugins_stats', 'danix_save_plugins_stats' ); - -// Schedule cron -if ( ! wp_next_scheduled( 'danix_save_plugins_stats' ) ) : - wp_schedule_event( 1407110400, 'daily', 'danix_save_plugins_stats' ); // 1407110400 is 08 / 4 / 2014 @ 0:0:0 UTC +if ( ! function_exists( 'matomo_tracking' ) ) : + function matomo_tracking() { + ?> + + + + -
-
-

- $data) { - if (is_array($data) ) : ?> -
- - -
-
-
-