Attachments Pro 2.2: Wicked Sweet New Features

Posted: September 12, 2011 Comments(9)

Since the debut of Attachments Pro, I’ve been really pumped on adding the features I’ve thought about since writing the original Attachments. I was able to take some time here and there since launch to make additions, little by little, and I think now is a good time to review the latest updates.

The ‘Big Picture’ with 2.2

Attachments was originally designed to facilitate very specific theme customization while making content population trivial. It was rooted in a need for clients to append media to various content types but not within the focal WordPress editor itself.

Many times a client site would have a list of PDFs associated with a page, for example, and it was completely customized. Sometimes there was an icon associated with it, sometimes a title field and/or caption blurb. Trying to use the main content editor to accomplish something was a painful process. Enter Attachments. The plugin let me completely customize the output and style as I wanted, all the while making it really easy for clients to use.

Attachments was primarily written for me though, based specifically on the way I wanted to use it. Many people who took interest in the plugin were puzzled when by simply activating it, the only visible changes occurred in the WordPress admin. Attachments Pro (until now) followed suit. Attachments Pro 2.2 aims to lower the barrier to entry and make integration easier for those not well versed in WordPress theme customization.

Shortcode support

The first feature to offer more direct integration with your theme is shortcode support. There’s now an (optional) toolbar button that when clicked displays a dialog allowing you to insert the content of an Attachments Pro meta box by way of a shortcode.

Screenshot of the new shortcode support in Attachments Pro 2.2

By default, Attachments Pro will output arbitrary markup for all of the added Attachments, but you can completely customize this output by adding one (or more) of the newly available filters for Attachments Pro.

attachments_pro_format_attachments

The attachments_pro_format_attachments filter runs on all instances of Attachments Pro.

attachments_pro_format_attachments_{instance}

The attachments_pro_format_attachments_{instance} filter runs only on instances of Attachments Pro that match {instance} which is the name of your Attachments Pro instance.

You can set up the shortcode filter as you would any traditional WordPress filter. A sample is as follows:

function attachments_pro_custom_format( $output, $existing_attachments )
{
  ob_start();
  if( !empty( $existing_attachments ) ) : ?>
    <div class="attachments">
      <ul>
        <?php foreach( $existing_attachments as $attachment ) : ?>
          <li>
            <a href="<?php echo $attachment['url']; ?>">
              <?php echo $attachment['name']; ?>
            </a>
          </li>
        <?php endforeach; ?>
      </ul>
    </div>
  <?php endif ;
  $output = ob_get_contents();
  ob_end_clean();
  return $output;
}

add_filter( 'attachments_pro_format_attachments', 
  'attachments_pro_custom_format', 10, 2 );

The above filter will be applied to all applicable Attachments Pro instances. If you’d like to run the filter only on an instance named documents, you can change the call to add_filter to be:

add_filter( 'attachments_pro_format_attachments_documents', 
  'attachments_pro_custom_format', 10, 2 );

Adding the shortcode will allow you/your clients to place Attachments Pro content anywhere within your main content area, and the filter will let you modify the markup as you’ve done when using native PHP on Attachments Pro output.

Auto-append to the_content()

This feature came as the direct result of a question I received about automatically appending Attachments content to RSS feeds. Without even further customization of your theme, it’s not possible out of the box. Even with further customization, it would involve all of the work required previously to include Attachments data within your theme.

I sought to find out the most minimally invasive way to accomplish inclusion in RSS feeds was to facilitate automatic inclusion in the_content(), so I did just that. Using the Advanced settings area per Attachments Pro instance, you can now choose to automatically append Attachments Pro content to the applicable post/page/CPT using your own formatting.

Screenshot of Attachments Pro 2.2 Settings

There is a full set of Magic Tags available for use within this special auto-append template, allowing you to make full use of everything available using the PHP-based implementation. The built in reference makes creating a template snippet as easy as possible.

Screenshot of the template reference in Attachments Pro 2.2

The goal with this feature is to lower the barrier to entry when it comes to using Attachments Pro and hopefully make it easier for site owners to more easily work with Attachments Pro.

Current feature list

With Attachments Pro 2.2 I’ve implemented the big features I had on my list when writing the first line of the plugin. The goal was to make it even more versatile and adaptable to any number of conditions and I think the current feature set accomplishes that.

  • Multiple Attachments meta boxes
  • Completely customizable fields and field labels
  • Ability to limit meta box addition based on rules
  • Limit the total number of Attachments that can be added per meta box
  • Limit the available Media library entries by file type (e.g. only allow images)
  • Compact view (hide Attachment fields in meta boxes)
  • Shortcode support per meta box with customization filters
  • Automatic and custom appending of Attachments to the_content()

With the listed features available as of today in Attachments Pro 2.2 I really feel that the plugin is a very comprehensive solution that will help even more WordPress users than it could have previously. I hope to have found a balance in usability of the plugin itself spanning the spectrum of users from theme customization novice to those of us who build themes from scratch each and every time. I hope the plugin is useful for those who want to get something up and running quickly without having to edit a template file, as well as those who want to integrate the plugin with the finest grain of control.

Available now, free upgrade

Attachments Pro 2.2 is available now and is a free upgrade to all current license holders. On that note, I’d like to make a point in saying that purchasing a license for Attachments Pro inherently includes lifetime upgrades. Further, the introductory price of $4.99 is still in place. Official support is offered weekdays from 10am to 4pm ET and there is an official channel for feature requests as well. I’d really love to hear what you guys think about Attachments Pro so far. I realize it’s only existed for a short time but if you’ve used Attachments or Attachments Pro and have an experience to share, I’d really like to hear it!

Get my newsletter

Receive periodic updates right in the mail!
  • This field is for validation purposes and should be left unchanged.

Comments

  1. Hi,

    Great plugin, would it be possible to attach from your AmazonS3 buckets?

    There is a plugin from tantan noodles that allows you to browse your Amazon account via the WordPress Media Library and insert links on the page.

    If you could do that via Attachments that would be awesome.

  2. Any way to link images in the options of this plugin? I have a template that uses this plugin to locate its images to display in the header slideshow. The only issue is you can set a link with in the Attachments plugin anywhere. Any ideas? Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *