How to use wp_get_attachment_image_src() properly…

Problem: No matter WHAT I do, wp_get_attachment_image_src() is NOT working. I JUST want the featured image source of this $post->ID.

Solution: Yes is probably is working… but stupidly I’m trying to pass it the POST ID and not the ATTACHMENT ID like I should be. The Attachment ID can be found with theĀ get_post_thumbnail_id() function, and then passed like this:

1
2
$thisimg = wp_get_attachment_image_src(get_post_thumbnail_id($arr->ID),full);
print_r($thisimg); //shows the Array of bits you need.

Duh… me.

Please let me know if this post was useful with a click, be honest šŸ™‚
Nope, not helpful...Yep, more useful than not! (No Ratings Yet)
Loading...

Warning: the CA certificate does not sign the certificate – Plesk 10 and GeoTrust Certs

Problem: After requesting a renewal QuickSSL Premium cert from GeoTrust, and uploading the Cert and CA Intermediates to the Plesk 10 interface, I’m warned that: “Warning: the CA certificate does not sign the certificate”.

Solution: Don’t worry about it! No idea why it happens. If you’re confident that you’ve added the correct Intermediate files, then go ahead and use one or two SSL Checkers like www.geocerts.com/ssl_checker and http://www.sslshopper.com/ssl-checker.html to confirm it’s all ok.

Notes: If there is a problem with the CA intermediate certs, it’s worth attempting to get them straight from the horses mouth. Sometimes the Intermediate cert you are sent along with your SSL Cert order isn’t enough. For all the current GeoTrust Intermediate certs, have a look here: https://knowledge.geotrust.com/support/knowledge-base/index?page=content&actp=CROSSLINK&id=SO15690

Please let me know if this post was useful with a click, be honest šŸ™‚
Nope, not helpful...Yep, more useful than not! (No Ratings Yet)
Loading...

Zurb Foundation Tooltips for and WordPress thumbnails

Problem: I wanted to use Foundation 4’s tooltips on some WordPress post thumbnail (featured) images, but wasn’t sure how to add the necessary data attribute and classes.

Solution: It turns out after some playing about that an array of attributes can be passed to the WordPress ‘get_the_post_thumbnail()‘ function. Firstly we need to add the class ‘has-tip’ (and any extra positioning classes like ‘tip-top’ if that’s where we want the tooltip to appear – see the Foundation Docs link at the top). We then need to add the data attribute ‘data-tooltip’. An example of how to do this is in the following code where I pull out a value from an Advanced Custom Field, and display a list of images with tooltips:

1
2
3
4
5
6
7
8
$icons = get_field('accom_spec_icons');
if ($icons && !is_wp_error($icons)) {
	echo '<ul class="small-block-grid-4">';
	foreach($icons as $icon) {
		echo '<li>',get_the_post_thumbnail($icon->ID,'box-thumb',array('title'=>trim(strip_tags($icon->post_title)),'class'=>'has-tip tip-top','data-tooltip'=>'')),'</li>';
	}
	echo '</ul>';
}

It’s important to add the ‘data-tooltip’ attribute with a value of ”, otherwise it wont be inserted into the generated image tag correctly.

Removing
tags around WordPress Shortcodes while retaining wpautop() changes.

