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/modules/import/class-import.php | Import.doImportGenerator | static function doImportGenerator( array $current_import ) : \Generator {
// Set post status
$current_import['default_post_status'] = ( isset( $_POST['show_imports_in_web'] ) ) ? 'publish' : 'private'; // @codingStandardsIgnoreLine
/**
* Maximum execution time, in seconds. If set to zero, no time limit
* ... | php | static function doImportGenerator( array $current_import ) : \Generator {
// Set post status
$current_import['default_post_status'] = ( isset( $_POST['show_imports_in_web'] ) ) ? 'publish' : 'private'; // @codingStandardsIgnoreLine
/**
* Maximum execution time, in seconds. If set to zero, no time limit
* ... | [
"static",
"function",
"doImportGenerator",
"(",
"array",
"$",
"current_import",
")",
":",
"\\",
"Generator",
"{",
"// Set post status",
"$",
"current_import",
"[",
"'default_post_status'",
"]",
"=",
"(",
"isset",
"(",
"$",
"_POST",
"[",
"'show_imports_in_web'",
"]... | Do Import
@param array $current_import WP option 'pressbooks_current_import'
@return \Generator | [
"Do",
"Import"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/class-import.php#L281-L368 |
pressbooks/pressbooks | inc/modules/import/class-import.php | Import.setImportOptions | static protected function setImportOptions() {
if ( ! check_admin_referer( 'pb-import' ) ) {
return false;
}
$overrides = [
'test_form' => false,
'test_type' => false,
];
if ( ! function_exists( 'wp_handle_upload' ) ) {
require_once( ABSPATH . 'wp-admin/includes/file.php' );
}
// If Import... | php | static protected function setImportOptions() {
if ( ! check_admin_referer( 'pb-import' ) ) {
return false;
}
$overrides = [
'test_form' => false,
'test_type' => false,
];
if ( ! function_exists( 'wp_handle_upload' ) ) {
require_once( ABSPATH . 'wp-admin/includes/file.php' );
}
// If Import... | [
"static",
"protected",
"function",
"setImportOptions",
"(",
")",
"{",
"if",
"(",
"!",
"check_admin_referer",
"(",
"'pb-import'",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"overrides",
"=",
"[",
"'test_form'",
"=>",
"false",
",",
"'test_type'",
"=>",
... | Look at $_POST and $_FILES, sets 'pressbooks_current_import' option based on submission
@return bool | [
"Look",
"at",
"$_POST",
"and",
"$_FILES",
"sets",
"pressbooks_current_import",
"option",
"based",
"on",
"submission"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/class-import.php#L382-L501 |
pressbooks/pressbooks | inc/modules/import/class-import.php | Import.hasApi | static protected function hasApi( &$upload ) {
$cloner = new Cloner( $upload['url'] );
$is_compatible = $cloner->isCompatible( $upload['url'] );
if ( $is_compatible ) {
$upload['url'] = $cloner->getSourceBookUrl();
return true;
}
return false;
} | php | static protected function hasApi( &$upload ) {
$cloner = new Cloner( $upload['url'] );
$is_compatible = $cloner->isCompatible( $upload['url'] );
if ( $is_compatible ) {
$upload['url'] = $cloner->getSourceBookUrl();
return true;
}
return false;
} | [
"static",
"protected",
"function",
"hasApi",
"(",
"&",
"$",
"upload",
")",
"{",
"$",
"cloner",
"=",
"new",
"Cloner",
"(",
"$",
"upload",
"[",
"'url'",
"]",
")",
";",
"$",
"is_compatible",
"=",
"$",
"cloner",
"->",
"isCompatible",
"(",
"$",
"upload",
... | @param array $upload Passed by reference because we want to change the URL
@return bool | [
"@param",
"array",
"$upload",
"Passed",
"by",
"reference",
"because",
"we",
"want",
"to",
"change",
"the",
"URL"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/class-import.php#L508-L516 |
pressbooks/pressbooks | inc/modules/import/class-import.php | Import.createFileFromUrl | static protected function createFileFromUrl() {
if ( ! check_admin_referer( 'pb-import' ) ) {
return false;
}
// check if it's a valid url
$url = trim( getset( '_POST', 'import_http', '' ) );
if ( false === filter_var( $url, FILTER_VALIDATE_URL ) ) {
$_SESSION['pb_errors'][] = __( 'Your URL does not a... | php | static protected function createFileFromUrl() {
if ( ! check_admin_referer( 'pb-import' ) ) {
return false;
}
// check if it's a valid url
$url = trim( getset( '_POST', 'import_http', '' ) );
if ( false === filter_var( $url, FILTER_VALIDATE_URL ) ) {
$_SESSION['pb_errors'][] = __( 'Your URL does not a... | [
"static",
"protected",
"function",
"createFileFromUrl",
"(",
")",
"{",
"if",
"(",
"!",
"check_admin_referer",
"(",
"'pb-import'",
")",
")",
"{",
"return",
"false",
";",
"}",
"// check if it's a valid url",
"$",
"url",
"=",
"trim",
"(",
"getset",
"(",
"'_POST'"... | Tries to download URL in $_POST['import_http'], impersonates $_FILES on success
Note: Faking the $_FILES array will cause PHP's is_uploaded_file() to fail
@return bool | [
"Tries",
"to",
"download",
"URL",
"in",
"$_POST",
"[",
"import_http",
"]",
"impersonates",
"$_FILES",
"on",
"success",
"Note",
":",
"Faking",
"the",
"$_FILES",
"array",
"will",
"cause",
"PHP",
"s",
"is_uploaded_file",
"()",
"to",
"fail"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/class-import.php#L524-L598 |
pressbooks/pressbooks | inc/modules/import/class-import.php | Import.isUrlSmallerThanUploadMaxSize | static protected function isUrlSmallerThanUploadMaxSize( $url, $max ) {
$response = wp_safe_remote_head(
$url, [
'redirection' => 2,
]
);
$size = (int) wp_remote_retrieve_header( $response, 'Content-Length' );
if ( empty( $size ) ) {
return true; // Unable to verify, return true and hope for the be... | php | static protected function isUrlSmallerThanUploadMaxSize( $url, $max ) {
$response = wp_safe_remote_head(
$url, [
'redirection' => 2,
]
);
$size = (int) wp_remote_retrieve_header( $response, 'Content-Length' );
if ( empty( $size ) ) {
return true; // Unable to verify, return true and hope for the be... | [
"static",
"protected",
"function",
"isUrlSmallerThanUploadMaxSize",
"(",
"$",
"url",
",",
"$",
"max",
")",
"{",
"$",
"response",
"=",
"wp_safe_remote_head",
"(",
"$",
"url",
",",
"[",
"'redirection'",
"=>",
"2",
",",
"]",
")",
";",
"$",
"size",
"=",
"(",... | Check that a URL is smaller than MAX UPLOAD without downloading the file
@param string $url
@param int $max
@return bool | [
"Check",
"that",
"a",
"URL",
"is",
"smaller",
"than",
"MAX",
"UPLOAD",
"without",
"downloading",
"the",
"file"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/class-import.php#L609-L620 |
pressbooks/pressbooks | inc/modules/import/class-import.php | Import.log | static function log( $message, array $more_info = [] ) {
/** $var \WP_User $current_user */
global $current_user;
$subject = '[ Import Log ]';
$info = [
'time' => strftime( '%c' ),
'user' => ( isset( $current_user ) ? $current_user->user_login : '__UNKNOWN__' ),
'site_url' => site_url(),
'blog_id... | php | static function log( $message, array $more_info = [] ) {
/** $var \WP_User $current_user */
global $current_user;
$subject = '[ Import Log ]';
$info = [
'time' => strftime( '%c' ),
'user' => ( isset( $current_user ) ? $current_user->user_login : '__UNKNOWN__' ),
'site_url' => site_url(),
'blog_id... | [
"static",
"function",
"log",
"(",
"$",
"message",
",",
"array",
"$",
"more_info",
"=",
"[",
"]",
")",
"{",
"/** $var \\WP_User $current_user */",
"global",
"$",
"current_user",
";",
"$",
"subject",
"=",
"'[ Import Log ]'",
";",
"$",
"info",
"=",
"[",
"'time'... | Log something using wp_mail() and error_log(), include useful WordPress info.
Note: This method is here temporarily. We are using it to find & fix bugs for the first iterations of import.
Do not count on this method being here in the future.
@deprecated
@param string $message
@param array $more_info | [
"Log",
"something",
"using",
"wp_mail",
"()",
"and",
"error_log",
"()",
"include",
"useful",
"WordPress",
"info",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/class-import.php#L661-L680 |
pressbooks/pressbooks | inc/modules/export/indesign/class-icml.php | Icml.convert | function convert() {
// Create ICML
$vars = [
'meta' => \Pressbooks\Book::getBookInformation(),
'book_contents' => $this->preProcessBookContents( \Pressbooks\Book::getBookContents() ),
];
$cc_copyright = strip_tags( $this->doCopyrightLicense( $vars['meta'] ) );
$vars['do_copyright_license'] = $cc_cop... | php | function convert() {
// Create ICML
$vars = [
'meta' => \Pressbooks\Book::getBookInformation(),
'book_contents' => $this->preProcessBookContents( \Pressbooks\Book::getBookContents() ),
];
$cc_copyright = strip_tags( $this->doCopyrightLicense( $vars['meta'] ) );
$vars['do_copyright_license'] = $cc_cop... | [
"function",
"convert",
"(",
")",
"{",
"// Create ICML",
"$",
"vars",
"=",
"[",
"'meta'",
"=>",
"\\",
"Pressbooks",
"\\",
"Book",
"::",
"getBookInformation",
"(",
")",
",",
"'book_contents'",
"=>",
"$",
"this",
"->",
"preProcessBookContents",
"(",
"\\",
"Pres... | Create $this->outputPath
@return bool | [
"Create",
"$this",
"-",
">",
"outputPath"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/indesign/class-icml.php#L32-L62 |
pressbooks/pressbooks | inc/modules/export/indesign/class-icml.php | Icml.logError | function logError( $message, array $more_info = [] ) {
$more_info['path'] = $this->outputPath;
parent::logError( $message, $more_info );
} | php | function logError( $message, array $more_info = [] ) {
$more_info['path'] = $this->outputPath;
parent::logError( $message, $more_info );
} | [
"function",
"logError",
"(",
"$",
"message",
",",
"array",
"$",
"more_info",
"=",
"[",
"]",
")",
"{",
"$",
"more_info",
"[",
"'path'",
"]",
"=",
"$",
"this",
"->",
"outputPath",
";",
"parent",
"::",
"logError",
"(",
"$",
"message",
",",
"$",
"more_in... | Add $this->outputPath as additional log info, fallback to parent.
@param $message
@param array $more_info (unused, overridden) | [
"Add",
"$this",
"-",
">",
"outputPath",
"as",
"additional",
"log",
"info",
"fallback",
"to",
"parent",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/indesign/class-icml.php#L89-L94 |
pressbooks/pressbooks | inc/modules/export/indesign/class-icml.php | Icml.bookHtmlError | protected function bookHtmlError( $book_html ) {
$message = "ICML conversion returned a file of zero bytes. \n";
$message .= 'This usually happens when bad XHTML (I.e. $book_html) is passed to the XSL transform routine. ' . "\n";
$message .= 'Analysis of $book_html follows: ' . "\n\n";
$book_html_path = $this... | php | protected function bookHtmlError( $book_html ) {
$message = "ICML conversion returned a file of zero bytes. \n";
$message .= 'This usually happens when bad XHTML (I.e. $book_html) is passed to the XSL transform routine. ' . "\n";
$message .= 'Analysis of $book_html follows: ' . "\n\n";
$book_html_path = $this... | [
"protected",
"function",
"bookHtmlError",
"(",
"$",
"book_html",
")",
"{",
"$",
"message",
"=",
"\"ICML conversion returned a file of zero bytes. \\n\"",
";",
"$",
"message",
".=",
"'This usually happens when bad XHTML (I.e. $book_html) is passed to the XSL transform routine. '",
"... | Log problems with $book_html that probably caused transformXML() to fail.
@param $book_html
@return string | [
"Log",
"problems",
"with",
"$book_html",
"that",
"probably",
"caused",
"transformXML",
"()",
"to",
"fail",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/indesign/class-icml.php#L104-L122 |
pressbooks/pressbooks | inc/modules/export/indesign/class-icml.php | Icml.preProcessPostContent | protected function preProcessPostContent( $content ) {
$content = apply_filters( 'the_content', $content );
$content = str_ireplace( [ '<b></b>', '<i></i>', '<strong></strong>', '<em></em>' ], '', $content );
$content = $this->fixAnnoyingCharacters( $content );
$content = $this->tidy( $content );
return $con... | php | protected function preProcessPostContent( $content ) {
$content = apply_filters( 'the_content', $content );
$content = str_ireplace( [ '<b></b>', '<i></i>', '<strong></strong>', '<em></em>' ], '', $content );
$content = $this->fixAnnoyingCharacters( $content );
$content = $this->tidy( $content );
return $con... | [
"protected",
"function",
"preProcessPostContent",
"(",
"$",
"content",
")",
"{",
"$",
"content",
"=",
"apply_filters",
"(",
"'the_content'",
",",
"$",
"content",
")",
";",
"$",
"content",
"=",
"str_ireplace",
"(",
"[",
"'<b></b>'",
",",
"'<i></i>'",
",",
"'<... | @param string $content
@return string | [
"@param",
"string",
"$content"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/indesign/class-icml.php#L190-L197 |
pressbooks/pressbooks | inc/modules/export/indesign/class-icml.php | Icml.tidy | protected function tidy( $html ) {
// Make XHTML 1.1 strict using htmlLawed
$html = \Pressbooks\Interactive\Content::init()->replaceInteractiveTags( $html );
$config = [
'valid_xhtml' => 1,
'unique_ids' => 'fixme-',
'hook' => '\Pressbooks\Sanitize\html5_to_xhtml11',
'tidy' => -1,
];
return \Pr... | php | protected function tidy( $html ) {
// Make XHTML 1.1 strict using htmlLawed
$html = \Pressbooks\Interactive\Content::init()->replaceInteractiveTags( $html );
$config = [
'valid_xhtml' => 1,
'unique_ids' => 'fixme-',
'hook' => '\Pressbooks\Sanitize\html5_to_xhtml11',
'tidy' => -1,
];
return \Pr... | [
"protected",
"function",
"tidy",
"(",
"$",
"html",
")",
"{",
"// Make XHTML 1.1 strict using htmlLawed",
"$",
"html",
"=",
"\\",
"Pressbooks",
"\\",
"Interactive",
"\\",
"Content",
"::",
"init",
"(",
")",
"->",
"replaceInteractiveTags",
"(",
"$",
"html",
")",
... | Tidy HTML
@param string $html
@return string | [
"Tidy",
"HTML"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/indesign/class-icml.php#L207-L221 |
pressbooks/pressbooks | inc/shortcodes/attributions/class-attachments.php | Attachments.hooks | static public function hooks( Attachments $obj ) {
add_shortcode( self::SHORTCODE, [ $obj, 'shortcodeHandler' ] );
// prevent further processing of formatted strings
add_filter(
'no_texturize_shortcodes',
function ( $excluded_shortcodes ) {
$excluded_shortcodes[] = Attachments::SHORTCODE;
return ... | php | static public function hooks( Attachments $obj ) {
add_shortcode( self::SHORTCODE, [ $obj, 'shortcodeHandler' ] );
// prevent further processing of formatted strings
add_filter(
'no_texturize_shortcodes',
function ( $excluded_shortcodes ) {
$excluded_shortcodes[] = Attachments::SHORTCODE;
return ... | [
"static",
"public",
"function",
"hooks",
"(",
"Attachments",
"$",
"obj",
")",
"{",
"add_shortcode",
"(",
"self",
"::",
"SHORTCODE",
",",
"[",
"$",
"obj",
",",
"'shortcodeHandler'",
"]",
")",
";",
"// prevent further processing of formatted strings",
"add_filter",
... | Hooks our bits into the machine
@since 5.5.0
@param Attachments $obj | [
"Hooks",
"our",
"bits",
"into",
"the",
"machine"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/shortcodes/attributions/class-attachments.php#L44-L79 |
pressbooks/pressbooks | inc/shortcodes/attributions/class-attachments.php | Attachments.getBookMedia | function getBookMedia( $reset = false ) {
// Cheap cache
static $book_media = null;
if ( $reset || $book_media === null ) {
$book_media = [];
$args = [
'post_type' => 'attachment',
'posts_per_page' => -1, // @codingStandardsIgnoreLine
'post_status' => 'inherit',
'no_found_rows' => true,
... | php | function getBookMedia( $reset = false ) {
// Cheap cache
static $book_media = null;
if ( $reset || $book_media === null ) {
$book_media = [];
$args = [
'post_type' => 'attachment',
'posts_per_page' => -1, // @codingStandardsIgnoreLine
'post_status' => 'inherit',
'no_found_rows' => true,
... | [
"function",
"getBookMedia",
"(",
"$",
"reset",
"=",
"false",
")",
"{",
"// Cheap cache",
"static",
"$",
"book_media",
"=",
"null",
";",
"if",
"(",
"$",
"reset",
"||",
"$",
"book_media",
"===",
"null",
")",
"{",
"$",
"book_media",
"=",
"[",
"]",
";",
... | Returns the array of attachments set in the instance variable.
@param bool $reset (optional, default is false)
@since 5.5.0
@return array|null | [
"Returns",
"the",
"array",
"of",
"attachments",
"set",
"in",
"the",
"instance",
"variable",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/shortcodes/attributions/class-attachments.php#L90-L109 |
pressbooks/pressbooks | inc/shortcodes/attributions/class-attachments.php | Attachments.getAttributions | function getAttributions( $content ) {
$media_in_page = get_media_embedded_in_content( $content );
// these are not the droids you're looking for
if ( empty( $media_in_page ) ) {
return $content;
}
// get all book attachments
$book_media = $this->getBookMedia();
if ( ! empty( $book_media ) ) {
$me... | php | function getAttributions( $content ) {
$media_in_page = get_media_embedded_in_content( $content );
// these are not the droids you're looking for
if ( empty( $media_in_page ) ) {
return $content;
}
// get all book attachments
$book_media = $this->getBookMedia();
if ( ! empty( $book_media ) ) {
$me... | [
"function",
"getAttributions",
"(",
"$",
"content",
")",
"{",
"$",
"media_in_page",
"=",
"get_media_embedded_in_content",
"(",
"$",
"content",
")",
";",
"// these are not the droids you're looking for",
"if",
"(",
"empty",
"(",
"$",
"media_in_page",
")",
")",
"{",
... | Produces a list of media attributions if they are
found in the current page and part of the media library
appends said list to the end of the content
@since 5.5.0
@param $content
@return string | [
"Produces",
"a",
"list",
"of",
"media",
"attributions",
"if",
"they",
"are",
"found",
"in",
"the",
"current",
"page",
"and",
"part",
"of",
"the",
"media",
"library",
"appends",
"said",
"list",
"to",
"the",
"end",
"of",
"the",
"content"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/shortcodes/attributions/class-attachments.php#L122-L147 |
pressbooks/pressbooks | inc/shortcodes/attributions/class-attachments.php | Attachments.getAttributionsMeta | public function getAttributionsMeta( $ids ) {
$all_attributions = [];
if ( $ids ) {
foreach ( $ids as $id ) {
$all_attributions[ $id ]['title'] = get_the_title( $id );
$all_attributions[ $id ]['title_url'] = get_post_meta( $id, 'pb_media_attribution_title_url', true );
$all_attributions[ $id ]['auth... | php | public function getAttributionsMeta( $ids ) {
$all_attributions = [];
if ( $ids ) {
foreach ( $ids as $id ) {
$all_attributions[ $id ]['title'] = get_the_title( $id );
$all_attributions[ $id ]['title_url'] = get_post_meta( $id, 'pb_media_attribution_title_url', true );
$all_attributions[ $id ]['auth... | [
"public",
"function",
"getAttributionsMeta",
"(",
"$",
"ids",
")",
"{",
"$",
"all_attributions",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"ids",
")",
"{",
"foreach",
"(",
"$",
"ids",
"as",
"$",
"id",
")",
"{",
"$",
"all_attributions",
"[",
"$",
"id",
"]... | Returns the gamut of attribution metadata that can be associated with an
attachment
@param array $ids of attachments
@return array all attribution metadata | [
"Returns",
"the",
"gamut",
"of",
"attribution",
"metadata",
"that",
"can",
"be",
"associated",
"with",
"an",
"attachment"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/shortcodes/attributions/class-attachments.php#L157-L173 |
pressbooks/pressbooks | inc/shortcodes/attributions/class-attachments.php | Attachments.attributionsContent | function attributionsContent( $attributions ) {
$media_attributions = '';
$html = '';
$licensing = new Licensing();
$supported = $licensing->getSupportedTypes();
if ( $attributions ) {
// generate appropriate markup for each field
foreach ( $attributions as $attribution ) {
// unset empty arrays
... | php | function attributionsContent( $attributions ) {
$media_attributions = '';
$html = '';
$licensing = new Licensing();
$supported = $licensing->getSupportedTypes();
if ( $attributions ) {
// generate appropriate markup for each field
foreach ( $attributions as $attribution ) {
// unset empty arrays
... | [
"function",
"attributionsContent",
"(",
"$",
"attributions",
")",
"{",
"$",
"media_attributions",
"=",
"''",
";",
"$",
"html",
"=",
"''",
";",
"$",
"licensing",
"=",
"new",
"Licensing",
"(",
")",
";",
"$",
"supported",
"=",
"$",
"licensing",
"->",
"getSu... | Produces an html blob of attribution statements for the array
of attachment ids it's given.
@since 5.5.0
@param array $attributions
@return string | [
"Produces",
"an",
"html",
"blob",
"of",
"attribution",
"statements",
"for",
"the",
"array",
"of",
"attachment",
"ids",
"it",
"s",
"given",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/shortcodes/attributions/class-attachments.php#L185-L267 |
pressbooks/pressbooks | inc/shortcodes/attributions/class-attachments.php | Attachments.shortcodeHandler | function shortcodeHandler( $atts, $content = '' ) {
$retval = '';
$a = shortcode_atts(
[
'id' => '',
], $atts
);
if ( ! empty( $a ) ) {
$meta = $this->getAttributionsMeta( $a );
$retval = $this->attributionsContent( $meta );
}
return $retval;
} | php | function shortcodeHandler( $atts, $content = '' ) {
$retval = '';
$a = shortcode_atts(
[
'id' => '',
], $atts
);
if ( ! empty( $a ) ) {
$meta = $this->getAttributionsMeta( $a );
$retval = $this->attributionsContent( $meta );
}
return $retval;
} | [
"function",
"shortcodeHandler",
"(",
"$",
"atts",
",",
"$",
"content",
"=",
"''",
")",
"{",
"$",
"retval",
"=",
"''",
";",
"$",
"a",
"=",
"shortcode_atts",
"(",
"[",
"'id'",
"=>",
"''",
",",
"]",
",",
"$",
"atts",
")",
";",
"if",
"(",
"!",
"emp... | If shortcode is present [media_attributions id='33']
returns the one attribution statement for that attachment
@since 5.5.0
@param array $atts
@param string $content
@return string | [
"If",
"shortcode",
"is",
"present",
"[",
"media_attributions",
"id",
"=",
"33",
"]",
"returns",
"the",
"one",
"attribution",
"statement",
"for",
"that",
"attachment"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/shortcodes/attributions/class-attachments.php#L280-L295 |
pressbooks/pressbooks | inc/covergenerator/class-covergenerator.php | Covergenerator.commandLineDefaults | static public function commandLineDefaults() {
if ( ! defined( 'PB_CONVERT_COMMAND' ) ) {
define( 'PB_CONVERT_COMMAND', '/usr/bin/convert' );
}
if ( ! defined( 'PB_GS_COMMAND' ) ) {
define( 'PB_GS_COMMAND', '/usr/bin/gs' );
}
if ( ! defined( 'PB_PDFINFO_COMMAND' ) ) {
define( 'PB_PDFINFO_COMMAND', '/... | php | static public function commandLineDefaults() {
if ( ! defined( 'PB_CONVERT_COMMAND' ) ) {
define( 'PB_CONVERT_COMMAND', '/usr/bin/convert' );
}
if ( ! defined( 'PB_GS_COMMAND' ) ) {
define( 'PB_GS_COMMAND', '/usr/bin/gs' );
}
if ( ! defined( 'PB_PDFINFO_COMMAND' ) ) {
define( 'PB_PDFINFO_COMMAND', '/... | [
"static",
"public",
"function",
"commandLineDefaults",
"(",
")",
"{",
"if",
"(",
"!",
"defined",
"(",
"'PB_CONVERT_COMMAND'",
")",
")",
"{",
"define",
"(",
"'PB_CONVERT_COMMAND'",
",",
"'/usr/bin/convert'",
")",
";",
"}",
"if",
"(",
"!",
"defined",
"(",
"'PB... | Set defaults for command line utilities | [
"Set",
"defaults",
"for",
"command",
"line",
"utilities"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/covergenerator/class-covergenerator.php#L47-L63 |
pressbooks/pressbooks | inc/modules/export/class-export.php | Export.getExportStylePath | function getExportStylePath( $type ) {
$fullpath = false;
if ( CustomCss::isCustomCss() ) {
$fullpath = CustomCss::getCustomCssFolder() . "$type.css";
if ( ! is_file( $fullpath ) ) {
$fullpath = false;
}
}
if ( ! $fullpath ) {
// Look for SCSS file
$fullpath = Container::get( 'Styles' )->g... | php | function getExportStylePath( $type ) {
$fullpath = false;
if ( CustomCss::isCustomCss() ) {
$fullpath = CustomCss::getCustomCssFolder() . "$type.css";
if ( ! is_file( $fullpath ) ) {
$fullpath = false;
}
}
if ( ! $fullpath ) {
// Look for SCSS file
$fullpath = Container::get( 'Styles' )->g... | [
"function",
"getExportStylePath",
"(",
"$",
"type",
")",
"{",
"$",
"fullpath",
"=",
"false",
";",
"if",
"(",
"CustomCss",
"::",
"isCustomCss",
"(",
")",
")",
"{",
"$",
"fullpath",
"=",
"CustomCss",
"::",
"getCustomCssFolder",
"(",
")",
".",
"\"$type.css\""... | Return the fullpath to an export module's style file.
@param string $type
@return string | [
"Return",
"the",
"fullpath",
"to",
"an",
"export",
"module",
"s",
"style",
"file",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-export.php#L114-L136 |
pressbooks/pressbooks | inc/modules/export/class-export.php | Export.truncateExportStylesheets | function truncateExportStylesheets( $type, $max = 1 ) {
// This method only supports Prince stylesheets at the moment.
if ( in_array( $type, [ 'prince' ], true ) ) {
$stylesheets = scandir_by_date( Container::get( 'Sass' )->pathToUserGeneratedCss() );
$max = absint( $max );
$i = 1;
foreach ( $stylesheet... | php | function truncateExportStylesheets( $type, $max = 1 ) {
// This method only supports Prince stylesheets at the moment.
if ( in_array( $type, [ 'prince' ], true ) ) {
$stylesheets = scandir_by_date( Container::get( 'Sass' )->pathToUserGeneratedCss() );
$max = absint( $max );
$i = 1;
foreach ( $stylesheet... | [
"function",
"truncateExportStylesheets",
"(",
"$",
"type",
",",
"$",
"max",
"=",
"1",
")",
"{",
"// This method only supports Prince stylesheets at the moment.",
"if",
"(",
"in_array",
"(",
"$",
"type",
",",
"[",
"'prince'",
"]",
",",
"true",
")",
")",
"{",
"$... | Remove all but the most recent compiled stylesheet.
@param string $type
@param int $max | [
"Remove",
"all",
"but",
"the",
"most",
"recent",
"compiled",
"stylesheet",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-export.php#L184-L199 |
pressbooks/pressbooks | inc/modules/export/class-export.php | Export.getExportScriptPath | function getExportScriptPath( $type ) {
$fullpath = false;
if ( CustomCss::isCustomCss() ) {
$fullpath = CustomCss::getCustomCssFolder() . "/$type.js";
if ( ! is_file( $fullpath ) ) {
$fullpath = false;
}
}
if ( ! $fullpath ) {
$dir = Container::get( 'Styles' )->getDir();
if ( Container::g... | php | function getExportScriptPath( $type ) {
$fullpath = false;
if ( CustomCss::isCustomCss() ) {
$fullpath = CustomCss::getCustomCssFolder() . "/$type.js";
if ( ! is_file( $fullpath ) ) {
$fullpath = false;
}
}
if ( ! $fullpath ) {
$dir = Container::get( 'Styles' )->getDir();
if ( Container::g... | [
"function",
"getExportScriptPath",
"(",
"$",
"type",
")",
"{",
"$",
"fullpath",
"=",
"false",
";",
"if",
"(",
"CustomCss",
"::",
"isCustomCss",
"(",
")",
")",
"{",
"$",
"fullpath",
"=",
"CustomCss",
"::",
"getCustomCssFolder",
"(",
")",
".",
"\"/$type.js\"... | Return the fullpath to an export module's Javascript file.
@param string $type
@return string | [
"Return",
"the",
"fullpath",
"to",
"an",
"export",
"module",
"s",
"Javascript",
"file",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-export.php#L208-L233 |
pressbooks/pressbooks | inc/modules/export/class-export.php | Export.getExportScriptUrl | function getExportScriptUrl( $type ) {
$url = false;
$dir = Container::get( 'Styles' )->getDir();
if ( Container::get( 'Styles' )->isCurrentThemeCompatible( 2 ) && realpath( "$dir/assets/scripts/$type/script.js" ) ) {
$url = apply_filters( 'pb_stylesheet_directory_uri', get_stylesheet_directory_uri() ) . "/a... | php | function getExportScriptUrl( $type ) {
$url = false;
$dir = Container::get( 'Styles' )->getDir();
if ( Container::get( 'Styles' )->isCurrentThemeCompatible( 2 ) && realpath( "$dir/assets/scripts/$type/script.js" ) ) {
$url = apply_filters( 'pb_stylesheet_directory_uri', get_stylesheet_directory_uri() ) . "/a... | [
"function",
"getExportScriptUrl",
"(",
"$",
"type",
")",
"{",
"$",
"url",
"=",
"false",
";",
"$",
"dir",
"=",
"Container",
"::",
"get",
"(",
"'Styles'",
")",
"->",
"getDir",
"(",
")",
";",
"if",
"(",
"Container",
"::",
"get",
"(",
"'Styles'",
")",
... | Return the public URL to an export module's Javascript file.
@param string $type
@return string | [
"Return",
"the",
"public",
"URL",
"to",
"an",
"export",
"module",
"s",
"Javascript",
"file",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-export.php#L242-L257 |
pressbooks/pressbooks | inc/modules/export/class-export.php | Export.logError | function logError( $message, array $more_info = [] ) {
/** $var \WP_User $current_user */
global $current_user;
$subject = get_class( $this );
$info = [
'time' => strftime( '%c' ),
'user' => ( isset( $current_user ) ? $current_user->user_login : '__UNKNOWN__' ),
'site_url' => site_url(),
'blog_id... | php | function logError( $message, array $more_info = [] ) {
/** $var \WP_User $current_user */
global $current_user;
$subject = get_class( $this );
$info = [
'time' => strftime( '%c' ),
'user' => ( isset( $current_user ) ? $current_user->user_login : '__UNKNOWN__' ),
'site_url' => site_url(),
'blog_id... | [
"function",
"logError",
"(",
"$",
"message",
",",
"array",
"$",
"more_info",
"=",
"[",
"]",
")",
"{",
"/** $var \\WP_User $current_user */",
"global",
"$",
"current_user",
";",
"$",
"subject",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"$",
"info",
"=",... | Log errors using wp_mail() and error_log(), include useful WordPress info.
@param string $message
@param array $more_info | [
"Log",
"errors",
"using",
"wp_mail",
"()",
"and",
"error_log",
"()",
"include",
"useful",
"WordPress",
"info",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-export.php#L281-L310 |
pressbooks/pressbooks | inc/modules/export/class-export.php | Export.verifyNonce | function verifyNonce( $timestamp, $md5 ) {
// Within range of 5 minutes?
$within_range = time() - $timestamp;
if ( $within_range > ( MINUTE_IN_SECONDS * 5 ) ) {
return false;
}
// Correct md5?
if ( md5( NONCE_KEY . $timestamp ) !== $md5 ) {
return false;
}
return true;
} | php | function verifyNonce( $timestamp, $md5 ) {
// Within range of 5 minutes?
$within_range = time() - $timestamp;
if ( $within_range > ( MINUTE_IN_SECONDS * 5 ) ) {
return false;
}
// Correct md5?
if ( md5( NONCE_KEY . $timestamp ) !== $md5 ) {
return false;
}
return true;
} | [
"function",
"verifyNonce",
"(",
"$",
"timestamp",
",",
"$",
"md5",
")",
"{",
"// Within range of 5 minutes?",
"$",
"within_range",
"=",
"time",
"(",
")",
"-",
"$",
"timestamp",
";",
"if",
"(",
"$",
"within_range",
">",
"(",
"MINUTE_IN_SECONDS",
"*",
"5",
"... | Verify that a NONCE was created within a range of 5 minutes and is valid.
@see nonce
@param string $timestamp unix timestamp
@param string $md5
@return bool | [
"Verify",
"that",
"a",
"NONCE",
"was",
"created",
"within",
"a",
"range",
"of",
"5",
"minutes",
"and",
"is",
"valid",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-export.php#L375-L389 |
pressbooks/pressbooks | inc/modules/export/class-export.php | Export.preProcessPostName | protected function preProcessPostName( $id ) {
if ( in_array( $id, $this->reservedIds, true ) ) {
$id = uniqid( "$id-" );
}
return \Pressbooks\Sanitize\sanitize_xml_id( $id );
} | php | protected function preProcessPostName( $id ) {
if ( in_array( $id, $this->reservedIds, true ) ) {
$id = uniqid( "$id-" );
}
return \Pressbooks\Sanitize\sanitize_xml_id( $id );
} | [
"protected",
"function",
"preProcessPostName",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"id",
",",
"$",
"this",
"->",
"reservedIds",
",",
"true",
")",
")",
"{",
"$",
"id",
"=",
"uniqid",
"(",
"\"$id-\"",
")",
";",
"}",
"return",
"... | Check a post_name against a list of reserved IDs, sanitize for use as an XML ID.
@param string $id
@return string | [
"Check",
"a",
"post_name",
"against",
"a",
"list",
"of",
"reserved",
"IDs",
"sanitize",
"for",
"use",
"as",
"an",
"XML",
"ID",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-export.php#L418-L425 |
pressbooks/pressbooks | inc/modules/export/class-export.php | Export.createTmpDir | protected function createTmpDir() {
$temp_file = tempnam( sys_get_temp_dir(), '' );
@unlink( $temp_file ); // @codingStandardsIgnoreLine
mkdir( $temp_file );
if ( ! is_dir( $temp_file ) ) {
return '';
}
return untrailingslashit( $temp_file );
} | php | protected function createTmpDir() {
$temp_file = tempnam( sys_get_temp_dir(), '' );
@unlink( $temp_file ); // @codingStandardsIgnoreLine
mkdir( $temp_file );
if ( ! is_dir( $temp_file ) ) {
return '';
}
return untrailingslashit( $temp_file );
} | [
"protected",
"function",
"createTmpDir",
"(",
")",
"{",
"$",
"temp_file",
"=",
"tempnam",
"(",
"sys_get_temp_dir",
"(",
")",
",",
"''",
")",
";",
"@",
"unlink",
"(",
"$",
"temp_file",
")",
";",
"// @codingStandardsIgnoreLine",
"mkdir",
"(",
"$",
"temp_file",... | Create a temporary directory, no trailing slash!
@return string | [
"Create",
"a",
"temporary",
"directory",
"no",
"trailing",
"slash!"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-export.php#L433-L444 |
pressbooks/pressbooks | inc/modules/export/class-export.php | Export.transformXML | protected function transformXML( $content, $path_to_xsl ) {
libxml_use_internal_errors( true );
$content = iconv( 'UTF-8', 'UTF-8//IGNORE', $content );
$xsl = new \DOMDocument();
$xsl->load( $path_to_xsl );
$proc = new \XSLTProcessor();
$proc->importStyleSheet( $xsl );
$old_value = libxml_disable_enti... | php | protected function transformXML( $content, $path_to_xsl ) {
libxml_use_internal_errors( true );
$content = iconv( 'UTF-8', 'UTF-8//IGNORE', $content );
$xsl = new \DOMDocument();
$xsl->load( $path_to_xsl );
$proc = new \XSLTProcessor();
$proc->importStyleSheet( $xsl );
$old_value = libxml_disable_enti... | [
"protected",
"function",
"transformXML",
"(",
"$",
"content",
",",
"$",
"path_to_xsl",
")",
"{",
"libxml_use_internal_errors",
"(",
"true",
")",
";",
"$",
"content",
"=",
"iconv",
"(",
"'UTF-8'",
",",
"'UTF-8//IGNORE'",
",",
"$",
"content",
")",
";",
"$",
... | Convert an XML string via XSLT file.
@param string $content
@param string $path_to_xsl
@return string | [
"Convert",
"an",
"XML",
"string",
"via",
"XSLT",
"file",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-export.php#L454-L476 |
pressbooks/pressbooks | inc/modules/export/class-export.php | Export.doCopyrightLicense | protected function doCopyrightLicense( $metadata, $title = '', $id = 0, $section_author = '' ) {
if ( ! empty( $section_author ) ) {
_deprecated_argument( __METHOD__, '4.1.0' );
}
try {
$licensing = new \Pressbooks\Licensing();
return $licensing->doLicense( $metadata, $id, $title );
} catch ( \Except... | php | protected function doCopyrightLicense( $metadata, $title = '', $id = 0, $section_author = '' ) {
if ( ! empty( $section_author ) ) {
_deprecated_argument( __METHOD__, '4.1.0' );
}
try {
$licensing = new \Pressbooks\Licensing();
return $licensing->doLicense( $metadata, $id, $title );
} catch ( \Except... | [
"protected",
"function",
"doCopyrightLicense",
"(",
"$",
"metadata",
",",
"$",
"title",
"=",
"''",
",",
"$",
"id",
"=",
"0",
",",
"$",
"section_author",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"section_author",
")",
")",
"{",
"_deprec... | Will create an html blob of copyright, returns empty string if something goes wrong
@param array $metadata
@param string $title (optional)
@param int $id (optional)
@param string $section_author (deprecated)
@return string $html blob | [
"Will",
"create",
"an",
"html",
"blob",
"of",
"copyright",
"returns",
"empty",
"string",
"if",
"something",
"goes",
"wrong"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-export.php#L488-L501 |
pressbooks/pressbooks | inc/modules/export/class-export.php | Export.doTocLicense | protected function doTocLicense( $post_id ) {
$option = get_option( 'pressbooks_theme_options_global' );
if ( ! empty( $option['copyright_license'] ) ) {
if ( 1 === absint( $option['copyright_license'] ) ) {
$section_license = get_post_meta( $post_id, 'pb_section_license', true );
if ( ! empty( $section_... | php | protected function doTocLicense( $post_id ) {
$option = get_option( 'pressbooks_theme_options_global' );
if ( ! empty( $option['copyright_license'] ) ) {
if ( 1 === absint( $option['copyright_license'] ) ) {
$section_license = get_post_meta( $post_id, 'pb_section_license', true );
if ( ! empty( $section_... | [
"protected",
"function",
"doTocLicense",
"(",
"$",
"post_id",
")",
"{",
"$",
"option",
"=",
"get_option",
"(",
"'pressbooks_theme_options_global'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"option",
"[",
"'copyright_license'",
"]",
")",
")",
"{",
"if",
... | Returns a string of text to be used in TOC, returns empty string if user doesn't want it displayed
@param int $post_id Post ID.
@return string | [
"Returns",
"a",
"string",
"of",
"text",
"to",
"be",
"used",
"in",
"TOC",
"returns",
"empty",
"string",
"if",
"user",
"doesn",
"t",
"want",
"it",
"displayed"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-export.php#L510-L530 |
pressbooks/pressbooks | inc/modules/export/class-export.php | Export.doSectionLevelLicense | protected function doSectionLevelLicense( $metadata, $post_id ) {
$option = get_option( 'pressbooks_theme_options_global' );
if ( ! empty( $option['copyright_license'] ) ) {
if ( 1 === absint( $option['copyright_license'] ) ) {
return '';
} elseif ( 2 === absint( $option['copyright_license'] ) ) {
$se... | php | protected function doSectionLevelLicense( $metadata, $post_id ) {
$option = get_option( 'pressbooks_theme_options_global' );
if ( ! empty( $option['copyright_license'] ) ) {
if ( 1 === absint( $option['copyright_license'] ) ) {
return '';
} elseif ( 2 === absint( $option['copyright_license'] ) ) {
$se... | [
"protected",
"function",
"doSectionLevelLicense",
"(",
"$",
"metadata",
",",
"$",
"post_id",
")",
"{",
"$",
"option",
"=",
"get_option",
"(",
"'pressbooks_theme_options_global'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"option",
"[",
"'copyright_license'",
... | Returns a string of text to be used in a section (chapter, front-matter, back-matter, ...)
returns empty string if user doesn't want it displayed
@param array $metadata
@param int $post_id Post ID.
@return string | [
"Returns",
"a",
"string",
"of",
"text",
"to",
"be",
"used",
"in",
"a",
"section",
"(",
"chapter",
"front",
"-",
"matter",
"back",
"-",
"matter",
"...",
")",
"returns",
"empty",
"string",
"if",
"user",
"doesn",
"t",
"want",
"it",
"displayed"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-export.php#L541-L559 |
pressbooks/pressbooks | inc/modules/export/class-export.php | Export.loadTemplate | protected function loadTemplate( $path, array $vars = [] ) {
try {
return \Pressbooks\Utility\template( $path, $vars );
} catch ( \Exception $e ) {
if ( WP_DEBUG ) {
return "File not found: {$path}";
} else {
return '';
}
}
} | php | protected function loadTemplate( $path, array $vars = [] ) {
try {
return \Pressbooks\Utility\template( $path, $vars );
} catch ( \Exception $e ) {
if ( WP_DEBUG ) {
return "File not found: {$path}";
} else {
return '';
}
}
} | [
"protected",
"function",
"loadTemplate",
"(",
"$",
"path",
",",
"array",
"$",
"vars",
"=",
"[",
"]",
")",
"{",
"try",
"{",
"return",
"\\",
"Pressbooks",
"\\",
"Utility",
"\\",
"template",
"(",
"$",
"path",
",",
"$",
"vars",
")",
";",
"}",
"catch",
... | Simple template system.
@param string $path
@param array $vars (optional)
@return string | [
"Simple",
"template",
"system",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-export.php#L569-L579 |
pressbooks/pressbooks | inc/modules/export/class-export.php | Export.getExportFolder | static function getExportFolder() {
$path = \Pressbooks\Utility\get_media_prefix() . 'exports/';
if ( ! file_exists( $path ) ) {
wp_mkdir_p( $path );
}
$path_to_htaccess = $path . '.htaccess';
if ( ! file_exists( $path_to_htaccess ) ) {
// Restrict access
\Pressbooks\Utility\put_contents( $path_to_... | php | static function getExportFolder() {
$path = \Pressbooks\Utility\get_media_prefix() . 'exports/';
if ( ! file_exists( $path ) ) {
wp_mkdir_p( $path );
}
$path_to_htaccess = $path . '.htaccess';
if ( ! file_exists( $path_to_htaccess ) ) {
// Restrict access
\Pressbooks\Utility\put_contents( $path_to_... | [
"static",
"function",
"getExportFolder",
"(",
")",
"{",
"$",
"path",
"=",
"\\",
"Pressbooks",
"\\",
"Utility",
"\\",
"get_media_prefix",
"(",
")",
".",
"'exports/'",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"wp_mkdir_p",
"(",
... | Get the fullpath to the Exports folder.
Create if not there. Create .htaccess protection if missing.
@return string fullpath | [
"Get",
"the",
"fullpath",
"to",
"the",
"Exports",
"folder",
".",
"Create",
"if",
"not",
"there",
".",
"Create",
".",
"htaccess",
"protection",
"if",
"missing",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-export.php#L600-L624 |
pressbooks/pressbooks | inc/modules/export/class-export.php | Export.formSubmit | static function formSubmit() {
if ( false === static::isFormSubmission() || false === current_user_can( 'edit_posts' ) ) {
// Don't do anything in this function, bail.
return;
}
// Override some WP behaviours when exporting
\Pressbooks\Sanitize\fix_audio_shortcode();
// Download
if ( ! empty( $_GET... | php | static function formSubmit() {
if ( false === static::isFormSubmission() || false === current_user_can( 'edit_posts' ) ) {
// Don't do anything in this function, bail.
return;
}
// Override some WP behaviours when exporting
\Pressbooks\Sanitize\fix_audio_shortcode();
// Download
if ( ! empty( $_GET... | [
"static",
"function",
"formSubmit",
"(",
")",
"{",
"if",
"(",
"false",
"===",
"static",
"::",
"isFormSubmission",
"(",
")",
"||",
"false",
"===",
"current_user_can",
"(",
"'edit_posts'",
")",
")",
"{",
"// Don't do anything in this function, bail.",
"return",
";",... | Catch form submissions
@see pressbooks/templates/admin/export.php | [
"Catch",
"form",
"submissions"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-export.php#L632-L648 |
pressbooks/pressbooks | inc/modules/export/class-export.php | Export.preExport | static function preExport() {
/**
* Let other plugins tweak things before exporting
*
* @since 4.4.0
*/
do_action( 'pb_pre_export' );
// --------------------------------------------------------------------------------------------------------
// Clear cache? Range is 1 hour.
$last_export = get_op... | php | static function preExport() {
/**
* Let other plugins tweak things before exporting
*
* @since 4.4.0
*/
do_action( 'pb_pre_export' );
// --------------------------------------------------------------------------------------------------------
// Clear cache? Range is 1 hour.
$last_export = get_op... | [
"static",
"function",
"preExport",
"(",
")",
"{",
"/**\n\t\t * Let other plugins tweak things before exporting\n\t\t *\n\t\t * @since 4.4.0\n\t\t */",
"do_action",
"(",
"'pb_pre_export'",
")",
";",
"// ------------------------------------------------------------------------------------------... | Pre-Export | [
"Pre",
"-",
"Export"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-export.php#L653-L672 |
pressbooks/pressbooks | inc/modules/export/class-export.php | Export.modules | static function modules() {
$modules = [];
if ( is_array( getset( '_GET', 'export_formats' ) ) && check_admin_referer( 'pb-export' ) ) {
// --------------------------------------------------------------------------------------------------------
// Define modules
$x = $_GET['export_formats'];
if ( iss... | php | static function modules() {
$modules = [];
if ( is_array( getset( '_GET', 'export_formats' ) ) && check_admin_referer( 'pb-export' ) ) {
// --------------------------------------------------------------------------------------------------------
// Define modules
$x = $_GET['export_formats'];
if ( iss... | [
"static",
"function",
"modules",
"(",
")",
"{",
"$",
"modules",
"=",
"[",
"]",
";",
"if",
"(",
"is_array",
"(",
"getset",
"(",
"'_GET'",
",",
"'export_formats'",
")",
")",
"&&",
"check_admin_referer",
"(",
"'pb-export'",
")",
")",
"{",
"// ----------------... | Define modules
@return array | [
"Define",
"modules"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-export.php#L679-L748 |
pressbooks/pressbooks | inc/modules/export/class-export.php | Export.exportGenerator | static function exportGenerator( $modules ) : \Generator {
/**
* Maximum execution time, in seconds. If set to zero, no time limit
* Overrides PHP's max_execution_time of a Nginx->PHP-FPM->PHP configuration
* See also request_terminate_timeout (PHP-FPM) and fastcgi_read_timeout (Nginx)
*
* @since 5.6.0... | php | static function exportGenerator( $modules ) : \Generator {
/**
* Maximum execution time, in seconds. If set to zero, no time limit
* Overrides PHP's max_execution_time of a Nginx->PHP-FPM->PHP configuration
* See also request_terminate_timeout (PHP-FPM) and fastcgi_read_timeout (Nginx)
*
* @since 5.6.0... | [
"static",
"function",
"exportGenerator",
"(",
"$",
"modules",
")",
":",
"\\",
"Generator",
"{",
"/**\n\t\t * Maximum execution time, in seconds. If set to zero, no time limit\n\t\t * Overrides PHP's max_execution_time of a Nginx->PHP-FPM->PHP configuration\n\t\t * See also request_terminate_ti... | @param array $modules
@return \Generator | [
"@param",
"array",
"$modules"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-export.php#L755-L823 |
pressbooks/pressbooks | inc/modules/export/class-export.php | Export.postExport | static function postExport() {
$conversion_error = static::$exportConversionError;
$validation_warning = static::$exportValidationWarning;
$outputs = static::$exportOutputs;
delete_transient( 'dirsize_cache' ); /** @see get_dirsize() */
if ( static::$switchedLocale ) {
restore_previous_locale();
}
... | php | static function postExport() {
$conversion_error = static::$exportConversionError;
$validation_warning = static::$exportValidationWarning;
$outputs = static::$exportOutputs;
delete_transient( 'dirsize_cache' ); /** @see get_dirsize() */
if ( static::$switchedLocale ) {
restore_previous_locale();
}
... | [
"static",
"function",
"postExport",
"(",
")",
"{",
"$",
"conversion_error",
"=",
"static",
"::",
"$",
"exportConversionError",
";",
"$",
"validation_warning",
"=",
"static",
"::",
"$",
"exportValidationWarning",
";",
"$",
"outputs",
"=",
"static",
"::",
"$",
"... | Post Export | [
"Post",
"Export"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-export.php#L828-L899 |
pressbooks/pressbooks | inc/modules/export/class-export.php | Export.isFormSubmission | static function isFormSubmission() {
if ( empty( $_REQUEST['page'] ) ) {
return false;
}
if ( 'pb_export' !== $_REQUEST['page'] ) {
return false;
}
if ( $_SERVER['REQUEST_METHOD'] === 'POST' ) {
return true;
}
if ( count( $_GET ) > 1 ) {
return true;
}
return false;
} | php | static function isFormSubmission() {
if ( empty( $_REQUEST['page'] ) ) {
return false;
}
if ( 'pb_export' !== $_REQUEST['page'] ) {
return false;
}
if ( $_SERVER['REQUEST_METHOD'] === 'POST' ) {
return true;
}
if ( count( $_GET ) > 1 ) {
return true;
}
return false;
} | [
"static",
"function",
"isFormSubmission",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"_REQUEST",
"[",
"'page'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"'pb_export'",
"!==",
"$",
"_REQUEST",
"[",
"'page'",
"]",
")",
"{",
"return... | Check if a user submitted something to admin.php?page=pb_export
@return bool | [
"Check",
"if",
"a",
"user",
"submitted",
"something",
"to",
"admin",
".",
"php?page",
"=",
"pb_export"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-export.php#L928-L947 |
pressbooks/pressbooks | inc/modules/export/class-export.php | Export.downloadExportFile | protected static function downloadExportFile( $filename, $inline ) {
$filepath = static::getExportFolder() . $filename;
\Pressbooks\Redirect\force_download( $filepath, $inline );
} | php | protected static function downloadExportFile( $filename, $inline ) {
$filepath = static::getExportFolder() . $filename;
\Pressbooks\Redirect\force_download( $filepath, $inline );
} | [
"protected",
"static",
"function",
"downloadExportFile",
"(",
"$",
"filename",
",",
"$",
"inline",
")",
"{",
"$",
"filepath",
"=",
"static",
"::",
"getExportFolder",
"(",
")",
".",
"$",
"filename",
";",
"\\",
"Pressbooks",
"\\",
"Redirect",
"\\",
"force_down... | Download an .htaccess protected file from the exports directory.
@param string $filename sanitized $_GET['download_export_file']
@param bool $inline | [
"Download",
"an",
".",
"htaccess",
"protected",
"file",
"from",
"the",
"exports",
"directory",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-export.php#L956-L959 |
pressbooks/pressbooks | symbionts/custom-metadata/custom_metadata.php | custom_metadata_manager._order_multi_select | function _order_multi_select( array $terms, array $value ) {
$ordered_terms = [];
foreach ( $value as $slug ) {
foreach ( $terms as $value_slug => $value_label ) {
if ( $value_slug === $slug ) {
$ordered_terms[ $value_slug ] = $value_label;
unset( $terms[ $value_slug ] );
continue;
}
}
... | php | function _order_multi_select( array $terms, array $value ) {
$ordered_terms = [];
foreach ( $value as $slug ) {
foreach ( $terms as $value_slug => $value_label ) {
if ( $value_slug === $slug ) {
$ordered_terms[ $value_slug ] = $value_label;
unset( $terms[ $value_slug ] );
continue;
}
}
... | [
"function",
"_order_multi_select",
"(",
"array",
"$",
"terms",
",",
"array",
"$",
"value",
")",
"{",
"$",
"ordered_terms",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"slug",
")",
"{",
"foreach",
"(",
"$",
"terms",
"as",
"$",
"value_... | Fix: In multi-select, selections do not appear in the order in which they were selected
@see https://github.com/select2/select2/issues/3106#issuecomment-339594053
@param array $terms
@param array $value
@return array | [
"Fix",
":",
"In",
"multi",
"-",
"select",
"selections",
"do",
"not",
"appear",
"in",
"the",
"order",
"in",
"which",
"they",
"were",
"selected"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/symbionts/custom-metadata/custom_metadata.php#L1422-L1434 |
pressbooks/pressbooks | symbionts/custom-metadata/custom_metadata.php | custom_metadata_manager._order_taxonomy_multi_select | function _order_taxonomy_multi_select( array $terms, array $value ) {
$ordered_terms = [];
foreach ( $value as $slug ) {
foreach ( $terms as $i => $term ) {
if ( $term->slug === $slug ) {
$ordered_terms[] = $term;
unset( $terms[ $i ] );
continue;
}
}
}
return array_merge( $ordered_t... | php | function _order_taxonomy_multi_select( array $terms, array $value ) {
$ordered_terms = [];
foreach ( $value as $slug ) {
foreach ( $terms as $i => $term ) {
if ( $term->slug === $slug ) {
$ordered_terms[] = $term;
unset( $terms[ $i ] );
continue;
}
}
}
return array_merge( $ordered_t... | [
"function",
"_order_taxonomy_multi_select",
"(",
"array",
"$",
"terms",
",",
"array",
"$",
"value",
")",
"{",
"$",
"ordered_terms",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"slug",
")",
"{",
"foreach",
"(",
"$",
"terms",
"as",
"$",
... | Fix: In multi-select, selections do not appear in the order in which they were selected
@see https://github.com/select2/select2/issues/3106#issuecomment-339594053
@param \WP_Term[] $terms
@param array $value
@return array | [
"Fix",
":",
"In",
"multi",
"-",
"select",
"selections",
"do",
"not",
"appear",
"in",
"the",
"order",
"in",
"which",
"they",
"were",
"selected"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/symbionts/custom-metadata/custom_metadata.php#L1446-L1458 |
pressbooks/pressbooks | inc/class-updates.php | Updates.gitHubUpdater | public function gitHubUpdater() {
static $updater = null;
if ( $updater === null ) {
$updater = \Puc_v4_Factory::buildUpdateChecker(
'https://github.com/pressbooks/pressbooks/',
untrailingslashit( PB_PLUGIN_DIR ) . '/pressbooks.php', // Fully qualified path to the main plugin file
'pressbooks',
2... | php | public function gitHubUpdater() {
static $updater = null;
if ( $updater === null ) {
$updater = \Puc_v4_Factory::buildUpdateChecker(
'https://github.com/pressbooks/pressbooks/',
untrailingslashit( PB_PLUGIN_DIR ) . '/pressbooks.php', // Fully qualified path to the main plugin file
'pressbooks',
2... | [
"public",
"function",
"gitHubUpdater",
"(",
")",
"{",
"static",
"$",
"updater",
"=",
"null",
";",
"if",
"(",
"$",
"updater",
"===",
"null",
")",
"{",
"$",
"updater",
"=",
"\\",
"Puc_v4_Factory",
"::",
"buildUpdateChecker",
"(",
"'https://github.com/pressbooks/... | GitHub Plugin Update Checker
Hooked into action `plugins_loaded`
@see https://github.com/YahnisElsts/plugin-update-checker | [
"GitHub",
"Plugin",
"Update",
"Checker",
"Hooked",
"into",
"action",
"plugins_loaded"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-updates.php#L61-L73 |
pressbooks/pressbooks | inc/class-updates.php | Updates.inPluginUpdateMessage | public function inPluginUpdateMessage( $plugin_data ) {
$untested_plugins = $this->getUntestedPlugins( $plugin_data['new_version'] );
if ( ! empty( $untested_plugins ) ) {
echo $this->blade->render(
'admin.incompatible-plugins', [
'version' => $plugin_data['new_version'],
'plugins' => $untested_plu... | php | public function inPluginUpdateMessage( $plugin_data ) {
$untested_plugins = $this->getUntestedPlugins( $plugin_data['new_version'] );
if ( ! empty( $untested_plugins ) ) {
echo $this->blade->render(
'admin.incompatible-plugins', [
'version' => $plugin_data['new_version'],
'plugins' => $untested_plu... | [
"public",
"function",
"inPluginUpdateMessage",
"(",
"$",
"plugin_data",
")",
"{",
"$",
"untested_plugins",
"=",
"$",
"this",
"->",
"getUntestedPlugins",
"(",
"$",
"plugin_data",
"[",
"'new_version'",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"unteste... | Check for incompatible plugins.
Displayed when user is looking at wp-admin/plugins.php
Hooked into action `in_plugin_update_message-{$file}`
@see \wp_plugin_update_row
@param array $plugin_data An array of plugin metadata | [
"Check",
"for",
"incompatible",
"plugins",
".",
"Displayed",
"when",
"user",
"is",
"looking",
"at",
"wp",
"-",
"admin",
"/",
"plugins",
".",
"php",
"Hooked",
"into",
"action",
"in_plugin_update_message",
"-",
"{",
"$file",
"}",
"@see",
"\\",
"wp_plugin_update_... | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-updates.php#L83-L95 |
pressbooks/pressbooks | inc/class-updates.php | Updates.coreUpgradePreamble | public function coreUpgradePreamble() {
$basename = $this->getBaseName();
$updateable_plugins = get_plugin_updates();
if ( $updateable_plugins[ $basename ]->update->new_version ?? null ) {
$plugin_data = $updateable_plugins[ $basename ]; // $plugin_data is in \stdClass format
} else {
return; // Bail
}
... | php | public function coreUpgradePreamble() {
$basename = $this->getBaseName();
$updateable_plugins = get_plugin_updates();
if ( $updateable_plugins[ $basename ]->update->new_version ?? null ) {
$plugin_data = $updateable_plugins[ $basename ]; // $plugin_data is in \stdClass format
} else {
return; // Bail
}
... | [
"public",
"function",
"coreUpgradePreamble",
"(",
")",
"{",
"$",
"basename",
"=",
"$",
"this",
"->",
"getBaseName",
"(",
")",
";",
"$",
"updateable_plugins",
"=",
"get_plugin_updates",
"(",
")",
";",
"if",
"(",
"$",
"updateable_plugins",
"[",
"$",
"basename"... | Check for incompatible plugins.
Displayed when user is looking at wp-admin/update-core.php
Hooked into action `core_upgrade_preamble` | [
"Check",
"for",
"incompatible",
"plugins",
".",
"Displayed",
"when",
"user",
"is",
"looking",
"at",
"wp",
"-",
"admin",
"/",
"update",
"-",
"core",
".",
"php",
"Hooked",
"into",
"action",
"core_upgrade_preamble"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-updates.php#L102-L122 |
pressbooks/pressbooks | inc/class-updates.php | Updates.getPluginsWithHeader | public function getPluginsWithHeader( $header ) {
$plugins = get_plugins();
$matches = [];
foreach ( $plugins as $file => $plugin ) {
if ( $plugin['Name'] === 'Pressbooks' ) {
continue; // Fix Pluginception...
}
if ( ! empty( $plugin[ $header ] ) ) {
$matches[ $file ] = $plugin;
}
}
return... | php | public function getPluginsWithHeader( $header ) {
$plugins = get_plugins();
$matches = [];
foreach ( $plugins as $file => $plugin ) {
if ( $plugin['Name'] === 'Pressbooks' ) {
continue; // Fix Pluginception...
}
if ( ! empty( $plugin[ $header ] ) ) {
$matches[ $file ] = $plugin;
}
}
return... | [
"public",
"function",
"getPluginsWithHeader",
"(",
"$",
"header",
")",
"{",
"$",
"plugins",
"=",
"get_plugins",
"(",
")",
";",
"$",
"matches",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"file",
"=>",
"$",
"plugin",
")",
"{",
"if",... | Get plugins that have a specific header
@param string $header
@return array of plugin info arrays | [
"Get",
"plugins",
"that",
"have",
"a",
"specific",
"header"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-updates.php#L183-L195 |
pressbooks/pressbooks | inc/class-updates.php | Updates.getPluginsWithPressbooksInDescription | public function getPluginsWithPressbooksInDescription() {
$plugins = get_plugins();
$matches = [];
foreach ( $plugins as $file => $plugin ) {
if ( $plugin['Name'] === 'Pressbooks' ) {
continue; // Fix Pluginception...
}
if ( stristr( $plugin['Name'], 'pressbooks' ) || stristr( $plugin['Description'],... | php | public function getPluginsWithPressbooksInDescription() {
$plugins = get_plugins();
$matches = [];
foreach ( $plugins as $file => $plugin ) {
if ( $plugin['Name'] === 'Pressbooks' ) {
continue; // Fix Pluginception...
}
if ( stristr( $plugin['Name'], 'pressbooks' ) || stristr( $plugin['Description'],... | [
"public",
"function",
"getPluginsWithPressbooksInDescription",
"(",
")",
"{",
"$",
"plugins",
"=",
"get_plugins",
"(",
")",
";",
"$",
"matches",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"file",
"=>",
"$",
"plugin",
")",
"{",
"if",
... | Get plugins with "Pressbooks" in the description
@return array of plugin info arrays | [
"Get",
"plugins",
"with",
"Pressbooks",
"in",
"the",
"description"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-updates.php#L202-L214 |
pressbooks/pressbooks | inc/shortcodes/glossary/class-glossary.php | Glossary.addTooltipScripts | public function addTooltipScripts() {
if ( ! is_admin() ) {
$assets = new Assets( 'pressbooks', 'plugin' );
wp_enqueue_script( 'glossary-tooltip', $assets->getPath( 'scripts/glossary-tooltip.js' ), false, null, true );
wp_enqueue_style( 'glossary-tooltip', $assets->getPath( 'styles/glossary-tooltip.css' ), f... | php | public function addTooltipScripts() {
if ( ! is_admin() ) {
$assets = new Assets( 'pressbooks', 'plugin' );
wp_enqueue_script( 'glossary-tooltip', $assets->getPath( 'scripts/glossary-tooltip.js' ), false, null, true );
wp_enqueue_style( 'glossary-tooltip', $assets->getPath( 'styles/glossary-tooltip.css' ), f... | [
"public",
"function",
"addTooltipScripts",
"(",
")",
"{",
"if",
"(",
"!",
"is_admin",
"(",
")",
")",
"{",
"$",
"assets",
"=",
"new",
"Assets",
"(",
"'pressbooks'",
",",
"'plugin'",
")",
";",
"wp_enqueue_script",
"(",
"'glossary-tooltip'",
",",
"$",
"assets... | Add JavaScript for the tooltip
@since 5.5.0 | [
"Add",
"JavaScript",
"for",
"the",
"tooltip"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/shortcodes/glossary/class-glossary.php#L74-L80 |
pressbooks/pressbooks | inc/shortcodes/glossary/class-glossary.php | Glossary.getGlossaryTerms | public function getGlossaryTerms( $reset = false ) {
// Cheap cache
static $glossary_terms = null;
if ( $reset || $glossary_terms === null ) {
$glossary_terms = [];
$args = [
'post_type' => 'glossary',
'posts_per_page' => -1, // @codingStandardsIgnoreLine
'post_status' => [ 'private', 'publish' ... | php | public function getGlossaryTerms( $reset = false ) {
// Cheap cache
static $glossary_terms = null;
if ( $reset || $glossary_terms === null ) {
$glossary_terms = [];
$args = [
'post_type' => 'glossary',
'posts_per_page' => -1, // @codingStandardsIgnoreLine
'post_status' => [ 'private', 'publish' ... | [
"public",
"function",
"getGlossaryTerms",
"(",
"$",
"reset",
"=",
"false",
")",
"{",
"// Cheap cache",
"static",
"$",
"glossary_terms",
"=",
"null",
";",
"if",
"(",
"$",
"reset",
"||",
"$",
"glossary_terms",
"===",
"null",
")",
"{",
"$",
"glossary_terms",
... | Gets the instance variable of glossary terms, returns as an array of
key = post_title, id = post ID, content = post_content. Sets an instance variable
@param bool $reset (optional, default is false)
@since 5.5.0
@return array | [
"Gets",
"the",
"instance",
"variable",
"of",
"glossary",
"terms",
"returns",
"as",
"an",
"array",
"of",
"key",
"=",
"post_title",
"id",
"=",
"post",
"ID",
"content",
"=",
"post_content",
".",
"Sets",
"an",
"instance",
"variable"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/shortcodes/glossary/class-glossary.php#L92-L121 |
pressbooks/pressbooks | inc/shortcodes/glossary/class-glossary.php | Glossary.getGlossaryTermsListbox | public function getGlossaryTermsListbox( $reset = false ) {
$values[] = [
'text' => '-- ' . __( 'Select', 'pressbooks' ) . ' --',
'value' => '',
];
$terms = $this->getGlossaryTerms( $reset );
foreach ( $terms as $title => $term ) {
$values[] = [
'text' => \Pressbooks\Sanitize\decode( $title ),
... | php | public function getGlossaryTermsListbox( $reset = false ) {
$values[] = [
'text' => '-- ' . __( 'Select', 'pressbooks' ) . ' --',
'value' => '',
];
$terms = $this->getGlossaryTerms( $reset );
foreach ( $terms as $title => $term ) {
$values[] = [
'text' => \Pressbooks\Sanitize\decode( $title ),
... | [
"public",
"function",
"getGlossaryTermsListbox",
"(",
"$",
"reset",
"=",
"false",
")",
"{",
"$",
"values",
"[",
"]",
"=",
"[",
"'text'",
"=>",
"'-- '",
".",
"__",
"(",
"'Select'",
",",
"'pressbooks'",
")",
".",
"' --'",
",",
"'value'",
"=>",
"''",
",",... | For tiny mce
Get both published and private terms
@param bool $reset (optional, default is false)
@return string | [
"For",
"tiny",
"mce",
"Get",
"both",
"published",
"and",
"private",
"terms"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/shortcodes/glossary/class-glossary.php#L131-L144 |
pressbooks/pressbooks | inc/shortcodes/glossary/class-glossary.php | Glossary.glossaryTerms | public function glossaryTerms( $type = '' ) {
$output = '';
$glossary = '';
$glossary_terms = $this->getGlossaryTerms();
if ( empty( $glossary_terms ) ) {
return '';
}
// make sure they are sorted in alphabetical order
$ok = ksort( $glossary_terms, SORT_LOCALE_STRING );
if ( true === $ok && count(... | php | public function glossaryTerms( $type = '' ) {
$output = '';
$glossary = '';
$glossary_terms = $this->getGlossaryTerms();
if ( empty( $glossary_terms ) ) {
return '';
}
// make sure they are sorted in alphabetical order
$ok = ksort( $glossary_terms, SORT_LOCALE_STRING );
if ( true === $ok && count(... | [
"public",
"function",
"glossaryTerms",
"(",
"$",
"type",
"=",
"''",
")",
"{",
"$",
"output",
"=",
"''",
";",
"$",
"glossary",
"=",
"''",
";",
"$",
"glossary_terms",
"=",
"$",
"this",
"->",
"getGlossaryTerms",
"(",
")",
";",
"if",
"(",
"empty",
"(",
... | Returns the HTML <dl> description list of all !published! glossary terms
@since 5.5.0
@see \Pressbooks\HTMLBook\Component\Glossary
@param string $type The slug of an entry in the Glossary Types taxonomy
@return string | [
"Returns",
"the",
"HTML",
"<dl",
">",
"description",
"list",
"of",
"all",
"!published!",
"glossary",
"terms"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/shortcodes/glossary/class-glossary.php#L156-L188 |
pressbooks/pressbooks | inc/shortcodes/glossary/class-glossary.php | Glossary.glossaryTooltip | public function glossaryTooltip( $glossary_term_id, $content ) {
global $id; // This is the Post ID, [@see WP_Query::setup_postdata, ...]
// Get the glossary post object the glossary term ID belongs to
$glossary_term = get_post( $glossary_term_id );
if ( ! $glossary_term ) {
return $content . 'no post';
... | php | public function glossaryTooltip( $glossary_term_id, $content ) {
global $id; // This is the Post ID, [@see WP_Query::setup_postdata, ...]
// Get the glossary post object the glossary term ID belongs to
$glossary_term = get_post( $glossary_term_id );
if ( ! $glossary_term ) {
return $content . 'no post';
... | [
"public",
"function",
"glossaryTooltip",
"(",
"$",
"glossary_term_id",
",",
"$",
"content",
")",
"{",
"global",
"$",
"id",
";",
"// This is the Post ID, [@see WP_Query::setup_postdata, ...]",
"// Get the glossary post object the glossary term ID belongs to",
"$",
"glossary_term",... | Returns the tooltip markup and content
@since 5.5.0
@param int $glossary_term_id
@param string $content
@return string | [
"Returns",
"the",
"tooltip",
"markup",
"and",
"content"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/shortcodes/glossary/class-glossary.php#L200-L216 |
pressbooks/pressbooks | inc/shortcodes/glossary/class-glossary.php | Glossary.webShortcodeHandler | public function webShortcodeHandler( $atts, $content ) {
global $id; // This is the Post ID, [@see WP_Query::setup_postdata, ...]
$a = shortcode_atts(
[
'id' => '',
'type' => '',
], $atts
);
if ( ! empty( $content ) ) {
// This is a tooltip
if ( $a['id'] ) {
if ( ! isset( $this->gloss... | php | public function webShortcodeHandler( $atts, $content ) {
global $id; // This is the Post ID, [@see WP_Query::setup_postdata, ...]
$a = shortcode_atts(
[
'id' => '',
'type' => '',
], $atts
);
if ( ! empty( $content ) ) {
// This is a tooltip
if ( $a['id'] ) {
if ( ! isset( $this->gloss... | [
"public",
"function",
"webShortcodeHandler",
"(",
"$",
"atts",
",",
"$",
"content",
")",
"{",
"global",
"$",
"id",
";",
"// This is the Post ID, [@see WP_Query::setup_postdata, ...]",
"$",
"a",
"=",
"shortcode_atts",
"(",
"[",
"'id'",
"=>",
"''",
",",
"'type'",
... | Webbook shortcode
Gets the tooltip if the param contains the post id,
or a list of terms if it's just the short-code
@since 5.5.0
@param array $atts
@param string $content
@return string | [
"Webbook",
"shortcode",
"Gets",
"the",
"tooltip",
"if",
"the",
"param",
"contains",
"the",
"post",
"id",
"or",
"a",
"list",
"of",
"terms",
"if",
"it",
"s",
"just",
"the",
"short",
"-",
"code"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/shortcodes/glossary/class-glossary.php#L230-L259 |
pressbooks/pressbooks | inc/shortcodes/glossary/class-glossary.php | Glossary.tooltipContent | function tooltipContent( $content ) {
global $id; // This is the Post ID, [@see WP_Query::setup_postdata, ...]
if ( ! empty( $this->glossaryTerms ) && isset( $this->glossaryTerms[ $id ] ) ) {
$glossary_terms = $this->glossaryTerms[ $id ];
} else {
return $content;
}
$content .= '<div class="glossary"... | php | function tooltipContent( $content ) {
global $id; // This is the Post ID, [@see WP_Query::setup_postdata, ...]
if ( ! empty( $this->glossaryTerms ) && isset( $this->glossaryTerms[ $id ] ) ) {
$glossary_terms = $this->glossaryTerms[ $id ];
} else {
return $content;
}
$content .= '<div class="glossary"... | [
"function",
"tooltipContent",
"(",
"$",
"content",
")",
"{",
"global",
"$",
"id",
";",
"// This is the Post ID, [@see WP_Query::setup_postdata, ...]",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"glossaryTerms",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
... | Post-process glossary shortcode, creating content for tooltips
@param $content
@return string | [
"Post",
"-",
"process",
"glossary",
"shortcode",
"creating",
"content",
"for",
"tooltips"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/shortcodes/glossary/class-glossary.php#L268-L288 |
pressbooks/pressbooks | inc/shortcodes/glossary/class-glossary.php | Glossary.sanitizeGlossaryTerm | public function sanitizeGlossaryTerm( $data ) {
if ( isset( $data['post_type'], $data['post_content'] ) && $data['post_type'] === 'glossary' ) {
$data['post_content'] = wp_kses(
$data['post_content'],
[
'a' => [
'href' => [],
'target' => [],
],
'br' => [],
'em' => [],
'... | php | public function sanitizeGlossaryTerm( $data ) {
if ( isset( $data['post_type'], $data['post_content'] ) && $data['post_type'] === 'glossary' ) {
$data['post_content'] = wp_kses(
$data['post_content'],
[
'a' => [
'href' => [],
'target' => [],
],
'br' => [],
'em' => [],
'... | [
"public",
"function",
"sanitizeGlossaryTerm",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'post_type'",
"]",
",",
"$",
"data",
"[",
"'post_content'",
"]",
")",
"&&",
"$",
"data",
"[",
"'post_type'",
"]",
"===",
"'glossary'",
... | @param array $data An array of slashed post data.
@return mixed | [
"@param",
"array",
"$data",
"An",
"array",
"of",
"slashed",
"post",
"data",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/shortcodes/glossary/class-glossary.php#L307-L324 |
pressbooks/pressbooks | inc/shortcodes/glossary/class-glossary.php | Glossary.backMatterAutoDisplay | public function backMatterAutoDisplay( $content ) {
$post = get_post();
if ( ! $post ) {
// Try to find using deprecated means
global $id;
$post = get_post( $id );
}
if ( ! $post ) {
// Unknown post
return $content;
}
if ( $post->post_type !== 'back-matter' ) {
// Post is not a back-matter... | php | public function backMatterAutoDisplay( $content ) {
$post = get_post();
if ( ! $post ) {
// Try to find using deprecated means
global $id;
$post = get_post( $id );
}
if ( ! $post ) {
// Unknown post
return $content;
}
if ( $post->post_type !== 'back-matter' ) {
// Post is not a back-matter... | [
"public",
"function",
"backMatterAutoDisplay",
"(",
"$",
"content",
")",
"{",
"$",
"post",
"=",
"get_post",
"(",
")",
";",
"if",
"(",
"!",
"$",
"post",
")",
"{",
"// Try to find using deprecated means",
"global",
"$",
"id",
";",
"$",
"post",
"=",
"get_post... | Automatically display shortcode list in Glossary back matter if content is empty
@param string $content
@return string | [
"Automatically",
"display",
"shortcode",
"list",
"in",
"Glossary",
"back",
"matter",
"if",
"content",
"is",
"empty"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/shortcodes/glossary/class-glossary.php#L333-L360 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.convert | public function convert() {
try {
foreach ( $this->convertGenerator() as $percentage => $info ) {
// Do nothing, this is a compatibility wrapper that makes the generator work like a regular function
}
} catch ( \Exception $e ) {
return false;
}
return true;
} | php | public function convert() {
try {
foreach ( $this->convertGenerator() as $percentage => $info ) {
// Do nothing, this is a compatibility wrapper that makes the generator work like a regular function
}
} catch ( \Exception $e ) {
return false;
}
return true;
} | [
"public",
"function",
"convert",
"(",
")",
"{",
"try",
"{",
"foreach",
"(",
"$",
"this",
"->",
"convertGenerator",
"(",
")",
"as",
"$",
"percentage",
"=>",
"$",
"info",
")",
"{",
"// Do nothing, this is a compatibility wrapper that makes the generator work like a regu... | Create $this->outputPath
@return bool | [
"Create",
"$this",
"-",
">",
"outputPath"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L267-L276 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.convertGenerator | public function convertGenerator() : \Generator {
yield 1 => $this->generatorPrefix . __( 'Initializing', 'pressbooks' );
// Sanity check
if ( empty( $this->tmpDir ) || ! is_dir( $this->tmpDir ) ) {
$this->logError( '$this->tmpDir must be set before calling convert().' );
throw new \Exception();
}
i... | php | public function convertGenerator() : \Generator {
yield 1 => $this->generatorPrefix . __( 'Initializing', 'pressbooks' );
// Sanity check
if ( empty( $this->tmpDir ) || ! is_dir( $this->tmpDir ) ) {
$this->logError( '$this->tmpDir must be set before calling convert().' );
throw new \Exception();
}
i... | [
"public",
"function",
"convertGenerator",
"(",
")",
":",
"\\",
"Generator",
"{",
"yield",
"1",
"=>",
"$",
"this",
"->",
"generatorPrefix",
".",
"__",
"(",
"'Initializing'",
",",
"'pressbooks'",
")",
";",
"// Sanity check",
"if",
"(",
"empty",
"(",
"$",
"th... | Yields an estimated percentage slice of: 1 to 80
@return \Generator
@throws \Exception | [
"Yields",
"an",
"estimated",
"percentage",
"slice",
"of",
":",
"1",
"to",
"80"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L284-L330 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.validate | public function validate() {
try {
foreach ( $this->validateGenerator() as $percentage => $info ) {
// Do nothing, this is a compatibility wrapper that makes the generator work like a regular function
}
} catch ( \Exception $e ) {
return false;
}
return true;
} | php | public function validate() {
try {
foreach ( $this->validateGenerator() as $percentage => $info ) {
// Do nothing, this is a compatibility wrapper that makes the generator work like a regular function
}
} catch ( \Exception $e ) {
return false;
}
return true;
} | [
"public",
"function",
"validate",
"(",
")",
"{",
"try",
"{",
"foreach",
"(",
"$",
"this",
"->",
"validateGenerator",
"(",
")",
"as",
"$",
"percentage",
"=>",
"$",
"info",
")",
"{",
"// Do nothing, this is a compatibility wrapper that makes the generator work like a re... | Check the sanity of $this->outputPath
@return bool | [
"Check",
"the",
"sanity",
"of",
"$this",
"-",
">",
"outputPath"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L337-L346 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.validateGenerator | public function validateGenerator() : \Generator {
yield 80 => $this->generatorPrefix . __( 'Validating file', 'pressbooks' );
// Epubcheck command, (quiet flag requires version 3.0.1+)
$command = PB_EPUBCHECK_COMMAND . ' -q ' . escapeshellcmd( $this->outputPath ) . ' 2>&1';
// Execute command
$output = [];... | php | public function validateGenerator() : \Generator {
yield 80 => $this->generatorPrefix . __( 'Validating file', 'pressbooks' );
// Epubcheck command, (quiet flag requires version 3.0.1+)
$command = PB_EPUBCHECK_COMMAND . ' -q ' . escapeshellcmd( $this->outputPath ) . ' 2>&1';
// Execute command
$output = [];... | [
"public",
"function",
"validateGenerator",
"(",
")",
":",
"\\",
"Generator",
"{",
"yield",
"80",
"=>",
"$",
"this",
"->",
"generatorPrefix",
".",
"__",
"(",
"'Validating file'",
",",
"'pressbooks'",
")",
";",
"// Epubcheck command, (quiet flag requires version 3.0.1+)... | Yields an estimated percentage slice of: 80 to 100
@return \Generator
@throws \Exception | [
"Yields",
"an",
"estimated",
"percentage",
"slice",
"of",
":",
"80",
"to",
"100"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L354-L386 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.mediaType | function mediaType( $file ) {
$mime = static::mimeType( $file );
$mime = explode( ';', $mime );
$mime = trim( $mime[0] );
return $mime;
} | php | function mediaType( $file ) {
$mime = static::mimeType( $file );
$mime = explode( ';', $mime );
$mime = trim( $mime[0] );
return $mime;
} | [
"function",
"mediaType",
"(",
"$",
"file",
")",
"{",
"$",
"mime",
"=",
"static",
"::",
"mimeType",
"(",
"$",
"file",
")",
";",
"$",
"mime",
"=",
"explode",
"(",
"';'",
",",
"$",
"mime",
")",
";",
"$",
"mime",
"=",
"trim",
"(",
"$",
"mime",
"[",... | Override mimeType, get rid of '; charset=binary'
@param string $file
@return mixed|string | [
"Override",
"mimeType",
"get",
"rid",
"of",
";",
"charset",
"=",
"binary"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L418-L425 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.themeOptionsOverrides | protected function themeOptionsOverrides() {
// --------------------------------------------------------------------
// CSS
$css = '';
$this->cssOverrides = apply_filters( 'pb_epub_css_override', $css ) . "\n";
// --------------------------------------------------------------------
// Hacks
$hacks = [... | php | protected function themeOptionsOverrides() {
// --------------------------------------------------------------------
// CSS
$css = '';
$this->cssOverrides = apply_filters( 'pb_epub_css_override', $css ) . "\n";
// --------------------------------------------------------------------
// Hacks
$hacks = [... | [
"protected",
"function",
"themeOptionsOverrides",
"(",
")",
"{",
"// --------------------------------------------------------------------",
"// CSS",
"$",
"css",
"=",
"''",
";",
"$",
"this",
"->",
"cssOverrides",
"=",
"apply_filters",
"(",
"'pb_epub_css_override'",
",",
"... | Override based on Theme Options | [
"Override",
"based",
"on",
"Theme",
"Options"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L431-L456 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.tidy | protected function tidy( $html ) {
// Make XHTML 1.1 strict using htmlLawed
$html = \Pressbooks\Interactive\Content::init()->replaceInteractiveTags( $html );
$config = [
'valid_xhtml' => 1,
'no_deprecated_attr' => 2,
'unique_ids' => 'fixme-',
'deny_attribute' => 'itemscope,itemtype,itemref,itemprop... | php | protected function tidy( $html ) {
// Make XHTML 1.1 strict using htmlLawed
$html = \Pressbooks\Interactive\Content::init()->replaceInteractiveTags( $html );
$config = [
'valid_xhtml' => 1,
'no_deprecated_attr' => 2,
'unique_ids' => 'fixme-',
'deny_attribute' => 'itemscope,itemtype,itemref,itemprop... | [
"protected",
"function",
"tidy",
"(",
"$",
"html",
")",
"{",
"// Make XHTML 1.1 strict using htmlLawed",
"$",
"html",
"=",
"\\",
"Pressbooks",
"\\",
"Interactive",
"\\",
"Content",
"::",
"init",
"(",
")",
"->",
"replaceInteractiveTags",
"(",
"$",
"html",
")",
... | Tidy HTML
@param string $html
@return string | [
"Tidy",
"HTML"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L539-L566 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.html5ToXhtml | protected function html5ToXhtml( $html ) {
$config = [
'valid_xhtml' => 1,
'unique_ids' => 0,
];
$html = \Pressbooks\HtmLawed::filter( $html, $config );
return $html;
} | php | protected function html5ToXhtml( $html ) {
$config = [
'valid_xhtml' => 1,
'unique_ids' => 0,
];
$html = \Pressbooks\HtmLawed::filter( $html, $config );
return $html;
} | [
"protected",
"function",
"html5ToXhtml",
"(",
"$",
"html",
")",
"{",
"$",
"config",
"=",
"[",
"'valid_xhtml'",
"=>",
"1",
",",
"'unique_ids'",
"=>",
"0",
",",
"]",
";",
"$",
"html",
"=",
"\\",
"Pressbooks",
"\\",
"HtmLawed",
"::",
"filter",
"(",
"$",
... | Clean up content processed by HTML5 Parser, change it back into XHTML
@param $html
@return string | [
"Clean",
"up",
"content",
"processed",
"by",
"HTML5",
"Parser",
"change",
"it",
"back",
"into",
"XHTML"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L575-L582 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.zipEpub | protected function zipEpub( $filename ) {
$zip = new \PclZip( $filename );
// Open Publication Structure 2.0.1
// mimetype must be uncompressed, unencrypted, and the first file in the ZIP archive
$list = $zip->create( $this->tmpDir . '/mimetype', PCLZIP_OPT_NO_COMPRESSION, PCLZIP_OPT_REMOVE_ALL_PATH );
if (... | php | protected function zipEpub( $filename ) {
$zip = new \PclZip( $filename );
// Open Publication Structure 2.0.1
// mimetype must be uncompressed, unencrypted, and the first file in the ZIP archive
$list = $zip->create( $this->tmpDir . '/mimetype', PCLZIP_OPT_NO_COMPRESSION, PCLZIP_OPT_REMOVE_ALL_PATH );
if (... | [
"protected",
"function",
"zipEpub",
"(",
"$",
"filename",
")",
"{",
"$",
"zip",
"=",
"new",
"\\",
"PclZip",
"(",
"$",
"filename",
")",
";",
"// Open Publication Structure 2.0.1",
"// mimetype must be uncompressed, unencrypted, and the first file in the ZIP archive",
"$",
... | Zip the contents of an EPUB following the conventions outlined in Open Publication Structure 2.0.1
@param $filename
@return bool | [
"Zip",
"the",
"contents",
"of",
"an",
"EPUB",
"following",
"the",
"conventions",
"outlined",
"in",
"Open",
"Publication",
"Structure",
"2",
".",
"0",
".",
"1"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L603-L631 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.createContainer | protected function createContainer() {
\Pressbooks\Utility\put_contents(
$this->tmpDir . '/mimetype',
utf8_decode( 'application/epub+zip' )
);
mkdir( $this->tmpDir . '/META-INF' );
mkdir( $this->tmpDir . '/OEBPS' );
mkdir( $this->tmpDir . '/OEBPS/assets' );
\Pressbooks\Utility\put_contents(
$thi... | php | protected function createContainer() {
\Pressbooks\Utility\put_contents(
$this->tmpDir . '/mimetype',
utf8_decode( 'application/epub+zip' )
);
mkdir( $this->tmpDir . '/META-INF' );
mkdir( $this->tmpDir . '/OEBPS' );
mkdir( $this->tmpDir . '/OEBPS/assets' );
\Pressbooks\Utility\put_contents(
$thi... | [
"protected",
"function",
"createContainer",
"(",
")",
"{",
"\\",
"Pressbooks",
"\\",
"Utility",
"\\",
"put_contents",
"(",
"$",
"this",
"->",
"tmpDir",
".",
"'/mimetype'",
",",
"utf8_decode",
"(",
"'application/epub+zip'",
")",
")",
";",
"mkdir",
"(",
"$",
"... | Create Open Publication Structure 2.0.1 container. | [
"Create",
"Open",
"Publication",
"Structure",
"2",
".",
"0",
".",
"1",
"container",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L637-L658 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.createOEBPSGenerator | protected function createOEBPSGenerator( $book_contents, $metadata ) : \Generator {
// First, setup and affect $this->stylesheet
yield 10 => $this->generatorPrefix . __( 'Compiling styles', 'pressbooks' );
$this->createStylesheet();
// Reset manifest
$this->manifest = [];
/* Note: order affects $this->ma... | php | protected function createOEBPSGenerator( $book_contents, $metadata ) : \Generator {
// First, setup and affect $this->stylesheet
yield 10 => $this->generatorPrefix . __( 'Compiling styles', 'pressbooks' );
$this->createStylesheet();
// Reset manifest
$this->manifest = [];
/* Note: order affects $this->ma... | [
"protected",
"function",
"createOEBPSGenerator",
"(",
"$",
"book_contents",
",",
"$",
"metadata",
")",
":",
"\\",
"Generator",
"{",
"// First, setup and affect $this->stylesheet",
"yield",
"10",
"=>",
"$",
"this",
"->",
"generatorPrefix",
".",
"__",
"(",
"'Compiling... | Yields an estimated percentage slice of: 10 to 75
Create OEBPS/* files.
@return \Generator
@throws \Exception | [
"Yields",
"an",
"estimated",
"percentage",
"slice",
"of",
":",
"10",
"to",
"75",
"Create",
"OEBPS",
"/",
"*",
"files",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L668-L717 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.createStylesheet | protected function createStylesheet() {
$this->stylesheet = strtolower( sanitize_file_name( wp_get_theme() . '.css' ) );
$path_to_tmp_stylesheet = $this->tmpDir . "/OEBPS/{$this->stylesheet}";
// Copy stylesheet
\Pressbooks\Utility\put_contents(
$path_to_tmp_stylesheet,
$this->loadTemplate( $this->expor... | php | protected function createStylesheet() {
$this->stylesheet = strtolower( sanitize_file_name( wp_get_theme() . '.css' ) );
$path_to_tmp_stylesheet = $this->tmpDir . "/OEBPS/{$this->stylesheet}";
// Copy stylesheet
\Pressbooks\Utility\put_contents(
$path_to_tmp_stylesheet,
$this->loadTemplate( $this->expor... | [
"protected",
"function",
"createStylesheet",
"(",
")",
"{",
"$",
"this",
"->",
"stylesheet",
"=",
"strtolower",
"(",
"sanitize_file_name",
"(",
"wp_get_theme",
"(",
")",
".",
"'.css'",
")",
")",
";",
"$",
"path_to_tmp_stylesheet",
"=",
"$",
"this",
"->",
"tm... | Create stylesheet. Change $this->stylesheet to a filename used by subsequent methods. | [
"Create",
"stylesheet",
".",
"Change",
"$this",
"-",
">",
"stylesheet",
"to",
"a",
"filename",
"used",
"by",
"subsequent",
"methods",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L723-L735 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.scrapeKneadAndSaveCss | protected function scrapeKneadAndSaveCss( $path_to_original_stylesheet, $path_to_copy_of_stylesheet ) {
$styles = Container::get( 'Styles' );
$scss = \Pressbooks\Utility\get_contents( $path_to_copy_of_stylesheet );
if ( $this->extraCss ) {
$scss .= "\n" . $this->loadTemplate( $this->extraCss );
}
$cust... | php | protected function scrapeKneadAndSaveCss( $path_to_original_stylesheet, $path_to_copy_of_stylesheet ) {
$styles = Container::get( 'Styles' );
$scss = \Pressbooks\Utility\get_contents( $path_to_copy_of_stylesheet );
if ( $this->extraCss ) {
$scss .= "\n" . $this->loadTemplate( $this->extraCss );
}
$cust... | [
"protected",
"function",
"scrapeKneadAndSaveCss",
"(",
"$",
"path_to_original_stylesheet",
",",
"$",
"path_to_copy_of_stylesheet",
")",
"{",
"$",
"styles",
"=",
"Container",
"::",
"get",
"(",
"'Styles'",
")",
";",
"$",
"scss",
"=",
"\\",
"Pressbooks",
"\\",
"Uti... | Parse CSS, copy assets, rewrite copy.
@param string $path_to_original_stylesheet *
@param string $path_to_copy_of_stylesheet | [
"Parse",
"CSS",
"copy",
"assets",
"rewrite",
"copy",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L744-L773 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.normalizeCssUrls | protected function normalizeCssUrls( $css, $scss_dir, $path_to_epub_assets ) {
$url_regex = '/url\(([\s])?([\"|\'])?(.*?)([\"|\'])?([\s])?\)/i';
$css = preg_replace_callback(
$url_regex, function ( $matches ) use ( $scss_dir, $path_to_epub_assets ) {
$buckram_dir = get_theme_root( 'pressbooks-book' ) . '/pr... | php | protected function normalizeCssUrls( $css, $scss_dir, $path_to_epub_assets ) {
$url_regex = '/url\(([\s])?([\"|\'])?(.*?)([\"|\'])?([\s])?\)/i';
$css = preg_replace_callback(
$url_regex, function ( $matches ) use ( $scss_dir, $path_to_epub_assets ) {
$buckram_dir = get_theme_root( 'pressbooks-book' ) . '/pr... | [
"protected",
"function",
"normalizeCssUrls",
"(",
"$",
"css",
",",
"$",
"scss_dir",
",",
"$",
"path_to_epub_assets",
")",
"{",
"$",
"url_regex",
"=",
"'/url\\(([\\s])?([\\\"|\\'])?(.*?)([\\\"|\\'])?([\\s])?\\)/i'",
";",
"$",
"css",
"=",
"preg_replace_callback",
"(",
"... | Search for all possible permutations of CSS url syntax -- url("*"), url('*'), and url(*) -- and update URLs as needed.
@param string $css The EPUB's (S)CSS content.
@param string $scss_dir The directory which contains the theme's SCSS files. No trailing slash.
@param string $path_to_epub_assets The EPUB's assets direc... | [
"Search",
"for",
"all",
"possible",
"permutations",
"of",
"CSS",
"url",
"syntax",
"--",
"url",
"(",
"*",
")",
"url",
"(",
"*",
")",
"and",
"url",
"(",
"*",
")",
"--",
"and",
"update",
"URLs",
"as",
"needed",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L784-L888 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.createFrontMatterGenerator | protected function createFrontMatterGenerator( $book_contents, $metadata ) : \Generator {
$front_matter_printf = '<div class="front-matter %1$s" id="%2$s">';
$front_matter_printf .= '<div class="front-matter-title-wrap"><h3 class="front-matter-number">%3$s</h3><h1 class="front-matter-title">%4$s</h1>%5$s</div>';
... | php | protected function createFrontMatterGenerator( $book_contents, $metadata ) : \Generator {
$front_matter_printf = '<div class="front-matter %1$s" id="%2$s">';
$front_matter_printf .= '<div class="front-matter-title-wrap"><h3 class="front-matter-number">%3$s</h3><h1 class="front-matter-title">%4$s</h1>%5$s</div>';
... | [
"protected",
"function",
"createFrontMatterGenerator",
"(",
"$",
"book_contents",
",",
"$",
"metadata",
")",
":",
"\\",
"Generator",
"{",
"$",
"front_matter_printf",
"=",
"'<div class=\"front-matter %1$s\" id=\"%2$s\">'",
";",
"$",
"front_matter_printf",
".=",
"'<div clas... | Yields an estimated percentage slice of: 30-40
@param array $book_contents
@param array $metadata
@return \Generator | [
"Yields",
"an",
"estimated",
"percentage",
"slice",
"of",
":",
"30",
"-",
"40"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L1267-L1379 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.createPartsAndChaptersGenerator | protected function createPartsAndChaptersGenerator( $book_contents, $metadata ) : \Generator {
$part_printf = '<div class="part %1$s" id="%2$s">';
$part_printf .= '<div class="part-title-wrap"><h3 class="part-number">%3$s</h3><h1 class="part-title">%4$s</h1></div>%5$s';
$part_printf .= '</div>';
$chapter_print... | php | protected function createPartsAndChaptersGenerator( $book_contents, $metadata ) : \Generator {
$part_printf = '<div class="part %1$s" id="%2$s">';
$part_printf .= '<div class="part-title-wrap"><h3 class="part-number">%3$s</h3><h1 class="part-title">%4$s</h1></div>%5$s';
$part_printf .= '</div>';
$chapter_print... | [
"protected",
"function",
"createPartsAndChaptersGenerator",
"(",
"$",
"book_contents",
",",
"$",
"metadata",
")",
":",
"\\",
"Generator",
"{",
"$",
"part_printf",
"=",
"'<div class=\"part %1$s\" id=\"%2$s\">'",
";",
"$",
"part_printf",
".=",
"'<div class=\"part-title-wrap... | Yields an estimated percentage slice of: 40-50
@param array $book_contents
@param array $metadata
@return \Generator | [
"Yields",
"an",
"estimated",
"percentage",
"slice",
"of",
":",
"40",
"-",
"50"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L1423-L1686 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.createBackMatterGenerator | protected function createBackMatterGenerator( $book_contents, $metadata ) : \Generator {
$back_matter_printf = '<div class="back-matter %1$s" id="%2$s">';
$back_matter_printf .= '<div class="back-matter-title-wrap"><h3 class="back-matter-number">%3$s</h3><h1 class="back-matter-title">%4$s</h1>%5$s</div>';
$back_m... | php | protected function createBackMatterGenerator( $book_contents, $metadata ) : \Generator {
$back_matter_printf = '<div class="back-matter %1$s" id="%2$s">';
$back_matter_printf .= '<div class="back-matter-title-wrap"><h3 class="back-matter-number">%3$s</h3><h1 class="back-matter-title">%4$s</h1>%5$s</div>';
$back_m... | [
"protected",
"function",
"createBackMatterGenerator",
"(",
"$",
"book_contents",
",",
"$",
"metadata",
")",
":",
"\\",
"Generator",
"{",
"$",
"back_matter_printf",
"=",
"'<div class=\"back-matter %1$s\" id=\"%2$s\">'",
";",
"$",
"back_matter_printf",
".=",
"'<div class=\"... | Yields an estimated percentage slice of: 50-60
@param array $book_contents
@param array $metadata
@return \Generator | [
"Yields",
"an",
"estimated",
"percentage",
"slice",
"of",
":",
"50",
"-",
"60"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L1696-L1798 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.createToc | protected function createToc( $book_contents, $metadata ) {
$vars = [
'post_title' => '',
'stylesheet' => $this->stylesheet,
'post_content' => '',
'isbn' => ( isset( $metadata['pb_ebook_isbn'] ) ) ? $metadata['pb_ebook_isbn'] : '',
'lang' => $this->lang,
];
// Start by inserting self into correct... | php | protected function createToc( $book_contents, $metadata ) {
$vars = [
'post_title' => '',
'stylesheet' => $this->stylesheet,
'post_content' => '',
'isbn' => ( isset( $metadata['pb_ebook_isbn'] ) ) ? $metadata['pb_ebook_isbn'] : '',
'lang' => $this->lang,
];
// Start by inserting self into correct... | [
"protected",
"function",
"createToc",
"(",
"$",
"book_contents",
",",
"$",
"metadata",
")",
"{",
"$",
"vars",
"=",
"[",
"'post_title'",
"=>",
"''",
",",
"'stylesheet'",
"=>",
"$",
"this",
"->",
"stylesheet",
",",
"'post_content'",
"=>",
"''",
",",
"'isbn'"... | Uses $this->manifest to generate itself.
@param array $book_contents
@param array $metadata | [
"Uses",
"$this",
"-",
">",
"manifest",
"to",
"generate",
"itself",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L1807-L1937 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.positionOfToc | protected function positionOfToc() {
$search = array_keys( $this->manifest );
if ( false === $this->frontMatterLastPos ) {
$array_pos = array_search( 'copyright', $search, true );
if ( false === $array_pos ) {
$array_pos = -1;
}
} else {
$array_pos = -1;
$preg = '/^front-matter-' . sprintf(... | php | protected function positionOfToc() {
$search = array_keys( $this->manifest );
if ( false === $this->frontMatterLastPos ) {
$array_pos = array_search( 'copyright', $search, true );
if ( false === $array_pos ) {
$array_pos = -1;
}
} else {
$array_pos = -1;
$preg = '/^front-matter-' . sprintf(... | [
"protected",
"function",
"positionOfToc",
"(",
")",
"{",
"$",
"search",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"manifest",
")",
";",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"frontMatterLastPos",
")",
"{",
"$",
"array_pos",
"=",
"array_search",
... | Determine position of TOC based on Chicago Manual Of Style.
@return int | [
"Determine",
"position",
"of",
"TOC",
"based",
"on",
"Chicago",
"Manual",
"Of",
"Style",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L1945-L1968 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.kneadHtml | protected function kneadHtml( $html, $type, $pos = 0 ) {
$html5 = new HtmlParser();
$dom = $html5->loadHTML( $html, [ 'disable_html_ns' => true ] ); // Disable default namespace for \DOMXPath compatibility
// Download images, change to relative paths
$dom = $this->scrapeAndKneadImages( $dom );
// Download ... | php | protected function kneadHtml( $html, $type, $pos = 0 ) {
$html5 = new HtmlParser();
$dom = $html5->loadHTML( $html, [ 'disable_html_ns' => true ] ); // Disable default namespace for \DOMXPath compatibility
// Download images, change to relative paths
$dom = $this->scrapeAndKneadImages( $dom );
// Download ... | [
"protected",
"function",
"kneadHtml",
"(",
"$",
"html",
",",
"$",
"type",
",",
"$",
"pos",
"=",
"0",
")",
"{",
"$",
"html5",
"=",
"new",
"HtmlParser",
"(",
")",
";",
"$",
"dom",
"=",
"$",
"html5",
"->",
"loadHTML",
"(",
"$",
"html",
",",
"[",
"... | Pummel the HTML into EPUB compatible dough.
@param string $html
@param string $type front-matter, part, chapter, back-matter, ...
@param int $pos (optional) position of content, used when creating filenames like: chapter-001, chapter-002, ...
@return string | [
"Pummel",
"the",
"HTML",
"into",
"EPUB",
"compatible",
"dough",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L1980-L2015 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.scrapeAndKneadImages | protected function scrapeAndKneadImages( \DOMDocument $doc ) {
$fullpath = $this->tmpDir . '/OEBPS/assets';
$images = $doc->getElementsByTagName( 'img' );
foreach ( $images as $image ) {
/** @var \DOMElement $image */
// Fetch image, change src
$url = $image->getAttribute( 'src' );
// Replace Buckra... | php | protected function scrapeAndKneadImages( \DOMDocument $doc ) {
$fullpath = $this->tmpDir . '/OEBPS/assets';
$images = $doc->getElementsByTagName( 'img' );
foreach ( $images as $image ) {
/** @var \DOMElement $image */
// Fetch image, change src
$url = $image->getAttribute( 'src' );
// Replace Buckra... | [
"protected",
"function",
"scrapeAndKneadImages",
"(",
"\\",
"DOMDocument",
"$",
"doc",
")",
"{",
"$",
"fullpath",
"=",
"$",
"this",
"->",
"tmpDir",
".",
"'/OEBPS/assets'",
";",
"$",
"images",
"=",
"$",
"doc",
"->",
"getElementsByTagName",
"(",
"'img'",
")",
... | Parse HTML snippet, download all found <img> tags into /OEBPS/assets/, return the HTML with changed <img> paths.
@param \DOMDocument $doc
@return \DOMDocument | [
"Parse",
"HTML",
"snippet",
"download",
"all",
"found",
"<img",
">",
"tags",
"into",
"/",
"OEBPS",
"/",
"assets",
"/",
"return",
"the",
"HTML",
"with",
"changed",
"<img",
">",
"paths",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L2025-L2049 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.fetchAndSaveUniqueImage | protected function fetchAndSaveUniqueImage( $url, $fullpath ) {
if ( isset( $this->fetchedImageCache[ $url ] ) ) {
return $this->fetchedImageCache[ $url ];
}
$args = [
'timeout' => $this->timeout,
];
$response = \Pressbooks\Utility\remote_get_retry( $url, $args );
// WordPress error?
if ( is_wp_e... | php | protected function fetchAndSaveUniqueImage( $url, $fullpath ) {
if ( isset( $this->fetchedImageCache[ $url ] ) ) {
return $this->fetchedImageCache[ $url ];
}
$args = [
'timeout' => $this->timeout,
];
$response = \Pressbooks\Utility\remote_get_retry( $url, $args );
// WordPress error?
if ( is_wp_e... | [
"protected",
"function",
"fetchAndSaveUniqueImage",
"(",
"$",
"url",
",",
"$",
"fullpath",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"fetchedImageCache",
"[",
"$",
"url",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"fetchedImageCache",
"... | Fetch an image with wp_remote_get(), save it to $fullpath with a unique name.
Will return an empty string if something went wrong.
@param $url string
@param $fullpath string
@return string filename | [
"Fetch",
"an",
"image",
"with",
"wp_remote_get",
"()",
"save",
"it",
"to",
"$fullpath",
"with",
"a",
"unique",
"name",
".",
"Will",
"return",
"an",
"empty",
"string",
"if",
"something",
"went",
"wrong",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L2061-L2175 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.fetchAndSaveUniqueFont | protected function fetchAndSaveUniqueFont( $url, $fullpath ) {
if ( isset( $this->fetchedFontCache[ $url ] ) ) {
return $this->fetchedFontCache[ $url ];
}
$args = [];
if ( defined( 'WP_ENV' ) && WP_ENV === 'development' ) {
$args['sslverify'] = false;
}
$response = wp_remote_get(
$url,
array... | php | protected function fetchAndSaveUniqueFont( $url, $fullpath ) {
if ( isset( $this->fetchedFontCache[ $url ] ) ) {
return $this->fetchedFontCache[ $url ];
}
$args = [];
if ( defined( 'WP_ENV' ) && WP_ENV === 'development' ) {
$args['sslverify'] = false;
}
$response = wp_remote_get(
$url,
array... | [
"protected",
"function",
"fetchAndSaveUniqueFont",
"(",
"$",
"url",
",",
"$",
"fullpath",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"fetchedFontCache",
"[",
"$",
"url",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"fetchedFontCache",
"[",... | Fetch a font with wp_remote_get(), save it to $fullpath with a unique name.
Will return an empty string if something went wrong.
@param $url string
@param $fullpath string
@return string filename | [
"Fetch",
"a",
"font",
"with",
"wp_remote_get",
"()",
"save",
"it",
"to",
"$fullpath",
"with",
"a",
"unique",
"name",
".",
"Will",
"return",
"an",
"empty",
"string",
"if",
"something",
"went",
"wrong",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L2187-L2239 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.kneadHref | protected function kneadHref( \DOMDocument $doc, $type, $pos ) {
$urls = $doc->getElementsByTagName( 'a' );
foreach ( $urls as $url ) {
/** @var \DOMElement $url */
$current_url = '' . $url->getAttribute( 'href' ); // Stringify
// Is this the the attributionUrl?
if ( $url->getAttribute( 'rel' ) === 'c... | php | protected function kneadHref( \DOMDocument $doc, $type, $pos ) {
$urls = $doc->getElementsByTagName( 'a' );
foreach ( $urls as $url ) {
/** @var \DOMElement $url */
$current_url = '' . $url->getAttribute( 'href' ); // Stringify
// Is this the the attributionUrl?
if ( $url->getAttribute( 'rel' ) === 'c... | [
"protected",
"function",
"kneadHref",
"(",
"\\",
"DOMDocument",
"$",
"doc",
",",
"$",
"type",
",",
"$",
"pos",
")",
"{",
"$",
"urls",
"=",
"$",
"doc",
"->",
"getElementsByTagName",
"(",
"'a'",
")",
";",
"foreach",
"(",
"$",
"urls",
"as",
"$",
"url",
... | Change hrefs
@param \DOMDocument $doc
@param string $type front-matter, part, chapter, back-matter, ...
@param int $pos (optional) position of content, used when creating filenames like: chapter-001, chapter-002, ...
@return \DOMDocument | [
"Change",
"hrefs"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L2262-L2311 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.fuzzyImageNameMatch | protected function fuzzyImageNameMatch( $file1, $file2 ) {
$file1 = basename( $file1 );
$file2 = basename( $file2 );
/* Compare extensions */
$file1 = explode( '.', $file1 );
$ext1 = strtolower( end( $file1 ) );
$file2 = explode( '.', $file2 );
$ext2 = strtolower( end( $file2 ) );
if ( $ext1 !== $e... | php | protected function fuzzyImageNameMatch( $file1, $file2 ) {
$file1 = basename( $file1 );
$file2 = basename( $file2 );
/* Compare extensions */
$file1 = explode( '.', $file1 );
$ext1 = strtolower( end( $file1 ) );
$file2 = explode( '.', $file2 );
$ext2 = strtolower( end( $file2 ) );
if ( $ext1 !== $e... | [
"protected",
"function",
"fuzzyImageNameMatch",
"(",
"$",
"file1",
",",
"$",
"file2",
")",
"{",
"$",
"file1",
"=",
"basename",
"(",
"$",
"file1",
")",
";",
"$",
"file2",
"=",
"basename",
"(",
"$",
"file2",
")",
";",
"/* Compare extensions */",
"$",
"file... | Fuzzy image name match.
For example: <a href="Some_Image-original.png"><img src="some_image-300x200.PNG" /></a>
We consider both 'href' and 'src' above 'the same'
@param string $file1
@param string $file2
@return bool | [
"Fuzzy",
"image",
"name",
"match",
".",
"For",
"example",
":",
"<a",
"href",
"=",
"Some_Image",
"-",
"original",
".",
"png",
">",
"<img",
"src",
"=",
"some_image",
"-",
"300x200",
".",
"PNG",
"/",
">",
"<",
"/",
"a",
">",
"We",
"consider",
"both",
... | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L2324-L2354 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.fuzzyHrefMatch | protected function fuzzyHrefMatch( $url, $pos ) {
if ( ! $pos ) {
return false;
}
$url = trim( $url );
// Remove trailing slash
$url = rtrim( $url, '/' );
// Change /foo/bar/#fragment to /foo/bar#fragment
if ( preg_match( '~/#[^/]*$~', $url ) ) {
$url = str_lreplace( '/#', '#', $url );
}
$doma... | php | protected function fuzzyHrefMatch( $url, $pos ) {
if ( ! $pos ) {
return false;
}
$url = trim( $url );
// Remove trailing slash
$url = rtrim( $url, '/' );
// Change /foo/bar/#fragment to /foo/bar#fragment
if ( preg_match( '~/#[^/]*$~', $url ) ) {
$url = str_lreplace( '/#', '#', $url );
}
$doma... | [
"protected",
"function",
"fuzzyHrefMatch",
"(",
"$",
"url",
",",
"$",
"pos",
")",
"{",
"if",
"(",
"!",
"$",
"pos",
")",
"{",
"return",
"false",
";",
"}",
"$",
"url",
"=",
"trim",
"(",
"$",
"url",
")",
";",
"// Remove trailing slash",
"$",
"url",
"=... | Try to determine if a URL is pointing to internal content.
@param $url
@param int $pos (optional) position of content, used when creating filenames like: chapter-001, chapter-002, ...
@return bool|string | [
"Try",
"to",
"determine",
"if",
"a",
"URL",
"is",
"pointing",
"to",
"internal",
"content",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L2365-L2475 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.fixOrder | protected function fixOrder( $order ) {
$fixed = [];
$fm = [];
foreach ( $order as $post_id => $val ) {
if ( $val['post_type'] === 'front-matter' ) {
$type = $this->taxonomy->getFrontMatterType( $post_id );
if ( ! in_array( $type, [ 'before-title', 'title-page', 'dedication', 'epigraph' ], true ) ) {
... | php | protected function fixOrder( $order ) {
$fixed = [];
$fm = [];
foreach ( $order as $post_id => $val ) {
if ( $val['post_type'] === 'front-matter' ) {
$type = $this->taxonomy->getFrontMatterType( $post_id );
if ( ! in_array( $type, [ 'before-title', 'title-page', 'dedication', 'epigraph' ], true ) ) {
... | [
"protected",
"function",
"fixOrder",
"(",
"$",
"order",
")",
"{",
"$",
"fixed",
"=",
"[",
"]",
";",
"$",
"fm",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"order",
"as",
"$",
"post_id",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"$",
"val",
"[",
"'p... | Reorder the book structure to conform to Chicago Style, so that the
book begins with Before Title, Title Page, Dedication, Epigraph.
@param array $order
@return array | [
"Reorder",
"the",
"book",
"structure",
"to",
"conform",
"to",
"Chicago",
"Style",
"so",
"that",
"the",
"book",
"begins",
"with",
"Before",
"Title",
"Title",
"Page",
"Dedication",
"Epigraph",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L2484-L2512 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.createOPF | protected function createOPF( $book_contents, $metadata ) {
if ( empty( $this->manifest ) ) {
throw new \Exception( '$this->manifest cannot be empty. Did you forget to call $this->createOEBPS() ?' );
}
// Vars
$vars = [
'manifest' => $this->manifest,
'stylesheet' => $this->stylesheet,
'lang' => $t... | php | protected function createOPF( $book_contents, $metadata ) {
if ( empty( $this->manifest ) ) {
throw new \Exception( '$this->manifest cannot be empty. Did you forget to call $this->createOEBPS() ?' );
}
// Vars
$vars = [
'manifest' => $this->manifest,
'stylesheet' => $this->stylesheet,
'lang' => $t... | [
"protected",
"function",
"createOPF",
"(",
"$",
"book_contents",
",",
"$",
"metadata",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"manifest",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'$this->manifest cannot be empty. Did you forget to c... | Create OPF File.
@param array $book_contents
@param array $metadata
@throws \Exception | [
"Create",
"OPF",
"File",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L2522-L2552 |
pressbooks/pressbooks | inc/modules/export/epub/class-epub201.php | Epub201.buildManifestAssetsHtml | protected function buildManifestAssetsHtml() {
$html = '';
$path_to_assets = $this->tmpDir . '/OEBPS/assets';
$assets = scandir( $path_to_assets );
$used_ids = [];
foreach ( $assets as $asset ) {
if ( '.' === $asset || '..' === $asset ) {
continue;
}
$mimetype = $this->mediaType( "$path_to_asse... | php | protected function buildManifestAssetsHtml() {
$html = '';
$path_to_assets = $this->tmpDir . '/OEBPS/assets';
$assets = scandir( $path_to_assets );
$used_ids = [];
foreach ( $assets as $asset ) {
if ( '.' === $asset || '..' === $asset ) {
continue;
}
$mimetype = $this->mediaType( "$path_to_asse... | [
"protected",
"function",
"buildManifestAssetsHtml",
"(",
")",
"{",
"$",
"html",
"=",
"''",
";",
"$",
"path_to_assets",
"=",
"$",
"this",
"->",
"tmpDir",
".",
"'/OEBPS/assets'",
";",
"$",
"assets",
"=",
"scandir",
"(",
"$",
"path_to_assets",
")",
";",
"$",
... | Find all the image files, insert them into the OPF file
@return string | [
"Find",
"all",
"the",
"image",
"files",
"insert",
"them",
"into",
"the",
"OPF",
"file"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/epub/class-epub201.php#L2559-L2595 |
pressbooks/pressbooks | inc/covergenerator/class-generator.php | Generator.getCoversFolder | public static function getCoversFolder() {
$path = \Pressbooks\Utility\get_media_prefix() . 'covers/';
if ( ! file_exists( $path ) ) {
mkdir( $path, 0775, true );
}
$path_to_htaccess = $path . '.htaccess';
if ( ! file_exists( $path_to_htaccess ) ) {
// Restrict access
\Pressbooks\Utility\put_conten... | php | public static function getCoversFolder() {
$path = \Pressbooks\Utility\get_media_prefix() . 'covers/';
if ( ! file_exists( $path ) ) {
mkdir( $path, 0775, true );
}
$path_to_htaccess = $path . '.htaccess';
if ( ! file_exists( $path_to_htaccess ) ) {
// Restrict access
\Pressbooks\Utility\put_conten... | [
"public",
"static",
"function",
"getCoversFolder",
"(",
")",
"{",
"$",
"path",
"=",
"\\",
"Pressbooks",
"\\",
"Utility",
"\\",
"get_media_prefix",
"(",
")",
".",
"'covers/'",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"mkdir",
... | Get the fullpath to the Covers folder.
Create if not there. Create .htaccess protection if missing.
@return string fullpath | [
"Get",
"the",
"fullpath",
"to",
"the",
"Covers",
"folder",
".",
"Create",
"if",
"not",
"there",
".",
"Create",
".",
"htaccess",
"protection",
"if",
"missing",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/covergenerator/class-generator.php#L83-L97 |
pressbooks/pressbooks | inc/covergenerator/class-generator.php | Generator.getScssVars | protected function getScssVars() {
$sass = '';
// Required
foreach ( $this->requiredSassVars as $var ) {
$method = $this->varToGetter( $var );
if ( ! method_exists( $this->input, $method ) ) {
throw new \LogicException( "Input::{$method}() not found." );
}
if ( empty( $this->input->{$method}() ... | php | protected function getScssVars() {
$sass = '';
// Required
foreach ( $this->requiredSassVars as $var ) {
$method = $this->varToGetter( $var );
if ( ! method_exists( $this->input, $method ) ) {
throw new \LogicException( "Input::{$method}() not found." );
}
if ( empty( $this->input->{$method}() ... | [
"protected",
"function",
"getScssVars",
"(",
")",
"{",
"$",
"sass",
"=",
"''",
";",
"// Required",
"foreach",
"(",
"$",
"this",
"->",
"requiredSassVars",
"as",
"$",
"var",
")",
"{",
"$",
"method",
"=",
"$",
"this",
"->",
"varToGetter",
"(",
"$",
"var",... | Generate SCSS vars based on Input object
@throws \LogicException
@throws \InvalidArgumentException
@return string | [
"Generate",
"SCSS",
"vars",
"based",
"on",
"Input",
"object"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/covergenerator/class-generator.php#L122-L150 |
pressbooks/pressbooks | inc/covergenerator/class-generator.php | Generator.formGenerator | public static function formGenerator( $format ) : \Generator {
wp_cache_delete( 'pressbooks_cg_options', 'options' ); // WordPress Core caches this key in the "options" group
wp_cache_delete( 'alloptions', 'options' );
$cg_options = get_option( 'pressbooks_cg_options' );
yield 20 => __( 'Calculating spine widt... | php | public static function formGenerator( $format ) : \Generator {
wp_cache_delete( 'pressbooks_cg_options', 'options' ); // WordPress Core caches this key in the "options" group
wp_cache_delete( 'alloptions', 'options' );
$cg_options = get_option( 'pressbooks_cg_options' );
yield 20 => __( 'Calculating spine widt... | [
"public",
"static",
"function",
"formGenerator",
"(",
"$",
"format",
")",
":",
"\\",
"Generator",
"{",
"wp_cache_delete",
"(",
"'pressbooks_cg_options'",
",",
"'options'",
")",
";",
"// WordPress Core caches this key in the \"options\" group",
"wp_cache_delete",
"(",
"'al... | Generate cover
Yields an estimated percentage slice of: 20 - 100
@see pressbooks/templates/admin/generator.php
@param string $format
@return \Generator
@throws \Exception | [
"Generate",
"cover",
"Yields",
"an",
"estimated",
"percentage",
"slice",
"of",
":",
"20",
"-",
"100"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/covergenerator/class-generator.php#L199-L302 |
pressbooks/pressbooks | inc/covergenerator/class-generator.php | Generator.formDelete | public static function formDelete() {
if ( check_admin_referer( 'pb-delete-cover' ) ) {
$filename = sanitize_file_name( $_POST['filename'] );
$path = static::getCoversFolder();
unlink( $path . $filename );
delete_transient( 'dirsize_cache' ); /** @see get_dirsize() */
}
\Pressbooks\Redirect\location... | php | public static function formDelete() {
if ( check_admin_referer( 'pb-delete-cover' ) ) {
$filename = sanitize_file_name( $_POST['filename'] );
$path = static::getCoversFolder();
unlink( $path . $filename );
delete_transient( 'dirsize_cache' ); /** @see get_dirsize() */
}
\Pressbooks\Redirect\location... | [
"public",
"static",
"function",
"formDelete",
"(",
")",
"{",
"if",
"(",
"check_admin_referer",
"(",
"'pb-delete-cover'",
")",
")",
"{",
"$",
"filename",
"=",
"sanitize_file_name",
"(",
"$",
"_POST",
"[",
"'filename'",
"]",
")",
";",
"$",
"path",
"=",
"stat... | Delete cover
@see pressbooks/templates/admin/generator.php | [
"Delete",
"cover"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/covergenerator/class-generator.php#L310-L320 |
pressbooks/pressbooks | inc/covergenerator/class-generator.php | Generator.formDeleteAll | public static function formDeleteAll() {
if ( ! empty( $_POST['delete_all_covers'] ) && check_admin_referer( 'pb-delete-all-covers' ) ) {
\Pressbooks\Utility\truncate_exports( 0, static::getCoversFolder() );
delete_transient( 'dirsize_cache' ); /** @see get_dirsize() */
}
\Pressbooks\Redirect\location( ad... | php | public static function formDeleteAll() {
if ( ! empty( $_POST['delete_all_covers'] ) && check_admin_referer( 'pb-delete-all-covers' ) ) {
\Pressbooks\Utility\truncate_exports( 0, static::getCoversFolder() );
delete_transient( 'dirsize_cache' ); /** @see get_dirsize() */
}
\Pressbooks\Redirect\location( ad... | [
"public",
"static",
"function",
"formDeleteAll",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"_POST",
"[",
"'delete_all_covers'",
"]",
")",
"&&",
"check_admin_referer",
"(",
"'pb-delete-all-covers'",
")",
")",
"{",
"\\",
"Pressbooks",
"\\",
"Utility",
... | Delete all covers
@see pressbooks/templates/admin/generator.php | [
"Delete",
"all",
"covers"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/covergenerator/class-generator.php#L327-L335 |
pressbooks/pressbooks | inc/covergenerator/class-generator.php | Generator._downloadCoverFile | protected static function _downloadCoverFile( $filename ) {
$filepath = static::getCoversFolder() . $filename;
\Pressbooks\Redirect\force_download( $filepath );
exit;
} | php | protected static function _downloadCoverFile( $filename ) {
$filepath = static::getCoversFolder() . $filename;
\Pressbooks\Redirect\force_download( $filepath );
exit;
} | [
"protected",
"static",
"function",
"_downloadCoverFile",
"(",
"$",
"filename",
")",
"{",
"$",
"filepath",
"=",
"static",
"::",
"getCoversFolder",
"(",
")",
".",
"$",
"filename",
";",
"\\",
"Pressbooks",
"\\",
"Redirect",
"\\",
"force_download",
"(",
"$",
"fi... | Download an .htaccess protected file from the exports directory.
@param string $filename sanitized $_GET['download_export_file'] | [
"Download",
"an",
".",
"htaccess",
"protected",
"file",
"from",
"the",
"exports",
"directory",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/covergenerator/class-generator.php#L353-L357 |
pressbooks/pressbooks | inc/covergenerator/class-generator.php | Generator.timestampedFileName | public function timestampedFileName( $extension, $fullpath = true ) {
$book_title = ( get_bloginfo( 'name' ) ) ? get_bloginfo( 'name' ) : __( 'book', 'pressbooks' );
$book_title_slug = sanitize_file_name( $book_title );
$book_title_slug = str_replace( [ '+' ], '', $book_title_slug ); // Remove symbols which confu... | php | public function timestampedFileName( $extension, $fullpath = true ) {
$book_title = ( get_bloginfo( 'name' ) ) ? get_bloginfo( 'name' ) : __( 'book', 'pressbooks' );
$book_title_slug = sanitize_file_name( $book_title );
$book_title_slug = str_replace( [ '+' ], '', $book_title_slug ); // Remove symbols which confu... | [
"public",
"function",
"timestampedFileName",
"(",
"$",
"extension",
",",
"$",
"fullpath",
"=",
"true",
")",
"{",
"$",
"book_title",
"=",
"(",
"get_bloginfo",
"(",
"'name'",
")",
")",
"?",
"get_bloginfo",
"(",
"'name'",
")",
":",
"__",
"(",
"'book'",
",",... | Create a timestamped filename.
@param string $extension
@param bool $fullpath
@return string | [
"Create",
"a",
"timestamped",
"filename",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/covergenerator/class-generator.php#L367-L382 |
pressbooks/pressbooks | inc/covergenerator/class-generator.php | Generator.generateWithPrince | public function generateWithPrince( $pdf_profile, $pdf_output_intent, $document_content, $output_path ) {
$log_file = create_tmp_file();
$prince = new \PrinceXMLPhp\PrinceWrapper( PB_PRINCE_COMMAND );
$prince->setHTML( true );
$prince->setCompress( true );
if ( defined( 'WP_ENV' ) && ( WP_ENV === 'development... | php | public function generateWithPrince( $pdf_profile, $pdf_output_intent, $document_content, $output_path ) {
$log_file = create_tmp_file();
$prince = new \PrinceXMLPhp\PrinceWrapper( PB_PRINCE_COMMAND );
$prince->setHTML( true );
$prince->setCompress( true );
if ( defined( 'WP_ENV' ) && ( WP_ENV === 'development... | [
"public",
"function",
"generateWithPrince",
"(",
"$",
"pdf_profile",
",",
"$",
"pdf_output_intent",
",",
"$",
"document_content",
",",
"$",
"output_path",
")",
"{",
"$",
"log_file",
"=",
"create_tmp_file",
"(",
")",
";",
"$",
"prince",
"=",
"new",
"\\",
"Pri... | @param string $pdf_profile
@param $pdf_output_intent
@param $document_content
@param $output_path
@return bool | [
"@param",
"string",
"$pdf_profile",
"@param",
"$pdf_output_intent",
"@param",
"$document_content",
"@param",
"$output_path"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/covergenerator/class-generator.php#L392-L413 |
pressbooks/pressbooks | inc/covergenerator/class-generator.php | Generator.generateWithDocraptor | public function generateWithDocraptor( $pdf_profile, $document_content, $output_path ) {
// Configure service
$configuration = \DocRaptor\Configuration::getDefaultConfiguration();
$configuration->setUsername( DOCRAPTOR_API_KEY );
// Save PDF as file in exports folder
$docraptor = new \DocRaptor\DocApi();
$... | php | public function generateWithDocraptor( $pdf_profile, $document_content, $output_path ) {
// Configure service
$configuration = \DocRaptor\Configuration::getDefaultConfiguration();
$configuration->setUsername( DOCRAPTOR_API_KEY );
// Save PDF as file in exports folder
$docraptor = new \DocRaptor\DocApi();
$... | [
"public",
"function",
"generateWithDocraptor",
"(",
"$",
"pdf_profile",
",",
"$",
"document_content",
",",
"$",
"output_path",
")",
"{",
"// Configure service",
"$",
"configuration",
"=",
"\\",
"DocRaptor",
"\\",
"Configuration",
"::",
"getDefaultConfiguration",
"(",
... | @param string $pdf_profile
@param string $document_content
@param string $output_path
@return bool | [
"@param",
"string",
"$pdf_profile",
"@param",
"string",
"$document_content",
"@param",
"string",
"$output_path"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/covergenerator/class-generator.php#L422-L482 |
pressbooks/pressbooks | inc/class-options.php | Options.sanitize | function sanitize( $input ) {
$options = [];
if ( ! is_array( $input ) ) {
$input = [];
}
if ( property_exists( $this, 'booleans' ) ) {
foreach ( $this->booleans as $key ) {
if ( empty( $input[ $key ] ) ) {
$options[ $key ] = 0;
} else {
$options[ $key ] = 1;
}
}
}
if ( pro... | php | function sanitize( $input ) {
$options = [];
if ( ! is_array( $input ) ) {
$input = [];
}
if ( property_exists( $this, 'booleans' ) ) {
foreach ( $this->booleans as $key ) {
if ( empty( $input[ $key ] ) ) {
$options[ $key ] = 0;
} else {
$options[ $key ] = 1;
}
}
}
if ( pro... | [
"function",
"sanitize",
"(",
"$",
"input",
")",
"{",
"$",
"options",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"input",
")",
")",
"{",
"$",
"input",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
... | Sanitize various options (boolean, string, integer, float).
@param array $input
@return array $options | [
"Sanitize",
"various",
"options",
"(",
"boolean",
"string",
"integer",
"float",
")",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-options.php#L85-L158 |
pressbooks/pressbooks | inc/class-options.php | Options.renderColorField | static function renderColorField( $args ) {
$defaults = [
'id' => null,
'name' => null,
'option' => null,
'value' => '',
'default' => '#000',
'description' => null,
'disabled' => false,
];
$args = wp_parse_args( $args, $defaults );
printf(
'<input id="%1$s" class="color-picker" name="%... | php | static function renderColorField( $args ) {
$defaults = [
'id' => null,
'name' => null,
'option' => null,
'value' => '',
'default' => '#000',
'description' => null,
'disabled' => false,
];
$args = wp_parse_args( $args, $defaults );
printf(
'<input id="%1$s" class="color-picker" name="%... | [
"static",
"function",
"renderColorField",
"(",
"$",
"args",
")",
"{",
"$",
"defaults",
"=",
"[",
"'id'",
"=>",
"null",
",",
"'name'",
"=>",
"null",
",",
"'option'",
"=>",
"null",
",",
"'value'",
"=>",
"''",
",",
"'default'",
"=>",
"'#000'",
",",
"'desc... | Render a WordPress color picker.
@param array $args {
Arguments to render the color picker.
@type string $id The id which will be assigned to the rendered field.
@type string $name The name of the field.
@type string $option The name of the option that the field is within.
@type string $value The stored value of the ... | [
"Render",
"a",
"WordPress",
"color",
"picker",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-options.php#L228-L256 |
pressbooks/pressbooks | inc/class-options.php | Options.renderCheckbox | static function renderCheckbox( $args ) {
$defaults = [
'id' => null,
'name' => null,
'option' => null,
'value' => '',
'label' => null,
'disabled' => false,
'description' => null,
];
$args = wp_parse_args( $args, $defaults );
printf(
'<input id="%s" name="%s[%s]" type="checkbox" value=... | php | static function renderCheckbox( $args ) {
$defaults = [
'id' => null,
'name' => null,
'option' => null,
'value' => '',
'label' => null,
'disabled' => false,
'description' => null,
];
$args = wp_parse_args( $args, $defaults );
printf(
'<input id="%s" name="%s[%s]" type="checkbox" value=... | [
"static",
"function",
"renderCheckbox",
"(",
"$",
"args",
")",
"{",
"$",
"defaults",
"=",
"[",
"'id'",
"=>",
"null",
",",
"'name'",
"=>",
"null",
",",
"'option'",
"=>",
"null",
",",
"'value'",
"=>",
"''",
",",
"'label'",
"=>",
"null",
",",
"'disabled'"... | Render a checkbox.
@param array $args | [
"Render",
"a",
"checkbox",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-options.php#L263-L292 |
pressbooks/pressbooks | inc/class-options.php | Options.renderRadioButtons | static function renderRadioButtons( $args ) {
$defaults = [
'id' => null,
'name' => null,
'option' => null,
'value' => '',
'choices' => [],
'custom' => false,
'disabled' => false,
];
$args = wp_parse_args( $args, $defaults );
$is_custom = false;
if ( ! array_key_exists( $args['value'], ... | php | static function renderRadioButtons( $args ) {
$defaults = [
'id' => null,
'name' => null,
'option' => null,
'value' => '',
'choices' => [],
'custom' => false,
'disabled' => false,
];
$args = wp_parse_args( $args, $defaults );
$is_custom = false;
if ( ! array_key_exists( $args['value'], ... | [
"static",
"function",
"renderRadioButtons",
"(",
"$",
"args",
")",
"{",
"$",
"defaults",
"=",
"[",
"'id'",
"=>",
"null",
",",
"'name'",
"=>",
"null",
",",
"'option'",
"=>",
"null",
",",
"'value'",
"=>",
"''",
",",
"'choices'",
"=>",
"[",
"]",
",",
"'... | Render radio buttons.
@param array $args | [
"Render",
"radio",
"buttons",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-options.php#L299-L331 |
pressbooks/pressbooks | inc/class-options.php | Options.renderSelect | static function renderSelect( $args ) {
$defaults = [
'id' => null,
'name' => null,
'option' => null,
'value' => '',
'choices' => [],
'multiple' => false,
'disabled' => false,
'description' => null,
];
$args = wp_parse_args( $args, $defaults );
$options = '';
foreach ( $args['choices... | php | static function renderSelect( $args ) {
$defaults = [
'id' => null,
'name' => null,
'option' => null,
'value' => '',
'choices' => [],
'multiple' => false,
'disabled' => false,
'description' => null,
];
$args = wp_parse_args( $args, $defaults );
$options = '';
foreach ( $args['choices... | [
"static",
"function",
"renderSelect",
"(",
"$",
"args",
")",
"{",
"$",
"defaults",
"=",
"[",
"'id'",
"=>",
"null",
",",
"'name'",
"=>",
"null",
",",
"'option'",
"=>",
"null",
",",
"'value'",
"=>",
"''",
",",
"'choices'",
"=>",
"[",
"]",
",",
"'multip... | Render a select element.
@param array $args | [
"Render",
"a",
"select",
"element",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-options.php#L338-L376 |
pressbooks/pressbooks | inc/class-options.php | Options.renderCustomSelect | static function renderCustomSelect( $args ) {
$defaults = [
'id' => null,
'name' => null,
'value' => '',
'choices' => [],
'multiple' => false,
'disabled' => false,
];
$args = wp_parse_args( $args, $defaults );
$is_custom = false;
if ( ! array_key_exists( $args['value'], $args['choices'] ) ... | php | static function renderCustomSelect( $args ) {
$defaults = [
'id' => null,
'name' => null,
'value' => '',
'choices' => [],
'multiple' => false,
'disabled' => false,
];
$args = wp_parse_args( $args, $defaults );
$is_custom = false;
if ( ! array_key_exists( $args['value'], $args['choices'] ) ... | [
"static",
"function",
"renderCustomSelect",
"(",
"$",
"args",
")",
"{",
"$",
"defaults",
"=",
"[",
"'id'",
"=>",
"null",
",",
"'name'",
"=>",
"null",
",",
"'value'",
"=>",
"''",
",",
"'choices'",
"=>",
"[",
"]",
",",
"'multiple'",
"=>",
"false",
",",
... | Render a custom select element.
@param array $args | [
"Render",
"a",
"custom",
"select",
"element",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-options.php#L383-L416 |
pressbooks/pressbooks | inc/modules/export/htmlbook/class-htmlbook.php | HTMLBook.convert | public function convert() {
// Get HTMLBook
$output = $this->transform( true );
if ( ! $output ) {
return false;
}
// Save HTMLBook as file in exports folder
$filename = $this->timestampedFileName( '-htmlbook.html' );
\Pressbooks\Utility\put_contents( $filename, $output );
$this->outputPath = $f... | php | public function convert() {
// Get HTMLBook
$output = $this->transform( true );
if ( ! $output ) {
return false;
}
// Save HTMLBook as file in exports folder
$filename = $this->timestampedFileName( '-htmlbook.html' );
\Pressbooks\Utility\put_contents( $filename, $output );
$this->outputPath = $f... | [
"public",
"function",
"convert",
"(",
")",
"{",
"// Get HTMLBook",
"$",
"output",
"=",
"$",
"this",
"->",
"transform",
"(",
"true",
")",
";",
"if",
"(",
"!",
"$",
"output",
")",
"{",
"return",
"false",
";",
"}",
"// Save HTMLBook as file in exports folder",
... | Create $this->outputPath
@return bool | [
"Create",
"$this",
"-",
">",
"outputPath"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/htmlbook/class-htmlbook.php#L122-L139 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.