Link for social button share on Telegram - telegram

Good evening,
In a classic post page of WordPress, I've four share buttons. In don't found the right link to share the post on Telegram. This one runs good for Facebook:
<a href="https://www.facebook.com/sharer/sharer.php?u=&t=" class="social-share-button social-share-button-fb" title="Partager sur Facebook" target="_blank" rel="nofollow noopener noreferrer" aria-label="Partager sur Facebook" onclick="window.open('https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(document.URL) + '&t=' + encodeURIComponent(document.URL)); return false;"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--! Font Awesome Pro 6.2.0 by #fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M279.14 288l14.22-92.66h-88.91v-60.13c0-25.35 12.42-50.06 52.24-50.06h40.42V6.26S260.43 0 225.36 0c-73.22 0-121.08 44.38-121.08 124.72v70.62H22.89V288h81.39v224h100.17V288z"/></svg>
Any idea for the same to Telegram? Thank you in advance.

https://t.me/share/url?url={url}&text={text}
where {url} is the URL the user will be sharing and {text} is an optional description that will be included with the link. Both values should be URL-encoded.
PHP Example:
function telegramForwardButton($url, $text = '') {
$share_url = 'https://t.me/share/url?url='.rawurlencode($url).'&text='.rawurlencode($text);
return "Share";
}
SOURCE

Related

How can I render contentful images dynamically in my gatsby portfolio website

I have been struggling to render images from contentful in my gatsby site. I have used gatsby-plugin-image to render the image from contentful. I cannot dynamically render the images. please help me.
I import
import { GatsbyImage, getImage } from "gatsby-plugin-image"
my graphQL query is.
const data = useStaticQuery(graphql`
query {
allContentfulBooks(sort: { bookTitle: ASC }) {
edges {
node {
bookTitle
author
date(formatString: "MMMM Do, YYYY")
type
bookCover {
gatsbyImageData(
width: 300
placeholder: NONE
quality: 75
layout: CONSTRAINED
)
}
slug
summary
}
}
}
contentfulBookHeading {
heading
mainText {
raw
}
}
}
`)
I try to render the book Cover here
<ol>
{data.allContentfulBooks.edges.map((edge) => {
const image = getImage(edge.node.bookCover.gatsbyImageData)
return (
<li className={bookStyles.books}>
<div className={bookStyles.bookThumbnail}>
<div className={bookStyles.bookCover}>
<GatsbyImage src={image} alt="Book Cover" />
</div>
<div>
<Link to={`/book/${edge.node.slug}`}>
<h3 className={bookStyles.title}>{edge.node.bookTitle}</h3>
</Link>
<h5 className={bookStyles.author}>
Author: {edge.node.author}
</h5>
<h6 className={bookStyles.type}>Type: {edge.node.type}</h6>
<p className={bookStyles.date}>Date Read: {edge.node.date}</p>
<p className={bookStyles.summary}> {edge.node.summary}</p>
<Link to={`/book/${edge.node.slug}`}>
<p className={bookStyles.fullnotes}>Read full book notes</p>
</Link>
</div>
</div>
<hr />
</li>
)
})}
</ol>
I tried to render the book cover image from contentful. but it's not working
My first thought when reading your ask was that you are looking to load data dynamically, as in at load time, my original answer would work for that. After rereading your question, I believe you are not having difficulty loading data dynamically at load time but, rather you are not seeing the images display using the useStaticQuery and loading the data at build time.
Steps to ensure you should see the media:
open http://localhost:8000/___graphql in a browser and run your query, ensure you see the media you are expecting.
If you do not see the media:
First, check Contentful and ensure that the media is published.
Next, try stopping your app and restarting it, ctrl c should cancel the running command, then start the site back up. This will ensure that you content is pulled in and ready to render.
If you see the media in graphical, my next suggestion is to debug your site and console.log the data. Try putting in console logs
console.log("gatsbyImageData", edge.node.bookCover.gatsbyImageData)
const image = getImage(edge.node.bookCover.gatsbyImageData)
console.log("image", image)
next open up the developer menu in your browser and click on console
reload the page and verify the output of the console logs. This should help you ensure that data is present.
If you are having a dynamic rendering issue the answer is, useStaticQuery, grabs all of your Contentful data at build time. This is by design and is part of why Gatsby is so fast. You will need to use something like Apollo in order to grab dynamic data in Gatsby. Check out this article that provides more details and a possible solution.

Icon link without text eslint error