Problem:
I’m building something using Drew Morris’ Foundation 4 Theme for WordPress (http://fwp.drewsymo.com/) and it allows shortcodes like [row] and [column] to be used, so that content can be aligned to the grid.

The problem is, when those shortcodes are used with any sort of line break after them, wpautop() plays havoc with the markup. I could just disable wpauto() with `remove_filter( ‘the_content’, ‘wpautop’ );` but I want it to effect all other content.

Solution:
Wordpress 3.6 has an nice new tag called has_shortcode() which can be used along with some RegEx and preg_replace() to replace the offending <br /> tags. Here’s my first version… it can be improved but it’s working pretty well so far!

add_filter ('the_content', 'cleangridshortcodes');
function cleangridshortcodes($content) {
  if(has_shortcode($content,'row') || has_shortcode($content,'column')) {
    $patterns = array("/([row])
/","/([column(.*)])
/","/([/column])
/"); $replacements = array('$1','$1','$1'); $content = preg_replace($patterns, $replacements, $content); } return $content; }

Uploading / Configuring a Laravel 4 app on cPanel type hosting ( public_html )

Problem: This morning I wanted to quickly move a little Laravel test project onto my live server. The default file structure of Laravel stores all the framework resources in a vertical tree of files and directories, and then the ‘public’ directory is adjacent to these. Like so:

- [app]
- [bootstrap]
- [public] etc

To host it on my CentOS box running cPanel I want to adhere to the following (standardish) structure:

- [.htpasswds]
- [etc]
- [mail]
- [public_ftp]
- [public_html] etc etc varies depending on server

I could just upload everything in my Laravel project to the ‘public_html’ directory… but then to run the app I’d need to browse to http://example.com/public/. Worse still, my whole framework file-structure will be visible if I browse to http://example.com

Solution: With a little path remapping in two files, this can be easily achieved. Here’s what I did:

1) Create a new directory called ‘laravel4’ adjacent to ‘public_html’ so that your remote file structure now looks like this: Continue reading “Uploading / Configuring a Laravel 4 app on cPanel type hosting ( public_html )”

Accessing selected payment type in Shopp Summary.php (Checkout and Order Confirmation page)

Problem: Someone on the Shopp Helpdesk asked how they could display the payment type that a customer had just selected, on the following Order Confirmation page. They were using multiple ‘Offline Payment’ type options, and presumably they needed the customer to be able to visually confirm what they’d selected. As far as I can see, there’s no template tag provided for this.

Solution: All sorts can be pulled from theĀ ShoppShopping() object directly. In this case the following worked:

1
<?php echo ShoppShopping()--->data->Order->Billing->cardtype; ?>

Bonus: To display the same info in reciept.php, the following can be used:

1
<?php echo shopp('purchase','cardtype','return=1'); ?>

cPanel Monthly Licensing in the UK for Rackspace Cloud Server

Problem: Ok not really a problem, but I’m trying to create a server set comprising as much UK based kit/software/support as possible. The server is on Rackspace’s UK Cloud arm.

Fix: After searching about it looks like LicensePal is a UK company.

Help me: If you found this link useful, and you’re about to order, please visit License Pal via my Affiliate link (you’ll get one also as soon as you buy anything from them): – Cheers!

Using Mac Image Capture with Nikon D70 (Direct Cable connection)

Problem: Recently I dug out my old Nikon D70 to take some pics on holiday. When I connected it to my Mac (OS X v10.8.4) via the USB cable, Image Capture fired-up as expected, but when I tired to Import them I got an error stating that Image Capture was unable to import the RAW images.

Solution: It turns out that the USB mode needs to be ‘M’ now, (Mass Storage Device Mode). To set this:

  1. Press ‘Menu’ on the D70 (after disconnecting it from the Mac.
  2. On the far left of the menu, select the spanner icon to enter the ‘Settings’ sub-menu.
  3. In the Settings menu, scroll up/down to get to the ‘USB’ setting.
  4. Enter the USB setting, and set it to ‘M’ rather than ‘P’ (Picture Transfer Protocol).
  5. Reconnect the USB cable, and the images should now import ok.

Intel Rapid Storage Technology alerts to Google Apps account

Problem: Intel Rapid Storage Technology allows for system warning and error alerts to be sent to an email address (or several if you want). In the mail settings it does allow for the port to be set, but there aren’t any authentication options.

Solution: Contrary to my previous beliefs, Google DOES seem to allow you to send unauthenticated on port 25 as long as it’s addressed to an address in your own domain. So I set:

  • FROM address to ‘app@mydomain.com’
  • TO address to ‘myaddress@mydomain.com’
  • Port to ’25’
  • Host to aspmx.l.google.com
    • And it works.. now I don’t get this.. surely it’s an open relay then? Comments?

    Get ID of the WordPress ‘Front Page’ in Theme’s functions.php

    Problem: I wanted to add some Meta Boxes to the homepage only, and have them only visible in WP-Admin when editingĀ thatĀ page.

    Solution:Ā Ā ProvidedĀ that a page has been selected in wp-admin > General Settings > Reading Settings > A Static Page [Front Page], then this code can be used to pull that value out as a Page ID: Continue reading “Get ID of the WordPress ‘Front Page’ in Theme’s functions.php”