Apture makes it easy to add contextual images, videos, reference guides, links, maps, music, news, documents and books to your blog to create a connected media experience that keeps readers engaged on your site. Version:1.3 Author: Apture, Inc. Author URI: http://www.apture.com */ /* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ $apture_site_token_key = "apture_site_token"; $apture_plugin_version = "wp_13"; $apture_wordpress_platform = "WordpressOrg"; $apture_domain = "http://www.apture.com"; $apture_prefilled_site_token = ""; $apture_nonce_action = 'apture-update-site-token'; function apture_die($msg) { if (!function_exists('wp_die')) { wp_die($msg); } else { die(); } } function apture_is_admin() { if (!function_exists('is_admin')) { return false; } else { return is_admin(); } } function apture_redirect($url) { if (!function_exists('wp_redirect')) { return header("Location: " . $url); } else { return wp_redirect($url); } die(); } function apture_nonce_field($action=-1, $name) { if (!function_exists('wp_nonce_field')) { return; } else { return wp_nonce_field($action, $name); } } function apture_verify_nonce($nonce, $action=-1) { if (!function_exists('wp_verify_nonce')) { return false; } else { return wp_verify_nonce($nonce, $action); } } function apture_get_domain() { global $apture_domain; return $apture_domain; } function apture_site_url() { $siteUrl = get_option('siteurl'); $siteUrlLen = strlen($siteUrl); if ($siteUrlLen > 0 && $siteUrl[strlen($siteUrl)-1] == '/') { $sep = ''; } else { $sep = '/'; } return "{$siteUrl}{$sep}"; } function apture_page_url() { return str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); } function apture_update_footer() { echo ""; $footerFile = TEMPLATEPATH . '/footer.php'; if (!file_exists($footerFile)) { $footerFile = ABSPATH . 'wp-content/themes/default/footer.php'; } $footerTemplate = file_get_contents($footerFile); if ($footerTemplate == FALSE) { $result = FALSE; } else if (!preg_match('/apture_script/', $footerTemplate)) { $footerTemplate = "\n".$footerTemplate; $fp = fopen($footerFile, 'w'); if ($fp == FALSE) { if (!preg_match('/wp_footer/', $footerTemplate)) # don't complain if they have wp_footer in their template already { $result = FALSE; } else { $result = TRUE; } } else { fwrite($fp, $footerTemplate); fclose($fp); $result = TRUE; } } else { $result = TRUE; } echo ""; return $result; } function apture_render_auto_install_form() { global $apture_nonce_action;?>

Apture Configuration

In order for users to view Apture links and embeds on your blog, your site's footer template should contain the following tag:
<?php function_exists('apture_script') && apture_script(); ?>
Click the button below to automatically add this tag to your site's footer.php template.

The input field below allows you to manually set the Apture site token associated with your blog. Most people will not need to do this, because a site token is automatically created the first time you use Apture. If you have already created a site, look up your site token.

If you don’t have an account yet, you can create one at Apture.com.

Your Apture Site Token
If you don’t know your site token you can login to Apture to get it.





"; if ($tokenSuccess && $footerSuccess) { $htmlMessage = "

ALL DONE!

"; } else if (!$tokenSuccess) { $htmlMessage = "Error saving settings."; } else if (!$footerSuccess) { $htmlMessage = "Error updating footer (is it writable?)."; } apture_render_after_auto_update_token($htmlMessage); } } else if (isset($_GET['activate'])) { apture_render_post_activation_page(); } else { apture_render_manual_install_form(); } } function apture_render_post_activation_page() { $siteUrl = apture_site_url(); $apture_domain = apture_get_domain(); echo '

Plugin Activated!

Congratulations. The Apture Editor Plugin has been successfully installed.

Go to the editing page of your blog to complete the setup wizard

When you load the editing page for your blog, the install wizard will launch and walk you through the final steps to complete the Apture installation.

'; } function apture_admin_page() { add_options_page('Apture Configuration', 'Apture Configuration', 9, basename(__FILE__), 'apture_options_page'); } add_action('admin_menu', 'apture_admin_page'); function apture_config_page() { if (function_exists('add_submenu_page')) add_submenu_page('plugins.php', __('Apture Configuration'), __('Apture Configuration'), 'manage_options', 'apture-config', 'apture_options_page'); } function apture_init() { add_action('admin_menu', 'apture_config_page'); } add_action('init', 'apture_init'); $apture_script_added_this_request = 0; function apture_script() { global $apture_site_token_key; global $apture_script_added_this_request; $siteToken = get_option($apture_site_token_key); $scriptDomain = apture_get_domain(); if ($siteToken && !$apture_script_added_this_request) { echo ""; $apture_script_added_this_request = 1; } } add_action('wp_footer', 'apture_script'); function apture_edit_script() { global $apture_site_token_key, $apture_wordpress_platform, $apture_plugin_version; $siteToken = get_option($apture_site_token_key); $scriptDomain = apture_get_domain(); $siteUrl = apture_site_url(); $configUrl = urlencode("{$siteUrl}wp-admin/options-general.php?page=apture.php&aptureAutoInstall&noheader&siteToken="); echo ""; } add_action('edit_form_advanced','apture_edit_script'); add_action('edit_page_form','apture_edit_script'); function apture_update_site_token_on_activation() { global $apture_site_token_key, $apture_prefilled_site_token; if (!empty($apture_prefilled_site_token)) { if (get_option($apture_site_token_key)) { update_option($apture_site_token_key, $apture_prefilled_site_token); } else { add_option($apture_site_token_key, $apture_prefilled_site_token); } } apture_redirect("options-general.php?page=apture.php&activate=true"); die; } function apture_remove_site_token_on_deactivation() { global $apture_site_token_key; $siteToken = get_option($apture_site_token_key); if ($siteToken) { delete_option($apture_site_token_key); } } register_activation_hook( __FILE__, 'apture_update_site_token_on_activation' ); register_deactivation_hook( __FILE__, 'apture_remove_site_token_on_deactivation' ); ?>