jeradin / acf-website-field Goto Github PK
View Code? Open in Web Editor NEWAdvanced Custom Fields add-on for Website URLs, allows for website URL, title and a checkbox to open externally or internally
Advanced Custom Fields add-on for Website URLs, allows for website URL, title and a checkbox to open externally or internally
First of all thanks for this plugin.
I noticed a bug when I set my field required. Indeed even if I put a value to my url field, an error message is fired.
Thanks for the plugin :)
It is possible to add simple HTML input validation by setting the input field type to "url".
Commit: 972c3e6
Location: website_url.php (line: 168)
Suggested modification:
echo '<td><input type="url" value="' . $link_title . '" id="' . $key . '" class="' . $class . '" name="'.$key.'[title]" /></td>';
Hello! Great plugin, works well.
I'm dealing with clients that are less-than-savvy when it comes to the internet, so I wanted to make this field a little more dumbproof. Users were entering websites in a huge variety of ways, some with the http:// and some without. I added some extra URL validation on the display end to make sure the link pops out ok each time.
website_url.php line 268-270:
// get value
$value = $this->get_value($post_id, $field);
$value['url'] = nicifyUrl( $value['url'] );
Extra formatting call in there, nicifyUrl()
. Corresponding functions from http://electrokami.com/coding/use-php-to-format-and-validate-a-url-with-these-easy-functions :
function nicifyUrl($url) {
$url = urldecode(strtolower($url));
$url = stripit($url);
// clean up url path
$url = explode("/",$url);
$arrUrl = parse_url($url[0]);
$urlRet = $arrUrl['path'];
// valid?
if(validateTheUrl($urlRet)){
return $urlRet;
}
else{
return "Invalid URL";
}
}
function stripit($url){
$url = trim($url);
$url = preg_replace("/^(http:\/\/)*(www.)*/is", "", $url);
$url = preg_replace("/\/.*$/is" , "" ,$url);
return $url;
}
function validateTheUrl($url){
if (!preg_match("#[a-z0-9-_.]+\.[a-z]{2,4}#i",$url)) {
return false;
}
else if(strpos($url,"@") !== false){
return false;
}
else{
return true;
}
}
Easy. Cheers!
I'm trying to get my catalog_url to link to an external site to work.
What happens instead is I get a plain http link (as in, you click on the link and it just goes to http). So I checked my ACF and yep, the link is in the field as http://www.example.com. Below is the code in my template:
<?php if( get_field('catalog_url') ): ?>
<p><strong>Catalog:</strong> <a href="<?php the_field('catalog_url')?>"> <?php the_field('catalog_url') ?> </a></p>
<?php endif; ?>
The expected output (if there is a URL in the field) is:
Catalog: http://www.example.com
Love the plugg.
Could u implement ability to use any url with trailing slashes?
URL validation is incorrect for version 2.1 when the URL is an empty string and the field is not required.
validateTheUrl in website_url_v5.php returns false if the URL is an empty string. As a result, even if the website field is not required, you can't save the post with a blank URL because it triggers a "Value must be a valid URL" error.
What would be nice is that you could select what kind of value you want to return just like at the image field.
A. complete link <a href="#">Title</a>
B. Array
array(
'title' => 'title of the link',
'url' = '' 'http://www.jaimemartinez.nl',
'external' => false
);
Because at this moment I have hacked core to return an array :)
array(
'link' => '<a href="#">Title</a>',
'title' => 'title of the link',
'url' = '' 'http://www.jaimemartinez.nl',
'external' => false
);
Thanks for the plugin by the way!
I just upgraded to 5.0 and the plugin is not working. It says it is but in the list, there is no Website option. I re-installed it after the upgrade and it is still not working.
I have noticed that the WordPress-GitHub-Plugin-Updater you're using makes the Wordpress admin area very sluggish. Page refreshes take about six seconds on my local machine, whereas they are almost instantaneous normally. I commented out the updater block that appears at the top of acf-website-field.php, and everything runs snappily again.
Open in Current Window?
If "Yes" than the user can check a box to have the link open in current window.
It is ambigous because the checkbox label "Current Window" and return array has "external => 1" when checked
The label must be "Open in a new windows"
Hi,
sorry to bother you with maybe a stupid question, but somehow I'm not able to figure out the php code for displaying a normal link URL.
I installed and activated both the ACF and your plugin and have implemented a custom post type with a couple of custom fields. One of them should be a link to a website and as the others (which work ok) I want to display it on the single-post.php site.
I just want to display the URL like every other normal link: Link
But how do I replace this correctly with the elements from your plugin? I looked for a documentation with code examples but couldn't find some...
Thank you for your help in advance...
Regards,
hurgl.
Hi Jeradin,
Another issue has suddenly occurred I'm afraid.
I have 3 website fields, one with the URL only and the other two with the Title field too, you can see them here: http://anotherfashion.co/about-us/partners/another-company/
In the Admin, in the Facebook and Twitter website fields I have the following:
Title: anotherco URL: facebook.com/another
Title: anotherco URL: twitter.com/another
But as you can see on the front end, all that's displaying is:
facebook.com
twitter.com
I've cached my browser, my site with W3 Total cache and have also 'purged from cache' the Field Group within which these fields sit.
I've also deleted the plugin and reinstalled but still no luck.
Do you know what the problem could be?
Thanks so much
Katri
@Jeradin In the field it display the "Internal Link" checkbox. When selecting this checkbox it is adding 'target="_blank"' in output. In coding also 'internal' term is used.
It will be perfect if you just change the "Internal Link" to "External Link" and all will be ok.
hi there!
first of all nice plugin. it is doing it's work.
i just noticed, that if i choose to return an array, then the 'http://' is not attached to the url.
don't know if you wanted it that way, but i think it should be consistent, so i thought i will inform you.
All other things are working fine but not "required"
I'm trying to create a hyperlink on images and while the link will come through, it is not on the image but rather creates it's own div behind the image. When going into developer tools, the code displays as an anchor tag and then the image rather than the anchor wrapped around the image. I can't seem to find any reason as to why this is happening. Any ideas?
Thanks!
Hi Jeradin,
Thanks for your plugin, it was just what I was looking for. It's mainly working bu there seems to be a wee big happening - after publishing/updating for the first time having filled in the website fields, the urls display fine on the front end but they disappear from the admin. So if I return to re-edit the page/post, the fields are blank and I have to re-enter them before Updating otherwise they'll then disappear from the front end.
Do you know what this could be?
Many thanks
Katri
When I enter a URL that is HTTPS, the link shows up as 'invalid'
Could you add support for
$value ='<a href="https://'.$the_url.'" '.$external.'>'.$title.'</a>';
This is a great add-on that saves me time. Thanks for the good work!
And, it would be even better if the admin could choose to enable the automatic adding of "http://" or force the content editor to add it manually so that they can use relative links with out the "http://" if so desired.
One use case for this is when you have a staging server and want to create links to pages on staging and have them still work when exporting the content to production without having to edit the links again or do a find-and-replace on the database.
It would be extra nice to add wordpress's link picker tool. I imagine Links picked with that tool would be dynamic and thus their base url would change when imported to another server.
Anyway, just my two cents.
Thanks again,
isaac
@Jeradin there's been a lot of improvement to the github-updater code. You might find it easier to stay up-to-date with its code by just running it as its own plugin for any of your projects.
You should tag your versions so that one can keep track of the releases. I see you have a changelog already.
Love the plugin add-on! I'm not sure if it's me (which it probably is...), but if the website field is left empty, the page displays "invalid URL" versus leaving it blank. Any help is much appreciated.
Nice work with the addon! saw your post at http://support.advancedcustomfields.com/
I'm pretty new to GitHub myself (so maybe this isn't the right place to suggest this), but you should rename your readme.txt to a .md (markdown) extension to let GitHub evaluate your markdown.
I'm looking into why.
Probably the current code will be outdated:
http://www.advancedcustomfields.com/resources/getting-started/migrating-from-v3-to-v4/
Hi!
If I insert a CPT via wp_insert_post and do then the update_post_meta function for a website-field, the value is saved fine in the database, but is not showing on the ui. it always shows the first character of the whole value.
didn't had time to look into your code, but maybe you have an idea what the cause could be.
cheers,
Sahin
Screen shots are always helpful. Thanks
There is no clearly documented method for outputting URLs via this ACF plugin. It would be handy if you added that to your readme.md.
Additionally, it seems that the URL title and value fields cannot be output as arrays when the website URLs are subfields of a repeater field.
I installed it and now on any page of my wordpress installation i get:
Parse error: syntax error, unexpected 'path' (T_STRING) in /home/(NAME)/public_html/(NAME)/wp-content/plugins/acf-website-field-master/website_url.php on line 430
Hi. I got everything uploaded to my site via ftp but I'm having trouble getting the code into my functions.php. Can you help me?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.