#1Pass for WordPress

##About 1Pass

1Pass is a platform for single-article sales.

When 1Pass users see an article for sale behind the 1Pass button on a participating
web site, they click it and the article appears. 1Pass takes care of all the
accounting behind the scenes.

This plugin makes that possible in the following ways:

- It populates the button embed code
- It provides a shortcode to add to posts where the 1Pass embed should appear
- It provides a built in Atom feed to make your content available to 1Pass

It also provides

- The option to use 1Pass to restrict content.

To use the plugin, you need

  * 1Pass API credentials

To get these, enter your email at 1pass.me.

##Basic usage

This assumes that you already have a paywall or some other means of restricting content. If you want to use 1Pass for this, see _Using 1Pass to control your content_, below.

####Initial setup

On activating the plugin, you'll find a new 1Pass section in your dashboard.

There, you'll need to fill in your 1Pass publishable key and secret key, and make sure that the 'Atom feed' option is checked under 'Feed options'.

####Enabling a post for 1Pass

When you visit the 'Edit Post' screen you'll find an 'Available on 1Pass' block on the right.

Tick the box to make that piece available on 1Pass.

####Displaying the button embed code

Display the button by placing the `<?php onepass(); ?>` tag in your `single.php` (or equivalent) template.

The function `is_onepass()` will tell you whether or not the current post has the 1Pass box ticked. It optionally takes a `$post` object as an argument.

An simple integration might look like this:

    if( is_onepass() ) {
      onepass();
    }

####Feed

The feed will update every time you update your website. 1Pass will automatically discover any new content or updates to your existing content.

####Test and Live environments

If you're a developer fine-tuning your 1Pass integration on a staging server, select "Test" to have 1Pass communicate with the 1Pass test server.

##Using 1Pass to control access to your content

If your content is currently free-to-air, you can use the 1Pass plugin to control access. Tick the 'Restrict your content with 1Pass' box on the settings page.

Once this setting is checked, you can lock up a piece by adding the `[1pass]` shortcode into the body copy, and ticking the 1Pass checkbox for that piece. This will result in the post content being truncated at that point and the 1Pass button being injected.

If you need to add furniture around the button, two action hooks are provided: `onepass_before_button` and `onepass_after_button`.

##Other

####Logo
The plugin provides a 1Pass logo for illustrating posts available on 1Pass:

    <img src="<?php echo onepass_get_logo_src(); ?>" width="100" height="100" title="Available on 1Pass" />

####Author names
1Pass does its best to figure out the author of each piece. If it gets it wrong, you can filter `onepass_get_author`, which works like the native hook [the_author](https://developer.wordpress.org/reference/hooks/the_author/).

####Restricting access

This section applies only if you're using 1Pass to restrict access to your content.

By defualt, all logged-out users will see articles truncated at `[1pass]`.

If you'd like to change this rule, or add your own, use the `onepass_restrictions` hook.

To remove the default behaviour:

    add_action( 'plugins_loaded', function() {
        remove_action( 'onepass_restrictions', 'onepass_reject_logged_out_users' );
    });

Adding a new restrictions, for example to show 1Pass only to users with the role 'subscriber':

    add_action( 'onepass_restrictions', 'onepass_reject_subscribers' );

    function onepass_reject_subscribers() {
        // returning true from this function will cause the button to show
        return current_user_can( 'subscriber' );
    }

####System requirements

PHP 5.4