I have a React project that shows a bunch of social media links that are just icons to their respective sites. I use icomoon fonts and whatnot to provide the icon-* classes to show the social media icons.
The error I get, understandably, is:
Anchors must have content and the content must be accessible by a screen reader
What should I do in this scenario where I don't want anything but the icon and no text? I'm not sure how to properly do this so everyone's happy.
Edit
I didn't think code was necessary since it doesn't pertain to anything really.
Here's the mapping that spits out the links. As you can see, no text. Just font-icons for whatever social media site is being linked to:
{this.props.siteInfo.social.map(function(item, i){
return <a key={i} className={`nav_item icon-${item.social_media_type}-square`} href={item.url} target="_blank" rel="noopener noreferrer"></a>
})}
Which results in:
<a key="0" class="nav_item icon-facebook-square" href="facebook.com/someprofile" target="_blank" rel="noopener noreferrer"></a>
I got the same problem and I solved it by just adding one white space
<a><i class="fa fa-phone" aria-hidden="true"></i> </a>
I found my answer here:
https://silktide.com/i-thought-title-text-improved-accessibility-i-was-wrong/
It seems you should add a some text that you can hide via CSS, although not with display:none; or anything of that sort. Screen readers will ignore that.
I'm not sure if this is the most current way to do things, but it does work and achieves accessibility and eslint is happy.
I encountered the same problem, solved it like this with React (same suggestion as #danielInixon
const IconLink = props => {
const { name } = props;
return <a aria-label={name} href="https://github.com/johnb8005/svg">
<i className={`fa fa-${name}`} aria-hidden="true"/>
</a>;
};
I solved it with the CSS workaround:
Add some Text.
Add some CSS:
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
That means you wrote you text in side the 'i' tag
as in
your text
instead
<a><i class="fa fa-phone" aria-hidden="true"></i> your text</a>
I had the same issues for my header design system and found a solution here:
https://github.com/gatsbyjs/gatsby/issues/20208
To clarify, here's the difference:
Before:
const ExternalButton = styled( ({ ...props}) => <a {...props} />)``
After:
const ExternalButton = styled( ({ children, ...props}) => <a {...props}{children} </ a>)
Please note that a space had to be included in the </ a> for it to render on the post. Please remove it for the functional answer

Add font awesome to admin bar in Wordpress

I am adding icons with javascript in my admin bar but the icon are displayed with "squares", so I tried adding the style with the icon like this :
$('#wp-admin-bar-root-default').replaceWith('<link rel="stylesheet" id="commentator-font-awesome-css" href=".../css/font-awesome.min.css" type="text/css" media="all" /><i class="fa fa-instagram" aria-hidden="true"></i>');
Any suggestion ?
Step by Step example using FontAwesome:
Including color and custom post types
Step by Step example using FontAwesome:
Including color and custom post types 👍
1 Pick an icon
Goto: http://fontawesome.io/icons/
Pick an icon, I have chosen "fa-flask" for this example.
2 Get the SVG
Goto: https://github.com/encharm/Font-Awesome-SVG-PNG/tree/master/black/svg
Find the icon, it will be the name without the fa prefix - in my case, that is "flask.svg".
Click the icon, then click "Raw" in Github
Bring the SVG into Wordpress
Inside your functions.php, where you register your custom post type, add the following snippet:
add_action('init', 'my_init');
function my_init() {
register_post_type('labs', [
'label' => 'Labs',
// .. ect
'menu_icon' => 'data:image/svg+xml;base64,' . base64_encode('<svg width="20" height="20" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path fill="black" d="M1591 1448q56 89 21.5 152.5t-140.5 63.5h-1152q-106 0-140.5-63.5t21.5-152.5l503-793v-399h-64q-26 0-45-19t-19-45 19-45 45-19h512q26 0 45 19t19 45-19 45-45 19h-64v399zm-779-725l-272 429h712l-272-429-20-31v-436h-128v436z"/></svg>')
]);
}
Important notes:
The contents of base64_encode is the copied raw string from Font Awesomes github page.
You need to change two small things within the svg string:
1: Add a fill="black" attribute to the path/s elements - this allows the color to be change by Wordpress.
2: (optional) Change the width and height to 20, as this is the admin width/height size and seems to result it a crisper result.

Append a link to all timecodes (Like YouTube)

i want to find all timecodes in my content area and build a simple link around it, so i can jump to a specific timecode on my Wordpress Mediaelement.
How can I do this so it finally looks like:
<div class="timecodes">
<li>
**<a class="go-to-time">**15:30**</a>** "Title"
</li>
</div>
I figured it out by myself, here is my solution:
var str=document.getElementById("timecodes").innerHTML;
var n=str.replace(/[0-9][0-9][:][0-9][0-9]/gi,function myFunction(x){return "<a class='go-to-time'>" + x + "</a>";});
document.getElementById("timecodes").innerHTML=n;

jquery-carousel disappearing

I'm using the jj-nextgen-jquery-carousel plugin for wordpress, the problem I'm having with it is that the carousel disappears when I resize the browser. I'm not sure if this is a jQuery problem, or if the plugin is conflicting with the Twenty Ten theme?
<div id="jcarousel" style="display:block; width:885px; height:75px;">
<?php echo do_shortcode('[jj-ngg-jquery-carousel html_id="carousel-test-two" skin_class="jcarousel-skin-property" gallery="3" width="162" height="75" visible="5" gap="21" scroll="1" auto="1"]'); ?>
</div>
That's the code I'm using in my header.
Thanks
This bug is documented here: https://github.com/jsor/jcarousel/issues/64
You can fix this issue if you edit the jcarousel.js file directly as described in comment #11 of the bug.
Change line 287 from this:
if (i + 1 < self.first) {
to this:
if (parseInt(jQuery(this).attr('jcarouselindex')) < self.first) {

Resources