PHP Class Pressbooks\Book

Datei anzeigen Open project: pressbooks/pressbooks Class Usage Examples

Public Properties

Property Type Description
$fixDupeSlugs array This can happen if a post is 'draft', 'pending', or 'auto-draft'

Public Methods

Method Description
__construct ( )
consolidatePost ( integer $pid, WP_Post $post ) : boolean Ensures this chapter/part/front matter has a "menu_order" when it is saved
deleteBookObjectCache ( ) Delete the Book Object cache(s)
deletePost ( integer $pid ) : boolean Put a Part/Chapter/Front Matter/Back Matter in the trash
get ( string $what = 'next' ) : string Fetch next, previous or first post
getBookContents ( ) : array Returns an array representing the entire structure of a book, in correct order, with a maximum amount of fields. Data is raw and must be post-processed.
getBookInformation ( $id = '' ) : array Returns book information in a useful, string only, format. Data is converted to HTML.
getBookStructure ( string $id = '' ) : array Returns an array representing the entire structure of a book, in correct order, with a minimum amount of fields. Data is raw and must be post-processed.
getFirst ( ) : string Select the very first post in a book. May be a chapter or a front matter post
getSubsections ( $id ) : array | false Returns an array of subsections in front matter, back matter, or chapters.
isBook ( ) : boolean Check if the current blog_id is considered a "book"
tagSubsections ( string $content, $id ) : string Returns chapter, front or back matter content with section ID and classes added.
updateBackMatter ( ) WP_Ajax hook. Updates the menu_order field associated with a back matter post after reordering it
updateChapter ( ) WP_Ajax hook. Updates the menu_order field associated with a chapter post after reordering it and update its associated part, if necessary
updateExportOptions ( ) WP_Ajax hook. Updates a post's "export" setting (export post into book or not)
updateFrontMatter ( ) WP_Ajax hook. Updates the menu_order field associated with a front matter post after reordering it
updateGlobalPrivacyOptions ( ) WP_Ajax hook. Updates a post's privacy setting (whether the post is published or privately published)
updatePrivacyOptions ( ) WP_Ajax hook. Updates a post's privacy setting (whether the post is published or privately published)
updateShowTitleOptions ( ) WP_Ajax hook. Updates a post's "show title" setting (show title in exports or not)

Protected Methods

Method Description
fixSlug ( string $old_post_name ) : string Fix empty slugs and Fix duplicate slugs.

Method Details

__construct() public method

public __construct ( )

consolidatePost() static public method

Ensures this chapter/part/front matter has a "menu_order" when it is saved
static public consolidatePost ( integer $pid, WP_Post $post ) : boolean
$pid integer Post ID
$post WP_Post Post
return boolean

deleteBookObjectCache() static public method

Delete the Book Object cache(s)
static public deleteBookObjectCache ( )

deletePost() static public method

Put a Part/Chapter/Front Matter/Back Matter in the trash
static public deletePost ( integer $pid ) : boolean
$pid integer
return boolean

fixSlug() protected static method

This can happen if a post is 'draft', 'pending', or 'auto-draft'
protected static fixSlug ( string $old_post_name ) : string
$old_post_name string
return string

get() static public method

Fetch next, previous or first post
static public get ( string $what = 'next' ) : string
$what string prev, next or first
return string URL of requested post

getBookContents() static public method

Returns an array representing the entire structure of a book, in correct order, with a maximum amount of fields. Data is raw and must be post-processed.
See also: bottom of this file for more info
static public getBookContents ( ) : array
return array

getBookInformation() static public method

Returns book information in a useful, string only, format. Data is converted to HTML.
static public getBookInformation ( $id = '' ) : array
return array

getBookStructure() static public method

Returns an array representing the entire structure of a book, in correct order, with a minimum amount of fields. Data is raw and must be post-processed.
See also: bottom of this file for more info
static public getBookStructure ( string $id = '' ) : array
$id string
return array

getFirst() static public method

Select the very first post in a book. May be a chapter or a front matter post
static public getFirst ( ) : string
return string permalink of the first post

getSubsections() static public method

Returns an array of subsections in front matter, back matter, or chapters.
static public getSubsections ( $id ) : array | false
$id
return array | false

isBook() static public method

Check if the current blog_id is considered a "book"
static public isBook ( ) : boolean
return boolean

tagSubsections() static public method

Returns chapter, front or back matter content with section ID and classes added.
static public tagSubsections ( string $content, $id ) : string
$content string
return string

updateBackMatter() static public method

WP_Ajax hook. Updates the menu_order field associated with a back matter post after reordering it
static public updateBackMatter ( )

updateChapter() static public method

WP_Ajax hook. Updates the menu_order field associated with a chapter post after reordering it and update its associated part, if necessary
static public updateChapter ( )

updateExportOptions() static public method

WP_Ajax hook. Updates a post's "export" setting (export post into book or not)
static public updateExportOptions ( )

updateFrontMatter() static public method

WP_Ajax hook. Updates the menu_order field associated with a front matter post after reordering it
static public updateFrontMatter ( )

updateGlobalPrivacyOptions() static public method

WP_Ajax hook. Updates a post's privacy setting (whether the post is published or privately published)
static public updateGlobalPrivacyOptions ( )

updatePrivacyOptions() static public method

WP_Ajax hook. Updates a post's privacy setting (whether the post is published or privately published)
static public updatePrivacyOptions ( )

updateShowTitleOptions() static public method

WP_Ajax hook. Updates a post's "show title" setting (show title in exports or not)
static public updateShowTitleOptions ( )

Property Details

$fixDupeSlugs static_oe public_oe property

This can happen if a post is 'draft', 'pending', or 'auto-draft'
See also: wp_unique_post_slug()
static public array $fixDupeSlugs
return array