'button', 'label' => 'Teilen' ), $atts, 'shareliascriptbtn'); if (is_singular()) { global $post; $title = get_the_title($post->ID); $content = apply_filters('the_content', $post->post_content); // Get the license terms $terms = wp_get_post_terms($post->ID, 'license'); if (!empty($terms) && !is_wp_error($terms)) { $term = $terms[0]; $license = $term->name; $license_url = term_description($term->term_id); $license_icon_url = "https://mirrors.creativecommons.org/presskit/buttons/88x31/png/" . str_replace("cc-", "", $term->slug) . ".png"; } else { // Default values if no license term is found $license = "No License"; $license_url = "#"; $license_icon_url = "#"; } // Get author and site information $post_author_id = $post->post_author; $post_author_name = get_the_author_meta('display_name', $post_author_id); $post_author_url = get_author_posts_url($post_author_id); $home_url = home_url(); $blogname = get_bloginfo('name'); $post_url = get_permalink($post->ID); // License HTML snippet $license_html = "
{$license}
Weiternutzung als OER ausdrücklich erlaubt: Dieses OER ist - sofern dies bei Teilinhalten nicht anders angegeben - lizenziert unter {$license}. Nennung gemäß TULLU-Regel bitte wie folgt:
{$title} ({$blogname}) von , Lizenz: {$license} .
"; $license_markdown = "\n\n---\n\n### OER-Lizenz\n\n". "Dieses Werk ist - sofern Inhalte nicht anders gekennzeichnet - lizenziert unter". "\n[$title]($post_url)\n[$license]($license_url) [$post_author_name]($post_author_url)/[$blogname]($home_url)"; // Convert content to Markdown $markdownContent = $this->convert_to_markdown($content).$license_markdown; // Convert Markdown content to gzip Base64 $contentHash = $this->create_gzip_base64_data($markdownContent); // Generate the link $link = sprintf( '%s', $contentHash, esc_attr($atts['class']), esc_html($atts['label']) ); return $license_html.$link; } return ''; } private function convert_to_markdown($content) { #$parsedown = new Parsedown(); #$contenthtml = $parsedown->text($content); $converter = new HtmlConverter(array('strip_tags' => true)); $markdown = $converter->convert($content); # $markdown = strip_tags($markdown); return $markdown; } private function create_gzip_base64_data($data) { $gzData = gzencode($data, 9); return base64_encode($gzData); } } // Initialize the plugin new PostToLiaScriptShortcodeButton();