-
Erick Hitter authoredErick Hitter authored
Code owners
automatically-paginate-posts.php 16.26 KiB
<?php
/*
Plugin Name: Automatically Paginate Posts
Plugin URI: http://www.oomphinc.com/plugins-modules/automatically-paginate-posts/
Description: Automatically inserts the <!--nextpage--> Quicktag into WordPress posts, pages, or custom post type content.
Version: 0.2
Author: Erick Hitter & Oomph, Inc.
Author URI: http://www.oomphinc.com/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Automatically_Paginate_Posts {
/**
* Class variables
*/
private $post_types;
private $post_types_default = array( 'post' );
private $num_pages;
private $paging_type_default = 'pages';
private $num_pages_default = 2;
private $num_words_default = '';
private $paging_types_allowed = array( 'pages', 'words' );
// Ensure option names match values in this::uninstall
private $option_name_post_types = 'autopaging_post_types';
private $option_name_paging_type = 'pages';
private $option_name_num_pages = 'autopaging_num_pages';
private $option_name_num_words = 'autopaging_num_words';
private $meta_key_disable_autopaging = '_disable_autopaging';
/**
* Register actions and filters
*
* @uses add_action, register_uninstall_hook, add_filter
* @return null
*/
public function __construct() {
//Filters
add_action( 'init', array( $this, 'action_init' ) );
//Admin settings
register_uninstall_hook( __FILE__, array( 'Automatically_Paginate_Posts', 'uninstall' ) );
add_filter( 'plugin_action_links', array( $this, 'filter_plugin_action_links' ), 10, 2 );
add_action( 'admin_init', array( $this, 'action_admin_init' ) );
//Post-type settings
add_action( 'add_meta_boxes', array( $this, 'action_add_meta_boxes' ) );
add_action( 'save_post', array( $this, 'action_save_post' ) );
add_filter( 'the_posts', array( $this, 'filter_the_posts' ) );
}
/**
* Set post types this plugin can act on, either from Reading page or via filter
* Also sets default number of pages to break content over, either from Reading page or via filter