1Pass for WordPress

The 1Pass WordPress plugin makes it easy to integrate 1Pass into your website or blog.

Contents

Overview

1Pass for WordPress lets you pick and choose posts to make available on 1Pass, and it puts the 1Pass button on those posts.

The plugin gives you a shortcode to place the 1Pass button on your page, and it generates a secure Atom feed so 1Pass has access to your content behind the scenes.

You can see the 1Pass plugin in action by visiting the demo at 1Pass Magazine.

Installation

Download the plugin from the WordPress plugin repository and activate it. Its default behaviour is to do nothing.

Visit the 1Pass Settings Page, accessible from the Dashboard, and add your 1Pass API Keys. You're now ready to add content to 1Pass.

Wordpress d8ff420e7be69c6b00e127ecb2648db4601a7f5ba7b18adf1e4cf50ca3b93dd1

The plugin settings page

Adding an article to 1Pass

When editing a post, tick the 'Available on 1Pass' box on the post edit screen and insert the [1pass] shortcode in the body text where you'd like the button to appear.

Wp metabox f6d80e21edf734230c4e344b5763ca0956517f7dc10edbae3e7adba0463b6a10

The 'Available on 1Pass' box

Wp shortcode 4a3e839f557f530b1d89ab95b72c0a0419a1888623e71359e64694f9fb7c618e

The [1pass] shortcode

Visit the article on your website to see the 1Pass button. Note that if you're logged in you will not see the button (though you can configure this—see below).

Viewing sales reports and setting prices

You will have received a link to your 1Pass Publisher Dashboard with your API keys. Visit the dashboard to see sales reports.

Customising the plugin

Determining who sees the 1Pass button

By default, only logged-out users and users without permission to edit posts will see the 1Pass button.

This rule is added by a filter, so you can remove this restriction by removing that filter.

<?php remove_filter( 'onepass_restrictions', 'onepass_reject_unauthorised_users' ); ?>

To add a new rule, just add your own filter

<?php /** This function receives the current post as its only argument. * If it returns true, the button will be shown. * * The effect of the below function will be to show the button to * logged out users on posts in the 'featured-articles' category */ function restrict_onepass_to_feature_articles( $post ) { return !is_user_logged_in() && in_category( 'feature-articles', $post ); } add_filter( 'onepass_restrictions', 'restrict_onepass_to_feature_articles' ); ?>
Manual usage: putting 1Pass in a template

If you already restrict your content or you want finer control over where 1Pass appears, you can dispense with the shortcode and add 1Pass to your page templates manually.

To put 1Pass into manual mode, uncheck the 'Use 1Pass Shortcode' button on the 1Pass Plugin Settings Page

The 1Pass button will no longer be shown where the shortcode appears. Placing the onepass() template tag in a post will display the 1Pass button.

The onepass_restrictions filter will be bypassed and the 1Pass button will appear wherever the template tag is rendered. You can use ordinary PHP conditional statements to decide whether to show it or not.

Here's an example of putting 1Pass in The Loop

<?php if( have_posts() ) : while( have_posts() ) : the_post(); ?> <h1 class="entry-title"><?php the_title(); ?></h1> <div class="entry-content"> <?php the_content(); ?> <?php if( !is_user_logged_in ) : ?> <?php show_subscription_offer(); // for example ?> <?php onepass(); ?> <?php endif; ?> </div> <?php endwhile; endif; ?>

(Note that onepass() can also be used outside the loop—just pass a $post as the first argument).

Atom feed

The plugin will set up an Atom feed at http://{yourwebsite.com}/feed/atom/1pass/.

Visiting that URL in your web browser should show an error page and the word 'Unauthorized'.

This will work out of the box in most cases, but if your server has a firewall you may need to configure it.

If you don't see the error page, please first flush your rewrite rules, then write to us if it still doesn't work.

Technical support

Just write to us! support@1pass.me