repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
pressbooks/pressbooks
inc/class-styles.php
Styles.isCurrentThemeCompatible
public function isCurrentThemeCompatible( $version = 1, $theme = null ) { if ( null === $theme ) { $theme = wp_get_theme(); } $basepath = $this->getDir( $theme ); $types = [ 'prince', 'epub', 'web', ]; foreach ( $types as $type ) { $path = ''; if ( 1 === $version && 'web' !== $type ) {...
php
public function isCurrentThemeCompatible( $version = 1, $theme = null ) { if ( null === $theme ) { $theme = wp_get_theme(); } $basepath = $this->getDir( $theme ); $types = [ 'prince', 'epub', 'web', ]; foreach ( $types as $type ) { $path = ''; if ( 1 === $version && 'web' !== $type ) {...
[ "public", "function", "isCurrentThemeCompatible", "(", "$", "version", "=", "1", ",", "$", "theme", "=", "null", ")", "{", "if", "(", "null", "===", "$", "theme", ")", "{", "$", "theme", "=", "wp_get_theme", "(", ")", ";", "}", "$", "basepath", "=", ...
Are the current theme's stylesheets SCSS compatible? @param int $version @param \WP_Theme $theme (optional) @return bool
[ "Are", "the", "current", "theme", "s", "stylesheets", "SCSS", "compatible?" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-styles.php#L324-L357
pressbooks/pressbooks
inc/class-styles.php
Styles.getBuckramVersion
public function getBuckramVersion() { $fullpath = realpath( $this->sass->pathToGlobals() . 'buckram.scss' ); if ( is_file( $fullpath ) ) { return get_file_data( $fullpath, [ 'version' => 'Version', ] )['version']; } return false; // No version available. }
php
public function getBuckramVersion() { $fullpath = realpath( $this->sass->pathToGlobals() . 'buckram.scss' ); if ( is_file( $fullpath ) ) { return get_file_data( $fullpath, [ 'version' => 'Version', ] )['version']; } return false; // No version available. }
[ "public", "function", "getBuckramVersion", "(", ")", "{", "$", "fullpath", "=", "realpath", "(", "$", "this", "->", "sass", "->", "pathToGlobals", "(", ")", ".", "'buckram.scss'", ")", ";", "if", "(", "is_file", "(", "$", "fullpath", ")", ")", "{", "re...
Get the version of Buckram for the current install or locked theme. @since 5.0.0 @see https://github.com/pressbooks/buckram/blob/master/styles/buckram.scss @return string|bool
[ "Get", "the", "version", "of", "Buckram", "for", "the", "current", "install", "or", "locked", "theme", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-styles.php#L368-L379
pressbooks/pressbooks
inc/class-styles.php
Styles.hasBuckram
public function hasBuckram( $version = 0 ) { if ( $this->isCurrentThemeCompatible( 2 ) && version_compare( $this->getBuckramVersion(), $version ) >= 0 ) { return true; } return false; }
php
public function hasBuckram( $version = 0 ) { if ( $this->isCurrentThemeCompatible( 2 ) && version_compare( $this->getBuckramVersion(), $version ) >= 0 ) { return true; } return false; }
[ "public", "function", "hasBuckram", "(", "$", "version", "=", "0", ")", "{", "if", "(", "$", "this", "->", "isCurrentThemeCompatible", "(", "2", ")", "&&", "version_compare", "(", "$", "this", "->", "getBuckramVersion", "(", ")", ",", "$", "version", ")"...
Check that the currently active theme uses Buckram (optionally a minimum version of Buckram). @since 5.3.0 @param int|string $version @return bool
[ "Check", "that", "the", "currently", "active", "theme", "uses", "Buckram", "(", "optionally", "a", "minimum", "version", "of", "Buckram", ")", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-styles.php#L390-L395
pressbooks/pressbooks
inc/class-styles.php
Styles.customizeWeb
public function customizeWeb( $overrides = [] ) { $path = $this->getPathToWebScss(); if ( $path ) { return $this->customize( 'web', \Pressbooks\Utility\get_contents( $path ), $overrides ); } return ''; }
php
public function customizeWeb( $overrides = [] ) { $path = $this->getPathToWebScss(); if ( $path ) { return $this->customize( 'web', \Pressbooks\Utility\get_contents( $path ), $overrides ); } return ''; }
[ "public", "function", "customizeWeb", "(", "$", "overrides", "=", "[", "]", ")", "{", "$", "path", "=", "$", "this", "->", "getPathToWebScss", "(", ")", ";", "if", "(", "$", "path", ")", "{", "return", "$", "this", "->", "customize", "(", "'web'", ...
@param array|string $overrides (optional) @return string
[ "@param", "array|string", "$overrides", "(", "optional", ")" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-styles.php#L402-L408
pressbooks/pressbooks
inc/class-styles.php
Styles.customizePrince
public function customizePrince( $overrides = [] ) { $path = $this->getPathToPrinceScss(); if ( $path ) { return $this->customize( 'prince', \Pressbooks\Utility\get_contents( $path ), $overrides ); } return ''; }
php
public function customizePrince( $overrides = [] ) { $path = $this->getPathToPrinceScss(); if ( $path ) { return $this->customize( 'prince', \Pressbooks\Utility\get_contents( $path ), $overrides ); } return ''; }
[ "public", "function", "customizePrince", "(", "$", "overrides", "=", "[", "]", ")", "{", "$", "path", "=", "$", "this", "->", "getPathToPrinceScss", "(", ")", ";", "if", "(", "$", "path", ")", "{", "return", "$", "this", "->", "customize", "(", "'pri...
@param array|string $overrides (optional) @return string
[ "@param", "array|string", "$overrides", "(", "optional", ")" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-styles.php#L415-L421
pressbooks/pressbooks
inc/class-styles.php
Styles.customizeEpub
public function customizeEpub( $overrides = [] ) { $path = $this->getPathToEpubScss(); if ( $path ) { return $this->customize( 'epub', \Pressbooks\Utility\get_contents( $path ), $overrides ); } return ''; }
php
public function customizeEpub( $overrides = [] ) { $path = $this->getPathToEpubScss(); if ( $path ) { return $this->customize( 'epub', \Pressbooks\Utility\get_contents( $path ), $overrides ); } return ''; }
[ "public", "function", "customizeEpub", "(", "$", "overrides", "=", "[", "]", ")", "{", "$", "path", "=", "$", "this", "->", "getPathToEpubScss", "(", ")", ";", "if", "(", "$", "path", ")", "{", "return", "$", "this", "->", "customize", "(", "'epub'",...
@param array|string $overrides (optional) @return string
[ "@param", "array|string", "$overrides", "(", "optional", ")" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-styles.php#L428-L434
pressbooks/pressbooks
inc/class-styles.php
Styles.customize
public function customize( $type, $scss, $overrides = [] ) { $scss = $this->applyOverrides( $scss, $overrides ); // Apply Theme Options if ( $type === 'prince' ) { $scss = apply_filters( 'pb_pdf_css_override', $scss ); } else { $scss = apply_filters( "pb_{$type}_css_override", $scss ); } if ( $this-...
php
public function customize( $type, $scss, $overrides = [] ) { $scss = $this->applyOverrides( $scss, $overrides ); // Apply Theme Options if ( $type === 'prince' ) { $scss = apply_filters( 'pb_pdf_css_override', $scss ); } else { $scss = apply_filters( "pb_{$type}_css_override", $scss ); } if ( $this-...
[ "public", "function", "customize", "(", "$", "type", ",", "$", "scss", ",", "$", "overrides", "=", "[", "]", ")", "{", "$", "scss", "=", "$", "this", "->", "applyOverrides", "(", "$", "scss", ",", "$", "overrides", ")", ";", "// Apply Theme Options", ...
Transpile SCSS based on theme compatibility @param string $type @param string $scss @param array|string $overrides @return string
[ "Transpile", "SCSS", "based", "on", "theme", "compatibility" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-styles.php#L445-L484
pressbooks/pressbooks
inc/class-styles.php
Styles.applyOverrides
public function applyOverrides( $scss, $overrides = [] ) { if ( ! is_array( $overrides ) ) { $overrides = (array) $overrides; } $overrides = implode( "\n", $overrides ); if ( $this->isCurrentThemeCompatible( 2 ) ) { // Prepend override variables (see: http://sass-lang.com/documentation/file.SASS_REFEREN...
php
public function applyOverrides( $scss, $overrides = [] ) { if ( ! is_array( $overrides ) ) { $overrides = (array) $overrides; } $overrides = implode( "\n", $overrides ); if ( $this->isCurrentThemeCompatible( 2 ) ) { // Prepend override variables (see: http://sass-lang.com/documentation/file.SASS_REFEREN...
[ "public", "function", "applyOverrides", "(", "$", "scss", ",", "$", "overrides", "=", "[", "]", ")", "{", "if", "(", "!", "is_array", "(", "$", "overrides", ")", ")", "{", "$", "overrides", "=", "(", "array", ")", "$", "overrides", ";", "}", "$", ...
Prepend or append SCSS overrides depending on which version of the theme architecture is in use. @param string $scss @param array|string $overrides @return string
[ "Prepend", "or", "append", "SCSS", "overrides", "depending", "on", "which", "version", "of", "the", "theme", "architecture", "is", "in", "use", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-styles.php#L494-L510
pressbooks/pressbooks
inc/class-styles.php
Styles.injectHouseStyles
public function injectHouseStyles( $css ) { $scan = [ '/*__INSERT_PDF_HOUSE_STYLE__*/' => get_theme_root( 'pressbooks-book' ) . '/pressbooks-book/assets/legacy/styles/_pdf-house-style.scss', '/*__INSERT_EPUB_HOUSE_STYLE__*/' => get_theme_root( 'pressbooks-book' ) . '/pressbooks-book/assets/legacy/styles/_epub-...
php
public function injectHouseStyles( $css ) { $scan = [ '/*__INSERT_PDF_HOUSE_STYLE__*/' => get_theme_root( 'pressbooks-book' ) . '/pressbooks-book/assets/legacy/styles/_pdf-house-style.scss', '/*__INSERT_EPUB_HOUSE_STYLE__*/' => get_theme_root( 'pressbooks-book' ) . '/pressbooks-book/assets/legacy/styles/_epub-...
[ "public", "function", "injectHouseStyles", "(", "$", "css", ")", "{", "$", "scan", "=", "[", "'/*__INSERT_PDF_HOUSE_STYLE__*/'", "=>", "get_theme_root", "(", "'pressbooks-book'", ")", ".", "'/pressbooks-book/assets/legacy/styles/_pdf-house-style.scss'", ",", "'/*__INSERT_EP...
Inject house styles into CSS @param string $css @return string
[ "Inject", "house", "styles", "into", "CSS" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-styles.php#L519-L534
pressbooks/pressbooks
inc/class-styles.php
Styles.updateWebBookStyleSheet
public function updateWebBookStyleSheet( $stylesheet = null ) { if ( CustomCss::isCustomCss() ) { // Compile pressbooks-book web stylesheet when using the *DEPRECATED* Custom CSS theme $theme = wp_get_theme( 'pressbooks-book' ); } else { $theme = wp_get_theme( $stylesheet ); } // Populate $url-base v...
php
public function updateWebBookStyleSheet( $stylesheet = null ) { if ( CustomCss::isCustomCss() ) { // Compile pressbooks-book web stylesheet when using the *DEPRECATED* Custom CSS theme $theme = wp_get_theme( 'pressbooks-book' ); } else { $theme = wp_get_theme( $stylesheet ); } // Populate $url-base v...
[ "public", "function", "updateWebBookStyleSheet", "(", "$", "stylesheet", "=", "null", ")", "{", "if", "(", "CustomCss", "::", "isCustomCss", "(", ")", ")", "{", "// Compile pressbooks-book web stylesheet when using the *DEPRECATED* Custom CSS theme", "$", "theme", "=", ...
Update and save the supplementary webBook stylesheet which incorporates user options, etc. @param string $stylesheet Directory name for the theme. Defaults to current theme. @return void
[ "Update", "and", "save", "the", "supplementary", "webBook", "stylesheet", "which", "incorporates", "user", "options", "etc", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-styles.php#L542-L573
pressbooks/pressbooks
inc/class-styles.php
Styles.maybeUpdateStylesheets
public function maybeUpdateStylesheets() { // If this is ajax/cron/404, don't update right now if ( wp_doing_ajax() || wp_doing_cron() || is_404() ) { return false; } // Compare current and previous Buckram versions $current_buckram_version = $this->getBuckramVersion(); $last_buckram_version = get_optio...
php
public function maybeUpdateStylesheets() { // If this is ajax/cron/404, don't update right now if ( wp_doing_ajax() || wp_doing_cron() || is_404() ) { return false; } // Compare current and previous Buckram versions $current_buckram_version = $this->getBuckramVersion(); $last_buckram_version = get_optio...
[ "public", "function", "maybeUpdateStylesheets", "(", ")", "{", "// If this is ajax/cron/404, don't update right now", "if", "(", "wp_doing_ajax", "(", ")", "||", "wp_doing_cron", "(", ")", "||", "is_404", "(", ")", ")", "{", "return", "false", ";", "}", "// Compar...
If the current theme's version or Buckram's version has increased, do SCSS stuff @return bool
[ "If", "the", "current", "theme", "s", "version", "or", "Buckram", "s", "version", "has", "increased", "do", "SCSS", "stuff" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-styles.php#L580-L617
pressbooks/pressbooks
inc/class-styles.php
Styles.renderDropdownForSlugs
public function renderDropdownForSlugs( $slug ) { $select_name = 'slug'; $select_id = $select_name; $redirect_url = get_admin_url( get_current_blog_id(), '/themes.php?page=' . $this::PAGE . '&slug=' ); $html = ''; $html .= " <script type='text/javascript'> // <![CDATA[ jQuery.noConflict(); jQuery(func...
php
public function renderDropdownForSlugs( $slug ) { $select_name = 'slug'; $select_id = $select_name; $redirect_url = get_admin_url( get_current_blog_id(), '/themes.php?page=' . $this::PAGE . '&slug=' ); $html = ''; $html .= " <script type='text/javascript'> // <![CDATA[ jQuery.noConflict(); jQuery(func...
[ "public", "function", "renderDropdownForSlugs", "(", "$", "slug", ")", "{", "$", "select_name", "=", "'slug'", ";", "$", "select_id", "=", "$", "select_name", ";", "$", "redirect_url", "=", "get_admin_url", "(", "get_current_blog_id", "(", ")", ",", "'/themes....
Render dropdown and JavaScript for slugs. @param string $slug @return string
[ "Render", "dropdown", "and", "JavaScript", "for", "slugs", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-styles.php#L651-L683
pressbooks/pressbooks
inc/class-styles.php
Styles.renderRevisionsTable
public function renderRevisionsTable( $slug, $post_id ) { $args = [ 'posts_per_page' => 10, 'post_type' => 'revision', 'post_status' => 'inherit', 'post_parent' => $post_id, 'orderby' => 'date', 'order' => 'DESC', ]; $q = new \WP_Query(); $results = $q->query( $args ); $html = '<table cla...
php
public function renderRevisionsTable( $slug, $post_id ) { $args = [ 'posts_per_page' => 10, 'post_type' => 'revision', 'post_status' => 'inherit', 'post_parent' => $post_id, 'orderby' => 'date', 'order' => 'DESC', ]; $q = new \WP_Query(); $results = $q->query( $args ); $html = '<table cla...
[ "public", "function", "renderRevisionsTable", "(", "$", "slug", ",", "$", "post_id", ")", "{", "$", "args", "=", "[", "'posts_per_page'", "=>", "10", ",", "'post_type'", "=>", "'revision'", ",", "'post_status'", "=>", "'inherit'", ",", "'post_parent'", "=>", ...
Render table for revisions. @param string $slug @param int $post_id @return string
[ "Render", "table", "for", "revisions", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-styles.php#L693-L716
pressbooks/pressbooks
inc/class-styles.php
Styles.formSubmit
public function formSubmit() { if ( empty( $this->isFormSubmission() ) || empty( current_user_can( 'edit_others_posts' ) ) ) { // Don't do anything in this function, bail. return; } // Process form if ( isset( $_GET['custom_styles'] ) && $_GET['custom_styles'] === 'yes' && isset( $_POST['your_styles'] )...
php
public function formSubmit() { if ( empty( $this->isFormSubmission() ) || empty( current_user_can( 'edit_others_posts' ) ) ) { // Don't do anything in this function, bail. return; } // Process form if ( isset( $_GET['custom_styles'] ) && $_GET['custom_styles'] === 'yes' && isset( $_POST['your_styles'] )...
[ "public", "function", "formSubmit", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "isFormSubmission", "(", ")", ")", "||", "empty", "(", "current_user_can", "(", "'edit_others_posts'", ")", ")", ")", "{", "// Don't do anything in this function, bail...
Save custom styles to database
[ "Save", "custom", "styles", "to", "database" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-styles.php#L721-L770
pressbooks/pressbooks
inc/shortcodes/class-tablepress.php
TablePress.loadShortcodes
public function loadShortcodes() { add_action( 'tablepress_run', function () { if ( \Pressbooks\Modules\Export\Export::isFormSubmission() ) { \TablePress::$model_options = \TablePress::load_model( 'options' ); \TablePress::$model_table = \TablePress::load_model( 'table' ); $GLOBALS['tablepress_f...
php
public function loadShortcodes() { add_action( 'tablepress_run', function () { if ( \Pressbooks\Modules\Export\Export::isFormSubmission() ) { \TablePress::$model_options = \TablePress::load_model( 'options' ); \TablePress::$model_table = \TablePress::load_model( 'table' ); $GLOBALS['tablepress_f...
[ "public", "function", "loadShortcodes", "(", ")", "{", "add_action", "(", "'tablepress_run'", ",", "function", "(", ")", "{", "if", "(", "\\", "Pressbooks", "\\", "Modules", "\\", "Export", "\\", "Export", "::", "isFormSubmission", "(", ")", ")", "{", "\\"...
Add actions and filters to TablePress to load shortcodes in the admin context.
[ "Add", "actions", "and", "filters", "to", "TablePress", "to", "load", "shortcodes", "in", "the", "admin", "context", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/shortcodes/class-tablepress.php#L47-L65
pressbooks/pressbooks
inc/modules/export/prince/class-docraptor.php
Docraptor.convert
public function convert() { // Sanity check if ( empty( $this->exportStylePath ) || ! is_file( $this->exportStylePath ) ) { $this->logError( '$this->exportStylePath must be set before calling convert().' ); return false; } // Set logfile $this->logfile = $this->createTmpFile(); // Set filename $f...
php
public function convert() { // Sanity check if ( empty( $this->exportStylePath ) || ! is_file( $this->exportStylePath ) ) { $this->logError( '$this->exportStylePath must be set before calling convert().' ); return false; } // Set logfile $this->logfile = $this->createTmpFile(); // Set filename $f...
[ "public", "function", "convert", "(", ")", "{", "// Sanity check", "if", "(", "empty", "(", "$", "this", "->", "exportStylePath", ")", "||", "!", "is_file", "(", "$", "this", "->", "exportStylePath", ")", ")", "{", "$", "this", "->", "logError", "(", "...
@since 5.4.0 Create $this->outputPath. @return bool|string
[ "@since", "5", ".", "4", ".", "0" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/prince/class-docraptor.php#L34-L140
pressbooks/pressbooks
inc/modules/export/prince/class-docraptor.php
Docraptor.getDetailedLog
protected function getDetailedLog( $id ) { // @see: https://docraptor.com/documentation/api#doc_log_listing $response = wp_remote_get( esc_url( 'https://docraptor.com/doc_logs.json?per_page=25&user_credentials=' . DOCRAPTOR_API_KEY ) ); if ( is_wp_error( $response ) ) { return $response->get_error_message(); ...
php
protected function getDetailedLog( $id ) { // @see: https://docraptor.com/documentation/api#doc_log_listing $response = wp_remote_get( esc_url( 'https://docraptor.com/doc_logs.json?per_page=25&user_credentials=' . DOCRAPTOR_API_KEY ) ); if ( is_wp_error( $response ) ) { return $response->get_error_message(); ...
[ "protected", "function", "getDetailedLog", "(", "$", "id", ")", "{", "// @see: https://docraptor.com/documentation/api#doc_log_listing", "$", "response", "=", "wp_remote_get", "(", "esc_url", "(", "'https://docraptor.com/doc_logs.json?per_page=25&user_credentials='", ".", "DOCRAP...
When given a DocRaptor async status ID, return the document generation log for the relevant job. @param string $id @return string
[ "When", "given", "a", "DocRaptor", "async", "status", "ID", "return", "the", "document", "generation", "log", "for", "the", "relevant", "job", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/prince/class-docraptor.php#L149-L164
pressbooks/pressbooks
inc/class-sass.php
Sass.defaultIncludePaths
public function defaultIncludePaths( $type, $theme = null ) { if ( null === $theme ) { $theme = wp_get_theme(); } return [ $this->pathToUserGeneratedSass(), $this->pathToGlobals(), $this->pathToFonts(), Container::get( 'Styles' )->getDir( $theme ) . "/assets/styles/$type/", ]; }
php
public function defaultIncludePaths( $type, $theme = null ) { if ( null === $theme ) { $theme = wp_get_theme(); } return [ $this->pathToUserGeneratedSass(), $this->pathToGlobals(), $this->pathToFonts(), Container::get( 'Styles' )->getDir( $theme ) . "/assets/styles/$type/", ]; }
[ "public", "function", "defaultIncludePaths", "(", "$", "type", ",", "$", "theme", "=", "null", ")", "{", "if", "(", "null", "===", "$", "theme", ")", "{", "$", "theme", "=", "wp_get_theme", "(", ")", ";", "}", "return", "[", "$", "this", "->", "pat...
Get default include paths @param string $type @param string $theme @return array
[ "Get", "default", "include", "paths" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-sass.php#L43-L55
pressbooks/pressbooks
inc/class-sass.php
Sass.getStringsToLocalize
public function getStringsToLocalize() { $switched_locale = switch_to_locale( Modules\Export\Export::locale() ); $localized = [ /** * Filter the label used for post types (front matter/parts/chapters/back matter) in the TOC and section headings. * * @since 5.6.0 * * @param string $label ...
php
public function getStringsToLocalize() { $switched_locale = switch_to_locale( Modules\Export\Export::locale() ); $localized = [ /** * Filter the label used for post types (front matter/parts/chapters/back matter) in the TOC and section headings. * * @since 5.6.0 * * @param string $label ...
[ "public", "function", "getStringsToLocalize", "(", ")", "{", "$", "switched_locale", "=", "switch_to_locale", "(", "Modules", "\\", "Export", "\\", "Export", "::", "locale", "(", ")", ")", ";", "$", "localized", "=", "[", "/**\n\t\t\t * Filter the label used for p...
Fetch an array of strings in (S)CSS which need to be localized @return array
[ "Fetch", "an", "array", "of", "strings", "in", "(", "S", ")", "CSS", "which", "need", "to", "be", "localized" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-sass.php#L62-L96
pressbooks/pressbooks
inc/class-sass.php
Sass.compile
public function compile( $scss, $includes = [] ) { $scss = $this->prependLocalizedVars( $scss ); try { $css = '/* Silence is golden. */'; // If no SCSS input was passed, prevent file write errors by putting a comment in the CSS output. $scssphp = new \Leafo\ScssPhp\Compiler; if ( ! empty( $scss ) || ! em...
php
public function compile( $scss, $includes = [] ) { $scss = $this->prependLocalizedVars( $scss ); try { $css = '/* Silence is golden. */'; // If no SCSS input was passed, prevent file write errors by putting a comment in the CSS output. $scssphp = new \Leafo\ScssPhp\Compiler; if ( ! empty( $scss ) || ! em...
[ "public", "function", "compile", "(", "$", "scss", ",", "$", "includes", "=", "[", "]", ")", "{", "$", "scss", "=", "$", "this", "->", "prependLocalizedVars", "(", "$", "scss", ")", ";", "try", "{", "$", "css", "=", "'/* Silence is golden. */'", ";", ...
Returns the compiled CSS from SCSS input @param string $scss @param array $includes (optional) @return string
[ "Returns", "the", "compiled", "CSS", "from", "SCSS", "input" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-sass.php#L182-L214
pressbooks/pressbooks
inc/class-sass.php
Sass.prependLocalizedVars
public function prependLocalizedVars( $scss ) { $strings = $this->getStringsToLocalize(); $localizations = ''; foreach ( $strings as $var => $string ) { $localizations .= "\$$var: '$string';\n"; } if ( WP_DEBUG ) { $this->debug( '/* Silence is golden. */', $localizations, 'localizations' ); } ret...
php
public function prependLocalizedVars( $scss ) { $strings = $this->getStringsToLocalize(); $localizations = ''; foreach ( $strings as $var => $string ) { $localizations .= "\$$var: '$string';\n"; } if ( WP_DEBUG ) { $this->debug( '/* Silence is golden. */', $localizations, 'localizations' ); } ret...
[ "public", "function", "prependLocalizedVars", "(", "$", "scss", ")", "{", "$", "strings", "=", "$", "this", "->", "getStringsToLocalize", "(", ")", ";", "$", "localizations", "=", "''", ";", "foreach", "(", "$", "strings", "as", "$", "var", "=>", "$", ...
Prepend localized version of content string variables. @param string $scss @return string
[ "Prepend", "localized", "version", "of", "content", "string", "variables", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-sass.php#L223-L236
pressbooks/pressbooks
inc/class-sass.php
Sass.parseVariables
public function parseVariables( $scss ) { $output = []; $parser = new \Leafo\ScssPhp\Parser( null ); $tree = $parser->parse( $scss ); foreach ( $tree->children as $item ) { if ( $item[0] === \Leafo\ScssPhp\Type::T_ASSIGN && $item[1][0] === \Leafo\ScssPhp\Type::T_VARIABLE && ! str_starts_with( $item[1][1], '_...
php
public function parseVariables( $scss ) { $output = []; $parser = new \Leafo\ScssPhp\Parser( null ); $tree = $parser->parse( $scss ); foreach ( $tree->children as $item ) { if ( $item[0] === \Leafo\ScssPhp\Type::T_ASSIGN && $item[1][0] === \Leafo\ScssPhp\Type::T_VARIABLE && ! str_starts_with( $item[1][1], '_...
[ "public", "function", "parseVariables", "(", "$", "scss", ")", "{", "$", "output", "=", "[", "]", ";", "$", "parser", "=", "new", "\\", "Leafo", "\\", "ScssPhp", "\\", "Parser", "(", "null", ")", ";", "$", "tree", "=", "$", "parser", "->", "parse",...
Parse an SCSS file into an array of variables. @param string $scss @return array
[ "Parse", "an", "SCSS", "file", "into", "an", "array", "of", "variables", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-sass.php#L245-L272
pressbooks/pressbooks
inc/class-sass.php
Sass.logException
protected function logException( \Exception $e ) { $subject = __( 'SASS Error' ); /** $var \WP_User $current_user */ global $current_user; $info = [ 'time' => strftime( '%c' ), 'user' => ( isset( $current_user ) ? $current_user->user_login : '__UNKNOWN__' ), 'site_url' => site_url(), 'blog_id' =>...
php
protected function logException( \Exception $e ) { $subject = __( 'SASS Error' ); /** $var \WP_User $current_user */ global $current_user; $info = [ 'time' => strftime( '%c' ), 'user' => ( isset( $current_user ) ? $current_user->user_login : '__UNKNOWN__' ), 'site_url' => site_url(), 'blog_id' =>...
[ "protected", "function", "logException", "(", "\\", "Exception", "$", "e", ")", "{", "$", "subject", "=", "__", "(", "'SASS Error'", ")", ";", "/** $var \\WP_User $current_user */", "global", "$", "current_user", ";", "$", "info", "=", "[", "'time'", "=>", "...
Log Exceptions @param \Exception $e
[ "Log", "Exceptions" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-sass.php#L279-L308
pressbooks/pressbooks
inc/class-sass.php
Sass.debug
public function debug( $css, $scss, $filename ) { $debug_dir = $this->pathToDebugDir(); $css_debug_file = $debug_dir . "/{$filename}.css"; \Pressbooks\Utility\put_contents( $css_debug_file, $css ); $scss_debug_file = $debug_dir . "/{$filename}.scss"; \Pressbooks\Utility\put_contents( $scss_debug_file, $scs...
php
public function debug( $css, $scss, $filename ) { $debug_dir = $this->pathToDebugDir(); $css_debug_file = $debug_dir . "/{$filename}.css"; \Pressbooks\Utility\put_contents( $css_debug_file, $css ); $scss_debug_file = $debug_dir . "/{$filename}.scss"; \Pressbooks\Utility\put_contents( $scss_debug_file, $scs...
[ "public", "function", "debug", "(", "$", "css", ",", "$", "scss", ",", "$", "filename", ")", "{", "$", "debug_dir", "=", "$", "this", "->", "pathToDebugDir", "(", ")", ";", "$", "css_debug_file", "=", "$", "debug_dir", ".", "\"/{$filename}.css\"", ";", ...
Write CSS to a a debug dir @param string $css @param string $scss @param string $filename
[ "Write", "CSS", "to", "a", "a", "debug", "dir" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-sass.php#L318-L327
pressbooks/pressbooks
inc/modules/export/wordpress/class-vanillawxr.php
VanillaWxr.deleteNode
private function deleteNode( $node ) { $this->deleteChildren( $node ); $parent = $node->parentNode; $oldnode = $parent->removeChild( $node ); }
php
private function deleteNode( $node ) { $this->deleteChildren( $node ); $parent = $node->parentNode; $oldnode = $parent->removeChild( $node ); }
[ "private", "function", "deleteNode", "(", "$", "node", ")", "{", "$", "this", "->", "deleteChildren", "(", "$", "node", ")", ";", "$", "parent", "=", "$", "node", "->", "parentNode", ";", "$", "oldnode", "=", "$", "parent", "->", "removeChild", "(", ...
deletes a node and all of its children @param \DOMNode $node
[ "deletes", "a", "node", "and", "all", "of", "its", "children" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/wordpress/class-vanillawxr.php#L123-L127
pressbooks/pressbooks
inc/modules/export/wordpress/class-vanillawxr.php
VanillaWxr.deleteChildren
private function deleteChildren( $node ) { while ( isset( $node->firstChild ) ) { $this->deleteChildren( $node->firstChild ); $node->removeChild( $node->firstChild ); } }
php
private function deleteChildren( $node ) { while ( isset( $node->firstChild ) ) { $this->deleteChildren( $node->firstChild ); $node->removeChild( $node->firstChild ); } }
[ "private", "function", "deleteChildren", "(", "$", "node", ")", "{", "while", "(", "isset", "(", "$", "node", "->", "firstChild", ")", ")", "{", "$", "this", "->", "deleteChildren", "(", "$", "node", "->", "firstChild", ")", ";", "$", "node", "->", "...
recursive function to delete all children of a node @param \DOMNode $node
[ "recursive", "function", "to", "delete", "all", "children", "of", "a", "node" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/wordpress/class-vanillawxr.php#L134-L139
pressbooks/pressbooks
inc/covergenerator/class-princejpg.php
PrinceJpg.generate
public function generate() { $tmp_pdf_path = create_tmp_file(); $success = $this->generateWithPrince( null, null, $this->generateHtml(), $tmp_pdf_path ); if ( true !== $success ) { throw new \Exception( 'Failed to create PDF file' ); } $output_path = $this->timestampedFileName( 'jpg' ); $this->convert( $...
php
public function generate() { $tmp_pdf_path = create_tmp_file(); $success = $this->generateWithPrince( null, null, $this->generateHtml(), $tmp_pdf_path ); if ( true !== $success ) { throw new \Exception( 'Failed to create PDF file' ); } $output_path = $this->timestampedFileName( 'jpg' ); $this->convert( $...
[ "public", "function", "generate", "(", ")", "{", "$", "tmp_pdf_path", "=", "create_tmp_file", "(", ")", ";", "$", "success", "=", "$", "this", "->", "generateWithPrince", "(", "null", ",", "null", ",", "$", "this", "->", "generateHtml", "(", ")", ",", ...
Generate Ebook JPG cover @throws \Exception @return string Output path
[ "Generate", "Ebook", "JPG", "cover" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/covergenerator/class-princejpg.php#L74-L84
pressbooks/pressbooks
inc/modules/import/wordpress/class-wxr.php
Wxr.dependencies
public function dependencies( $downloads = null, $contributors = null ) { $this->downloads = $downloads ? $downloads : new Downloads( $this ); $this->contributors = $contributors ? $contributors : new Contributors(); }
php
public function dependencies( $downloads = null, $contributors = null ) { $this->downloads = $downloads ? $downloads : new Downloads( $this ); $this->contributors = $contributors ? $contributors : new Contributors(); }
[ "public", "function", "dependencies", "(", "$", "downloads", "=", "null", ",", "$", "contributors", "=", "null", ")", "{", "$", "this", "->", "downloads", "=", "$", "downloads", "?", "$", "downloads", ":", "new", "Downloads", "(", "$", "this", ")", ";"...
For testing, ability to mock objects @param null Downloads $downloads @param null \Pressbooks\Contributors $contributors
[ "For", "testing", "ability", "to", "mock", "objects" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/wordpress/class-wxr.php#L86-L89
pressbooks/pressbooks
inc/modules/import/wordpress/class-wxr.php
Wxr.setCurrentImportOption
function setCurrentImportOption( array $upload ) { try { $parser = new Parser(); $xml = $parser->parse( $upload['file'] ); } catch ( \Exception $e ) { return false; } $this->pbCheck( $xml ); $this->sourceBookUrl = $xml['base_url']; $option = [ 'file' => $upload['file'], 'url' => $upload['...
php
function setCurrentImportOption( array $upload ) { try { $parser = new Parser(); $xml = $parser->parse( $upload['file'] ); } catch ( \Exception $e ) { return false; } $this->pbCheck( $xml ); $this->sourceBookUrl = $xml['base_url']; $option = [ 'file' => $upload['file'], 'url' => $upload['...
[ "function", "setCurrentImportOption", "(", "array", "$", "upload", ")", "{", "try", "{", "$", "parser", "=", "new", "Parser", "(", ")", ";", "$", "xml", "=", "$", "parser", "->", "parse", "(", "$", "upload", "[", "'file'", "]", ")", ";", "}", "catc...
@param array $upload @return bool
[ "@param", "array", "$upload" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/wordpress/class-wxr.php#L110-L170
pressbooks/pressbooks
inc/modules/import/wordpress/class-wxr.php
Wxr.import
function import( array $current_import ) { try { $parser = new Parser(); $xml = $parser->parse( $current_import['file'] ); } catch ( \Exception $e ) { return false; } wp_defer_term_counting( true ); $this->pbCheck( $xml ); $this->sourceBookUrl = $xml['base_url']; $this->knownMedia = $this->bu...
php
function import( array $current_import ) { try { $parser = new Parser(); $xml = $parser->parse( $current_import['file'] ); } catch ( \Exception $e ) { return false; } wp_defer_term_counting( true ); $this->pbCheck( $xml ); $this->sourceBookUrl = $xml['base_url']; $this->knownMedia = $this->bu...
[ "function", "import", "(", "array", "$", "current_import", ")", "{", "try", "{", "$", "parser", "=", "new", "Parser", "(", ")", ";", "$", "xml", "=", "$", "parser", "->", "parse", "(", "$", "current_import", "[", "'file'", "]", ")", ";", "}", "catc...
@param array $current_import @return bool
[ "@param", "array", "$current_import" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/wordpress/class-wxr.php#L178-L361
pressbooks/pressbooks
inc/modules/import/wordpress/class-wxr.php
Wxr.pbCheck
protected function pbCheck( array $xml ) { $pt = 0; $ch = 0; $fm = 0; $bm = 0; $meta = 0; foreach ( $xml['posts'] as $p ) { if ( 'part' === $p['post_type'] ) { $pt = 1; } elseif ( 'chapter' === $p['post_type'] ) { $ch = 1; } elseif ( 'front-matter' === $p['post_type'] ) { $fm = 1; ...
php
protected function pbCheck( array $xml ) { $pt = 0; $ch = 0; $fm = 0; $bm = 0; $meta = 0; foreach ( $xml['posts'] as $p ) { if ( 'part' === $p['post_type'] ) { $pt = 1; } elseif ( 'chapter' === $p['post_type'] ) { $ch = 1; } elseif ( 'front-matter' === $p['post_type'] ) { $fm = 1; ...
[ "protected", "function", "pbCheck", "(", "array", "$", "xml", ")", "{", "$", "pt", "=", "0", ";", "$", "ch", "=", "0", ";", "$", "fm", "=", "0", ";", "$", "bm", "=", "0", ";", "$", "meta", "=", "0", ";", "foreach", "(", "$", "xml", "[", "...
Is it a WXR generated by PB? @param array $xml
[ "Is", "it", "a", "WXR", "generated", "by", "PB?" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/wordpress/class-wxr.php#L368-L396
pressbooks/pressbooks
inc/modules/import/wordpress/class-wxr.php
Wxr.customNestedSort
protected function customNestedSort( $xml ) { $array = []; //first, put them in ascending menu_order usort( $xml, function ( $a, $b ) { return ( $a['menu_order'] - $b['menu_order'] ); } ); // Start with book info foreach ( $xml as $p ) { if ( 'metadata' === $p['post_type'] ) { $array[] = ...
php
protected function customNestedSort( $xml ) { $array = []; //first, put them in ascending menu_order usort( $xml, function ( $a, $b ) { return ( $a['menu_order'] - $b['menu_order'] ); } ); // Start with book info foreach ( $xml as $p ) { if ( 'metadata' === $p['post_type'] ) { $array[] = ...
[ "protected", "function", "customNestedSort", "(", "$", "xml", ")", "{", "$", "array", "=", "[", "]", ";", "//first, put them in ascending menu_order", "usort", "(", "$", "xml", ",", "function", "(", "$", "a", ",", "$", "b", ")", "{", "return", "(", "$", ...
Custom sort for the xml posts to put them in correct nested order @param array $xml @return array sorted $xml
[ "Custom", "sort", "for", "the", "xml", "posts", "to", "put", "them", "in", "correct", "nested", "order" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/wordpress/class-wxr.php#L405-L466
pressbooks/pressbooks
inc/modules/import/wordpress/class-wxr.php
Wxr.bookInfoPid
protected function bookInfoPid() { $post = ( new Metadata() )->getMetaPost(); if ( empty( $post->ID ) ) { $new_post = [ 'post_title' => __( 'Book Info', 'pressbooks' ), 'post_type' => 'metadata', 'post_status' => 'publish', ]; $pid = wp_insert_post( add_magic_quotes( $new_post ) ); } else { ...
php
protected function bookInfoPid() { $post = ( new Metadata() )->getMetaPost(); if ( empty( $post->ID ) ) { $new_post = [ 'post_title' => __( 'Book Info', 'pressbooks' ), 'post_type' => 'metadata', 'post_status' => 'publish', ]; $pid = wp_insert_post( add_magic_quotes( $new_post ) ); } else { ...
[ "protected", "function", "bookInfoPid", "(", ")", "{", "$", "post", "=", "(", "new", "Metadata", "(", ")", ")", "->", "getMetaPost", "(", ")", ";", "if", "(", "empty", "(", "$", "post", "->", "ID", ")", ")", "{", "$", "new_post", "=", "[", "'post...
Get existing Meta Post, if none exists create one @return int Post ID
[ "Get", "existing", "Meta", "Post", "if", "none", "exists", "create", "one" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/wordpress/class-wxr.php#L474-L489
pressbooks/pressbooks
inc/modules/import/wordpress/class-wxr.php
Wxr.insertNewPost
protected function insertNewPost( $post_type, $p, $html, $chapter_parent, $post_status ) { $new_post = [ 'post_title' => wp_strip_all_tags( $p['post_title'] ), 'post_name' => $p['post_name'], 'post_type' => $post_type, 'post_status' => ( 'part' === $post_type ) ? 'publish' : $post_status, 'post_conten...
php
protected function insertNewPost( $post_type, $p, $html, $chapter_parent, $post_status ) { $new_post = [ 'post_title' => wp_strip_all_tags( $p['post_title'] ), 'post_name' => $p['post_name'], 'post_type' => $post_type, 'post_status' => ( 'part' === $post_type ) ? 'publish' : $post_status, 'post_conten...
[ "protected", "function", "insertNewPost", "(", "$", "post_type", ",", "$", "p", ",", "$", "html", ",", "$", "chapter_parent", ",", "$", "post_status", ")", "{", "$", "new_post", "=", "[", "'post_title'", "=>", "wp_strip_all_tags", "(", "$", "p", "[", "'p...
Insert a new post @param string $post_type Post Type @param array $p Single Item Returned From \Pressbooks\Modules\Import\WordPress\Parser::parse @param string $html @param int $chapter_parent @param string $post_status @return int Post ID
[ "Insert", "a", "new", "post" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/wordpress/class-wxr.php#L502-L519
pressbooks/pressbooks
inc/modules/import/wordpress/class-wxr.php
Wxr.importPbPostMeta
protected function importPbPostMeta( $pid, $p ) { $data_model = $this->figureOutDataModel( $p['postmeta'] ); $meta_to_update = apply_filters( 'pb_import_metakeys', [ 'pb_section_license', 'pb_short_title', 'pb_subtitle', 'pb_show_title' ] ); foreach ( $meta_to_update as $meta_key ) { $meta_val = $this->searc...
php
protected function importPbPostMeta( $pid, $p ) { $data_model = $this->figureOutDataModel( $p['postmeta'] ); $meta_to_update = apply_filters( 'pb_import_metakeys', [ 'pb_section_license', 'pb_short_title', 'pb_subtitle', 'pb_show_title' ] ); foreach ( $meta_to_update as $meta_key ) { $meta_val = $this->searc...
[ "protected", "function", "importPbPostMeta", "(", "$", "pid", ",", "$", "p", ")", "{", "$", "data_model", "=", "$", "this", "->", "figureOutDataModel", "(", "$", "p", "[", "'postmeta'", "]", ")", ";", "$", "meta_to_update", "=", "apply_filters", "(", "'p...
Import Pressbooks specific post meta @param int $pid Post ID @param array $p Single Item Returned From \Pressbooks\Modules\Import\WordPress\Parser::parse
[ "Import", "Pressbooks", "specific", "post", "meta" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/wordpress/class-wxr.php#L527-L556
pressbooks/pressbooks
inc/modules/import/wordpress/class-wxr.php
Wxr.importMetaBoxes
protected function importMetaBoxes( $pid, $p ) { $data_model = $this->figureOutDataModel( $p['postmeta'] ); // List of meta data keys that can support multiple values: $metadata_array_values = [ 'pb_keywords_tags', 'pb_bisac_subject', 'pb_additional_subjects', ]; // Clear old meta boxes $metadat...
php
protected function importMetaBoxes( $pid, $p ) { $data_model = $this->figureOutDataModel( $p['postmeta'] ); // List of meta data keys that can support multiple values: $metadata_array_values = [ 'pb_keywords_tags', 'pb_bisac_subject', 'pb_additional_subjects', ]; // Clear old meta boxes $metadat...
[ "protected", "function", "importMetaBoxes", "(", "$", "pid", ",", "$", "p", ")", "{", "$", "data_model", "=", "$", "this", "->", "figureOutDataModel", "(", "$", "p", "[", "'postmeta'", "]", ")", ";", "// List of meta data keys that can support multiple values:", ...
@see \Pressbooks\Admin\Metaboxes\add_meta_boxes @param int $pid Post ID @param array $p Single Item Returned From \Pressbooks\Modules\Import\WordPress\Parser::parse
[ "@see", "\\", "Pressbooks", "\\", "Admin", "\\", "Metaboxes", "\\", "add_meta_boxes" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/wordpress/class-wxr.php#L564-L619
pressbooks/pressbooks
inc/modules/import/wordpress/class-wxr.php
Wxr.searchForMetaValue
protected function searchForMetaValue( $meta_key, array $postmeta ) { if ( empty( $postmeta ) ) { return ''; } foreach ( $postmeta as $meta ) { // prefer this value, if it's set if ( $meta_key === $meta['key'] ) { $meta_val = $meta['value']; if ( is_serialized( $meta_val ) ) { $meta_val = ...
php
protected function searchForMetaValue( $meta_key, array $postmeta ) { if ( empty( $postmeta ) ) { return ''; } foreach ( $postmeta as $meta ) { // prefer this value, if it's set if ( $meta_key === $meta['key'] ) { $meta_val = $meta['value']; if ( is_serialized( $meta_val ) ) { $meta_val = ...
[ "protected", "function", "searchForMetaValue", "(", "$", "meta_key", ",", "array", "$", "postmeta", ")", "{", "if", "(", "empty", "(", "$", "postmeta", ")", ")", "{", "return", "''", ";", "}", "foreach", "(", "$", "postmeta", "as", "$", "meta", ")", ...
Check for PB specific metadata, returns empty string if not found. @param string $meta_key @param array $postmeta @return string meta field value
[ "Check", "for", "PB", "specific", "metadata", "returns", "empty", "string", "if", "not", "found", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/wordpress/class-wxr.php#L629-L650
pressbooks/pressbooks
inc/modules/import/wordpress/class-wxr.php
Wxr.buildListOfKnownMedia
public function buildListOfKnownMedia( $xml ) { $known_media = []; foreach ( $xml['posts'] as $item ) { if ( $item['post_type'] !== 'attachment' ) { continue; // Not an attachment, skip } $x = []; foreach ( $item['postmeta'] as $meta ) { if ( $meta['key'] === '_wp_attachment_metadata' ) { ...
php
public function buildListOfKnownMedia( $xml ) { $known_media = []; foreach ( $xml['posts'] as $item ) { if ( $item['post_type'] !== 'attachment' ) { continue; // Not an attachment, skip } $x = []; foreach ( $item['postmeta'] as $meta ) { if ( $meta['key'] === '_wp_attachment_metadata' ) { ...
[ "public", "function", "buildListOfKnownMedia", "(", "$", "xml", ")", "{", "$", "known_media", "=", "[", "]", ";", "foreach", "(", "$", "xml", "[", "'posts'", "]", "as", "$", "item", ")", "{", "if", "(", "$", "item", "[", "'post_type'", "]", "!==", ...
Parse XML to build an array of known images @param array $xml @return \Pressbooks\Entities\Cloner\Media[]
[ "Parse", "XML", "to", "build", "an", "array", "of", "known", "images" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/wordpress/class-wxr.php#L659-L692
pressbooks/pressbooks
inc/modules/import/wordpress/class-wxr.php
Wxr.createMediaEntity
protected function createMediaEntity( $item ) { $m = new \Pressbooks\Entities\Cloner\Media(); $m->id = $item['post_id']; $m->title = $item['post_title']; $m->description = $item['post_content']; $m->caption = $item['post_excerpt']; if ( isset( $item['postmeta'] ) && is_array( $item['postmeta'] ) ) { fo...
php
protected function createMediaEntity( $item ) { $m = new \Pressbooks\Entities\Cloner\Media(); $m->id = $item['post_id']; $m->title = $item['post_title']; $m->description = $item['post_content']; $m->caption = $item['post_excerpt']; if ( isset( $item['postmeta'] ) && is_array( $item['postmeta'] ) ) { fo...
[ "protected", "function", "createMediaEntity", "(", "$", "item", ")", "{", "$", "m", "=", "new", "\\", "Pressbooks", "\\", "Entities", "\\", "Cloner", "\\", "Media", "(", ")", ";", "$", "m", "->", "id", "=", "$", "item", "[", "'post_id'", "]", ";", ...
@param array $item @return \Pressbooks\Entities\Cloner\Media
[ "@param", "array", "$item" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/wordpress/class-wxr.php#L699-L721
pressbooks/pressbooks
inc/modules/import/wordpress/class-wxr.php
Wxr.checkInternalShortcodes
protected function checkInternalShortcodes( $post_id, $html ) { // Glossary if ( has_shortcode( $html, \Pressbooks\Shortcodes\Glossary\Glossary::SHORTCODE ) ) { $this->postsWithGlossaryShortcodesToFix[] = $post_id; } // Attachments if ( has_shortcode( $html, \Pressbooks\Shortcodes\Attributions\Attachments:...
php
protected function checkInternalShortcodes( $post_id, $html ) { // Glossary if ( has_shortcode( $html, \Pressbooks\Shortcodes\Glossary\Glossary::SHORTCODE ) ) { $this->postsWithGlossaryShortcodesToFix[] = $post_id; } // Attachments if ( has_shortcode( $html, \Pressbooks\Shortcodes\Attributions\Attachments:...
[ "protected", "function", "checkInternalShortcodes", "(", "$", "post_id", ",", "$", "html", ")", "{", "// Glossary", "if", "(", "has_shortcode", "(", "$", "html", ",", "\\", "Pressbooks", "\\", "Shortcodes", "\\", "Glossary", "\\", "Glossary", "::", "SHORTCODE"...
Check if post content contains shortcodes with references to internal IDs that we will need to fix @param int $post_id @param string $html
[ "Check", "if", "post", "content", "contains", "shortcodes", "with", "references", "to", "internal", "IDs", "that", "we", "will", "need", "to", "fix" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/wordpress/class-wxr.php#L745-L756
pressbooks/pressbooks
inc/modules/import/wordpress/class-wxr.php
Wxr.fixInternalShortcodes
protected function fixInternalShortcodes() { // Because $fix replaces left to right, it might replace a previously inserted value when doing multiple replacements. // Solved by creating a placeholder that can't possibly fall into the replacement order gotcha (famous last words) $fix = function ( $post_id, $transi...
php
protected function fixInternalShortcodes() { // Because $fix replaces left to right, it might replace a previously inserted value when doing multiple replacements. // Solved by creating a placeholder that can't possibly fall into the replacement order gotcha (famous last words) $fix = function ( $post_id, $transi...
[ "protected", "function", "fixInternalShortcodes", "(", ")", "{", "// Because $fix replaces left to right, it might replace a previously inserted value when doing multiple replacements.", "// Solved by creating a placeholder that can't possibly fall into the replacement order gotcha (famous last words)...
Fix shortcodes with references to internal IDs
[ "Fix", "shortcodes", "with", "references", "to", "internal", "IDs" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/wordpress/class-wxr.php#L761-L797
pressbooks/pressbooks
inc/modules/import/wordpress/class-wxr.php
Wxr.figureOutDataModel
protected function figureOutDataModel( $postmeta ) { foreach ( $this->contributors->valid as $contributor_type ) { if ( $this->searchForMetaValue( $contributor_type, $postmeta ) ) { return 5; }; } foreach ( $this->contributors->deprecated as $contributor_type ) { if ( $this->searchForMetaValue( $co...
php
protected function figureOutDataModel( $postmeta ) { foreach ( $this->contributors->valid as $contributor_type ) { if ( $this->searchForMetaValue( $contributor_type, $postmeta ) ) { return 5; }; } foreach ( $this->contributors->deprecated as $contributor_type ) { if ( $this->searchForMetaValue( $co...
[ "protected", "function", "figureOutDataModel", "(", "$", "postmeta", ")", "{", "foreach", "(", "$", "this", "->", "contributors", "->", "valid", "as", "$", "contributor_type", ")", "{", "if", "(", "$", "this", "->", "searchForMetaValue", "(", "$", "contribut...
For backwards-compatibility, some PB5 field names are pluralized so that any third-party code that looks for the old fields will still be able to retrieve them. That means both the old and new fields could still be in the XML. If we try to import both it causes buggy behaviour. This function helps us pick either/or. @...
[ "For", "backwards", "-", "compatibility", "some", "PB5", "field", "names", "are", "pluralized", "so", "that", "any", "third", "-", "party", "code", "that", "looks", "for", "the", "old", "fields", "will", "still", "be", "able", "to", "retrieve", "them", "."...
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/wordpress/class-wxr.php#L808-L824
pressbooks/pressbooks
inc/api/endpoints/controller/class-search.php
Search.register_routes
public function register_routes() { register_rest_route( $this->namespace, '/' . $this->rest_base, [ [ 'methods' => \WP_REST_Server::READABLE, 'callback' => [ $this, 'get_items' ], 'permission_callback' => [ $this, 'get_items_permissions_check' ], 'args' => $this->get_collection_params(), ...
php
public function register_routes() { register_rest_route( $this->namespace, '/' . $this->rest_base, [ [ 'methods' => \WP_REST_Server::READABLE, 'callback' => [ $this, 'get_items' ], 'permission_callback' => [ $this, 'get_items_permissions_check' ], 'args' => $this->get_collection_params(), ...
[ "public", "function", "register_routes", "(", ")", "{", "register_rest_route", "(", "$", "this", "->", "namespace", ",", "'/'", ".", "$", "this", "->", "rest_base", ",", "[", "[", "'methods'", "=>", "\\", "WP_REST_Server", "::", "READABLE", ",", "'callback'"...
Registers routes for Books
[ "Registers", "routes", "for", "Books" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/api/endpoints/controller/class-search.php#L18-L31
pressbooks/pressbooks
inc/api/endpoints/controller/class-search.php
Search.get_items
public function get_items( $request ) { // Register missing routes $this->registerRouteDependencies(); // Override search request $search = $request->get_query_params(); unset( $search['per_page'], $search['next'] ); $request['search'] = ! empty( $search ) ? $search : [ null => null, ]; // Set some w...
php
public function get_items( $request ) { // Register missing routes $this->registerRouteDependencies(); // Override search request $search = $request->get_query_params(); unset( $search['per_page'], $search['next'] ); $request['search'] = ! empty( $search ) ? $search : [ null => null, ]; // Set some w...
[ "public", "function", "get_items", "(", "$", "request", ")", "{", "// Register missing routes", "$", "this", "->", "registerRouteDependencies", "(", ")", ";", "// Override search request", "$", "search", "=", "$", "request", "->", "get_query_params", "(", ")", ";"...
@param \WP_REST_Request $request @return \WP_REST_Response
[ "@param", "\\", "WP_REST_Request", "$request" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/api/endpoints/controller/class-search.php#L57-L75
pressbooks/pressbooks
inc/api/endpoints/controller/class-search.php
Search.find
public function find( $search ) { if ( ! is_array( $search ) ) { wp_die( 'LogicException: $search should be a [meta_key => val] array' ); } if ( $search === [ null => null, ] ) { return false; // Abort search } if ( $this->paramSearchMeta( $search ) !== false ) { return true; } return fa...
php
public function find( $search ) { if ( ! is_array( $search ) ) { wp_die( 'LogicException: $search should be a [meta_key => val] array' ); } if ( $search === [ null => null, ] ) { return false; // Abort search } if ( $this->paramSearchMeta( $search ) !== false ) { return true; } return fa...
[ "public", "function", "find", "(", "$", "search", ")", "{", "if", "(", "!", "is_array", "(", "$", "search", ")", ")", "{", "wp_die", "(", "'LogicException: $search should be a [meta_key => val] array'", ")", ";", "}", "if", "(", "$", "search", "===", "[", ...
Overridable find method for how to search a book @param mixed $search @return bool
[ "Overridable", "find", "method", "for", "how", "to", "search", "a", "book" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/api/endpoints/controller/class-search.php#L84-L101
pressbooks/pressbooks
inc/api/endpoints/controller/class-search.php
Search.paramSearchMeta
protected function paramSearchMeta( array $search ) { // Book Metadata $request_metadata = new \WP_REST_Request( 'GET', '/pressbooks/v2/metadata' ); $response_metadata = rest_do_request( $request_metadata ); $book_metadata = $response_metadata->get_data(); if ( $this->keyValueSearchInMeta( $search, $book_met...
php
protected function paramSearchMeta( array $search ) { // Book Metadata $request_metadata = new \WP_REST_Request( 'GET', '/pressbooks/v2/metadata' ); $response_metadata = rest_do_request( $request_metadata ); $book_metadata = $response_metadata->get_data(); if ( $this->keyValueSearchInMeta( $search, $book_met...
[ "protected", "function", "paramSearchMeta", "(", "array", "$", "search", ")", "{", "// Book Metadata", "$", "request_metadata", "=", "new", "\\", "WP_REST_Request", "(", "'GET'", ",", "'/pressbooks/v2/metadata'", ")", ";", "$", "response_metadata", "=", "rest_do_req...
Parameter based search @param array $search @return bool
[ "Parameter", "based", "search" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/api/endpoints/controller/class-search.php#L110-L143
pressbooks/pressbooks
inc/api/endpoints/controller/class-search.php
Search.keyValueSearchInMeta
protected function keyValueSearchInMeta( array $search, array $metadata ) { $found = []; foreach ( $search as $search_key => $needle ) { $found[ $search_key ] = false; if ( isset( $metadata[ $search_key ] ) ) { $haystack = is_array( $metadata[ $search_key ] ) ? $metadata[ $search_key ] : (array) $metadat...
php
protected function keyValueSearchInMeta( array $search, array $metadata ) { $found = []; foreach ( $search as $search_key => $needle ) { $found[ $search_key ] = false; if ( isset( $metadata[ $search_key ] ) ) { $haystack = is_array( $metadata[ $search_key ] ) ? $metadata[ $search_key ] : (array) $metadat...
[ "protected", "function", "keyValueSearchInMeta", "(", "array", "$", "search", ",", "array", "$", "metadata", ")", "{", "$", "found", "=", "[", "]", ";", "foreach", "(", "$", "search", "as", "$", "search_key", "=>", "$", "needle", ")", "{", "$", "found"...
subjects=biology,technology&keywords=education returns all books in a collection with either subject 'biology' OR 'technology' AND the keyword 'education', (where 'subjects' and 'keywords' are keys in $metadata ) @param array $search @param array $metadata @return bool
[ "subjects", "=", "biology", "technology&keywords", "=", "education", "returns", "all", "books", "in", "a", "collection", "with", "either", "subject", "biology", "OR", "technology", "AND", "the", "keyword", "education", "(", "where", "subjects", "and", "keywords", ...
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/api/endpoints/controller/class-search.php#L155-L185
pressbooks/pressbooks
symbionts/pressbooks-latex/pb-latex-admin.php
PBLatexAdmin.addOptions
function addOptions() { if ( is_array( $this->options ) ) extract( $this->options, EXTR_SKIP ); global $themecolors; if ( empty($bg) ) $bg = isset( $themecolors['bg'] ) ? $themecolors['bg'] : 'transparent'; if ( empty($fg) ) $fg = isset( $themecolors['text'] ) ? $themecolors['text'] : '000000'; if...
php
function addOptions() { if ( is_array( $this->options ) ) extract( $this->options, EXTR_SKIP ); global $themecolors; if ( empty($bg) ) $bg = isset( $themecolors['bg'] ) ? $themecolors['bg'] : 'transparent'; if ( empty($fg) ) $fg = isset( $themecolors['text'] ) ? $themecolors['text'] : '000000'; if...
[ "function", "addOptions", "(", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "options", ")", ")", "extract", "(", "$", "this", "->", "options", ",", "EXTR_SKIP", ")", ";", "global", "$", "themecolors", ";", "if", "(", "empty", "(", "$", ...
Sets up default options
[ "Sets", "up", "default", "options" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/symbionts/pressbooks-latex/pb-latex-admin.php#L298-L320
pressbooks/pressbooks
inc/covergenerator/class-sku.php
Sku.invocation
public function invocation( $sku, $not_used_1, $not_used_2, $text_font, $text_size ) { $ps[] = "50 50 moveto ({$sku}) (includetext textfont={$text_font} textsize={$text_size} height=0.5)"; $ps[] = '/code128 /uk.co.terryburton.bwipp findresource exec'; return implode( "\n", $ps ) . "\n"; }
php
public function invocation( $sku, $not_used_1, $not_used_2, $text_font, $text_size ) { $ps[] = "50 50 moveto ({$sku}) (includetext textfont={$text_font} textsize={$text_size} height=0.5)"; $ps[] = '/code128 /uk.co.terryburton.bwipp findresource exec'; return implode( "\n", $ps ) . "\n"; }
[ "public", "function", "invocation", "(", "$", "sku", ",", "$", "not_used_1", ",", "$", "not_used_2", ",", "$", "text_font", ",", "$", "text_size", ")", "{", "$", "ps", "[", "]", "=", "\"50 50 moveto ({$sku}) (includetext textfont={$text_font} textsize={$text_size} h...
SKU Invocation Code. @see https://github.com/bwipp/postscriptbarcode/wiki/Code-128 @see https://github.com/bwipp/postscriptbarcode/wiki/Symbol-Dimensions @see https://github.com/bwipp/postscriptbarcode/wiki/Text-Properties @param string $sku @param string $not_used_1 @param float $not_used_2 @param string $text_font ...
[ "SKU", "Invocation", "Code", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/covergenerator/class-sku.php#L105-L111
pressbooks/pressbooks
inc/covergenerator/class-sku.php
Sku.compile
public function compile( $path_to_ps ) { if ( empty( $this->sku ) ) { throw new \LogicException( '$this->sku is not set' ); } $sku = \Pressbooks\Utility\get_contents( PB_PLUGIN_DIR . 'symbionts/postscriptbarcode/code128.ps' ); $invocation = $this->invocation( $this->sku, null, null, $this->tex...
php
public function compile( $path_to_ps ) { if ( empty( $this->sku ) ) { throw new \LogicException( '$this->sku is not set' ); } $sku = \Pressbooks\Utility\get_contents( PB_PLUGIN_DIR . 'symbionts/postscriptbarcode/code128.ps' ); $invocation = $this->invocation( $this->sku, null, null, $this->tex...
[ "public", "function", "compile", "(", "$", "path_to_ps", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "sku", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "'$this->sku is not set'", ")", ";", "}", "$", "sku", "=", "\\", "Pressboo...
Compile a SKU Postscript file @param string $path_to_ps @throws \LogicException
[ "Compile", "a", "SKU", "Postscript", "file" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/covergenerator/class-sku.php#L121-L142
pressbooks/pressbooks
inc/admin/class-network-managers-list-table.php
Network_Managers_List_Table.column_user_login
function column_user_login( $item ) { // Build row actions $current_user = wp_get_current_user(); if ( absint( $item['ID'] ) !== absint( $current_user->ID ) ) { // Don't let users restrict themselves if ( ! empty( $item['restricted'] ) ) { $actions = [ 'unrestrict' => '<a data-restrict="0" data-rest...
php
function column_user_login( $item ) { // Build row actions $current_user = wp_get_current_user(); if ( absint( $item['ID'] ) !== absint( $current_user->ID ) ) { // Don't let users restrict themselves if ( ! empty( $item['restricted'] ) ) { $actions = [ 'unrestrict' => '<a data-restrict="0" data-rest...
[ "function", "column_user_login", "(", "$", "item", ")", "{", "// Build row actions", "$", "current_user", "=", "wp_get_current_user", "(", ")", ";", "if", "(", "absint", "(", "$", "item", "[", "'ID'", "]", ")", "!==", "absint", "(", "$", "current_user", "-...
************************************************************************ Custom column method for the user_login column. @see WP_List_Table::::single_row_columns() @param array $item A singular item (one full row's worth of data) @return string HTML to be placed inside the column <td> *******************************...
[ "************************************************************************", "Custom", "column", "method", "for", "the", "user_login", "column", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/admin/class-network-managers-list-table.php#L68-L94
pressbooks/pressbooks
inc/admin/class-network-managers-list-table.php
Network_Managers_List_Table.prepare_items
function prepare_items() { /** * Define column headers. */ $columns = $this->get_columns(); $hidden = []; $sortable = $this->get_sortable_columns(); /** * Build column header array. */ $this->_column_headers = [ $columns, $hidden, $sortable ]; /** * Check for sorting input and sort the d...
php
function prepare_items() { /** * Define column headers. */ $columns = $this->get_columns(); $hidden = []; $sortable = $this->get_sortable_columns(); /** * Build column header array. */ $this->_column_headers = [ $columns, $hidden, $sortable ]; /** * Check for sorting input and sort the d...
[ "function", "prepare_items", "(", ")", "{", "/**\n\t\t * Define column headers.\n\t\t */", "$", "columns", "=", "$", "this", "->", "get_columns", "(", ")", ";", "$", "hidden", "=", "[", "]", ";", "$", "sortable", "=", "$", "this", "->", "get_sortable_columns",...
************************************************************************ Prepare data for display @global \wpdb $wpdb @uses $this->_column_headers @uses $this->items @uses $this->get_columns() @uses $this->get_sortable_columns() @uses $this->get_pagenum() @uses $this->set_pagination_args() ****************************...
[ "************************************************************************", "Prepare", "data", "for", "display" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/admin/class-network-managers-list-table.php#L153-L197
pressbooks/pressbooks
inc/theme/class-lock.php
Lock.toggleThemeLock
public function toggleThemeLock( $old_value, $value, $option ) { if ( isset( $value['theme_lock'] ) && 1 === absint( $value['theme_lock'] ) ) { return $this->lockTheme(); } elseif ( 1 === absint( $old_value['theme_lock'] ) && empty( $value['theme_lock'] ) ) { return $this->unlockTheme(); } return false; ...
php
public function toggleThemeLock( $old_value, $value, $option ) { if ( isset( $value['theme_lock'] ) && 1 === absint( $value['theme_lock'] ) ) { return $this->lockTheme(); } elseif ( 1 === absint( $old_value['theme_lock'] ) && empty( $value['theme_lock'] ) ) { return $this->unlockTheme(); } return false; ...
[ "public", "function", "toggleThemeLock", "(", "$", "old_value", ",", "$", "value", ",", "$", "option", ")", "{", "if", "(", "isset", "(", "$", "value", "[", "'theme_lock'", "]", ")", "&&", "1", "===", "absint", "(", "$", "value", "[", "'theme_lock'", ...
@param array $old_value @param array $value @param $option @return mixed
[ "@param", "array", "$old_value", "@param", "array", "$value", "@param", "$option" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/theme/class-lock.php#L76-L83
pressbooks/pressbooks
inc/theme/class-lock.php
Lock.lockTheme
public function lockTheme() { if ( true === $this->copyAssets() ) { $time = time(); $data = $this->generateLock( $time ); $_SESSION['pb_notices'][] = sprintf( '<strong>%s</strong>', sprintf( __( 'Your book&rsquo;s theme, %1$s, has been locked in its current state as of %2$s at %3$s.', 'pressbook...
php
public function lockTheme() { if ( true === $this->copyAssets() ) { $time = time(); $data = $this->generateLock( $time ); $_SESSION['pb_notices'][] = sprintf( '<strong>%s</strong>', sprintf( __( 'Your book&rsquo;s theme, %1$s, has been locked in its current state as of %2$s at %3$s.', 'pressbook...
[ "public", "function", "lockTheme", "(", ")", "{", "if", "(", "true", "===", "$", "this", "->", "copyAssets", "(", ")", ")", "{", "$", "time", "=", "time", "(", ")", ";", "$", "data", "=", "$", "this", "->", "generateLock", "(", "$", "time", ")", ...
Lock the current theme by copying assets to the lock directory and generating a timestamped lockfile. @return mixed
[ "Lock", "the", "current", "theme", "by", "copying", "assets", "to", "the", "lock", "directory", "and", "generating", "a", "timestamped", "lockfile", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/theme/class-lock.php#L90-L114
pressbooks/pressbooks
inc/theme/class-lock.php
Lock.generateLock
public function generateLock( $time ) { $theme = wp_get_theme(); global $_wp_theme_features; $theme_features = is_array( $_wp_theme_features ) ? array_keys( $_wp_theme_features ) : []; $data = [ 'stylesheet' => get_stylesheet(), 'name' => $theme->get( 'Name' ), 'version' => $theme->get( 'Version' ), ...
php
public function generateLock( $time ) { $theme = wp_get_theme(); global $_wp_theme_features; $theme_features = is_array( $_wp_theme_features ) ? array_keys( $_wp_theme_features ) : []; $data = [ 'stylesheet' => get_stylesheet(), 'name' => $theme->get( 'Name' ), 'version' => $theme->get( 'Version' ), ...
[ "public", "function", "generateLock", "(", "$", "time", ")", "{", "$", "theme", "=", "wp_get_theme", "(", ")", ";", "global", "$", "_wp_theme_features", ";", "$", "theme_features", "=", "is_array", "(", "$", "_wp_theme_features", ")", "?", "array_keys", "(",...
@param $time @return array
[ "@param", "$time" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/theme/class-lock.php#L179-L196
pressbooks/pressbooks
inc/theme/class-lock.php
Lock.isLocked
public function isLocked() { $options = get_option( 'pressbooks_export_options' ); if ( realpath( $this->getLockDir( false ) . '/lock.json' ) && isset( $options['theme_lock'] ) && 1 === absint( $options['theme_lock'] ) ) { return true; } return false; }
php
public function isLocked() { $options = get_option( 'pressbooks_export_options' ); if ( realpath( $this->getLockDir( false ) . '/lock.json' ) && isset( $options['theme_lock'] ) && 1 === absint( $options['theme_lock'] ) ) { return true; } return false; }
[ "public", "function", "isLocked", "(", ")", "{", "$", "options", "=", "get_option", "(", "'pressbooks_export_options'", ")", ";", "if", "(", "realpath", "(", "$", "this", "->", "getLockDir", "(", "false", ")", ".", "'/lock.json'", ")", "&&", "isset", "(", ...
Check for a lockfile. @return bool
[ "Check", "for", "a", "lockfile", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/theme/class-lock.php#L214-L220
pressbooks/pressbooks
inc/theme/class-lock.php
Lock.getLockData
public function getLockData() { $json = \Pressbooks\Utility\get_contents( $this->getLockDir( false ) . '/lock.json' ); $output = json_decode( $json, true ); return $output; }
php
public function getLockData() { $json = \Pressbooks\Utility\get_contents( $this->getLockDir( false ) . '/lock.json' ); $output = json_decode( $json, true ); return $output; }
[ "public", "function", "getLockData", "(", ")", "{", "$", "json", "=", "\\", "Pressbooks", "\\", "Utility", "\\", "get_contents", "(", "$", "this", "->", "getLockDir", "(", "false", ")", ".", "'/lock.json'", ")", ";", "$", "output", "=", "json_decode", "(...
Load data from the lockfile. @return array
[ "Load", "data", "from", "the", "lockfile", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/theme/class-lock.php#L227-L231
pressbooks/pressbooks
inc/theme/class-lock.php
Lock.globalComponentsPath
public function globalComponentsPath( $path ) { $dir = $this->getLockDir( false ) . '/global-components/'; if ( file_exists( $dir ) ) { return $dir; } else { return $path; } }
php
public function globalComponentsPath( $path ) { $dir = $this->getLockDir( false ) . '/global-components/'; if ( file_exists( $dir ) ) { return $dir; } else { return $path; } }
[ "public", "function", "globalComponentsPath", "(", "$", "path", ")", "{", "$", "dir", "=", "$", "this", "->", "getLockDir", "(", "false", ")", ".", "'/global-components/'", ";", "if", "(", "file_exists", "(", "$", "dir", ")", ")", "{", "return", "$", "...
@param string $path @return string
[ "@param", "string", "$path" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/theme/class-lock.php#L238-L245
pressbooks/pressbooks
inc/theme/class-lock.php
Lock.restrictThemeManagement
public function restrictThemeManagement() { $locked = $this->isLocked(); if ( $locked ) { $data = $this->getLockData(); // Redirect and notify users of theme lock status. $check_against_url = wp_parse_url( ( is_ssl() ? 'http://' : 'https://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], PHP_URL_PA...
php
public function restrictThemeManagement() { $locked = $this->isLocked(); if ( $locked ) { $data = $this->getLockData(); // Redirect and notify users of theme lock status. $check_against_url = wp_parse_url( ( is_ssl() ? 'http://' : 'https://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], PHP_URL_PA...
[ "public", "function", "restrictThemeManagement", "(", ")", "{", "$", "locked", "=", "$", "this", "->", "isLocked", "(", ")", ";", "if", "(", "$", "locked", ")", "{", "$", "data", "=", "$", "this", "->", "getLockData", "(", ")", ";", "// Redirect and no...
Restrict access to Themes and Theme Options.
[ "Restrict", "access", "to", "Themes", "and", "Theme", "Options", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/theme/class-lock.php#L250-L283
pressbooks/pressbooks
inc/modules/themeoptions/class-admin.php
Admin.getTabs
public function getTabs() { $tabs = [ 'global' => '\Pressbooks\Modules\ThemeOptions\GlobalOptions', 'web' => '\Pressbooks\Modules\ThemeOptions\WebOptions', 'pdf' => '\Pressbooks\Modules\ThemeOptions\PDFOptions', 'ebook' => '\Pressbooks\Modules\ThemeOptions\EbookOptions', ]; if ( false === get_site_tr...
php
public function getTabs() { $tabs = [ 'global' => '\Pressbooks\Modules\ThemeOptions\GlobalOptions', 'web' => '\Pressbooks\Modules\ThemeOptions\WebOptions', 'pdf' => '\Pressbooks\Modules\ThemeOptions\PDFOptions', 'ebook' => '\Pressbooks\Modules\ThemeOptions\EbookOptions', ]; if ( false === get_site_tr...
[ "public", "function", "getTabs", "(", ")", "{", "$", "tabs", "=", "[", "'global'", "=>", "'\\Pressbooks\\Modules\\ThemeOptions\\GlobalOptions'", ",", "'web'", "=>", "'\\Pressbooks\\Modules\\ThemeOptions\\WebOptions'", ",", "'pdf'", "=>", "'\\Pressbooks\\Modules\\ThemeOptions\...
Returns a filtered array of tabs that we should be loading. @returns array
[ "Returns", "a", "filtered", "array", "of", "tabs", "that", "we", "should", "be", "loading", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/themeoptions/class-admin.php#L53-L81
pressbooks/pressbooks
inc/modules/themeoptions/class-admin.php
Admin.loadTabs
public function loadTabs() { foreach ( $this->getTabs() as $slug => $subclass ) { /** @var \Pressbooks\Options $subclass (not instantiated, just a string) */ add_filter( "option_page_capability_pressbooks_theme_options_$slug", [ $this, 'setPermissions' ], 10, 1 ); add_filter( "pb_theme_options_{$slug}_defaul...
php
public function loadTabs() { foreach ( $this->getTabs() as $slug => $subclass ) { /** @var \Pressbooks\Options $subclass (not instantiated, just a string) */ add_filter( "option_page_capability_pressbooks_theme_options_$slug", [ $this, 'setPermissions' ], 10, 1 ); add_filter( "pb_theme_options_{$slug}_defaul...
[ "public", "function", "loadTabs", "(", ")", "{", "foreach", "(", "$", "this", "->", "getTabs", "(", ")", "as", "$", "slug", "=>", "$", "subclass", ")", "{", "/** @var \\Pressbooks\\Options $subclass (not instantiated, just a string) */", "add_filter", "(", "\"option...
Register the settings on each tab, run upgrade() if needed.
[ "Register", "the", "settings", "on", "each", "tab", "run", "upgrade", "()", "if", "needed", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/themeoptions/class-admin.php#L99-L116
pressbooks/pressbooks
inc/modules/themeoptions/class-admin.php
Admin.render
public function render() { ?> <div class="wrap"> <h1><?php echo wp_get_theme(); ?> <?php _e( 'Theme Options', 'pressbooks' ); ?></h1> <?php settings_errors(); ?> <?php $active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'global'; ?> <h2 class="nav-tab-wrapper"> <?php foreach ( $this->getTabs() as $...
php
public function render() { ?> <div class="wrap"> <h1><?php echo wp_get_theme(); ?> <?php _e( 'Theme Options', 'pressbooks' ); ?></h1> <?php settings_errors(); ?> <?php $active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'global'; ?> <h2 class="nav-tab-wrapper"> <?php foreach ( $this->getTabs() as $...
[ "public", "function", "render", "(", ")", "{", "?>\n\t\t<div class=\"wrap\">\n\t\t\t<h1><?php", "echo", "wp_get_theme", "(", ")", ";", "?> <?php", "_e", "(", "'Theme Options'", ",", "'pressbooks'", ")", ";", "?></h1>\n\t\t\t<?php", "settings_errors", "(", ")", ";", ...
Render the theme options page and load the appropriate tab.
[ "Render", "the", "theme", "options", "page", "and", "load", "the", "appropriate", "tab", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/themeoptions/class-admin.php#L135-L157
pressbooks/pressbooks
inc/modules/themeoptions/class-admin.php
Admin.afterSwitchTheme
public function afterSwitchTheme() { $this->clearCache(); foreach ( $this->getTabs() as $slug => $subclass ) { /** @var \Pressbooks\Options $subclass (not instantiated, just a string) */ $current_options = get_option( "pressbooks_theme_options_{$slug}", [] ); if ( ! empty( $current_options ) ) { update...
php
public function afterSwitchTheme() { $this->clearCache(); foreach ( $this->getTabs() as $slug => $subclass ) { /** @var \Pressbooks\Options $subclass (not instantiated, just a string) */ $current_options = get_option( "pressbooks_theme_options_{$slug}", [] ); if ( ! empty( $current_options ) ) { update...
[ "public", "function", "afterSwitchTheme", "(", ")", "{", "$", "this", "->", "clearCache", "(", ")", ";", "foreach", "(", "$", "this", "->", "getTabs", "(", ")", "as", "$", "slug", "=>", "$", "subclass", ")", "{", "/** @var \\Pressbooks\\Options $subclass (no...
Override saved options with filtered defaults when switching theme
[ "Override", "saved", "options", "with", "filtered", "defaults", "when", "switching", "theme" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/themeoptions/class-admin.php#L162-L171
pressbooks/pressbooks
inc/api/endpoints/controller/class-toc.php
Toc.get_item_schema
public function get_item_schema() { $item = [ 'id' => [ 'description' => __( 'Unique identifier for the object.' ), 'type' => 'integer', 'context' => [ 'view' ], 'readonly' => true, ], 'title' => [ 'description' => __( 'The title for the object.' ), 'type' => 'string', 'context' ...
php
public function get_item_schema() { $item = [ 'id' => [ 'description' => __( 'Unique identifier for the object.' ), 'type' => 'integer', 'context' => [ 'view' ], 'readonly' => true, ], 'title' => [ 'description' => __( 'The title for the object.' ), 'type' => 'string', 'context' ...
[ "public", "function", "get_item_schema", "(", ")", "{", "$", "item", "=", "[", "'id'", "=>", "[", "'description'", "=>", "__", "(", "'Unique identifier for the object.'", ")", ",", "'type'", "=>", "'integer'", ",", "'context'", "=>", "[", "'view'", "]", ",",...
Retrieves TOC schema, conforming to JSON Schema @return array
[ "Retrieves", "TOC", "schema", "conforming", "to", "JSON", "Schema" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/api/endpoints/controller/class-toc.php#L70-L238
pressbooks/pressbooks
inc/api/endpoints/controller/class-toc.php
Toc.get_item
public function get_item( $request ) { // Register missing routes $this->registerRouteDependencies(); $struct = Book::getBookStructure(); unset( $struct['__order'] ); $struct = $this->fixBookStructure( $struct, current_user_can( 'edit_posts' ) ); $response = rest_ensure_response( $struct ); $this->link...
php
public function get_item( $request ) { // Register missing routes $this->registerRouteDependencies(); $struct = Book::getBookStructure(); unset( $struct['__order'] ); $struct = $this->fixBookStructure( $struct, current_user_can( 'edit_posts' ) ); $response = rest_ensure_response( $struct ); $this->link...
[ "public", "function", "get_item", "(", "$", "request", ")", "{", "// Register missing routes", "$", "this", "->", "registerRouteDependencies", "(", ")", ";", "$", "struct", "=", "Book", "::", "getBookStructure", "(", ")", ";", "unset", "(", "$", "struct", "[...
@param \WP_REST_Request $request Full data about the request. @return \WP_Error|\WP_REST_Response Response object on success, or WP_Error object on failure.
[ "@param", "\\", "WP_REST_Request", "$request", "Full", "data", "about", "the", "request", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/api/endpoints/controller/class-toc.php#L263-L279
pressbooks/pressbooks
inc/api/endpoints/controller/class-toc.php
Toc.registerRouteDependencies
protected function registerRouteDependencies() { $this->frontMatterMetadata->register_routes(); $this->backMatterMetadata->register_routes(); $this->chapterMetadata->register_routes(); }
php
protected function registerRouteDependencies() { $this->frontMatterMetadata->register_routes(); $this->backMatterMetadata->register_routes(); $this->chapterMetadata->register_routes(); }
[ "protected", "function", "registerRouteDependencies", "(", ")", "{", "$", "this", "->", "frontMatterMetadata", "->", "register_routes", "(", ")", ";", "$", "this", "->", "backMatterMetadata", "->", "register_routes", "(", ")", ";", "$", "this", "->", "chapterMet...
Define route dependencies. Toc content is built by querying section metadata, but those API routes may not exist at the root level.
[ "Define", "route", "dependencies", ".", "Toc", "content", "is", "built", "by", "querying", "section", "metadata", "but", "those", "API", "routes", "may", "not", "exist", "at", "the", "root", "level", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/api/endpoints/controller/class-toc.php#L285-L289
pressbooks/pressbooks
inc/api/endpoints/controller/class-toc.php
Toc.fixBookStructure
protected function fixBookStructure( array $book_structure, $has_permission ) { $toc = []; $replacement_keys = [ 'ID' => 'id', 'post_title' => 'title', 'post_name' => 'slug', 'post_author' => 'author', 'post_status' => 'status', ]; $toc['front-matter'] = $this->fixFrontMatterStructure( $book_s...
php
protected function fixBookStructure( array $book_structure, $has_permission ) { $toc = []; $replacement_keys = [ 'ID' => 'id', 'post_title' => 'title', 'post_name' => 'slug', 'post_author' => 'author', 'post_status' => 'status', ]; $toc['front-matter'] = $this->fixFrontMatterStructure( $book_s...
[ "protected", "function", "fixBookStructure", "(", "array", "$", "book_structure", ",", "$", "has_permission", ")", "{", "$", "toc", "=", "[", "]", ";", "$", "replacement_keys", "=", "[", "'ID'", "=>", "'id'", ",", "'post_title'", "=>", "'title'", ",", "'po...
@param array $book_structure @param bool $has_permission @return array
[ "@param", "array", "$book_structure", "@param", "bool", "$has_permission" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/api/endpoints/controller/class-toc.php#L297-L314
pressbooks/pressbooks
inc/api/endpoints/controller/class-toc.php
Toc.fixFrontMatterStructure
protected function fixFrontMatterStructure( array $book_structure, $has_permission, array $replacement_keys ) { $base = 'front-matter'; $rest_url = rest_url( sprintf( '%s/%s', $this->namespace, $base ) ); // Front-matter $front_matter = []; foreach ( $book_structure['front-matter'] as $old_fm ) { if ( $h...
php
protected function fixFrontMatterStructure( array $book_structure, $has_permission, array $replacement_keys ) { $base = 'front-matter'; $rest_url = rest_url( sprintf( '%s/%s', $this->namespace, $base ) ); // Front-matter $front_matter = []; foreach ( $book_structure['front-matter'] as $old_fm ) { if ( $h...
[ "protected", "function", "fixFrontMatterStructure", "(", "array", "$", "book_structure", ",", "$", "has_permission", ",", "array", "$", "replacement_keys", ")", "{", "$", "base", "=", "'front-matter'", ";", "$", "rest_url", "=", "rest_url", "(", "sprintf", "(", ...
@param array $book_structure @param $has_permission @param array $replacement_keys @return array
[ "@param", "array", "$book_structure", "@param", "$has_permission", "@param", "array", "$replacement_keys" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/api/endpoints/controller/class-toc.php#L323-L362
pressbooks/pressbooks
inc/api/endpoints/controller/class-toc.php
Toc.fixPartChapterStructure
protected function fixPartChapterStructure( array $book_structure, $has_permission, array $replacement_keys ) { $part_base = 'parts'; $part_rest_url = rest_url( sprintf( '%s/%s', $this->namespace, $part_base ) ); $chapter_base = 'chapters'; $chapter_rest_url = rest_url( sprintf( '%s/%s', $this->namespace, $cha...
php
protected function fixPartChapterStructure( array $book_structure, $has_permission, array $replacement_keys ) { $part_base = 'parts'; $part_rest_url = rest_url( sprintf( '%s/%s', $this->namespace, $part_base ) ); $chapter_base = 'chapters'; $chapter_rest_url = rest_url( sprintf( '%s/%s', $this->namespace, $cha...
[ "protected", "function", "fixPartChapterStructure", "(", "array", "$", "book_structure", ",", "$", "has_permission", ",", "array", "$", "replacement_keys", ")", "{", "$", "part_base", "=", "'parts'", ";", "$", "part_rest_url", "=", "rest_url", "(", "sprintf", "(...
@param array $book_structure @param $has_permission @param array $replacement_keys @return array
[ "@param", "array", "$book_structure", "@param", "$has_permission", "@param", "array", "$replacement_keys" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/api/endpoints/controller/class-toc.php#L371-L426
pressbooks/pressbooks
inc/api/endpoints/controller/class-toc.php
Toc.fixBackMatterStructure
protected function fixBackMatterStructure( array $book_structure, $has_permission, array $replacement_keys ) { $base = 'back-matter'; $rest_url = rest_url( sprintf( '%s/%s', $this->namespace, $base ) ); $back_matter = []; foreach ( $book_structure['back-matter'] as $old_bm ) { if ( $has_permission || in_ar...
php
protected function fixBackMatterStructure( array $book_structure, $has_permission, array $replacement_keys ) { $base = 'back-matter'; $rest_url = rest_url( sprintf( '%s/%s', $this->namespace, $base ) ); $back_matter = []; foreach ( $book_structure['back-matter'] as $old_bm ) { if ( $has_permission || in_ar...
[ "protected", "function", "fixBackMatterStructure", "(", "array", "$", "book_structure", ",", "$", "has_permission", ",", "array", "$", "replacement_keys", ")", "{", "$", "base", "=", "'back-matter'", ";", "$", "rest_url", "=", "rest_url", "(", "sprintf", "(", ...
@param array $book_structure @param $has_permission @param array $replacement_keys @return array
[ "@param", "array", "$book_structure", "@param", "$has_permission", "@param", "array", "$replacement_keys" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/api/endpoints/controller/class-toc.php#L435-L473
pressbooks/pressbooks
inc/admin/class-publishoptions.php
PublishOptions.init
function init() { $_option = $this->getSlug(); $_page = $_option; $_section = $this->getSlug() . '_section'; add_settings_section( $_section, '', [ $this, 'display' ], $_page ); add_settings_field( 'amazon', __( 'Amazon URL', 'pressbooks' ), [ $this, 'renderAmazonField' ], $_page, ...
php
function init() { $_option = $this->getSlug(); $_page = $_option; $_section = $this->getSlug() . '_section'; add_settings_section( $_section, '', [ $this, 'display' ], $_page ); add_settings_field( 'amazon', __( 'Amazon URL', 'pressbooks' ), [ $this, 'renderAmazonField' ], $_page, ...
[ "function", "init", "(", ")", "{", "$", "_option", "=", "$", "this", "->", "getSlug", "(", ")", ";", "$", "_page", "=", "$", "_option", ";", "$", "_section", "=", "$", "this", "->", "getSlug", "(", ")", ".", "'_section'", ";", "add_settings_section",...
Configure the publish options page using the settings API.
[ "Configure", "the", "publish", "options", "page", "using", "the", "settings", "API", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/admin/class-publishoptions.php#L52-L117
pressbooks/pressbooks
inc/admin/class-publishoptions.php
PublishOptions.display
function display() { ob_start(); ?> <p><?php _e( 'Once your book is finished, you can download the files and submit them to ebookstores and print-on-demand providers.', 'pressbooks' ); ?></p> <div class="postbox"> <div class="inside"> <h3><?php _e( 'Ebook Stores', 'pressbooks' ); ?></h3> <p><?php prin...
php
function display() { ob_start(); ?> <p><?php _e( 'Once your book is finished, you can download the files and submit them to ebookstores and print-on-demand providers.', 'pressbooks' ); ?></p> <div class="postbox"> <div class="inside"> <h3><?php _e( 'Ebook Stores', 'pressbooks' ); ?></h3> <p><?php prin...
[ "function", "display", "(", ")", "{", "ob_start", "(", ")", ";", "?>\n\t\t<p><?php", "_e", "(", "'Once your book is finished, you can download the files and submit them to ebookstores and print-on-demand providers.'", ",", "'pressbooks'", ")", ";", "?></p>\n\n\t\t<div class=\"postb...
Display the publish options page description.
[ "Display", "the", "publish", "options", "page", "description", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/admin/class-publishoptions.php#L122-L161
pressbooks/pressbooks
inc/admin/class-publishoptions.php
PublishOptions.renderAmazonField
function renderAmazonField() { $this->renderField( [ 'id' => 'amazon', 'name' => $this->getSlug(), 'option' => 'amazon', 'value' => ( isset( $this->options['amazon'] ) ) ? $this->options['amazon'] : '', 'type' => 'url', 'class' => 'regular-text code', ] ); }
php
function renderAmazonField() { $this->renderField( [ 'id' => 'amazon', 'name' => $this->getSlug(), 'option' => 'amazon', 'value' => ( isset( $this->options['amazon'] ) ) ? $this->options['amazon'] : '', 'type' => 'url', 'class' => 'regular-text code', ] ); }
[ "function", "renderAmazonField", "(", ")", "{", "$", "this", "->", "renderField", "(", "[", "'id'", "=>", "'amazon'", ",", "'name'", "=>", "$", "this", "->", "getSlug", "(", ")", ",", "'option'", "=>", "'amazon'", ",", "'value'", "=>", "(", "isset", "(...
Render the amazon field.
[ "Render", "the", "amazon", "field", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/admin/class-publishoptions.php#L190-L201
pressbooks/pressbooks
inc/admin/class-publishoptions.php
PublishOptions.renderOReillyField
function renderOReillyField() { $this->renderField( [ 'id' => 'oreilly', 'name' => $this->getSlug(), 'option' => 'oreilly', 'value' => ( isset( $this->options['oreilly'] ) ) ? $this->options['oreilly'] : '', 'type' => 'url', 'class' => 'regular-text code', ] ); }
php
function renderOReillyField() { $this->renderField( [ 'id' => 'oreilly', 'name' => $this->getSlug(), 'option' => 'oreilly', 'value' => ( isset( $this->options['oreilly'] ) ) ? $this->options['oreilly'] : '', 'type' => 'url', 'class' => 'regular-text code', ] ); }
[ "function", "renderOReillyField", "(", ")", "{", "$", "this", "->", "renderField", "(", "[", "'id'", "=>", "'oreilly'", ",", "'name'", "=>", "$", "this", "->", "getSlug", "(", ")", ",", "'option'", "=>", "'oreilly'", ",", "'value'", "=>", "(", "isset", ...
Render the oreilly field.
[ "Render", "the", "oreilly", "field", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/admin/class-publishoptions.php#L206-L217
pressbooks/pressbooks
inc/admin/class-publishoptions.php
PublishOptions.renderBarnesAndNobleField
function renderBarnesAndNobleField() { $this->renderField( [ 'id' => 'barnesandnoble', 'name' => $this->getSlug(), 'option' => 'barnesandnoble', 'value' => ( isset( $this->options['barnesandnoble'] ) ) ? $this->options['barnesandnoble'] : '', 'type' => 'url', 'class' => 'regular-text code',...
php
function renderBarnesAndNobleField() { $this->renderField( [ 'id' => 'barnesandnoble', 'name' => $this->getSlug(), 'option' => 'barnesandnoble', 'value' => ( isset( $this->options['barnesandnoble'] ) ) ? $this->options['barnesandnoble'] : '', 'type' => 'url', 'class' => 'regular-text code',...
[ "function", "renderBarnesAndNobleField", "(", ")", "{", "$", "this", "->", "renderField", "(", "[", "'id'", "=>", "'barnesandnoble'", ",", "'name'", "=>", "$", "this", "->", "getSlug", "(", ")", ",", "'option'", "=>", "'barnesandnoble'", ",", "'value'", "=>"...
Render the barnesandnoble field.
[ "Render", "the", "barnesandnoble", "field", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/admin/class-publishoptions.php#L222-L233
pressbooks/pressbooks
inc/admin/class-publishoptions.php
PublishOptions.renderKoboField
function renderKoboField() { $this->renderField( [ 'id' => 'kobo', 'name' => $this->getSlug(), 'option' => 'kobo', 'value' => ( isset( $this->options['kobo'] ) ) ? $this->options['kobo'] : '', 'type' => 'url', 'class' => 'regular-text code', ] ); }
php
function renderKoboField() { $this->renderField( [ 'id' => 'kobo', 'name' => $this->getSlug(), 'option' => 'kobo', 'value' => ( isset( $this->options['kobo'] ) ) ? $this->options['kobo'] : '', 'type' => 'url', 'class' => 'regular-text code', ] ); }
[ "function", "renderKoboField", "(", ")", "{", "$", "this", "->", "renderField", "(", "[", "'id'", "=>", "'kobo'", ",", "'name'", "=>", "$", "this", "->", "getSlug", "(", ")", ",", "'option'", "=>", "'kobo'", ",", "'value'", "=>", "(", "isset", "(", "...
Render the barnesandnoble field.
[ "Render", "the", "barnesandnoble", "field", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/admin/class-publishoptions.php#L238-L249
pressbooks/pressbooks
inc/admin/class-publishoptions.php
PublishOptions.renderiBooksField
function renderiBooksField() { $this->renderField( [ 'id' => 'ibooks', 'name' => $this->getSlug(), 'option' => 'ibooks', 'value' => ( isset( $this->options['ibooks'] ) ) ? $this->options['ibooks'] : '', 'type' => 'url', 'class' => 'regular-text code', ] ); }
php
function renderiBooksField() { $this->renderField( [ 'id' => 'ibooks', 'name' => $this->getSlug(), 'option' => 'ibooks', 'value' => ( isset( $this->options['ibooks'] ) ) ? $this->options['ibooks'] : '', 'type' => 'url', 'class' => 'regular-text code', ] ); }
[ "function", "renderiBooksField", "(", ")", "{", "$", "this", "->", "renderField", "(", "[", "'id'", "=>", "'ibooks'", ",", "'name'", "=>", "$", "this", "->", "getSlug", "(", ")", ",", "'option'", "=>", "'ibooks'", ",", "'value'", "=>", "(", "isset", "(...
Render the ibooks field.
[ "Render", "the", "ibooks", "field", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/admin/class-publishoptions.php#L254-L265
pressbooks/pressbooks
inc/admin/class-publishoptions.php
PublishOptions.renderOtherServiceField
function renderOtherServiceField() { $this->renderField( [ 'id' => 'otherservice', 'name' => $this->getSlug(), 'option' => 'otherservice', 'value' => ( isset( $this->options['otherservice'] ) ) ? $this->options['otherservice'] : '', 'type' => 'url', 'class' => 'regular-text code', ] );...
php
function renderOtherServiceField() { $this->renderField( [ 'id' => 'otherservice', 'name' => $this->getSlug(), 'option' => 'otherservice', 'value' => ( isset( $this->options['otherservice'] ) ) ? $this->options['otherservice'] : '', 'type' => 'url', 'class' => 'regular-text code', ] );...
[ "function", "renderOtherServiceField", "(", ")", "{", "$", "this", "->", "renderField", "(", "[", "'id'", "=>", "'otherservice'", ",", "'name'", "=>", "$", "this", "->", "getSlug", "(", ")", ",", "'option'", "=>", "'otherservice'", ",", "'value'", "=>", "(...
Render the ibooks field.
[ "Render", "the", "ibooks", "field", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/admin/class-publishoptions.php#L270-L281
pressbooks/pressbooks
inc/admin/class-exportoptions.php
ExportOptions.init
function init() { $_option = $this->getSlug(); $_page = $_option; $_section = $this->getSlug() . '_section'; add_settings_section( $_section, '', [ $this, 'display' ], $_page ); add_settings_field( 'email_validation_logs', __( 'Email Validation Logs', 'pressbooks' ), [ $this, 'renderE...
php
function init() { $_option = $this->getSlug(); $_page = $_option; $_section = $this->getSlug() . '_section'; add_settings_section( $_section, '', [ $this, 'display' ], $_page ); add_settings_field( 'email_validation_logs', __( 'Email Validation Logs', 'pressbooks' ), [ $this, 'renderE...
[ "function", "init", "(", ")", "{", "$", "_option", "=", "$", "this", "->", "getSlug", "(", ")", ";", "$", "_page", "=", "$", "_option", ";", "$", "_section", "=", "$", "this", "->", "getSlug", "(", ")", ".", "'_section'", ";", "add_settings_section",...
Configure the export options page using the settings API.
[ "Configure", "the", "export", "options", "page", "using", "the", "settings", "API", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/admin/class-exportoptions.php#L52-L94
pressbooks/pressbooks
inc/admin/class-exportoptions.php
ExportOptions.renderEmailValidationLogsField
function renderEmailValidationLogsField( $args ) { $this->renderRadioButtons( [ 'id' => 'email_validation_logs', 'name' => $this->getSlug(), 'option' => 'email_validation_logs', 'value' => ( isset( $this->options['email_validation_logs'] ) ) ? $this->options['email_validation_logs'] : '', 'choi...
php
function renderEmailValidationLogsField( $args ) { $this->renderRadioButtons( [ 'id' => 'email_validation_logs', 'name' => $this->getSlug(), 'option' => 'email_validation_logs', 'value' => ( isset( $this->options['email_validation_logs'] ) ) ? $this->options['email_validation_logs'] : '', 'choi...
[ "function", "renderEmailValidationLogsField", "(", "$", "args", ")", "{", "$", "this", "->", "renderRadioButtons", "(", "[", "'id'", "=>", "'email_validation_logs'", ",", "'name'", "=>", "$", "this", "->", "getSlug", "(", ")", ",", "'option'", "=>", "'email_va...
Render the email_validation_logs radio buttons. @param array $args
[ "Render", "the", "email_validation_logs", "radio", "buttons", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/admin/class-exportoptions.php#L141-L151
pressbooks/pressbooks
inc/admin/class-exportoptions.php
ExportOptions.renderThemeLockField
function renderThemeLockField( $args ) { $this->renderCheckbox( [ 'id' => 'theme_lock', 'name' => $this->getSlug(), 'option' => 'theme_lock', 'value' => ( isset( $this->options['theme_lock'] ) ) ? $this->options['theme_lock'] : '', 'label' => $args[0], 'description' => __( 'This will preven...
php
function renderThemeLockField( $args ) { $this->renderCheckbox( [ 'id' => 'theme_lock', 'name' => $this->getSlug(), 'option' => 'theme_lock', 'value' => ( isset( $this->options['theme_lock'] ) ) ? $this->options['theme_lock'] : '', 'label' => $args[0], 'description' => __( 'This will preven...
[ "function", "renderThemeLockField", "(", "$", "args", ")", "{", "$", "this", "->", "renderCheckbox", "(", "[", "'id'", "=>", "'theme_lock'", ",", "'name'", "=>", "$", "this", "->", "getSlug", "(", ")", ",", "'option'", "=>", "'theme_lock'", ",", "'value'",...
Render the lock_theme checkbox. @param array $args
[ "Render", "the", "lock_theme", "checkbox", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/admin/class-exportoptions.php#L158-L169
pressbooks/pressbooks
inc/class-htmlawed.php
HtmLawed.filter
static function filter( $html, array $config = null, $spec = null ) { return \Htmlawed::filter( $html, $config, $spec ); }
php
static function filter( $html, array $config = null, $spec = null ) { return \Htmlawed::filter( $html, $config, $spec ); }
[ "static", "function", "filter", "(", "$", "html", ",", "array", "$", "config", "=", "null", ",", "$", "spec", "=", "null", ")", "{", "return", "\\", "Htmlawed", "::", "filter", "(", "$", "html", ",", "$", "config", ",", "$", "spec", ")", ";", "}"...
Wrapper for htmLawed() function. @param string $html @param int|array $config @param array|string $spec @return string
[ "Wrapper", "for", "htmLawed", "()", "function", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-htmlawed.php#L23-L25
pressbooks/pressbooks
inc/class-book.php
Book.getBookInformation
static function getBookInformation( $id = null ) { if ( ! empty( $id ) && is_int( $id ) ) { $blog_id = $id; switch_to_blog( $blog_id ); } else { global $blog_id; } // ----------------------------------------------------------------------------- // Is cached? // -----------------------------------...
php
static function getBookInformation( $id = null ) { if ( ! empty( $id ) && is_int( $id ) ) { $blog_id = $id; switch_to_blog( $blog_id ); } else { global $blog_id; } // ----------------------------------------------------------------------------- // Is cached? // -----------------------------------...
[ "static", "function", "getBookInformation", "(", "$", "id", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "id", ")", "&&", "is_int", "(", "$", "id", ")", ")", "{", "$", "blog_id", "=", "$", "id", ";", "switch_to_blog", "(", "$", "blog...
Returns book information in a useful, string only, format. Data is converted to HTML. @param int $id The book ID. @return array
[ "Returns", "book", "information", "in", "a", "useful", "string", "only", "format", ".", "Data", "is", "converted", "to", "HTML", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-book.php#L82-L192
pressbooks/pressbooks
inc/class-book.php
Book.getBookStructure
static function getBookStructure( $id = null ) { if ( ! empty( $id ) && is_int( $id ) ) { $blog_id = $id; switch_to_blog( $id ); } else { global $blog_id; } // ----------------------------------------------------------------------------- // Is cached? // ------------------------------------------...
php
static function getBookStructure( $id = null ) { if ( ! empty( $id ) && is_int( $id ) ) { $blog_id = $id; switch_to_blog( $id ); } else { global $blog_id; } // ----------------------------------------------------------------------------- // Is cached? // ------------------------------------------...
[ "static", "function", "getBookStructure", "(", "$", "id", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "id", ")", "&&", "is_int", "(", "$", "id", ")", ")", "{", "$", "blog_id", "=", "$", "id", ";", "switch_to_blog", "(", "$", "id", ...
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 bottom of this file for more info @param int $id @return 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", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-book.php#L205-L365
pressbooks/pressbooks
inc/class-book.php
Book.getBookContents
static function getBookContents() { global $blog_id; // ----------------------------------------------------------------------------- // Is cached? // ----------------------------------------------------------------------------- $cache_id = "book-cnt-$blog_id"; if ( static::useCache() ) { $book_conten...
php
static function getBookContents() { global $blog_id; // ----------------------------------------------------------------------------- // Is cached? // ----------------------------------------------------------------------------- $cache_id = "book-cnt-$blog_id"; if ( static::useCache() ) { $book_conten...
[ "static", "function", "getBookContents", "(", ")", "{", "global", "$", "blog_id", ";", "// -----------------------------------------------------------------------------", "// Is cached?", "// -----------------------------------------------------------------------------", "$", "cache_id",...
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 bottom of this file for more info @return 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", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-book.php#L375-L427
pressbooks/pressbooks
inc/class-book.php
Book.wordCount
static function wordCount( $selected_for_export = false ) { $wc = 0; $wc_selected_for_export = 0; foreach ( static::getBookStructure() as $key => $section ) { if ( $key === 'front-matter' || $key === 'back-matter' ) { foreach ( $section as $val ) { $wc += $val['word_count']; if ( $val['export'] )...
php
static function wordCount( $selected_for_export = false ) { $wc = 0; $wc_selected_for_export = 0; foreach ( static::getBookStructure() as $key => $section ) { if ( $key === 'front-matter' || $key === 'back-matter' ) { foreach ( $section as $val ) { $wc += $val['word_count']; if ( $val['export'] )...
[ "static", "function", "wordCount", "(", "$", "selected_for_export", "=", "false", ")", "{", "$", "wc", "=", "0", ";", "$", "wc_selected_for_export", "=", "0", ";", "foreach", "(", "static", "::", "getBookStructure", "(", ")", "as", "$", "key", "=>", "$",...
@param bool $selected_for_export (optional) @return int
[ "@param", "bool", "$selected_for_export", "(", "optional", ")" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-book.php#L434-L459
pressbooks/pressbooks
inc/class-book.php
Book.deleteBookObjectCache
static function deleteBookObjectCache() { global $blog_id; // Book Object wp_cache_delete( "book-inf-$blog_id", 'pb' ); // Delete the cached value for getBookInfo() wp_cache_delete( "book-str-$blog_id", 'pb' ); // Delete the cached value for getBookStructure() wp_cache_delete( "book-cnt-$blog_id", 'pb' ); /...
php
static function deleteBookObjectCache() { global $blog_id; // Book Object wp_cache_delete( "book-inf-$blog_id", 'pb' ); // Delete the cached value for getBookInfo() wp_cache_delete( "book-str-$blog_id", 'pb' ); // Delete the cached value for getBookStructure() wp_cache_delete( "book-cnt-$blog_id", 'pb' ); /...
[ "static", "function", "deleteBookObjectCache", "(", ")", "{", "global", "$", "blog_id", ";", "// Book Object", "wp_cache_delete", "(", "\"book-inf-$blog_id\"", ",", "'pb'", ")", ";", "// Delete the cached value for getBookInfo()", "wp_cache_delete", "(", "\"book-str-$blog_i...
Delete the Book Object cache(s)
[ "Delete", "the", "Book", "Object", "cache", "(", "s", ")" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-book.php#L476-L502
pressbooks/pressbooks
inc/class-book.php
Book.getSubsections
static function getSubsections( $id ) { $parent = get_post( $id ); if ( empty( $parent ) ) { return false; } $has_shortcode = has_shortcode( $parent->post_content, 'heading' ); if ( stripos( $parent->post_content, '<h1' ) === false && $has_shortcode === false ) { // No <h1> or [heading] shortcode return...
php
static function getSubsections( $id ) { $parent = get_post( $id ); if ( empty( $parent ) ) { return false; } $has_shortcode = has_shortcode( $parent->post_content, 'heading' ); if ( stripos( $parent->post_content, '<h1' ) === false && $has_shortcode === false ) { // No <h1> or [heading] shortcode return...
[ "static", "function", "getSubsections", "(", "$", "id", ")", "{", "$", "parent", "=", "get_post", "(", "$", "id", ")", ";", "if", "(", "empty", "(", "$", "parent", ")", ")", "{", "return", "false", ";", "}", "$", "has_shortcode", "=", "has_shortcode"...
Returns an array of subsections in front matter, back matter, or chapters. @param $id @return array|false
[ "Returns", "an", "array", "of", "subsections", "in", "front", "matter", "back", "matter", "or", "chapters", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-book.php#L511-L541
pressbooks/pressbooks
inc/class-book.php
Book.getAllSubsections
static function getAllSubsections( $book_structure ) { if ( Export::shouldParseSubsections() ) { $book_subsections_transient = \Pressbooks\Book::SUBSECTIONS_TRANSIENT; $subsection_processing_transient = \Pressbooks\Book::SUBSECTION_PROCESSING_TRANSIENT; $book_subsections = get_transient( $book_subsections_tr...
php
static function getAllSubsections( $book_structure ) { if ( Export::shouldParseSubsections() ) { $book_subsections_transient = \Pressbooks\Book::SUBSECTIONS_TRANSIENT; $subsection_processing_transient = \Pressbooks\Book::SUBSECTION_PROCESSING_TRANSIENT; $book_subsections = get_transient( $book_subsections_tr...
[ "static", "function", "getAllSubsections", "(", "$", "book_structure", ")", "{", "if", "(", "Export", "::", "shouldParseSubsections", "(", ")", ")", "{", "$", "book_subsections_transient", "=", "\\", "Pressbooks", "\\", "Book", "::", "SUBSECTIONS_TRANSIENT", ";", ...
Returns an array of front matter, chapters, and back matter which contain subsections. @param array $book_structure The book structure from getBookStructure() @return array The subsections, grouped by parent post type
[ "Returns", "an", "array", "of", "front", "matter", "chapters", "and", "back", "matter", "which", "contain", "subsections", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-book.php#L549-L587
pressbooks/pressbooks
inc/class-book.php
Book.tagSubsections
static function tagSubsections( $content, $id ) { $parent = get_post( $id ); if ( empty( $parent ) ) { return false; } if ( stripos( $content, '<h1' ) === false ) { return false; } $type = $parent->post_type; $s = 1; $doc = new HtmlParser(); $dom = $doc->loadHTML( $content ); $sections = $do...
php
static function tagSubsections( $content, $id ) { $parent = get_post( $id ); if ( empty( $parent ) ) { return false; } if ( stripos( $content, '<h1' ) === false ) { return false; } $type = $parent->post_type; $s = 1; $doc = new HtmlParser(); $dom = $doc->loadHTML( $content ); $sections = $do...
[ "static", "function", "tagSubsections", "(", "$", "content", ",", "$", "id", ")", "{", "$", "parent", "=", "get_post", "(", "$", "id", ")", ";", "if", "(", "empty", "(", "$", "parent", ")", ")", "{", "return", "false", ";", "}", "if", "(", "strip...
Returns chapter, front or back matter content with section ID and classes added. @param string $content @param int $id @return string|false
[ "Returns", "chapter", "front", "or", "back", "matter", "content", "with", "section", "ID", "and", "classes", "added", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-book.php#L597-L623
pressbooks/pressbooks
inc/class-book.php
Book.get
static function get( $what = 'next', $return_post_id = false, $admin_mode = false ) { if ( 'first' === $what ) { return static::getFirst( $return_post_id, $admin_mode ); } global $blog_id; global $post; $current_post_id = $post->ID; $book_structure = static::getBookStructure(); $order = $book_struc...
php
static function get( $what = 'next', $return_post_id = false, $admin_mode = false ) { if ( 'first' === $what ) { return static::getFirst( $return_post_id, $admin_mode ); } global $blog_id; global $post; $current_post_id = $post->ID; $book_structure = static::getBookStructure(); $order = $book_struc...
[ "static", "function", "get", "(", "$", "what", "=", "'next'", ",", "$", "return_post_id", "=", "false", ",", "$", "admin_mode", "=", "false", ")", "{", "if", "(", "'first'", "===", "$", "what", ")", "{", "return", "static", "::", "getFirst", "(", "$"...
Fetch next, previous or first post @param string $what prev, next or first @param bool $return_post_id (optional) @param bool $admin_mode (optional) @return mixed URL of requested post, or Post ID if $return_post_id is set to true
[ "Fetch", "next", "previous", "or", "first", "post" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-book.php#L647-L701
pressbooks/pressbooks
inc/class-book.php
Book.getFirst
static function getFirst( $return_post_id = false, $admin_mode = false ) { global $blog_id; $book_structure = static::getBookStructure(); $order = $book_structure['__order']; $pos = array_keys( $order ); reset( $pos ); while ( $first_id = current( $pos ) ) { if ( $admin_mode ) { if ( current_user_...
php
static function getFirst( $return_post_id = false, $admin_mode = false ) { global $blog_id; $book_structure = static::getBookStructure(); $order = $book_structure['__order']; $pos = array_keys( $order ); reset( $pos ); while ( $first_id = current( $pos ) ) { if ( $admin_mode ) { if ( current_user_...
[ "static", "function", "getFirst", "(", "$", "return_post_id", "=", "false", ",", "$", "admin_mode", "=", "false", ")", "{", "global", "$", "blog_id", ";", "$", "book_structure", "=", "static", "::", "getBookStructure", "(", ")", ";", "$", "order", "=", "...
Select the very first post in a book. May be a chapter or a front matter post @param bool $return_post_id (optional) @param bool $admin_mode (optional) @return mixed URL of first post, or Post ID if $return_post_id is set to true
[ "Select", "the", "very", "first", "post", "in", "a", "book", ".", "May", "be", "a", "chapter", "or", "a", "front", "matter", "post" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-book.php#L712-L747
pressbooks/pressbooks
inc/class-book.php
Book.getChapterNumber
static function getChapterNumber( $post_id, $type_of = 'webbook' ) { if ( empty( static::$__order ) ) { self::$__order = static::getBookStructure()['__order']; } $lookup = static::$__order; if ( $type_of === 'webbook' ) { $post_statii = [ 'web-only', 'publish' ]; } else { $post_statii = [ 'private'...
php
static function getChapterNumber( $post_id, $type_of = 'webbook' ) { if ( empty( static::$__order ) ) { self::$__order = static::getBookStructure()['__order']; } $lookup = static::$__order; if ( $type_of === 'webbook' ) { $post_statii = [ 'web-only', 'publish' ]; } else { $post_statii = [ 'private'...
[ "static", "function", "getChapterNumber", "(", "$", "post_id", ",", "$", "type_of", "=", "'webbook'", ")", "{", "if", "(", "empty", "(", "static", "::", "$", "__order", ")", ")", "{", "self", "::", "$", "__order", "=", "static", "::", "getBookStructure",...
@since 5.2.0 @param $post_id @param string $type_of (optional) webbook, exports @return int
[ "@since", "5", ".", "2", ".", "0" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-book.php#L757-L801
pressbooks/pressbooks
inc/class-book.php
Book.consolidatePost
static function consolidatePost( $pid, $post ) { if ( false === Book::isBook() || wp_is_post_revision( $pid ) || 'auto-draft' === get_post_status( $pid ) ) { return false; } /** @var $wpdb \wpdb */ global $wpdb; $success = true; // if this is a new post, set its order if ( empty( $post->menu_order )...
php
static function consolidatePost( $pid, $post ) { if ( false === Book::isBook() || wp_is_post_revision( $pid ) || 'auto-draft' === get_post_status( $pid ) ) { return false; } /** @var $wpdb \wpdb */ global $wpdb; $success = true; // if this is a new post, set its order if ( empty( $post->menu_order )...
[ "static", "function", "consolidatePost", "(", "$", "pid", ",", "$", "post", ")", "{", "if", "(", "false", "===", "Book", "::", "isBook", "(", ")", "||", "wp_is_post_revision", "(", "$", "pid", ")", "||", "'auto-draft'", "===", "get_post_status", "(", "$"...
Ensures this chapter/part/front matter has a "menu_order" when it is saved @param integer $pid Post ID @param \WP_Post $post Post @return bool
[ "Ensures", "this", "chapter", "/", "part", "/", "front", "matter", "has", "a", "menu_order", "when", "it", "is", "saved" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-book.php#L812-L868
pressbooks/pressbooks
inc/class-book.php
Book.deletePost
static function deletePost( $pid ) { if ( false === Book::isBook() || wp_is_post_revision( $pid ) || 'auto-draft' === get_post_status( $pid ) ) { return false; } /** @var $wpdb \wpdb */ global $wpdb; // remove chapter/part/front matter // decrement order of everything with a higher order, and if chapt...
php
static function deletePost( $pid ) { if ( false === Book::isBook() || wp_is_post_revision( $pid ) || 'auto-draft' === get_post_status( $pid ) ) { return false; } /** @var $wpdb \wpdb */ global $wpdb; // remove chapter/part/front matter // decrement order of everything with a higher order, and if chapt...
[ "static", "function", "deletePost", "(", "$", "pid", ")", "{", "if", "(", "false", "===", "Book", "::", "isBook", "(", ")", "||", "wp_is_post_revision", "(", "$", "pid", ")", "||", "'auto-draft'", "===", "get_post_status", "(", "$", "pid", ")", ")", "{...
Put a Part/Chapter/Front Matter/Back Matter in the trash @param int $pid @return bool
[ "Put", "a", "Part", "/", "Chapter", "/", "Front", "Matter", "/", "Back", "Matter", "in", "the", "trash" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-book.php#L878-L958
pressbooks/pressbooks
inc/class-book.php
Book.getPostsIdsToExport
static protected function getPostsIdsToExport() { $post_ids_to_export = []; global $wpdb; $results = $wpdb->get_results( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_status IN (%s, %s) AND post_type IN (%s, %s, %s, %s, %s)", [ 'private', 'publish', 'front-matter', 'part', 'chapter', 'bac...
php
static protected function getPostsIdsToExport() { $post_ids_to_export = []; global $wpdb; $results = $wpdb->get_results( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_status IN (%s, %s) AND post_type IN (%s, %s, %s, %s, %s)", [ 'private', 'publish', 'front-matter', 'part', 'chapter', 'bac...
[ "static", "protected", "function", "getPostsIdsToExport", "(", ")", "{", "$", "post_ids_to_export", "=", "[", "]", ";", "global", "$", "wpdb", ";", "$", "results", "=", "$", "wpdb", "->", "get_results", "(", "$", "wpdb", "->", "prepare", "(", "\"SELECT ID ...
Fetch all pb_export meta values for this book @return array
[ "Fetch", "all", "pb_export", "meta", "values", "for", "this", "book" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-book.php#L965-L981
pressbooks/pressbooks
inc/shortcodes/footnotes/class-footnotes.php
Footnotes.shortcodeHandler
function shortcodeHandler( $atts, $content = '' ) { global $id; // This is the Post ID, [@see WP_Query::setup_postdata, ...] $a = shortcode_atts( [ 'numbered' => 'yes', 'symbol' => '*', 'suptext' => ' ', ], $atts ); if ( ! $content ) { return ''; } if ( ! isset( $this->footnotes[ $i...
php
function shortcodeHandler( $atts, $content = '' ) { global $id; // This is the Post ID, [@see WP_Query::setup_postdata, ...] $a = shortcode_atts( [ 'numbered' => 'yes', 'symbol' => '*', 'suptext' => ' ', ], $atts ); if ( ! $content ) { return ''; } if ( ! isset( $this->footnotes[ $i...
[ "function", "shortcodeHandler", "(", "$", "atts", ",", "$", "content", "=", "''", ")", "{", "global", "$", "id", ";", "// This is the Post ID, [@see WP_Query::setup_postdata, ...]", "$", "a", "=", "shortcode_atts", "(", "[", "'numbered'", "=>", "'yes'", ",", "'s...
Pre-process footnote shortcode @param array $atts @param string $content @return string
[ "Pre", "-", "process", "footnote", "shortcode" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/shortcodes/footnotes/class-footnotes.php#L70-L118
pressbooks/pressbooks
inc/shortcodes/footnotes/class-footnotes.php
Footnotes.footnoteContent
function footnoteContent( $content ) { global $id; // This is the Post ID, [@see WP_Query::setup_postdata, ...] if ( ! empty( $this->footnotes ) && isset( $this->footnotes[ $id ] ) ) { $footnotes = $this->footnotes[ $id ]; } else { return $content; } if ( $this->numbered[ $id ] ) { $content .= '<h...
php
function footnoteContent( $content ) { global $id; // This is the Post ID, [@see WP_Query::setup_postdata, ...] if ( ! empty( $this->footnotes ) && isset( $this->footnotes[ $id ] ) ) { $footnotes = $this->footnotes[ $id ]; } else { return $content; } if ( $this->numbered[ $id ] ) { $content .= '<h...
[ "function", "footnoteContent", "(", "$", "content", ")", "{", "global", "$", "id", ";", "// This is the Post ID, [@see WP_Query::setup_postdata, ...]", "if", "(", "!", "empty", "(", "$", "this", "->", "footnotes", ")", "&&", "isset", "(", "$", "this", "->", "f...
Post-process footnote shortcode @param $content @return string
[ "Post", "-", "process", "footnote", "shortcode" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/shortcodes/footnotes/class-footnotes.php#L128-L159
pressbooks/pressbooks
inc/shortcodes/footnotes/class-footnotes.php
Footnotes.convertWordFootnotes
static function convertWordFootnotes() { if ( ! current_user_can( 'edit_posts' ) || ! check_ajax_referer( 'pb-footnote-convert', false, false ) ) { static::ajaxFailure( __( 'Invalid permissions.', 'pressbooks' ) ); return; } $html = urldecode( stripslashes( $_POST['content'] ) ); /** * Regular expre...
php
static function convertWordFootnotes() { if ( ! current_user_can( 'edit_posts' ) || ! check_ajax_referer( 'pb-footnote-convert', false, false ) ) { static::ajaxFailure( __( 'Invalid permissions.', 'pressbooks' ) ); return; } $html = urldecode( stripslashes( $_POST['content'] ) ); /** * Regular expre...
[ "static", "function", "convertWordFootnotes", "(", ")", "{", "if", "(", "!", "current_user_can", "(", "'edit_posts'", ")", "||", "!", "check_ajax_referer", "(", "'pb-footnote-convert'", ",", "false", ",", "false", ")", ")", "{", "static", "::", "ajaxFailure", ...
WP_Ajax hook. Convert MS Word footnotes to Pressbooks compatible [footnotes]
[ "WP_Ajax", "hook", ".", "Convert", "MS", "Word", "footnotes", "to", "Pressbooks", "compatible", "[", "footnotes", "]" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/shortcodes/footnotes/class-footnotes.php#L181-L275
Athari/YaLinqo
YaLinqo/EnumerablePagination.php
EnumerablePagination.elementAt
public function elementAt($key) { /** @var $it \Iterator|\ArrayAccess */ $it = $this->getIterator(); if ($it instanceof \ArrayAccess) { if (!$it->offsetExists($key)) throw new \UnexpectedValueException(Errors::NO_KEY); return $it->offsetGet($key); ...
php
public function elementAt($key) { /** @var $it \Iterator|\ArrayAccess */ $it = $this->getIterator(); if ($it instanceof \ArrayAccess) { if (!$it->offsetExists($key)) throw new \UnexpectedValueException(Errors::NO_KEY); return $it->offsetGet($key); ...
[ "public", "function", "elementAt", "(", "$", "key", ")", "{", "/** @var $it \\Iterator|\\ArrayAccess */", "$", "it", "=", "$", "this", "->", "getIterator", "(", ")", ";", "if", "(", "$", "it", "instanceof", "\\", "ArrayAccess", ")", "{", "if", "(", "!", ...
Returns the value at a specified key in a sequence. <p><b>Syntax</b>: elementAt (key) <p>Returns the value at a specified key in a sequence. <p>If the type of source iterator implements {@link ArrayAccess}, that implementation is used to obtain the value at the specified key. Otherwise, this method obtains the specifie...
[ "Returns", "the", "value", "at", "a", "specified", "key", "in", "a", "sequence", ".", "<p", ">", "<b", ">", "Syntax<", "/", "b", ">", ":", "elementAt", "(", "key", ")", "<p", ">", "Returns", "the", "value", "at", "a", "specified", "key", "in", "a",...
train
https://github.com/Athari/YaLinqo/blob/939469772b36d4d454836681e0be2f220cf1e5cb/YaLinqo/EnumerablePagination.php#L29-L45