Get a href in input field customizer wordpress - php

I'm trying to get a field in the customizer for inserting the link to the LinkedIn profiles of my customer.
Before I made a text field and used the wpautop function. That works very well. Does anybody know a quick way to let the user insert a plain link like example.com what will be displayed like https://example.com?
With a page _blank please :-)
For my text i used this code:
<?php echo wpautop (get_theme_mod('themename-expression-text') )?>
I guess i'll need something like:
<?php echo wpautoahref (get_theme_mod('themename-expression-text'))?>
I just can't find it :-)

Fixed it! Definitely to deep into the code today :-)
<a target="_blank" href="<?php echo (get_theme_mod('themename-example-externallink') )?>">Linkedin</a>

Related

PHP Snipped not rendering in iframe

I'm trying to open the user_url within an iframe on a private user page in Wordpress.
I put the following code into a snippet:
<?php echo get_the_author_meta('user_url',$userID); ?>
When I use the short code on the user page it does display the user URL, I can also use it in an hyperlink like this:
link text
But when I put the short code into an Iframe the short code does not change into the URL anymore.
<iframe src="[cmruncode name='dash']" height="300" width="300" title="Iframe"></iframe>
Does anyone knows why this is not working and know a solution?
Thanks Peter
If you are using WordPress shortcode then you have to call shotcode using function do_shortcode.
You can try this one
<iframe src="<?php echo do_shortcode( '[cmruncode name="dash"]' ); ?>" height="300" width="300" title="Iframe"></iframe>
And I'm not sure why anchort text display right output. That's weird.
Anyway if you used do_shortcode to output your shortcode then it will work every place.
This only works when I put it directly into the template, in that case no snippet-shortcode is needed at all. But the content needs to be hidden when the user is logged-out.
Normally the plugin "client portal" that I use should take care of this
but it has a content block that does not support PHP and also does not render the php snippet that I made.
Any suggestions?
The solution was to put the iframe code completely into a snippet.
Like this:
<iframe src="<?php echo the_author_meta('user_url',$userID); ?>" height="2400" width="100%" title="Iframe"></iframe>

linked text instead of web address

I've got some php code that is calling in a website link from my database. The result is the full website link 'www.store.com', but what I'd prefer is to just have some linked text e.g., 'read more' so that the actual web address is not visible. The portion of the code that is specific to the website call is as follows:
<?php $v['website'] = str_replace('&','&', $v['website']); ?>
<website><?php echo $v['website']; ?></website>
In the case $['website'] contains the web address...
Then you are looking for soemthing like this
<a href="<?php echo $['website']; ?>" >Read more </a>
I would also recommend add target="_blank" to the <a> tag, so the user wont leave your website and the link will open in a new tab.
I don't know what the <website> tag is. But for the anchor tag this,
Read More
will work.
Also see,
Adding php code to html anchor tag
<?php $v['website'] = str_replace('&','&', $v['website']); ?>
<website><?php echo 'Read More'; ?></website>

Angular ng-init fails to assign with html elemets

I have a administration corner on my web, where can Admin create and post news.
It's implemented with html alements as helper. Admin clics on buttons and elements helps him, to style his text.
It looks this:
I have an option to Edit existing News as well.
Problem is if I try to assign this html text into my variable in ng-init
It all go bad.
<h4 ng-init="TextAreaText = '<?php if ($_GET["NID"]) $Admin->DrawNewsByID($_GET["NID"]) ?>'"> Editor </h4>
It means if there is NewsID in Get, It selects News text in php and tries to assign it into TextAreaText varible.
But it is shown like this:
Because of my bad quotation marks.
As you can see: - source code from my browser
Is it possible to samehow fix it?
Thanks a lot.

Assign button image to links from db

php newbie. echoing out links to product pages, the following code works fine:
<a href="<?php echo $rows[$product_buy];?>"<p>Click Here for Details</p></a>
but, would like to change text link "Click Here..." to an image of a button.
tried different ways, searched around, still haven't figured it out
You could simply style your link to look like a button (by giving it a class/id to make sure not all links are targeted) or you can put an img tag between the a tag.
<img src="path_to_img" alt="">

Display an img inside a php echo string

I am fairly new to the code world and am trying to display an image inside of an echo string.
Here is the code
<?php
echo String::insert(
__("Are you owner of this listing? :claim_link"),
array('claim_link'=>$html->link(
__("CLAIM IT NOW"),
array("controller"=>"listing_claims",
"action"=>"claim",$listingData['Listing']['id']
)
)
))
?></div>
The code works fine, however, I want to replace ... (__("CLAIM IT NOW") ... with an image instead of just text...something like 'img src='my-image.png'. The goal is to get a button to appear instead of text.
so far, when I make the change, I see whatever text I have typed in.
Any help is appreciated.
Replace:
"CLAIM IT NOW"
with:
"<img src='yourimage.png' alt='Image'>"
If you are using CakePHP you should do something like:
$html->link($html->image('yourimage.png', ...

Categories