repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
pressbooks/pressbooks | inc/class-catalog.php | Catalog.formSubmit | static function formSubmit() {
if ( empty( static::isFormSubmission() ) || empty( current_user_can( 'read' ) ) ) {
// Don't do anything in this function, bail.
return;
}
if ( static::isCurrentAction( 'add' ) ) {
static::formBulk( 'add' );
} elseif ( static::isCurrentAction( 'remove' ) ) {
static::... | php | static function formSubmit() {
if ( empty( static::isFormSubmission() ) || empty( current_user_can( 'read' ) ) ) {
// Don't do anything in this function, bail.
return;
}
if ( static::isCurrentAction( 'add' ) ) {
static::formBulk( 'add' );
} elseif ( static::isCurrentAction( 'remove' ) ) {
static::... | [
"static",
"function",
"formSubmit",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"static",
"::",
"isFormSubmission",
"(",
")",
")",
"||",
"empty",
"(",
"current_user_can",
"(",
"'read'",
")",
")",
")",
"{",
"// Don't do anything in this function, bail.",
"return",
... | Catch me | [
"Catch",
"me"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L1035-L1054 |
pressbooks/pressbooks | inc/class-catalog.php | Catalog.isFormSubmission | static function isFormSubmission() {
if ( empty( $_REQUEST['page'] ) ) {
return false;
}
if ( 'pb_catalog' !== $_REQUEST['page'] ) {
return false;
}
if ( $_SERVER['REQUEST_METHOD'] === 'POST' ) {
return true;
}
if ( static::isCurrentAction( 'add' ) || static::isCurrentAction( 'remove' ) ) {
... | php | static function isFormSubmission() {
if ( empty( $_REQUEST['page'] ) ) {
return false;
}
if ( 'pb_catalog' !== $_REQUEST['page'] ) {
return false;
}
if ( $_SERVER['REQUEST_METHOD'] === 'POST' ) {
return true;
}
if ( static::isCurrentAction( 'add' ) || static::isCurrentAction( 'remove' ) ) {
... | [
"static",
"function",
"isFormSubmission",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"_REQUEST",
"[",
"'page'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"'pb_catalog'",
"!==",
"$",
"_REQUEST",
"[",
"'page'",
"]",
")",
"{",
"retur... | Check if a user submitted something to index.php?page=pb_catalog
@return bool | [
"Check",
"if",
"a",
"user",
"submitted",
"something",
"to",
"index",
".",
"php?page",
"=",
"pb_catalog"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L1062-L1081 |
pressbooks/pressbooks | inc/class-catalog.php | Catalog.isCurrentAction | static function isCurrentAction( $action ) {
if ( isset( $_REQUEST['action'] ) && -1 !== (int) $_REQUEST['action'] ) {
$compare = $_REQUEST['action'];
} elseif ( isset( $_REQUEST['action2'] ) && -1 !== (int) $_REQUEST['action2'] ) {
$compare = $_REQUEST['action2'];
} else {
return false;
}
return (... | php | static function isCurrentAction( $action ) {
if ( isset( $_REQUEST['action'] ) && -1 !== (int) $_REQUEST['action'] ) {
$compare = $_REQUEST['action'];
} elseif ( isset( $_REQUEST['action2'] ) && -1 !== (int) $_REQUEST['action2'] ) {
$compare = $_REQUEST['action2'];
} else {
return false;
}
return (... | [
"static",
"function",
"isCurrentAction",
"(",
"$",
"action",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_REQUEST",
"[",
"'action'",
"]",
")",
"&&",
"-",
"1",
"!==",
"(",
"int",
")",
"$",
"_REQUEST",
"[",
"'action'",
"]",
")",
"{",
"$",
"compare",
"="... | Two actions are possible in a generic WP_List_Table form. The first takes precedence.
@param $action
@see \WP_List_Table::current_action
@return bool | [
"Two",
"actions",
"are",
"possible",
"in",
"a",
"generic",
"WP_List_Table",
"form",
".",
"The",
"first",
"takes",
"precedence",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L1093-L1104 |
pressbooks/pressbooks | inc/class-catalog.php | Catalog.deleteLogo | static function deleteLogo() {
check_ajax_referer( 'pb-delete-catalog-logo' );
$image_url = $_POST['filename'];
$user_id = (int) $_POST['pid'];
$book = get_active_blog_for_user( $user_id );
if ( current_user_can_for_blog( $book->blog_id, 'upload_files' ) ) {
switch_to_blog( $book->blog_id );
// Del... | php | static function deleteLogo() {
check_ajax_referer( 'pb-delete-catalog-logo' );
$image_url = $_POST['filename'];
$user_id = (int) $_POST['pid'];
$book = get_active_blog_for_user( $user_id );
if ( current_user_can_for_blog( $book->blog_id, 'upload_files' ) ) {
switch_to_blog( $book->blog_id );
// Del... | [
"static",
"function",
"deleteLogo",
"(",
")",
"{",
"check_ajax_referer",
"(",
"'pb-delete-catalog-logo'",
")",
";",
"$",
"image_url",
"=",
"$",
"_POST",
"[",
"'filename'",
"]",
";",
"$",
"user_id",
"=",
"(",
"int",
")",
"$",
"_POST",
"[",
"'pid'",
"]",
"... | WP_Ajax hook for pb_delete_catalog_logo | [
"WP_Ajax",
"hook",
"for",
"pb_delete_catalog_logo"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L1110-L1136 |
pressbooks/pressbooks | inc/class-catalog.php | Catalog.formBulk | protected static function formBulk( $action ) {
if ( ! class_exists( '\WP_List_Table' ) ) {
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
}
$redirect_url = get_admin_url( get_current_blog_id(), '/index.php?page=pb_catalog' );
$redirect_url = Admin\Catalog_List_Table::addSearchParam... | php | protected static function formBulk( $action ) {
if ( ! class_exists( '\WP_List_Table' ) ) {
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
}
$redirect_url = get_admin_url( get_current_blog_id(), '/index.php?page=pb_catalog' );
$redirect_url = Admin\Catalog_List_Table::addSearchParam... | [
"protected",
"static",
"function",
"formBulk",
"(",
"$",
"action",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"'\\WP_List_Table'",
")",
")",
"{",
"require_once",
"(",
"ABSPATH",
".",
"'wp-admin/includes/class-wp-list-table.php'",
")",
";",
"}",
"$",
"redirec... | Save bulk actions
@param $action | [
"Save",
"bulk",
"actions"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L1144-L1206 |
pressbooks/pressbooks | inc/class-catalog.php | Catalog.formTags | protected static function formTags() {
check_admin_referer( 'pb-user-catalog' );
if ( ! empty( $_REQUEST['ID'] ) ) {
list( $user_id, $blog_id ) = explode( ':', $_REQUEST['ID'] );
} else {
$user_id = '';
$blog_id = '';
}
if ( ! empty( $_REQUEST['user_id'] ) ) {
$user_id = absint( $_REQUEST['user_... | php | protected static function formTags() {
check_admin_referer( 'pb-user-catalog' );
if ( ! empty( $_REQUEST['ID'] ) ) {
list( $user_id, $blog_id ) = explode( ':', $_REQUEST['ID'] );
} else {
$user_id = '';
$blog_id = '';
}
if ( ! empty( $_REQUEST['user_id'] ) ) {
$user_id = absint( $_REQUEST['user_... | [
"protected",
"static",
"function",
"formTags",
"(",
")",
"{",
"check_admin_referer",
"(",
"'pb-user-catalog'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"_REQUEST",
"[",
"'ID'",
"]",
")",
")",
"{",
"list",
"(",
"$",
"user_id",
",",
"$",
"blog_id",
"... | Save tags to database | [
"Save",
"tags",
"to",
"database"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L1212-L1265 |
pressbooks/pressbooks | inc/class-catalog.php | Catalog.formProfile | protected static function formProfile() {
check_admin_referer( 'pb-user-catalog' );
$user_id = isset( $_REQUEST['user_id'] ) ? absint( $_REQUEST['user_id'] ) : 0;
if ( empty( $user_id ) || ! current_user_can( 'edit_user', $user_id ) ) {
wp_die( __( 'You do not have permission to do that.', 'pressbooks' ) );... | php | protected static function formProfile() {
check_admin_referer( 'pb-user-catalog' );
$user_id = isset( $_REQUEST['user_id'] ) ? absint( $_REQUEST['user_id'] ) : 0;
if ( empty( $user_id ) || ! current_user_can( 'edit_user', $user_id ) ) {
wp_die( __( 'You do not have permission to do that.', 'pressbooks' ) );... | [
"protected",
"static",
"function",
"formProfile",
"(",
")",
"{",
"check_admin_referer",
"(",
"'pb-user-catalog'",
")",
";",
"$",
"user_id",
"=",
"isset",
"(",
"$",
"_REQUEST",
"[",
"'user_id'",
"]",
")",
"?",
"absint",
"(",
"$",
"_REQUEST",
"[",
"'user_id'",... | Save catalog profile to database | [
"Save",
"catalog",
"profile",
"to",
"database"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L1271-L1301 |
pressbooks/pressbooks | inc/class-catalog.php | Catalog.formAddByUrl | static function formAddByUrl() {
check_admin_referer( 'bulk-books' ); // Nonce auto-generated by WP_List_Table
$catalog = new static();
$user_id = $catalog->getUserId();
// Set Redirect URL
if ( get_current_user_id() !== $user_id ) {
$redirect_url = get_admin_url( get_current_blog_id(), '/index.php?page... | php | static function formAddByUrl() {
check_admin_referer( 'bulk-books' ); // Nonce auto-generated by WP_List_Table
$catalog = new static();
$user_id = $catalog->getUserId();
// Set Redirect URL
if ( get_current_user_id() !== $user_id ) {
$redirect_url = get_admin_url( get_current_blog_id(), '/index.php?page... | [
"static",
"function",
"formAddByUrl",
"(",
")",
"{",
"check_admin_referer",
"(",
"'bulk-books'",
")",
";",
"// Nonce auto-generated by WP_List_Table",
"$",
"catalog",
"=",
"new",
"static",
"(",
")",
";",
"$",
"user_id",
"=",
"$",
"catalog",
"->",
"getUserId",
"(... | Add Book by URL | [
"Add",
"Book",
"by",
"URL"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L1307-L1357 |
pressbooks/pressbooks | inc/modules/import/wordpress/class-downloads.php | Downloads.scrapeAndKneadImages | public function scrapeAndKneadImages( \DOMDocument $dom ) {
$images = $dom->getElementsByTagName( 'img' );
$attachments = [];
foreach ( $images as $image ) {
/** @var \DOMElement $image */
// Fetch image, change src
$src_old = $image->getAttribute( 'src' );
$attachment_id = $this->fetchAndSaveUnique... | php | public function scrapeAndKneadImages( \DOMDocument $dom ) {
$images = $dom->getElementsByTagName( 'img' );
$attachments = [];
foreach ( $images as $image ) {
/** @var \DOMElement $image */
// Fetch image, change src
$src_old = $image->getAttribute( 'src' );
$attachment_id = $this->fetchAndSaveUnique... | [
"public",
"function",
"scrapeAndKneadImages",
"(",
"\\",
"DOMDocument",
"$",
"dom",
")",
"{",
"$",
"images",
"=",
"$",
"dom",
"->",
"getElementsByTagName",
"(",
"'img'",
")",
";",
"$",
"attachments",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"images",
"as... | Parse HTML snippet, save all found <img> tags using media_handle_sideload(), return the HTML with changed <img> paths.
@param \DOMDocument $dom
@return array An array containing the \DOMDocument and the IDs of created attachments | [
"Parse",
"HTML",
"snippet",
"save",
"all",
"found",
"<img",
">",
"tags",
"using",
"media_handle_sideload",
"()",
"return",
"the",
"HTML",
"with",
"changed",
"<img",
">",
"paths",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/wordpress/class-downloads.php#L61-L86 |
pressbooks/pressbooks | inc/modules/import/wordpress/class-downloads.php | Downloads.fetchAndSaveUniqueImage | public function fetchAndSaveUniqueImage( $url ) {
if ( ! filter_var( $url, FILTER_VALIDATE_URL ) ) {
return 0;
}
if ( ! $this->sameAsSource( $url ) ) {
return -1;
}
$known_media = $this->wxr->getKnownMedia();
$filename = $this->basename( $url );
$attached_file = image_strip_baseurl( $url );
if (... | php | public function fetchAndSaveUniqueImage( $url ) {
if ( ! filter_var( $url, FILTER_VALIDATE_URL ) ) {
return 0;
}
if ( ! $this->sameAsSource( $url ) ) {
return -1;
}
$known_media = $this->wxr->getKnownMedia();
$filename = $this->basename( $url );
$attached_file = image_strip_baseurl( $url );
if (... | [
"public",
"function",
"fetchAndSaveUniqueImage",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"!",
"filter_var",
"(",
"$",
"url",
",",
"FILTER_VALIDATE_URL",
")",
")",
"{",
"return",
"0",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"sameAsSource",
"(",
"$",
... | Load remote url of image into WP using media_handle_sideload()
Will return -1 if image is not hosted on the source Pb network, or 0 if something went wrong.
@param string $url
@see media_handle_sideload
@return int attachment ID, -1 if image is not hosted on the source Pb network, or 0 if import failed | [
"Load",
"remote",
"url",
"of",
"image",
"into",
"WP",
"using",
"media_handle_sideload",
"()",
"Will",
"return",
"-",
"1",
"if",
"image",
"is",
"not",
"hosted",
"on",
"the",
"source",
"Pb",
"network",
"or",
"0",
"if",
"something",
"went",
"wrong",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/wordpress/class-downloads.php#L98-L185 |
pressbooks/pressbooks | inc/modules/import/wordpress/class-downloads.php | Downloads.replaceImage | public function replaceImage( $attachment_id, $src_old, $image ) {
$known_media = $this->wxr->getKnownMedia();
$src_new = wp_get_attachment_url( $attachment_id );
if ( $this->sameAsSource( $src_old ) && isset( $known_media[ image_strip_baseurl( $src_old ) ] ) ) {
$basename_old = $this->basename( $src_old );
... | php | public function replaceImage( $attachment_id, $src_old, $image ) {
$known_media = $this->wxr->getKnownMedia();
$src_new = wp_get_attachment_url( $attachment_id );
if ( $this->sameAsSource( $src_old ) && isset( $known_media[ image_strip_baseurl( $src_old ) ] ) ) {
$basename_old = $this->basename( $src_old );
... | [
"public",
"function",
"replaceImage",
"(",
"$",
"attachment_id",
",",
"$",
"src_old",
",",
"$",
"image",
")",
"{",
"$",
"known_media",
"=",
"$",
"this",
"->",
"wxr",
"->",
"getKnownMedia",
"(",
")",
";",
"$",
"src_new",
"=",
"wp_get_attachment_url",
"(",
... | @param int $attachment_id
@param string $src_old
@param \DOMElement $image
@return string | [
"@param",
"int",
"$attachment_id",
"@param",
"string",
"$src_old",
"@param",
"\\",
"DOMElement",
"$image"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/wordpress/class-downloads.php#L194-L233 |
pressbooks/pressbooks | inc/modules/import/wordpress/class-downloads.php | Downloads.fetchAndSaveUniqueMedia | public function fetchAndSaveUniqueMedia( $url ) {
if ( ! filter_var( $url, FILTER_VALIDATE_URL ) ) {
return 0;
}
if ( ! $this->sameAsSource( $url ) ) {
return -1;
}
$known_media = $this->wxr->getKnownMedia();
$filename = $this->basename( $url );
$attached_file = media_strip_baseurl( $url );
if (... | php | public function fetchAndSaveUniqueMedia( $url ) {
if ( ! filter_var( $url, FILTER_VALIDATE_URL ) ) {
return 0;
}
if ( ! $this->sameAsSource( $url ) ) {
return -1;
}
$known_media = $this->wxr->getKnownMedia();
$filename = $this->basename( $url );
$attached_file = media_strip_baseurl( $url );
if (... | [
"public",
"function",
"fetchAndSaveUniqueMedia",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"!",
"filter_var",
"(",
"$",
"url",
",",
"FILTER_VALIDATE_URL",
")",
")",
"{",
"return",
"0",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"sameAsSource",
"(",
"$",
... | Load remote media into WP using media_handle_sideload()
Will return -1 if media is not hosted on the source Pb network, or 0 if something went wrong.
@param string $url
@see media_handle_sideload
@return int attachment ID, -1 if media is not hosted on the source Pb network, or 0 if import failed | [
"Load",
"remote",
"media",
"into",
"WP",
"using",
"media_handle_sideload",
"()",
"Will",
"return",
"-",
"1",
"if",
"media",
"is",
"not",
"hosted",
"on",
"the",
"source",
"Pb",
"network",
"or",
"0",
"if",
"something",
"went",
"wrong",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/wordpress/class-downloads.php#L293-L357 |
pressbooks/pressbooks | inc/modules/import/wordpress/class-downloads.php | Downloads.basename | public function basename( $url ) {
$filename = explode( '?', basename( $url ) );
$filename = array_shift( $filename );
$filename = explode( '#', $filename )[0]; // Remove trailing anchors
$filename = sanitize_file_name( urldecode( $filename ) );
return $filename;
} | php | public function basename( $url ) {
$filename = explode( '?', basename( $url ) );
$filename = array_shift( $filename );
$filename = explode( '#', $filename )[0]; // Remove trailing anchors
$filename = sanitize_file_name( urldecode( $filename ) );
return $filename;
} | [
"public",
"function",
"basename",
"(",
"$",
"url",
")",
"{",
"$",
"filename",
"=",
"explode",
"(",
"'?'",
",",
"basename",
"(",
"$",
"url",
")",
")",
";",
"$",
"filename",
"=",
"array_shift",
"(",
"$",
"filename",
")",
";",
"$",
"filename",
"=",
"e... | Get sanitized basename without query string or anchors
@param $url
@return array|mixed|string | [
"Get",
"sanitized",
"basename",
"without",
"query",
"string",
"or",
"anchors"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/wordpress/class-downloads.php#L366-L373 |
pressbooks/pressbooks | inc/modules/export/xhtml/class-xhtml11.php | Xhtml11.convertGenerator | public function convertGenerator() : \Generator {
yield 1 => $this->generatorPrefix . __( 'Initializing', 'pressbooks' );
yield from $this->transformGenerator();
if ( ! $this->transformOutput ) {
throw new \Exception();
}
yield 75 => $this->generatorPrefix . __( 'Saving file to exports folder', 'pressbo... | php | public function convertGenerator() : \Generator {
yield 1 => $this->generatorPrefix . __( 'Initializing', 'pressbooks' );
yield from $this->transformGenerator();
if ( ! $this->transformOutput ) {
throw new \Exception();
}
yield 75 => $this->generatorPrefix . __( 'Saving file to exports folder', 'pressbo... | [
"public",
"function",
"convertGenerator",
"(",
")",
":",
"\\",
"Generator",
"{",
"yield",
"1",
"=>",
"$",
"this",
"->",
"generatorPrefix",
".",
"__",
"(",
"'Initializing'",
",",
"'pressbooks'",
")",
";",
"yield",
"from",
"$",
"this",
"->",
"transformGenerato... | 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/xhtml/class-xhtml11.php#L178-L192 |
pressbooks/pressbooks | inc/modules/export/xhtml/class-xhtml11.php | Xhtml11.validateGenerator | public function validateGenerator() : \Generator {
yield 80 => $this->generatorPrefix . __( 'Validating file', 'pressbooks' );
// Xmllint params
$command = PB_XMLLINT_COMMAND . ' --html --valid --noout ' . escapeshellcmd( $this->outputPath ) . ' 2>&1';
// Execute command
$output = [];
$return_var = 0;
e... | php | public function validateGenerator() : \Generator {
yield 80 => $this->generatorPrefix . __( 'Validating file', 'pressbooks' );
// Xmllint params
$command = PB_XMLLINT_COMMAND . ' --html --valid --noout ' . escapeshellcmd( $this->outputPath ) . ' 2>&1';
// Execute command
$output = [];
$return_var = 0;
e... | [
"public",
"function",
"validateGenerator",
"(",
")",
":",
"\\",
"Generator",
"{",
"yield",
"80",
"=>",
"$",
"this",
"->",
"generatorPrefix",
".",
"__",
"(",
"'Validating file'",
",",
"'pressbooks'",
")",
";",
"// Xmllint params",
"$",
"command",
"=",
"PB_XMLLI... | 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/xhtml/class-xhtml11.php#L216-L234 |
pressbooks/pressbooks | inc/modules/export/xhtml/class-xhtml11.php | Xhtml11.transform | public function transform( $return = false ) {
// Check permissions
if ( ! current_user_can( 'edit_posts' ) ) {
$timestamp = ( isset( $_REQUEST['timestamp'] ) ) ? absint( $_REQUEST['timestamp'] ) : 0;
$hashkey = ( isset( $_REQUEST['hashkey'] ) ) ? $_REQUEST['hashkey'] : '';
if ( ! $this->verifyNonce( $ti... | php | public function transform( $return = false ) {
// Check permissions
if ( ! current_user_can( 'edit_posts' ) ) {
$timestamp = ( isset( $_REQUEST['timestamp'] ) ) ? absint( $_REQUEST['timestamp'] ) : 0;
$hashkey = ( isset( $_REQUEST['hashkey'] ) ) ? $_REQUEST['hashkey'] : '';
if ( ! $this->verifyNonce( $ti... | [
"public",
"function",
"transform",
"(",
"$",
"return",
"=",
"false",
")",
"{",
"// Check permissions",
"if",
"(",
"!",
"current_user_can",
"(",
"'edit_posts'",
")",
")",
"{",
"$",
"timestamp",
"=",
"(",
"isset",
"(",
"$",
"_REQUEST",
"[",
"'timestamp'",
"]... | Procedure for "format/xhtml" rewrite rule.
Supported http (aka $_GET) params:
+ timestamp: (int) combines with `hashkey` to allow a 3rd party service temporary access
+ hashkey: (string) combines with `timestamp` to allow a 3rd party service temporary access
+ endnotes: (bool) move all footnotes to end of the book
+ ... | [
"Procedure",
"for",
"format",
"/",
"xhtml",
"rewrite",
"rule",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/xhtml/class-xhtml11.php#L257-L283 |
pressbooks/pressbooks | inc/modules/export/xhtml/class-xhtml11.php | Xhtml11.transformGenerator | public function transformGenerator() : \Generator {
do_action( 'pb_pre_export' );
// Override footnote shortcode
if ( ! empty( $_GET['endnotes'] ) ) {
add_shortcode( 'footnote', [ $this, 'endnoteShortcode' ] );
} else {
add_shortcode( 'footnote', [ $this, 'footnoteShortcode' ] );
}
// -------------... | php | public function transformGenerator() : \Generator {
do_action( 'pb_pre_export' );
// Override footnote shortcode
if ( ! empty( $_GET['endnotes'] ) ) {
add_shortcode( 'footnote', [ $this, 'endnoteShortcode' ] );
} else {
add_shortcode( 'footnote', [ $this, 'footnoteShortcode' ] );
}
// -------------... | [
"public",
"function",
"transformGenerator",
"(",
")",
":",
"\\",
"Generator",
"{",
"do_action",
"(",
"'pb_pre_export'",
")",
";",
"// Override footnote shortcode",
"if",
"(",
"!",
"empty",
"(",
"$",
"_GET",
"[",
"'endnotes'",
"]",
")",
")",
"{",
"add_shortcode... | Yields an estimated percentage slice of: 10 to 75
@return \Generator
@throws \Exception | [
"Yields",
"an",
"estimated",
"percentage",
"slice",
"of",
":",
"10",
"to",
"75"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/xhtml/class-xhtml11.php#L291-L436 |
pressbooks/pressbooks | inc/modules/export/xhtml/class-xhtml11.php | Xhtml11.endnoteShortcode | function endnoteShortcode( $atts, $content = null ) {
global $id; // This is the Post ID, [@see WP_Query::setup_postdata, preProcessBookContents, ...]
if ( ! $content ) {
return '';
}
$this->endnotes[ $id ][] = trim( $content );
return '<sup class="endnote">' . count( $this->endnotes[ $id ] ) . '</sup>... | php | function endnoteShortcode( $atts, $content = null ) {
global $id; // This is the Post ID, [@see WP_Query::setup_postdata, preProcessBookContents, ...]
if ( ! $content ) {
return '';
}
$this->endnotes[ $id ][] = trim( $content );
return '<sup class="endnote">' . count( $this->endnotes[ $id ] ) . '</sup>... | [
"function",
"endnoteShortcode",
"(",
"$",
"atts",
",",
"$",
"content",
"=",
"null",
")",
"{",
"global",
"$",
"id",
";",
"// This is the Post ID, [@see WP_Query::setup_postdata, preProcessBookContents, ...]",
"if",
"(",
"!",
"$",
"content",
")",
"{",
"return",
"''",
... | Convert footnotes to endnotes by moving them to the end of the_content()
@see doEndnotes
@param array $atts
@param null $content
@return string | [
"Convert",
"footnotes",
"to",
"endnotes",
"by",
"moving",
"them",
"to",
"the",
"end",
"of",
"the_content",
"()"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/xhtml/class-xhtml11.php#L479-L490 |
pressbooks/pressbooks | inc/modules/export/xhtml/class-xhtml11.php | Xhtml11.doEndnotes | function doEndnotes( $id ) {
if ( ! isset( $this->endnotes[ $id ] ) || ! count( $this->endnotes[ $id ] ) ) {
return '';
}
$e = '<div class="endnotes">';
$e .= '<hr />';
$e .= '<h3>' . __( 'Notes', 'pressbooks' ) . '</h3>';
$e .= '<ol>';
foreach ( $this->endnotes[ $id ] as $endnote ) {
$e .= "<li><... | php | function doEndnotes( $id ) {
if ( ! isset( $this->endnotes[ $id ] ) || ! count( $this->endnotes[ $id ] ) ) {
return '';
}
$e = '<div class="endnotes">';
$e .= '<hr />';
$e .= '<h3>' . __( 'Notes', 'pressbooks' ) . '</h3>';
$e .= '<ol>';
foreach ( $this->endnotes[ $id ] as $endnote ) {
$e .= "<li><... | [
"function",
"doEndnotes",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"endnotes",
"[",
"$",
"id",
"]",
")",
"||",
"!",
"count",
"(",
"$",
"this",
"->",
"endnotes",
"[",
"$",
"id",
"]",
")",
")",
"{",
"return",
"... | Style endnotes.
@see endnoteShortcode
@param $id
@return string | [
"Style",
"endnotes",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/xhtml/class-xhtml11.php#L502-L518 |
pressbooks/pressbooks | inc/modules/export/xhtml/class-xhtml11.php | Xhtml11.removeAttributionLink | protected function removeAttributionLink( $content ) {
if ( stripos( $content, '<a' ) === false ) {
// There are no <a> tags to look at, skip this
return $content;
}
$changed = false;
$html5 = new HtmlParser();
$dom = $html5->loadHTML( $content );
$urls = $dom->getElementsByTagName( 'a' );
foreach... | php | protected function removeAttributionLink( $content ) {
if ( stripos( $content, '<a' ) === false ) {
// There are no <a> tags to look at, skip this
return $content;
}
$changed = false;
$html5 = new HtmlParser();
$dom = $html5->loadHTML( $content );
$urls = $dom->getElementsByTagName( 'a' );
foreach... | [
"protected",
"function",
"removeAttributionLink",
"(",
"$",
"content",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"content",
",",
"'<a'",
")",
"===",
"false",
")",
"{",
"// There are no <a> tags to look at, skip this",
"return",
"$",
"content",
";",
"}",
"$",
"... | Removes the CC attribution link. Returns valid xhtml.
@since 4.1
@param string $content
@return string | [
"Removes",
"the",
"CC",
"attribution",
"link",
".",
"Returns",
"valid",
"xhtml",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/xhtml/class-xhtml11.php#L679-L709 |
pressbooks/pressbooks | inc/modules/export/xhtml/class-xhtml11.php | Xhtml11.echoFrontMatterGenerator | protected function echoFrontMatterGenerator( $book_contents, $metadata ) : \Generator {
$front_matter_printf = '<div class="front-matter %1$s" id="%2$s" title="%3$s">';
$front_matter_printf .= '<div class="front-matter-title-wrap"><h3 class="front-matter-number">%4$s</h3><h1 class="front-matter-title">%5$s</h1>%6$s... | php | protected function echoFrontMatterGenerator( $book_contents, $metadata ) : \Generator {
$front_matter_printf = '<div class="front-matter %1$s" id="%2$s" title="%3$s">';
$front_matter_printf .= '<div class="front-matter-title-wrap"><h3 class="front-matter-number">%4$s</h3><h1 class="front-matter-title">%5$s</h1>%6$s... | [
"protected",
"function",
"echoFrontMatterGenerator",
"(",
"$",
"book_contents",
",",
"$",
"metadata",
")",
":",
"\\",
"Generator",
"{",
"$",
"front_matter_printf",
"=",
"'<div class=\"front-matter %1$s\" id=\"%2$s\" title=\"%3$s\">'",
";",
"$",
"front_matter_printf",
".=",
... | Yields an estimated percentage slice of: 50 to 60
@param array $book_contents
@param array $metadata
@return \Generator | [
"Yields",
"an",
"estimated",
"percentage",
"slice",
"of",
":",
"50",
"to",
"60"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/xhtml/class-xhtml11.php#L1217-L1307 |
pressbooks/pressbooks | inc/modules/export/xhtml/class-xhtml11.php | Xhtml11.echoPartsAndChaptersGenerator | protected function echoPartsAndChaptersGenerator( $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_printf ... | php | protected function echoPartsAndChaptersGenerator( $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_printf ... | [
"protected",
"function",
"echoPartsAndChaptersGenerator",
"(",
"$",
"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: 60 to 70
@param array $book_contents
@param array $metadata
@return \Generator | [
"Yields",
"an",
"estimated",
"percentage",
"slice",
"of",
":",
"60",
"to",
"70"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/xhtml/class-xhtml11.php#L1330-L1503 |
pressbooks/pressbooks | inc/modules/export/xhtml/class-xhtml11.php | Xhtml11.echoBackMatterGenerator | protected function echoBackMatterGenerator( $book_contents, $metadata ) : \Generator {
$back_matter_printf = '<div class="back-matter %1$s" id="%2$s" title="%3$s">';
$back_matter_printf .= '<div class="back-matter-title-wrap"><h3 class="back-matter-number">%4$s</h3><h1 class="back-matter-title">%5$s</h1>%6$s</div>'... | php | protected function echoBackMatterGenerator( $book_contents, $metadata ) : \Generator {
$back_matter_printf = '<div class="back-matter %1$s" id="%2$s" title="%3$s">';
$back_matter_printf .= '<div class="back-matter-title-wrap"><h3 class="back-matter-number">%4$s</h3><h1 class="back-matter-title">%5$s</h1>%6$s</div>'... | [
"protected",
"function",
"echoBackMatterGenerator",
"(",
"$",
"book_contents",
",",
"$",
"metadata",
")",
":",
"\\",
"Generator",
"{",
"$",
"back_matter_printf",
"=",
"'<div class=\"back-matter %1$s\" id=\"%2$s\" title=\"%3$s\">'",
";",
"$",
"back_matter_printf",
".=",
"'... | Yields an estimated percentage slice of: 70 to 80
@param array $book_contents
@param array $metadata
@return \Generator | [
"Yields",
"an",
"estimated",
"percentage",
"slice",
"of",
":",
"70",
"to",
"80"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/xhtml/class-xhtml11.php#L1513-L1590 |
pressbooks/pressbooks | inc/class-pressbooks.php | Pressbooks.registerThemeDirectories | function registerThemeDirectories() {
/**
* Register additional theme directories.
*
* Additional theme directories (e.g. those within another plugin, or custom
* subdirectories of wp-content) may be registered via this action hook.
*
* @since 3.8.0
*/
do_action( 'pressbooks_register_theme_dir... | php | function registerThemeDirectories() {
/**
* Register additional theme directories.
*
* Additional theme directories (e.g. those within another plugin, or custom
* subdirectories of wp-content) may be registered via this action hook.
*
* @since 3.8.0
*/
do_action( 'pressbooks_register_theme_dir... | [
"function",
"registerThemeDirectories",
"(",
")",
"{",
"/**\n\t\t * Register additional theme directories.\n\t\t *\n\t\t * Additional theme directories (e.g. those within another plugin, or custom\n\t\t * subdirectories of wp-content) may be registered via this action hook.\n\t\t *\n\t\t * @since 3.8.0\n\... | Register theme directories, set a filter that hides themes under certain conditions | [
"Register",
"theme",
"directories",
"set",
"a",
"filter",
"that",
"hides",
"themes",
"under",
"certain",
"conditions"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-pressbooks.php#L39-L58 |
pressbooks/pressbooks | inc/class-pressbooks.php | Pressbooks.allowedBookThemes | function allowedBookThemes( $themes ) {
$compare = search_theme_directories();
$themes = array_intersect_key( $themes, $compare );
foreach ( $compare as $key => $val ) {
$stylesheet = str_replace( 'style.css', '', $val['theme_file'] );
$theme = wp_get_theme( $stylesheet, $val['theme_root'] );
// Hide any... | php | function allowedBookThemes( $themes ) {
$compare = search_theme_directories();
$themes = array_intersect_key( $themes, $compare );
foreach ( $compare as $key => $val ) {
$stylesheet = str_replace( 'style.css', '', $val['theme_file'] );
$theme = wp_get_theme( $stylesheet, $val['theme_root'] );
// Hide any... | [
"function",
"allowedBookThemes",
"(",
"$",
"themes",
")",
"{",
"$",
"compare",
"=",
"search_theme_directories",
"(",
")",
";",
"$",
"themes",
"=",
"array_intersect_key",
"(",
"$",
"themes",
",",
"$",
"compare",
")",
";",
"foreach",
"(",
"$",
"compare",
"as... | Used by add_filter( 'allowed_themes' ). Will hide any non-book themes.
@param array $themes
@return array | [
"Used",
"by",
"add_filter",
"(",
"allowed_themes",
")",
".",
"Will",
"hide",
"any",
"non",
"-",
"book",
"themes",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-pressbooks.php#L68-L81 |
pressbooks/pressbooks | inc/modules/searchandreplace/types/class-content.php | Content.find | function find( $pattern, $limit, $offset, $orderby ) {
global $wpdb;
$results = [];
$sql = "SELECT ID, post_content, post_title FROM {$wpdb->posts}
WHERE post_type IN ('part','chapter','front-matter','back-matter')
AND post_status NOT IN ('trash','inherit')
ORDER BY ID ";
$sql .= ( 'asc' === $order... | php | function find( $pattern, $limit, $offset, $orderby ) {
global $wpdb;
$results = [];
$sql = "SELECT ID, post_content, post_title FROM {$wpdb->posts}
WHERE post_type IN ('part','chapter','front-matter','back-matter')
AND post_status NOT IN ('trash','inherit')
ORDER BY ID ";
$sql .= ( 'asc' === $order... | [
"function",
"find",
"(",
"$",
"pattern",
",",
"$",
"limit",
",",
"$",
"offset",
",",
"$",
"orderby",
")",
"{",
"global",
"$",
"wpdb",
";",
"$",
"results",
"=",
"[",
"]",
";",
"$",
"sql",
"=",
"\"SELECT ID, post_content, post_title FROM {$wpdb->posts}\n\t\t\t... | @param $pattern
@param $limit
@param $offset
@param $orderby
@return \Pressbooks\Modules\SearchAndReplace\Result[] | [
"@param",
"$pattern",
"@param",
"$limit",
"@param",
"$offset",
"@param",
"$orderby"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/searchandreplace/types/class-content.php#L21-L49 |
pressbooks/pressbooks | inc/modules/searchandreplace/types/class-content.php | Content.getOptions | function getOptions( $result ) {
$options[] = '<a href="' . get_permalink( $result->id ) . '">' . __( 'view', 'pressbooks' ) . '</a>';
if ( current_user_can( 'edit_post', $result->id ) ) {
$options[] = '<a href="' . get_bloginfo( 'wpurl' ) . '/wp-admin/post.php?action=edit&post=' . $result->id . '">' . __( '... | php | function getOptions( $result ) {
$options[] = '<a href="' . get_permalink( $result->id ) . '">' . __( 'view', 'pressbooks' ) . '</a>';
if ( current_user_can( 'edit_post', $result->id ) ) {
$options[] = '<a href="' . get_bloginfo( 'wpurl' ) . '/wp-admin/post.php?action=edit&post=' . $result->id . '">' . __( '... | [
"function",
"getOptions",
"(",
"$",
"result",
")",
"{",
"$",
"options",
"[",
"]",
"=",
"'<a href=\"'",
".",
"get_permalink",
"(",
"$",
"result",
"->",
"id",
")",
".",
"'\">'",
".",
"__",
"(",
"'view'",
",",
"'pressbooks'",
")",
".",
"'</a>'",
";",
"i... | @param object $result
@return array | [
"@param",
"object",
"$result"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/searchandreplace/types/class-content.php#L56-L62 |
pressbooks/pressbooks | inc/modules/searchandreplace/types/class-content.php | Content.getContent | function getContent( $id ) {
global $wpdb;
$post = $wpdb->get_row( $wpdb->prepare( "SELECT post_content FROM {$wpdb->posts} WHERE id=%d", $id ) );
return $post->post_content;
} | php | function getContent( $id ) {
global $wpdb;
$post = $wpdb->get_row( $wpdb->prepare( "SELECT post_content FROM {$wpdb->posts} WHERE id=%d", $id ) );
return $post->post_content;
} | [
"function",
"getContent",
"(",
"$",
"id",
")",
"{",
"global",
"$",
"wpdb",
";",
"$",
"post",
"=",
"$",
"wpdb",
"->",
"get_row",
"(",
"$",
"wpdb",
"->",
"prepare",
"(",
"\"SELECT post_content FROM {$wpdb->posts} WHERE id=%d\"",
",",
"$",
"id",
")",
")",
";"... | @param int $id
@return string | [
"@param",
"int",
"$id"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/searchandreplace/types/class-content.php#L77-L81 |
pressbooks/pressbooks | inc/modules/searchandreplace/class-search.php | Search.regexValidate | function regexValidate( $expr ) {
// evaluate expression without input and capture potential error message
$regex_error = 'invalid';
$error_handler = function( $errno, $errstr, $errfile, $errline ) use ( &$regex_error ) {
$regex_error = preg_replace( '/(.*?):/', '', $errstr, 1 );
};
// detect possibility t... | php | function regexValidate( $expr ) {
// evaluate expression without input and capture potential error message
$regex_error = 'invalid';
$error_handler = function( $errno, $errstr, $errfile, $errline ) use ( &$regex_error ) {
$regex_error = preg_replace( '/(.*?):/', '', $errstr, 1 );
};
// detect possibility t... | [
"function",
"regexValidate",
"(",
"$",
"expr",
")",
"{",
"// evaluate expression without input and capture potential error message",
"$",
"regex_error",
"=",
"'invalid'",
";",
"$",
"error_handler",
"=",
"function",
"(",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"e... | @param string $expr
@return null|string | [
"@param",
"string",
"$expr"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/searchandreplace/class-search.php#L52-L81 |
pressbooks/pressbooks | inc/modules/searchandreplace/class-search.php | Search.searchAndReplace | function searchAndReplace( $search, $replace, $limit, $offset, $orderby, $save = false ) {
// escape potential backreferences when not in regex mode
if ( ! $this->regex ) {
$replace = str_replace( '\\', '\\\\', $replace );
$replace = str_replace( '$', '\\$', $replace );
}
$this->replace = $replace;
$res... | php | function searchAndReplace( $search, $replace, $limit, $offset, $orderby, $save = false ) {
// escape potential backreferences when not in regex mode
if ( ! $this->regex ) {
$replace = str_replace( '\\', '\\\\', $replace );
$replace = str_replace( '$', '\\$', $replace );
}
$this->replace = $replace;
$res... | [
"function",
"searchAndReplace",
"(",
"$",
"search",
",",
"$",
"replace",
",",
"$",
"limit",
",",
"$",
"offset",
",",
"$",
"orderby",
",",
"$",
"save",
"=",
"false",
")",
"{",
"// escape potential backreferences when not in regex mode",
"if",
"(",
"!",
"$",
"... | @param string $search
@param string $replace
@param int $limit
@param int $offset
@param string $orderby
@param bool $save
@return \Pressbooks\Modules\SearchAndReplace\Result[] | [
"@param",
"string",
"$search",
"@param",
"string",
"$replace",
"@param",
"int",
"$limit",
"@param",
"int",
"$offset",
"@param",
"string",
"$orderby",
"@param",
"bool",
"$save"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/searchandreplace/class-search.php#L93-L105 |
pressbooks/pressbooks | inc/modules/searchandreplace/class-search.php | Search.searchForPattern | function searchForPattern( $search, $limit, $offset, $orderby ) {
if ( ! in_array( $orderby, [ 'asc', 'desc' ], true ) ) {
$orderby = 'asc';
}
$limit = intval( $limit );
$offset = intval( $offset );
if ( strlen( $search ) > 0 ) {
/**
* Maximum execution time, in seconds. If set to zero, no time limi... | php | function searchForPattern( $search, $limit, $offset, $orderby ) {
if ( ! in_array( $orderby, [ 'asc', 'desc' ], true ) ) {
$orderby = 'asc';
}
$limit = intval( $limit );
$offset = intval( $offset );
if ( strlen( $search ) > 0 ) {
/**
* Maximum execution time, in seconds. If set to zero, no time limi... | [
"function",
"searchForPattern",
"(",
"$",
"search",
",",
"$",
"limit",
",",
"$",
"offset",
",",
"$",
"orderby",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"orderby",
",",
"[",
"'asc'",
",",
"'desc'",
"]",
",",
"true",
")",
")",
"{",
"$",
"or... | @param string $search
@param int $limit
@param int $offset
@param string $orderby
@return string|\Pressbooks\Modules\SearchAndReplace\Result[] | [
"@param",
"string",
"$search",
"@param",
"int",
"$limit",
"@param",
"int",
"$offset",
"@param",
"string",
"$orderby"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/searchandreplace/class-search.php#L115-L147 |
pressbooks/pressbooks | inc/modules/searchandreplace/class-search.php | Search.getSearches | static function getSearches() {
static $search_types = null; // Cheap cache
if ( ! is_array( $search_types ) ) {
$classes = [];
$files = glob( __DIR__ . '/types/*.php' );
foreach ( $files as $file ) {
preg_match( '/class-(.*?)\.php/', $file, $match );
$class = __NAMESPACE__ . '\Types\\' . ucfirst( ... | php | static function getSearches() {
static $search_types = null; // Cheap cache
if ( ! is_array( $search_types ) ) {
$classes = [];
$files = glob( __DIR__ . '/types/*.php' );
foreach ( $files as $file ) {
preg_match( '/class-(.*?)\.php/', $file, $match );
$class = __NAMESPACE__ . '\Types\\' . ucfirst( ... | [
"static",
"function",
"getSearches",
"(",
")",
"{",
"static",
"$",
"search_types",
"=",
"null",
";",
"// Cheap cache",
"if",
"(",
"!",
"is_array",
"(",
"$",
"search_types",
")",
")",
"{",
"$",
"classes",
"=",
"[",
"]",
";",
"$",
"files",
"=",
"glob",
... | Scan types/*.php directory for classes we can use
@return array | [
"Scan",
"types",
"/",
"*",
".",
"php",
"directory",
"for",
"classes",
"we",
"can",
"use"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/searchandreplace/class-search.php#L154-L169 |
pressbooks/pressbooks | inc/modules/searchandreplace/class-search.php | Search.validSearch | static function validSearch( $class ) {
$classes = Search::getSearches();
foreach ( $classes as $item ) {
if ( strcasecmp( get_class( $item ), $class ) === 0 ) {
return true;
}
}
return false;
} | php | static function validSearch( $class ) {
$classes = Search::getSearches();
foreach ( $classes as $item ) {
if ( strcasecmp( get_class( $item ), $class ) === 0 ) {
return true;
}
}
return false;
} | [
"static",
"function",
"validSearch",
"(",
"$",
"class",
")",
"{",
"$",
"classes",
"=",
"Search",
"::",
"getSearches",
"(",
")",
";",
"foreach",
"(",
"$",
"classes",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"strcasecmp",
"(",
"get_class",
"(",
"$",
"it... | @param string $class
@return bool | [
"@param",
"string",
"$class"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/searchandreplace/class-search.php#L176-L184 |
pressbooks/pressbooks | inc/modules/searchandreplace/class-search.php | Search.matches | function matches( $pattern, $content, $id ) {
$matches = null;
if ( preg_match_all( $pattern, $content, $matches, PREG_OFFSET_CAPTURE ) > 0 ) {
// Reduce memory usage by doing preg_replace() for the same $pattern/$replacement combination only once
$content_replace = preg_replace( $pattern, $this->replace, $co... | php | function matches( $pattern, $content, $id ) {
$matches = null;
if ( preg_match_all( $pattern, $content, $matches, PREG_OFFSET_CAPTURE ) > 0 ) {
// Reduce memory usage by doing preg_replace() for the same $pattern/$replacement combination only once
$content_replace = preg_replace( $pattern, $this->replace, $co... | [
"function",
"matches",
"(",
"$",
"pattern",
",",
"$",
"content",
",",
"$",
"id",
")",
"{",
"$",
"matches",
"=",
"null",
";",
"if",
"(",
"preg_match_all",
"(",
"$",
"pattern",
",",
"$",
"content",
",",
"$",
"matches",
",",
"PREG_OFFSET_CAPTURE",
")",
... | @param string $pattern
@param string $content
@param int $id
@return \Pressbooks\Modules\SearchAndReplace\Result[]|false | [
"@param",
"string",
"$pattern",
"@param",
"string",
"$content",
"@param",
"int",
"$id"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/searchandreplace/class-search.php#L193-L262 |
pressbooks/pressbooks | inc/shortcodes/wikipublisher/class-glyphs.php | Glyphs.init | public static function init() {
if ( is_null( self::$instance ) ) {
self::$instance = new self();
self::hooks( self::$instance );
}
return self::$instance;
} | php | public static function init() {
if ( is_null( self::$instance ) ) {
self::$instance = new self();
self::hooks( self::$instance );
}
return self::$instance;
} | [
"public",
"static",
"function",
"init",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"self",
"::",
"$",
"instance",
")",
")",
"{",
"self",
"::",
"$",
"instance",
"=",
"new",
"self",
"(",
")",
";",
"self",
"::",
"hooks",
"(",
"self",
"::",
"$",
"inst... | Function to init our class, set filters & hooks, set a singleton instance
@deprecated
@return Glyphs | [
"Function",
"to",
"init",
"our",
"class",
"set",
"filters",
"&",
"hooks",
"set",
"a",
"singleton",
"instance"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/shortcodes/wikipublisher/class-glyphs.php#L36-L42 |
pressbooks/pressbooks | inc/shortcodes/wikipublisher/class-glyphs.php | Glyphs.langShortcode | public function langShortcode( $atts, $content = null ) {
$a = shortcode_atts(
[
'lang' => '',
], $atts
);
if ( empty( $content ) || empty( $a['lang'] ) || ! in_array( $a['lang'], $this->supported_languages, true ) ) {
// We don't support this language
$_error = "*** ERROR: Unsupported pb_langua... | php | public function langShortcode( $atts, $content = null ) {
$a = shortcode_atts(
[
'lang' => '',
], $atts
);
if ( empty( $content ) || empty( $a['lang'] ) || ! in_array( $a['lang'], $this->supported_languages, true ) ) {
// We don't support this language
$_error = "*** ERROR: Unsupported pb_langua... | [
"public",
"function",
"langShortcode",
"(",
"$",
"atts",
",",
"$",
"content",
"=",
"null",
")",
"{",
"$",
"a",
"=",
"shortcode_atts",
"(",
"[",
"'lang'",
"=>",
"''",
",",
"]",
",",
"$",
"atts",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"content",
"... | @param $atts
@param null $content
@return string | [
"@param",
"$atts",
"@param",
"null",
"$content"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/shortcodes/wikipublisher/class-glyphs.php#L70-L107 |
pressbooks/pressbooks | inc/shortcodes/wikipublisher/class-glyphs.php | Glyphs.greek | private function greek( $text, $lang = 'grc' ) {
$monotonics = [
"'a" => 'ά',
"'e" => 'έ',
"'h" => 'ή',
"'i" => 'ί',
"'o" => 'ό',
"'u" => 'ύ',
"'w" => 'ώ',
"'A" => 'Ά',
"'E" => 'Έ',
"'H" => 'Ή',
"'I" => 'Ί',
"'O" => 'Ό',
... | php | private function greek( $text, $lang = 'grc' ) {
$monotonics = [
"'a" => 'ά',
"'e" => 'έ',
"'h" => 'ή',
"'i" => 'ί',
"'o" => 'ό',
"'u" => 'ύ',
"'w" => 'ώ',
"'A" => 'Ά',
"'E" => 'Έ',
"'H" => 'Ή',
"'I" => 'Ί',
"'O" => 'Ό',
... | [
"private",
"function",
"greek",
"(",
"$",
"text",
",",
"$",
"lang",
"=",
"'grc'",
")",
"{",
"$",
"monotonics",
"=",
"[",
"\"'a\"",
"=>",
"'ά'",
",",
"\"'e\"",
"=>",
"'έ'",
",",
"\"'h\"",
"=>",
"'ή'",
",",
"\"'i\"",
"=>",
"'ί'",
",",... | @param $text
@param string $lang
@return string | [
"@param",
"$text",
"@param",
"string",
"$lang"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/shortcodes/wikipublisher/class-glyphs.php#L116-L421 |
pressbooks/pressbooks | inc/covergenerator/class-spine.php | Spine.countPagesInMostRecentPdf | public function countPagesInMostRecentPdf() {
$files = \Pressbooks\Utility\group_exports();
if ( empty( $files ) ) {
return 0;
}
foreach ( $files as $date => $exports ) {
foreach ( $exports as $file ) {
$file_extension = substr( strrchr( $file, '.' ), 1 );
if ( 'pdf' === $file_extension ) {
... | php | public function countPagesInMostRecentPdf() {
$files = \Pressbooks\Utility\group_exports();
if ( empty( $files ) ) {
return 0;
}
foreach ( $files as $date => $exports ) {
foreach ( $exports as $file ) {
$file_extension = substr( strrchr( $file, '.' ), 1 );
if ( 'pdf' === $file_extension ) {
... | [
"public",
"function",
"countPagesInMostRecentPdf",
"(",
")",
"{",
"$",
"files",
"=",
"\\",
"Pressbooks",
"\\",
"Utility",
"\\",
"group_exports",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"files",
")",
")",
"{",
"return",
"0",
";",
"}",
"foreach",
"(... | Count the pages in the most recent PDF export
@return int | [
"Count",
"the",
"pages",
"in",
"the",
"most",
"recent",
"PDF",
"export"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/covergenerator/class-spine.php#L81-L107 |
pressbooks/pressbooks | inc/covergenerator/class-spine.php | Spine.countPagesInPdf | public function countPagesInPdf( $path_to_pdf ) {
if ( ! file_exists( $path_to_pdf ) ) {
throw new \InvalidArgumentException( "File not found: $path_to_pdf" );
}
$output = [];
$return_var = 0;
$command = PB_PDFINFO_COMMAND . ' ' . escapeshellarg( $path_to_pdf ) . ' | awk \'/Pages/ {print $2}\'';
exec( ... | php | public function countPagesInPdf( $path_to_pdf ) {
if ( ! file_exists( $path_to_pdf ) ) {
throw new \InvalidArgumentException( "File not found: $path_to_pdf" );
}
$output = [];
$return_var = 0;
$command = PB_PDFINFO_COMMAND . ' ' . escapeshellarg( $path_to_pdf ) . ' | awk \'/Pages/ {print $2}\'';
exec( ... | [
"public",
"function",
"countPagesInPdf",
"(",
"$",
"path_to_pdf",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path_to_pdf",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"File not found: $path_to_pdf\"",
")",
";",
"}",
"$",
"o... | Count the pages in a PDF file
@param $path_to_pdf
@return int | [
"Count",
"the",
"pages",
"in",
"a",
"PDF",
"file"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/covergenerator/class-spine.php#L117-L129 |
pressbooks/pressbooks | inc/class-metadata.php | Metadata.getMetaPostId | public function getMetaPostId() {
$args = [
'post_type' => 'metadata',
'posts_per_page' => 1,
'post_status' => 'publish',
'orderby' => 'modified',
'no_found_rows' => true,
'cache_results' => true,
'fields' => 'ids',
];
$q = new \WP_Query();
$results = $q->query( $args );
if ( empty( $re... | php | public function getMetaPostId() {
$args = [
'post_type' => 'metadata',
'posts_per_page' => 1,
'post_status' => 'publish',
'orderby' => 'modified',
'no_found_rows' => true,
'cache_results' => true,
'fields' => 'ids',
];
$q = new \WP_Query();
$results = $q->query( $args );
if ( empty( $re... | [
"public",
"function",
"getMetaPostId",
"(",
")",
"{",
"$",
"args",
"=",
"[",
"'post_type'",
"=>",
"'metadata'",
",",
"'posts_per_page'",
"=>",
"1",
",",
"'post_status'",
"=>",
"'publish'",
",",
"'orderby'",
"=>",
"'modified'",
",",
"'no_found_rows'",
"=>",
"tr... | Returns the latest "metadata" post ID. There should be only one per book.
@return int | [
"Returns",
"the",
"latest",
"metadata",
"post",
"ID",
".",
"There",
"should",
"be",
"only",
"one",
"per",
"book",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-metadata.php#L48-L67 |
pressbooks/pressbooks | inc/class-metadata.php | Metadata.getMetaPost | public function getMetaPost() {
$args = [
'post_type' => 'metadata',
'posts_per_page' => 1,
'post_status' => 'publish',
'orderby' => 'modified',
'no_found_rows' => true,
'cache_results' => true,
];
$q = new \WP_Query();
$results = $q->query( $args );
if ( empty( $results ) ) {
return f... | php | public function getMetaPost() {
$args = [
'post_type' => 'metadata',
'posts_per_page' => 1,
'post_status' => 'publish',
'orderby' => 'modified',
'no_found_rows' => true,
'cache_results' => true,
];
$q = new \WP_Query();
$results = $q->query( $args );
if ( empty( $results ) ) {
return f... | [
"public",
"function",
"getMetaPost",
"(",
")",
"{",
"$",
"args",
"=",
"[",
"'post_type'",
"=>",
"'metadata'",
",",
"'posts_per_page'",
"=>",
"1",
",",
"'post_status'",
"=>",
"'publish'",
",",
"'orderby'",
"=>",
"'modified'",
",",
"'no_found_rows'",
"=>",
"true... | Returns the latest "metadata" post. There should be only one per book.
@return \WP_Post|bool | [
"Returns",
"the",
"latest",
"metadata",
"post",
".",
"There",
"should",
"be",
"only",
"one",
"per",
"book",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-metadata.php#L75-L94 |
pressbooks/pressbooks | inc/class-metadata.php | Metadata.getMidByKey | public function getMidByKey( $post_id, $meta_key ) {
/** @var \wpdb $wpdb */
global $wpdb;
$mid = $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s LIMIT 1 ", $post_id, $meta_key ) );
if ( ! empty( $mid ) ) {
return absint( $mid );
}
return false;... | php | public function getMidByKey( $post_id, $meta_key ) {
/** @var \wpdb $wpdb */
global $wpdb;
$mid = $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s LIMIT 1 ", $post_id, $meta_key ) );
if ( ! empty( $mid ) ) {
return absint( $mid );
}
return false;... | [
"public",
"function",
"getMidByKey",
"(",
"$",
"post_id",
",",
"$",
"meta_key",
")",
"{",
"/** @var \\wpdb $wpdb */",
"global",
"$",
"wpdb",
";",
"$",
"mid",
"=",
"$",
"wpdb",
"->",
"get_var",
"(",
"$",
"wpdb",
"->",
"prepare",
"(",
"\"SELECT meta_id FROM $w... | Return a database ID for a given meta key.
@param int $post_id
@param string $meta_key
@return int|bool | [
"Return",
"a",
"database",
"ID",
"for",
"a",
"given",
"meta",
"key",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-metadata.php#L122-L132 |
pressbooks/pressbooks | inc/class-metadata.php | Metadata.jsonSerialize | public function jsonSerialize() {
$request = new \WP_REST_Request( 'GET', '/pressbooks/v2/metadata' );
$meta = new \Pressbooks\Api\Endpoints\Controller\Metadata();
$metadata = $meta
->get_item( $request )
->get_data();
return apply_filters( 'pb_json_metadata', $metadata );
} | php | public function jsonSerialize() {
$request = new \WP_REST_Request( 'GET', '/pressbooks/v2/metadata' );
$meta = new \Pressbooks\Api\Endpoints\Controller\Metadata();
$metadata = $meta
->get_item( $request )
->get_data();
return apply_filters( 'pb_json_metadata', $metadata );
} | [
"public",
"function",
"jsonSerialize",
"(",
")",
"{",
"$",
"request",
"=",
"new",
"\\",
"WP_REST_Request",
"(",
"'GET'",
",",
"'/pressbooks/v2/metadata'",
")",
";",
"$",
"meta",
"=",
"new",
"\\",
"Pressbooks",
"\\",
"Api",
"\\",
"Endpoints",
"\\",
"Controlle... | Returns a JSON object of the book information which can be posted to an API.
@since 4.0.0
@return array | [
"Returns",
"a",
"JSON",
"object",
"of",
"the",
"book",
"information",
"which",
"can",
"be",
"posted",
"to",
"an",
"API",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-metadata.php#L141-L150 |
pressbooks/pressbooks | inc/class-metadata.php | Metadata.upgrade | public function upgrade( $version ) {
if ( $version < 1 ) {
// Upgrade from version 0 (closed source service) to version 1 (initial open source offering)
$this->upgradeEcommerce();
$this->upgradeBookInformation();
$this->upgradeBook();
}
if ( $version < 3 ) {
\Pressbooks\CustomCss::upgradeCustomCs... | php | public function upgrade( $version ) {
if ( $version < 1 ) {
// Upgrade from version 0 (closed source service) to version 1 (initial open source offering)
$this->upgradeEcommerce();
$this->upgradeBookInformation();
$this->upgradeBook();
}
if ( $version < 3 ) {
\Pressbooks\CustomCss::upgradeCustomCs... | [
"public",
"function",
"upgrade",
"(",
"$",
"version",
")",
"{",
"if",
"(",
"$",
"version",
"<",
"1",
")",
"{",
"// Upgrade from version 0 (closed source service) to version 1 (initial open source offering)",
"$",
"this",
"->",
"upgradeEcommerce",
"(",
")",
";",
"$",
... | Upgrade metadata.
@param int $version | [
"Upgrade",
"metadata",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-metadata.php#L161-L198 |
pressbooks/pressbooks | inc/class-metadata.php | Metadata.upgradeEcommerce | public function upgradeEcommerce() {
$options = get_option( 'ecomm-url' );
$compare = $this->getDeprecatedComparisonTable( 'ecommerce' );
$new_options = [];
if ( $options ) {
foreach ( $options as $meta_key => $meta_value ) {
$new_meta_key = ( isset( $compare[ $meta_key ] ) ) ? $compare[ $meta_key ] : ... | php | public function upgradeEcommerce() {
$options = get_option( 'ecomm-url' );
$compare = $this->getDeprecatedComparisonTable( 'ecommerce' );
$new_options = [];
if ( $options ) {
foreach ( $options as $meta_key => $meta_value ) {
$new_meta_key = ( isset( $compare[ $meta_key ] ) ) ? $compare[ $meta_key ] : ... | [
"public",
"function",
"upgradeEcommerce",
"(",
")",
"{",
"$",
"options",
"=",
"get_option",
"(",
"'ecomm-url'",
")",
";",
"$",
"compare",
"=",
"$",
"this",
"->",
"getDeprecatedComparisonTable",
"(",
"'ecommerce'",
")",
";",
"$",
"new_options",
"=",
"[",
"]",... | Upgrade Ecommerce metadata - from version 0 (closed source) to version 1 (first open source version, february 2013)
@deprecated | [
"Upgrade",
"Ecommerce",
"metadata",
"-",
"from",
"version",
"0",
"(",
"closed",
"source",
")",
"to",
"version",
"1",
"(",
"first",
"open",
"source",
"version",
"february",
"2013",
")"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-metadata.php#L206-L223 |
pressbooks/pressbooks | inc/class-metadata.php | Metadata.upgradeBookInformation | public function upgradeBookInformation() {
// Metadata
$meta_post = $this->getMetaPost();
if ( ! $meta_post ) {
return; // Do nothing
}
$metadata = $this->getMetaPostMetadata();
$compare = $this->getDeprecatedComparisonTable( 'metadata' );
foreach ( $metadata as $meta_key => $meta_value ) {
$new... | php | public function upgradeBookInformation() {
// Metadata
$meta_post = $this->getMetaPost();
if ( ! $meta_post ) {
return; // Do nothing
}
$metadata = $this->getMetaPostMetadata();
$compare = $this->getDeprecatedComparisonTable( 'metadata' );
foreach ( $metadata as $meta_key => $meta_value ) {
$new... | [
"public",
"function",
"upgradeBookInformation",
"(",
")",
"{",
"// Metadata",
"$",
"meta_post",
"=",
"$",
"this",
"->",
"getMetaPost",
"(",
")",
";",
"if",
"(",
"!",
"$",
"meta_post",
")",
"{",
"return",
";",
"// Do nothing",
"}",
"$",
"metadata",
"=",
"... | Upgrade book information - from version 0 (closed source) to version 1 (first open source version, february 2013)
@deprecated | [
"Upgrade",
"book",
"information",
"-",
"from",
"version",
"0",
"(",
"closed",
"source",
")",
"to",
"version",
"1",
"(",
"first",
"open",
"source",
"version",
"february",
"2013",
")"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-metadata.php#L231-L270 |
pressbooks/pressbooks | inc/class-metadata.php | Metadata.upgradeBook | public function upgradeBook() {
$book_structure = Book::getBookStructure();
foreach ( $book_structure['__order'] as $post_id => $_ ) {
$meta = get_post_meta( $post_id );
$compare = $this->getDeprecatedComparisonTable( get_post_type( $post_id ) );
foreach ( $meta as $meta_key => $meta_value ) {
$new_... | php | public function upgradeBook() {
$book_structure = Book::getBookStructure();
foreach ( $book_structure['__order'] as $post_id => $_ ) {
$meta = get_post_meta( $post_id );
$compare = $this->getDeprecatedComparisonTable( get_post_type( $post_id ) );
foreach ( $meta as $meta_key => $meta_value ) {
$new_... | [
"public",
"function",
"upgradeBook",
"(",
")",
"{",
"$",
"book_structure",
"=",
"Book",
"::",
"getBookStructure",
"(",
")",
";",
"foreach",
"(",
"$",
"book_structure",
"[",
"'__order'",
"]",
"as",
"$",
"post_id",
"=>",
"$",
"_",
")",
"{",
"$",
"meta",
... | Upgrade book metadata - from version 0 (closed source) to version 1 (first open source version, february 2013)
@deprecated | [
"Upgrade",
"book",
"metadata",
"-",
"from",
"version",
"0",
"(",
"closed",
"source",
")",
"to",
"version",
"1",
"(",
"first",
"open",
"source",
"version",
"february",
"2013",
")"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-metadata.php#L278-L304 |
pressbooks/pressbooks | inc/class-metadata.php | Metadata.getDeprecatedComparisonTable | public function getDeprecatedComparisonTable( $table, $new_as_keys = false ) {
if ( 'chapter' === $table ) {
// Chapter
$metadata = [
'short-title' => 'pb_short_title',
'subtitle' => 'pb_subtitle',
'chap_author' => 'pb_section_author',
'chapter-export' => 'pb_export',
'show-title' => 'pb_sho... | php | public function getDeprecatedComparisonTable( $table, $new_as_keys = false ) {
if ( 'chapter' === $table ) {
// Chapter
$metadata = [
'short-title' => 'pb_short_title',
'subtitle' => 'pb_subtitle',
'chap_author' => 'pb_section_author',
'chapter-export' => 'pb_export',
'show-title' => 'pb_sho... | [
"public",
"function",
"getDeprecatedComparisonTable",
"(",
"$",
"table",
",",
"$",
"new_as_keys",
"=",
"false",
")",
"{",
"if",
"(",
"'chapter'",
"===",
"$",
"table",
")",
"{",
"// Chapter",
"$",
"metadata",
"=",
"[",
"'short-title'",
"=>",
"'pb_short_title'",... | Upgrade from version 0 (closed source) to version 1 (first open source version, february 2013)
@deprecated
@param string $table
@param bool $new_as_keys
@return array | [
"Upgrade",
"from",
"version",
"0",
"(",
"closed",
"source",
")",
"to",
"version",
"1",
"(",
"first",
"open",
"source",
"version",
"february",
"2013",
")"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-metadata.php#L317-L396 |
pressbooks/pressbooks | inc/class-metadata.php | Metadata.fixDoubleSlashBug | public function fixDoubleSlashBug() {
$theme = wp_get_theme();
if ( ! $theme->exists() || ! $theme->is_allowed() ) {
return; // Do nothing
} else {
switch_theme( $theme->get_stylesheet() );
}
} | php | public function fixDoubleSlashBug() {
$theme = wp_get_theme();
if ( ! $theme->exists() || ! $theme->is_allowed() ) {
return; // Do nothing
} else {
switch_theme( $theme->get_stylesheet() );
}
} | [
"public",
"function",
"fixDoubleSlashBug",
"(",
")",
"{",
"$",
"theme",
"=",
"wp_get_theme",
"(",
")",
";",
"if",
"(",
"!",
"$",
"theme",
"->",
"exists",
"(",
")",
"||",
"!",
"$",
"theme",
"->",
"is_allowed",
"(",
")",
")",
"{",
"return",
";",
"// ... | Fix a double slash bug by reactivating theme with new settings.
@see \Pressbooks\Pressbooks::registerThemeDirectories | [
"Fix",
"a",
"double",
"slash",
"bug",
"by",
"reactivating",
"theme",
"with",
"new",
"settings",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-metadata.php#L403-L411 |
pressbooks/pressbooks | inc/class-metadata.php | Metadata.changeDefaultBookCover | public function changeDefaultBookCover() {
$post = $this->getMetaPost();
if ( $post ) {
$pb_cover_image = get_post_meta( $post->ID, 'pb_cover_image', true );
if ( preg_match( '~assets/images/default-book-cover\.png$~', $pb_cover_image ) ) {
update_post_meta( $post->ID, 'pb_cover_image', \Pressbooks\Imag... | php | public function changeDefaultBookCover() {
$post = $this->getMetaPost();
if ( $post ) {
$pb_cover_image = get_post_meta( $post->ID, 'pb_cover_image', true );
if ( preg_match( '~assets/images/default-book-cover\.png$~', $pb_cover_image ) ) {
update_post_meta( $post->ID, 'pb_cover_image', \Pressbooks\Imag... | [
"public",
"function",
"changeDefaultBookCover",
"(",
")",
"{",
"$",
"post",
"=",
"$",
"this",
"->",
"getMetaPost",
"(",
")",
";",
"if",
"(",
"$",
"post",
")",
"{",
"$",
"pb_cover_image",
"=",
"get_post_meta",
"(",
"$",
"post",
"->",
"ID",
",",
"'pb_cov... | Change default book cover from PNG to JPG | [
"Change",
"default",
"book",
"cover",
"from",
"PNG",
"to",
"JPG"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-metadata.php#L417-L428 |
pressbooks/pressbooks | inc/class-metadata.php | Metadata.makeThumbnailsForBookCover | public function makeThumbnailsForBookCover() {
$post = $this->getMetaPost();
if ( $post ) {
$pb_cover_image = get_post_meta( $post->ID, 'pb_cover_image', true );
if ( $pb_cover_image && ! \Pressbooks\Image\is_default_cover( $pb_cover_image ) ) {
$path = \Pressbooks\Utility\get_media_path( $pb_cover_ima... | php | public function makeThumbnailsForBookCover() {
$post = $this->getMetaPost();
if ( $post ) {
$pb_cover_image = get_post_meta( $post->ID, 'pb_cover_image', true );
if ( $pb_cover_image && ! \Pressbooks\Image\is_default_cover( $pb_cover_image ) ) {
$path = \Pressbooks\Utility\get_media_path( $pb_cover_ima... | [
"public",
"function",
"makeThumbnailsForBookCover",
"(",
")",
"{",
"$",
"post",
"=",
"$",
"this",
"->",
"getMetaPost",
"(",
")",
";",
"if",
"(",
"$",
"post",
")",
"{",
"$",
"pb_cover_image",
"=",
"get_post_meta",
"(",
"$",
"post",
"->",
"ID",
",",
"'pb... | Generate thumbnails for a user uploaded cover | [
"Generate",
"thumbnails",
"for",
"a",
"user",
"uploaded",
"cover"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-metadata.php#L434-L460 |
pressbooks/pressbooks | inc/class-metadata.php | Metadata.resetLandingPage | public function resetLandingPage() {
/** @var $wpdb \wpdb */
global $wpdb;
update_option( 'show_on_front', 'page' );
$id = $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE post_name = 'cover' AND post_type = 'page' AND post_status = 'publish' " );
if ( $id ) {
update_option( 'page_on_front', $id );
... | php | public function resetLandingPage() {
/** @var $wpdb \wpdb */
global $wpdb;
update_option( 'show_on_front', 'page' );
$id = $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE post_name = 'cover' AND post_type = 'page' AND post_status = 'publish' " );
if ( $id ) {
update_option( 'page_on_front', $id );
... | [
"public",
"function",
"resetLandingPage",
"(",
")",
"{",
"/** @var $wpdb \\wpdb */",
"global",
"$",
"wpdb",
";",
"update_option",
"(",
"'show_on_front'",
",",
"'page'",
")",
";",
"$",
"id",
"=",
"$",
"wpdb",
"->",
"get_var",
"(",
"\"SELECT ID FROM {$wpdb->posts} W... | Fix broken landing page | [
"Fix",
"broken",
"landing",
"page"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-metadata.php#L466-L482 |
pressbooks/pressbooks | inc/class-metadata.php | Metadata.migratePartContentToEditor | public function migratePartContentToEditor() {
/** @var $wpdb \wpdb */
global $wpdb;
$parts = $wpdb->get_results( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'part' AND post_status = 'publish' " );
foreach ( $parts as $part ) {
$pb_part_content = trim( get_post_meta( $part->ID, 'pb_part_content', true... | php | public function migratePartContentToEditor() {
/** @var $wpdb \wpdb */
global $wpdb;
$parts = $wpdb->get_results( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'part' AND post_status = 'publish' " );
foreach ( $parts as $part ) {
$pb_part_content = trim( get_post_meta( $part->ID, 'pb_part_content', true... | [
"public",
"function",
"migratePartContentToEditor",
"(",
")",
"{",
"/** @var $wpdb \\wpdb */",
"global",
"$",
"wpdb",
";",
"$",
"parts",
"=",
"$",
"wpdb",
"->",
"get_results",
"(",
"\"SELECT ID FROM {$wpdb->posts} WHERE post_type = 'part' AND post_status = 'publish' \"",
")",... | Migrate part content to content editor | [
"Migrate",
"part",
"content",
"to",
"content",
"editor"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-metadata.php#L488-L511 |
pressbooks/pressbooks | inc/class-metadata.php | Metadata.postStatiiConversion | public function postStatiiConversion( $status, $pb_export ) {
if ( ! is_bool( $pb_export ) ) {
return $status; // Doing it wrong...
}
if ( $pb_export ) {
// When pb_export = true and post_status = draft, new post_status = private
if ( $status === 'draft' ) {
return 'private';
}
// When pb_exp... | php | public function postStatiiConversion( $status, $pb_export ) {
if ( ! is_bool( $pb_export ) ) {
return $status; // Doing it wrong...
}
if ( $pb_export ) {
// When pb_export = true and post_status = draft, new post_status = private
if ( $status === 'draft' ) {
return 'private';
}
// When pb_exp... | [
"public",
"function",
"postStatiiConversion",
"(",
"$",
"status",
",",
"$",
"pb_export",
")",
"{",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"pb_export",
")",
")",
"{",
"return",
"$",
"status",
";",
"// Doing it wrong...",
"}",
"if",
"(",
"$",
"pb_export",
")... | @since 5.0.0
@param string $status
@param bool $pb_export
@return string | [
"@since",
"5",
".",
"0",
".",
"0"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-metadata.php#L562-L589 |
pressbooks/pressbooks | inc/covergenerator/class-princepdf.php | PrincePdf.generate | public function generate() {
$output_path = $this->timestampedFileName( 'pdf' );
$success = $this->generateWithPrince( $this->pdfProfile, $this->pdfOutputIntent, $this->generateHtml(), $output_path );
if ( true !== $success ) {
throw new \Exception( 'Failed to create PDF file' );
}
delete_transient( 'dirsi... | php | public function generate() {
$output_path = $this->timestampedFileName( 'pdf' );
$success = $this->generateWithPrince( $this->pdfProfile, $this->pdfOutputIntent, $this->generateHtml(), $output_path );
if ( true !== $success ) {
throw new \Exception( 'Failed to create PDF file' );
}
delete_transient( 'dirsi... | [
"public",
"function",
"generate",
"(",
")",
"{",
"$",
"output_path",
"=",
"$",
"this",
"->",
"timestampedFileName",
"(",
"'pdf'",
")",
";",
"$",
"success",
"=",
"$",
"this",
"->",
"generateWithPrince",
"(",
"$",
"this",
"->",
"pdfProfile",
",",
"$",
"thi... | Generate PDF print cover
@throws \Exception
@return string Output path | [
"Generate",
"PDF",
"print",
"cover"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/covergenerator/class-princepdf.php#L91-L99 |
pressbooks/pressbooks | inc/modules/export/class-table.php | Table.column_file | public function column_file( $item ) {
$html = '<div class="export-file">';
$html .= $this->getIcon( $item['file'] );
$html .= '<div class="export-file-name">' . esc_html( $item['file'] ) . '</div>';
$html .= '</div>';
$delete_url = sprintf( '/admin.php?page=%s&action=%s&ID=%s', $_REQUEST['page'], 'delete', ... | php | public function column_file( $item ) {
$html = '<div class="export-file">';
$html .= $this->getIcon( $item['file'] );
$html .= '<div class="export-file-name">' . esc_html( $item['file'] ) . '</div>';
$html .= '</div>';
$delete_url = sprintf( '/admin.php?page=%s&action=%s&ID=%s', $_REQUEST['page'], 'delete', ... | [
"public",
"function",
"column_file",
"(",
"$",
"item",
")",
"{",
"$",
"html",
"=",
"'<div class=\"export-file\">'",
";",
"$",
"html",
".=",
"$",
"this",
"->",
"getIcon",
"(",
"$",
"item",
"[",
"'file'",
"]",
")",
";",
"$",
"html",
".=",
"'<div class=\"ex... | @param array $item A singular item (one full row's worth of data)
@return string Text to be placed inside the column <td> | [
"@param",
"array",
"$item",
"A",
"singular",
"item",
"(",
"one",
"full",
"row",
"s",
"worth",
"of",
"data",
")"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-table.php#L66-L96 |
pressbooks/pressbooks | inc/modules/export/class-table.php | Table.column_pin | public function column_pin( $item ) {
$format = $this->getTinyHash( $item['format'] );
$html = "<input type='checkbox' id='pin[{$item['ID']}]' name='pin[{$item['ID']}]' value='{$format}' " . checked( $item['pin'], true, false ) . '/>';
$html .= "<label for='pin[{$item['ID']}]'>Pin this file</label>";
return $ht... | php | public function column_pin( $item ) {
$format = $this->getTinyHash( $item['format'] );
$html = "<input type='checkbox' id='pin[{$item['ID']}]' name='pin[{$item['ID']}]' value='{$format}' " . checked( $item['pin'], true, false ) . '/>';
$html .= "<label for='pin[{$item['ID']}]'>Pin this file</label>";
return $ht... | [
"public",
"function",
"column_pin",
"(",
"$",
"item",
")",
"{",
"$",
"format",
"=",
"$",
"this",
"->",
"getTinyHash",
"(",
"$",
"item",
"[",
"'format'",
"]",
")",
";",
"$",
"html",
"=",
"\"<input type='checkbox' id='pin[{$item['ID']}]' name='pin[{$item['ID']}]' va... | @param array $item A singular item (one full row's worth of data)
@return string Text to be placed inside the column <td> | [
"@param",
"array",
"$item",
"A",
"singular",
"item",
"(",
"one",
"full",
"row",
"s",
"worth",
"of",
"data",
")"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-table.php#L112-L117 |
pressbooks/pressbooks | inc/modules/export/class-table.php | Table.prepare_items | public function prepare_items() {
// Define Columns
$columns = $this->get_columns();
$hidden = [];
$sortable = $this->get_sortable_columns();
$this->_column_headers = [ $columns, $hidden, $sortable ];
// Data
$data = $this->getLatestExports();
// Pagination
$per_page = $this->get_items_per_page( 'p... | php | public function prepare_items() {
// Define Columns
$columns = $this->get_columns();
$hidden = [];
$sortable = $this->get_sortable_columns();
$this->_column_headers = [ $columns, $hidden, $sortable ];
// Data
$data = $this->getLatestExports();
// Pagination
$per_page = $this->get_items_per_page( 'p... | [
"public",
"function",
"prepare_items",
"(",
")",
"{",
"// Define Columns",
"$",
"columns",
"=",
"$",
"this",
"->",
"get_columns",
"(",
")",
";",
"$",
"hidden",
"=",
"[",
"]",
";",
"$",
"sortable",
"=",
"$",
"this",
"->",
"get_sortable_columns",
"(",
")",... | Prepares the list of items for displaying. | [
"Prepares",
"the",
"list",
"of",
"items",
"for",
"displaying",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-table.php#L159-L193 |
pressbooks/pressbooks | inc/modules/export/class-table.php | Table.inlineJs | public function inlineJs() {
// Process any actions first
$this->processBulkActions();
$this->truncateExports();
$js = '';
// Map the export form to equivalents in latest exports table
$filetypes = \Pressbooks\Modules\Export\filetypes();
$map = [];
foreach ( $filetypes as $k => $v ) {
$map[ "export_... | php | public function inlineJs() {
// Process any actions first
$this->processBulkActions();
$this->truncateExports();
$js = '';
// Map the export form to equivalents in latest exports table
$filetypes = \Pressbooks\Modules\Export\filetypes();
$map = [];
foreach ( $filetypes as $k => $v ) {
$map[ "export_... | [
"public",
"function",
"inlineJs",
"(",
")",
"{",
"// Process any actions first",
"$",
"this",
"->",
"processBulkActions",
"(",
")",
";",
"$",
"this",
"->",
"truncateExports",
"(",
")",
";",
"$",
"js",
"=",
"''",
";",
"// Map the export form to equivalents in lates... | Inline JavaScript to be echoed in template before <table>
Process any actions the table needs to do in here
@return string | [
"Inline",
"JavaScript",
"to",
"be",
"echoed",
"in",
"template",
"before",
"<table",
">",
"Process",
"any",
"actions",
"the",
"table",
"needs",
"to",
"do",
"in",
"here"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-table.php#L201-L236 |
pressbooks/pressbooks | inc/modules/export/class-table.php | Table.getPins | protected function getPins( $reset = false ) {
if ( $reset ) {
$this->_pins = [];
}
if ( empty( $this->_pins ) ) {
$pins = get_transient( self::PIN );
if ( ! is_array( $pins ) ) {
$pins = [];
}
$this->_pins = $pins;
}
return $this->_pins;
} | php | protected function getPins( $reset = false ) {
if ( $reset ) {
$this->_pins = [];
}
if ( empty( $this->_pins ) ) {
$pins = get_transient( self::PIN );
if ( ! is_array( $pins ) ) {
$pins = [];
}
$this->_pins = $pins;
}
return $this->_pins;
} | [
"protected",
"function",
"getPins",
"(",
"$",
"reset",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"reset",
")",
"{",
"$",
"this",
"->",
"_pins",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_pins",
")",
")",
"{",
"$",
"p... | @param bool $reset
@return array | [
"@param",
"bool",
"$reset"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-table.php#L259-L271 |
pressbooks/pressbooks | inc/modules/export/class-table.php | Table.truncateExports | protected function truncateExports( $keep_the_last = 3 ) {
// Sort files by modification time
$files = [];
foreach ( $this->getFiles() as $filepath ) {
$files[ $filepath ] = filemtime( $filepath );
}
arsort( $files );
// Group sorted files by format
// Start with/prioritize pins, to to reduce likeliho... | php | protected function truncateExports( $keep_the_last = 3 ) {
// Sort files by modification time
$files = [];
foreach ( $this->getFiles() as $filepath ) {
$files[ $filepath ] = filemtime( $filepath );
}
arsort( $files );
// Group sorted files by format
// Start with/prioritize pins, to to reduce likeliho... | [
"protected",
"function",
"truncateExports",
"(",
"$",
"keep_the_last",
"=",
"3",
")",
"{",
"// Sort files by modification time",
"$",
"files",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getFiles",
"(",
")",
"as",
"$",
"filepath",
")",
"{",
"$"... | Keep the last three of each specific export format
@param int $keep_the_last (optional) | [
"Keep",
"the",
"last",
"three",
"of",
"each",
"specific",
"export",
"format"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-table.php#L289-L323 |
pressbooks/pressbooks | inc/modules/export/class-table.php | Table.getCssClass | protected function getCssClass( $file ) {
$file_extension = substr( strrchr( $file, '.' ), 1 );
switch ( $file_extension ) {
case 'epub':
$pre_suffix = strstr( $file, '._3.epub' );
break;
case 'pdf':
$pre_suffix = strstr( $file, '._print.pdf' );
break;
case 'html':
$pre_suffix = strstr(... | php | protected function getCssClass( $file ) {
$file_extension = substr( strrchr( $file, '.' ), 1 );
switch ( $file_extension ) {
case 'epub':
$pre_suffix = strstr( $file, '._3.epub' );
break;
case 'pdf':
$pre_suffix = strstr( $file, '._print.pdf' );
break;
case 'html':
$pre_suffix = strstr(... | [
"protected",
"function",
"getCssClass",
"(",
"$",
"file",
")",
"{",
"$",
"file_extension",
"=",
"substr",
"(",
"strrchr",
"(",
"$",
"file",
",",
"'.'",
")",
",",
"1",
")",
";",
"switch",
"(",
"$",
"file_extension",
")",
"{",
"case",
"'epub'",
":",
"$... | @param string $file
@return string | [
"@param",
"string",
"$file"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-table.php#L351-L401 |
pressbooks/pressbooks | inc/modules/export/class-table.php | Table.getIcon | protected function getIcon( $file, $size = 'large' ) {
$file_class = $this->getCssClass( $file );
$html = "<div class='export-file-icon {$size} {$file_class}' title='" . esc_attr( $file ) . "'></div>";
return $html;
} | php | protected function getIcon( $file, $size = 'large' ) {
$file_class = $this->getCssClass( $file );
$html = "<div class='export-file-icon {$size} {$file_class}' title='" . esc_attr( $file ) . "'></div>";
return $html;
} | [
"protected",
"function",
"getIcon",
"(",
"$",
"file",
",",
"$",
"size",
"=",
"'large'",
")",
"{",
"$",
"file_class",
"=",
"$",
"this",
"->",
"getCssClass",
"(",
"$",
"file",
")",
";",
"$",
"html",
"=",
"\"<div class='export-file-icon {$size} {$file_class}' tit... | @param string $file
@param string $size
@return string | [
"@param",
"string",
"$file",
"@param",
"string",
"$size"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-table.php#L409-L413 |
pressbooks/pressbooks | inc/modules/export/class-table.php | Table.getFormat | protected function getFormat( $file ) {
$file_class = $this->getCssClass( $file );
return \Pressbooks\Modules\Export\get_name_from_filetype_slug( $file_class );
} | php | protected function getFormat( $file ) {
$file_class = $this->getCssClass( $file );
return \Pressbooks\Modules\Export\get_name_from_filetype_slug( $file_class );
} | [
"protected",
"function",
"getFormat",
"(",
"$",
"file",
")",
"{",
"$",
"file_class",
"=",
"$",
"this",
"->",
"getCssClass",
"(",
"$",
"file",
")",
";",
"return",
"\\",
"Pressbooks",
"\\",
"Modules",
"\\",
"Export",
"\\",
"get_name_from_filetype_slug",
"(",
... | @param string $file
@return string | [
"@param",
"string",
"$file"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-table.php#L420-L423 |
pressbooks/pressbooks | inc/modules/export/class-table.php | Table.processBulkActions | protected function processBulkActions() {
if ( 'delete' === $this->current_action() ) {
check_admin_referer( 'bulk-files' );
$ids = isset( $_REQUEST['ID'] ) ? $_REQUEST['ID'] : [];
if ( ! is_array( $ids ) ) {
$ids = [ $ids ];
}
if ( ! empty( $ids ) ) {
$latest_exports = $this->getLatestExports(... | php | protected function processBulkActions() {
if ( 'delete' === $this->current_action() ) {
check_admin_referer( 'bulk-files' );
$ids = isset( $_REQUEST['ID'] ) ? $_REQUEST['ID'] : [];
if ( ! is_array( $ids ) ) {
$ids = [ $ids ];
}
if ( ! empty( $ids ) ) {
$latest_exports = $this->getLatestExports(... | [
"protected",
"function",
"processBulkActions",
"(",
")",
"{",
"if",
"(",
"'delete'",
"===",
"$",
"this",
"->",
"current_action",
"(",
")",
")",
"{",
"check_admin_referer",
"(",
"'bulk-files'",
")",
";",
"$",
"ids",
"=",
"isset",
"(",
"$",
"_REQUEST",
"[",
... | Delete | [
"Delete"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/class-table.php#L428-L442 |
pressbooks/pressbooks | inc/interactive/class-phet.php | Phet.registerEmbedHandlerForWeb | public function registerEmbedHandlerForWeb() {
wp_embed_register_handler(
self::EMBED_ID,
self::EMBED_URL_REGEX,
function ( $matches, $attr, $url, $rawattr ) {
$embed = sprintf(
'<iframe src="https://phet.colorado.edu/sims/html/%1$s" width="800" height="600" scrolling="no" allowfullscreen></iframe>'... | php | public function registerEmbedHandlerForWeb() {
wp_embed_register_handler(
self::EMBED_ID,
self::EMBED_URL_REGEX,
function ( $matches, $attr, $url, $rawattr ) {
$embed = sprintf(
'<iframe src="https://phet.colorado.edu/sims/html/%1$s" width="800" height="600" scrolling="no" allowfullscreen></iframe>'... | [
"public",
"function",
"registerEmbedHandlerForWeb",
"(",
")",
"{",
"wp_embed_register_handler",
"(",
"self",
"::",
"EMBED_ID",
",",
"self",
"::",
"EMBED_URL_REGEX",
",",
"function",
"(",
"$",
"matches",
",",
"$",
"attr",
",",
"$",
"url",
",",
"$",
"rawattr",
... | Register embed handler for web | [
"Register",
"embed",
"handler",
"for",
"web"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/interactive/class-phet.php#L29-L41 |
pressbooks/pressbooks | inc/interactive/class-phet.php | Phet.registerEmbedHandlerForExport | public function registerEmbedHandlerForExport() {
wp_embed_register_handler(
self::EMBED_ID,
self::EMBED_URL_REGEX,
function ( $matches, $attr, $url, $rawattr ) {
global $id; // This is the Post ID, [@see WP_Query::setup_postdata, ...]
$embed = $this->blade->render(
'interactive.shared', [
... | php | public function registerEmbedHandlerForExport() {
wp_embed_register_handler(
self::EMBED_ID,
self::EMBED_URL_REGEX,
function ( $matches, $attr, $url, $rawattr ) {
global $id; // This is the Post ID, [@see WP_Query::setup_postdata, ...]
$embed = $this->blade->render(
'interactive.shared', [
... | [
"public",
"function",
"registerEmbedHandlerForExport",
"(",
")",
"{",
"wp_embed_register_handler",
"(",
"self",
"::",
"EMBED_ID",
",",
"self",
"::",
"EMBED_URL_REGEX",
",",
"function",
"(",
"$",
"matches",
",",
"$",
"attr",
",",
"$",
"url",
",",
"$",
"rawattr"... | Register embed handler for exports | [
"Register",
"embed",
"handler",
"for",
"exports"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/interactive/class-phet.php#L46-L61 |
pressbooks/pressbooks | inc/modules/import/odf/class-odt.php | Odt.import | function import( array $current_import ) {
try {
$this->isValidZip( $current_import['file'] );
} catch ( \Exception $e ) {
return false;
}
$xml = $this->getZipContent( 'content.xml' );
$meta = $this->getZipContent( 'meta.xml' );
// introduce a stylesheet
$proc = new \XSLTProcessor();
$xsl = new... | php | function import( array $current_import ) {
try {
$this->isValidZip( $current_import['file'] );
} catch ( \Exception $e ) {
return false;
}
$xml = $this->getZipContent( 'content.xml' );
$meta = $this->getZipContent( 'meta.xml' );
// introduce a stylesheet
$proc = new \XSLTProcessor();
$xsl = new... | [
"function",
"import",
"(",
"array",
"$",
"current_import",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"isValidZip",
"(",
"$",
"current_import",
"[",
"'file'",
"]",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
"... | Imports content, only after options (chapters, parts) have been selected
@param array $current_import
@return boolean - returns false if import fails | [
"Imports",
"content",
"only",
"after",
"options",
"(",
"chapters",
"parts",
")",
"have",
"been",
"selected"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/odf/class-odt.php#L54-L92 |
pressbooks/pressbooks | inc/modules/import/odf/class-odt.php | Odt.kneadAndInsert | protected function kneadAndInsert( $html, $title, $post_type, $chapter_parent, $post_status ) {
$body = $this->tidy( $html );
$body = $this->kneadHTML( $body );
$title = wp_strip_all_tags( $title );
$new_post = [
'post_title' => $title,
'post_content' => $body,
'post_type' => $post_type,
'post_st... | php | protected function kneadAndInsert( $html, $title, $post_type, $chapter_parent, $post_status ) {
$body = $this->tidy( $html );
$body = $this->kneadHTML( $body );
$title = wp_strip_all_tags( $title );
$new_post = [
'post_title' => $title,
'post_content' => $body,
'post_type' => $post_type,
'post_st... | [
"protected",
"function",
"kneadAndInsert",
"(",
"$",
"html",
",",
"$",
"title",
",",
"$",
"post_type",
",",
"$",
"chapter_parent",
",",
"$",
"post_status",
")",
"{",
"$",
"body",
"=",
"$",
"this",
"->",
"tidy",
"(",
"$",
"html",
")",
";",
"$",
"body"... | Pummel then insert HTML into our database
@param string $html
@param string $title
@param string $post_type (front-matter', 'chapter', 'back-matter')
@param int $chapter_parent
@param string $post_status | [
"Pummel",
"then",
"insert",
"HTML",
"into",
"our",
"database"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/odf/class-odt.php#L118-L141 |
pressbooks/pressbooks | inc/modules/import/odf/class-odt.php | Odt.kneadHTML | protected function kneadHTML( $body ) {
libxml_use_internal_errors( true );
$old_value = libxml_disable_entity_loader( true );
$doc = new \DOMDocument( '1.0', 'UTF-8' );
$doc->loadXML( $body );
libxml_disable_entity_loader( $old_value );
// Download images, change to relative paths
$doc = $this->scrape... | php | protected function kneadHTML( $body ) {
libxml_use_internal_errors( true );
$old_value = libxml_disable_entity_loader( true );
$doc = new \DOMDocument( '1.0', 'UTF-8' );
$doc->loadXML( $body );
libxml_disable_entity_loader( $old_value );
// Download images, change to relative paths
$doc = $this->scrape... | [
"protected",
"function",
"kneadHTML",
"(",
"$",
"body",
")",
"{",
"libxml_use_internal_errors",
"(",
"true",
")",
";",
"$",
"old_value",
"=",
"libxml_disable_entity_loader",
"(",
"true",
")",
";",
"$",
"doc",
"=",
"new",
"\\",
"DOMDocument",
"(",
"'1.0'",
",... | Pummel the HTML into WordPress compatible dough.
@param string $body
@return string - modified with correct image paths | [
"Pummel",
"the",
"HTML",
"into",
"WordPress",
"compatible",
"dough",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/odf/class-odt.php#L151-L169 |
pressbooks/pressbooks | inc/modules/import/odf/class-odt.php | Odt.scrapeAndKneadImages | protected function scrapeAndKneadImages( \DOMDocument $doc ) {
$images = $doc->getElementsByTagName( 'img' );
foreach ( $images as $image ) {
/** @var \DOMElement $image */
// Fetch image, change src
$old_src = $image->getAttribute( 'src' );
$new_src = $this->fetchAndSaveUniqueImage( $old_src );
if ... | php | protected function scrapeAndKneadImages( \DOMDocument $doc ) {
$images = $doc->getElementsByTagName( 'img' );
foreach ( $images as $image ) {
/** @var \DOMElement $image */
// Fetch image, change src
$old_src = $image->getAttribute( 'src' );
$new_src = $this->fetchAndSaveUniqueImage( $old_src );
if ... | [
"protected",
"function",
"scrapeAndKneadImages",
"(",
"\\",
"DOMDocument",
"$",
"doc",
")",
"{",
"$",
"images",
"=",
"$",
"doc",
"->",
"getElementsByTagName",
"(",
"'img'",
")",
";",
"foreach",
"(",
"$",
"images",
"as",
"$",
"image",
")",
"{",
"/** @var \\... | Parse HTML snippet, save all found <img> tags using media_handle_sideload(), return the HTML with changed <img> paths.
@param \DOMDocument $doc
@return \DOMDocument | [
"Parse",
"HTML",
"snippet",
"save",
"all",
"found",
"<img",
">",
"tags",
"using",
"media_handle_sideload",
"()",
"return",
"the",
"HTML",
"with",
"changed",
"<img",
">",
"paths",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/odf/class-odt.php#L179-L197 |
pressbooks/pressbooks | inc/modules/import/odf/class-odt.php | Odt.fetchAndSaveUniqueImage | protected function fetchAndSaveUniqueImage( $href ) {
$img_location = $href;
// Cheap cache
static $already_done = [];
if ( isset( $already_done[ $img_location ] ) ) {
return $already_done[ $img_location ];
}
/* Process */
// Basename without query string
$filename = explode( '?', basename( $href... | php | protected function fetchAndSaveUniqueImage( $href ) {
$img_location = $href;
// Cheap cache
static $already_done = [];
if ( isset( $already_done[ $img_location ] ) ) {
return $already_done[ $img_location ];
}
/* Process */
// Basename without query string
$filename = explode( '?', basename( $href... | [
"protected",
"function",
"fetchAndSaveUniqueImage",
"(",
"$",
"href",
")",
"{",
"$",
"img_location",
"=",
"$",
"href",
";",
"// Cheap cache",
"static",
"$",
"already_done",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"already_done",
"[",
"$",
"img_lo... | Extract url from zip and load into WP using media_handle_sideload()
Will return an empty string if something went wrong.
@param string $href original filename, with (relative) path
@see media_handle_sideload
@return string filename | [
"Extract",
"url",
"from",
"zip",
"and",
"load",
"into",
"WP",
"using",
"media_handle_sideload",
"()",
"Will",
"return",
"an",
"empty",
"string",
"if",
"something",
"went",
"wrong",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/odf/class-odt.php#L210-L274 |
pressbooks/pressbooks | inc/modules/import/odf/class-odt.php | Odt.setCurrentImportOption | function setCurrentImportOption( array $upload ) {
try {
$this->isValidZip( $upload['file'] );
} catch ( \Exception $e ) {
return false;
}
$option = [
'file' => $upload['file'],
'url' => $upload['url'] ?? null,
'file_type' => $upload['type'],
'type_of' => self::TYPE_OF,
'chapters' => [],
... | php | function setCurrentImportOption( array $upload ) {
try {
$this->isValidZip( $upload['file'] );
} catch ( \Exception $e ) {
return false;
}
$option = [
'file' => $upload['file'],
'url' => $upload['url'] ?? null,
'file_type' => $upload['type'],
'type_of' => self::TYPE_OF,
'chapters' => [],
... | [
"function",
"setCurrentImportOption",
"(",
"array",
"$",
"upload",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"isValidZip",
"(",
"$",
"upload",
"[",
"'file'",
"]",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
"... | Chapter detection
@param array $upload
@return boolean | [
"Chapter",
"detection"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/odf/class-odt.php#L309-L328 |
pressbooks/pressbooks | inc/modules/import/odf/class-odt.php | Odt.getChapter | protected function getChapter( \DOMNodeList $dom_list, $index, $chapter_title ) {
if ( empty( $chapter_title ) ) {
$chapter_title = 'unknown';
}
$chapter = new \DOMDocument( '1.0', 'UTF-8' );
// create a new node element
$root = $chapter->createElement( 'div' );
$root->setAttribute( 'class', $chapter_t... | php | protected function getChapter( \DOMNodeList $dom_list, $index, $chapter_title ) {
if ( empty( $chapter_title ) ) {
$chapter_title = 'unknown';
}
$chapter = new \DOMDocument( '1.0', 'UTF-8' );
// create a new node element
$root = $chapter->createElement( 'div' );
$root->setAttribute( 'class', $chapter_t... | [
"protected",
"function",
"getChapter",
"(",
"\\",
"DOMNodeList",
"$",
"dom_list",
",",
"$",
"index",
",",
"$",
"chapter_title",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"chapter_title",
")",
")",
"{",
"$",
"chapter_title",
"=",
"'unknown'",
";",
"}",
"$",... | Find where to start, iterate through a list, add elements to a
new DomDocument, return resulting xhtml
@param \DOMNodeList $dom_list
@param int $index
@param string $chapter_title
@return string XHTML | [
"Find",
"where",
"to",
"start",
"iterate",
"through",
"a",
"list",
"add",
"elements",
"to",
"a",
"new",
"DomDocument",
"return",
"resulting",
"xhtml"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/odf/class-odt.php#L405-L450 |
pressbooks/pressbooks | inc/modules/import/odf/class-odt.php | Odt.parseContent | protected function parseContent( \DomDocument $xml, $chapter_title ) {
$element = $xml->documentElement;
$node_list = $element->childNodes;
$chapter_node = '';
$index = 0;
// loop through child siblings
for ( $i = 0; $i < $node_list->length; $i++ ) {
$chapter_node = $this->findTheNode( $node_list->ite... | php | protected function parseContent( \DomDocument $xml, $chapter_title ) {
$element = $xml->documentElement;
$node_list = $element->childNodes;
$chapter_node = '';
$index = 0;
// loop through child siblings
for ( $i = 0; $i < $node_list->length; $i++ ) {
$chapter_node = $this->findTheNode( $node_list->ite... | [
"protected",
"function",
"parseContent",
"(",
"\\",
"DomDocument",
"$",
"xml",
",",
"$",
"chapter_title",
")",
"{",
"$",
"element",
"=",
"$",
"xml",
"->",
"documentElement",
";",
"$",
"node_list",
"=",
"$",
"element",
"->",
"childNodes",
";",
"$",
"chapter... | Find and return the identified chapter
@param \DomDocument $xml
@param string $chapter_title
@return string XML | [
"Find",
"and",
"return",
"the",
"identified",
"chapter"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/odf/class-odt.php#L461-L485 |
pressbooks/pressbooks | inc/modules/import/odf/class-odt.php | Odt.getFuzzyChapterTitles | protected function getFuzzyChapterTitles() {
$chapters = [];
$xml = $this->getZipContent( 'content.xml' );
// introduce a stylesheet
$proc = new \XSLTProcessor();
$xsl = new \DOMDocument();
$xsl->load( __DIR__ . '/xsl/odt2html.xsl' );
$proc->importStylesheet( $xsl );
// throw it back into the DOM
... | php | protected function getFuzzyChapterTitles() {
$chapters = [];
$xml = $this->getZipContent( 'content.xml' );
// introduce a stylesheet
$proc = new \XSLTProcessor();
$xsl = new \DOMDocument();
$xsl->load( __DIR__ . '/xsl/odt2html.xsl' );
$proc->importStylesheet( $xsl );
// throw it back into the DOM
... | [
"protected",
"function",
"getFuzzyChapterTitles",
"(",
")",
"{",
"$",
"chapters",
"=",
"[",
"]",
";",
"$",
"xml",
"=",
"$",
"this",
"->",
"getZipContent",
"(",
"'content.xml'",
")",
";",
"// introduce a stylesheet",
"$",
"proc",
"=",
"new",
"\\",
"XSLTProces... | Returns an array of available chapters, or 'unknown' if none
@return array Chapter titles | [
"Returns",
"an",
"array",
"of",
"available",
"chapters",
"or",
"unknown",
"if",
"none"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/odf/class-odt.php#L493-L525 |
pressbooks/pressbooks | inc/modules/import/odf/class-odt.php | Odt.getZipContent | protected function getZipContent( $file, $as_xml = true ) {
// Locates an entry using its name
$index = $this->zip->locateName( $file );
if ( false === $index ) {
return false;
}
// returns the contents using its index
$content = $this->zip->getFromIndex( $index );
// if it's not xml, return
if (... | php | protected function getZipContent( $file, $as_xml = true ) {
// Locates an entry using its name
$index = $this->zip->locateName( $file );
if ( false === $index ) {
return false;
}
// returns the contents using its index
$content = $this->zip->getFromIndex( $index );
// if it's not xml, return
if (... | [
"protected",
"function",
"getZipContent",
"(",
"$",
"file",
",",
"$",
"as_xml",
"=",
"true",
")",
"{",
"// Locates an entry using its name",
"$",
"index",
"=",
"$",
"this",
"->",
"zip",
"->",
"locateName",
"(",
"$",
"file",
")",
";",
"if",
"(",
"false",
... | Locates an entry using its name, returns the entry contents
@param string $file - path to a file
@param boolean $as_xml
@return boolean|\DOMDocument | [
"Locates",
"an",
"entry",
"using",
"its",
"name",
"returns",
"the",
"entry",
"contents"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/odf/class-odt.php#L536-L567 |
pressbooks/pressbooks | inc/admin/network/class-sharingandprivacyoptions.php | SharingAndPrivacyOptions.renderAllowRedistributionField | function renderAllowRedistributionField( $args ) {
$options = get_site_option( $this->getSlug() );
$this->renderCheckbox(
[
'id' => 'allow_redistribution',
'name' => $this->getSlug(),
'option' => 'allow_redistribution',
'value' => ( isset( $options['allow_redistribution'] ) ) ? $options['allow_re... | php | function renderAllowRedistributionField( $args ) {
$options = get_site_option( $this->getSlug() );
$this->renderCheckbox(
[
'id' => 'allow_redistribution',
'name' => $this->getSlug(),
'option' => 'allow_redistribution',
'value' => ( isset( $options['allow_redistribution'] ) ) ? $options['allow_re... | [
"function",
"renderAllowRedistributionField",
"(",
"$",
"args",
")",
"{",
"$",
"options",
"=",
"get_site_option",
"(",
"$",
"this",
"->",
"getSlug",
"(",
")",
")",
";",
"$",
"this",
"->",
"renderCheckbox",
"(",
"[",
"'id'",
"=>",
"'allow_redistribution'",
",... | Render the allow_redistribution checkbox.
@param array $args | [
"Render",
"the",
"allow_redistribution",
"checkbox",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/admin/network/class-sharingandprivacyoptions.php#L169-L180 |
pressbooks/pressbooks | inc/admin/network/class-sharingandprivacyoptions.php | SharingAndPrivacyOptions.renderAllowRootApi | function renderAllowRootApi( $args ) {
$options = get_site_option( $this->getSlug() );
$this->renderCheckbox(
[
'id' => 'enable_network_api',
'name' => $this->getSlug(),
'option' => 'enable_network_api',
'value' => ( isset( $options['enable_network_api'] ) ) ? $options['enable_network_api'] : '',... | php | function renderAllowRootApi( $args ) {
$options = get_site_option( $this->getSlug() );
$this->renderCheckbox(
[
'id' => 'enable_network_api',
'name' => $this->getSlug(),
'option' => 'enable_network_api',
'value' => ( isset( $options['enable_network_api'] ) ) ? $options['enable_network_api'] : '',... | [
"function",
"renderAllowRootApi",
"(",
"$",
"args",
")",
"{",
"$",
"options",
"=",
"get_site_option",
"(",
"$",
"this",
"->",
"getSlug",
"(",
")",
")",
";",
"$",
"this",
"->",
"renderCheckbox",
"(",
"[",
"'id'",
"=>",
"'enable_network_api'",
",",
"'name'",... | Render the enable_network_api checkbox.
@param array $args | [
"Render",
"the",
"enable_network_api",
"checkbox",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/admin/network/class-sharingandprivacyoptions.php#L187-L198 |
pressbooks/pressbooks | inc/admin/network/class-sharingandprivacyoptions.php | SharingAndPrivacyOptions.renderAllowCloning | function renderAllowCloning( $args ) {
$options = get_site_option( $this->getSlug() );
$this->renderCheckbox(
[
'id' => 'enable_cloning',
'name' => $this->getSlug(),
'option' => 'enable_cloning',
'value' => ( isset( $options['enable_cloning'] ) ) ? $options['enable_cloning'] : '',
'label' => ... | php | function renderAllowCloning( $args ) {
$options = get_site_option( $this->getSlug() );
$this->renderCheckbox(
[
'id' => 'enable_cloning',
'name' => $this->getSlug(),
'option' => 'enable_cloning',
'value' => ( isset( $options['enable_cloning'] ) ) ? $options['enable_cloning'] : '',
'label' => ... | [
"function",
"renderAllowCloning",
"(",
"$",
"args",
")",
"{",
"$",
"options",
"=",
"get_site_option",
"(",
"$",
"this",
"->",
"getSlug",
"(",
")",
")",
";",
"$",
"this",
"->",
"renderCheckbox",
"(",
"[",
"'id'",
"=>",
"'enable_cloning'",
",",
"'name'",
"... | Render the enable_cloning checkbox.
@param array $args | [
"Render",
"the",
"enable_cloning",
"checkbox",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/admin/network/class-sharingandprivacyoptions.php#L205-L216 |
pressbooks/pressbooks | inc/modules/export/prince/class-filters.php | Filters.overridePrince | public function overridePrince() {
$use_hooks = true;
if ( ! defined( 'DOCRAPTOR_API_KEY' ) ) {
// No API key
$use_hooks = false;
}
$plugin = 'pressbooks-docraptor/pressbooks-docraptor.php';
if ( file_exists( WP_PLUGIN_DIR . "/{$plugin}" ) && is_plugin_active( $plugin ) ) {
// The old, deprecated plu... | php | public function overridePrince() {
$use_hooks = true;
if ( ! defined( 'DOCRAPTOR_API_KEY' ) ) {
// No API key
$use_hooks = false;
}
$plugin = 'pressbooks-docraptor/pressbooks-docraptor.php';
if ( file_exists( WP_PLUGIN_DIR . "/{$plugin}" ) && is_plugin_active( $plugin ) ) {
// The old, deprecated plu... | [
"public",
"function",
"overridePrince",
"(",
")",
"{",
"$",
"use_hooks",
"=",
"true",
";",
"if",
"(",
"!",
"defined",
"(",
"'DOCRAPTOR_API_KEY'",
")",
")",
"{",
"// No API key",
"$",
"use_hooks",
"=",
"false",
";",
"}",
"$",
"plugin",
"=",
"'pressbooks-doc... | @since 5.4.0
@return bool | [
"@since",
"5",
".",
"4",
".",
"0"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/prince/class-filters.php#L48-L60 |
pressbooks/pressbooks | inc/modules/export/prince/class-filters.php | Filters.addToModules | public function addToModules( $modules ) {
if ( isset( $_POST['export_formats']['docraptor'] ) && check_admin_referer( 'pb-export' ) ) {
$modules[] = '\Pressbooks\Modules\Export\Prince\Docraptor';
}
if ( isset( $_POST['export_formats']['docraptor_print'] ) && check_admin_referer( 'pb-export' ) ) {
$modules[... | php | public function addToModules( $modules ) {
if ( isset( $_POST['export_formats']['docraptor'] ) && check_admin_referer( 'pb-export' ) ) {
$modules[] = '\Pressbooks\Modules\Export\Prince\Docraptor';
}
if ( isset( $_POST['export_formats']['docraptor_print'] ) && check_admin_referer( 'pb-export' ) ) {
$modules[... | [
"public",
"function",
"addToModules",
"(",
"$",
"modules",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_POST",
"[",
"'export_formats'",
"]",
"[",
"'docraptor'",
"]",
")",
"&&",
"check_admin_referer",
"(",
"'pb-export'",
")",
")",
"{",
"$",
"modules",
"[",
"... | @since 5.4.0
Add this module to the export batch currently in progress.
@param array $modules an array of active export module classnames
@return array $modules | [
"@since",
"5",
".",
"4",
".",
"0"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/prince/class-filters.php#L93-L101 |
pressbooks/pressbooks | inc/cloner/class-downloads.php | Downloads.fetchAndSaveUniqueImage | public function fetchAndSaveUniqueImage( $url ) {
if ( ! filter_var( $url, FILTER_VALIDATE_URL ) ) {
return 0;
}
if ( ! $this->sameAsSource( $url ) ) {
return -1;
}
$known_media = $this->cloner->getKnownMedia();
$filename = $this->basename( $url );
$attached_file = image_strip_baseurl( $url );
i... | php | public function fetchAndSaveUniqueImage( $url ) {
if ( ! filter_var( $url, FILTER_VALIDATE_URL ) ) {
return 0;
}
if ( ! $this->sameAsSource( $url ) ) {
return -1;
}
$known_media = $this->cloner->getKnownMedia();
$filename = $this->basename( $url );
$attached_file = image_strip_baseurl( $url );
i... | [
"public",
"function",
"fetchAndSaveUniqueImage",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"!",
"filter_var",
"(",
"$",
"url",
",",
"FILTER_VALIDATE_URL",
")",
")",
"{",
"return",
"0",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"sameAsSource",
"(",
"$",
... | Load remote url of image into WP using media_handle_sideload()
Will return -1 if image is not hosted on the source Pb network, or 0 if something went wrong.
@param string $url
@see \Pressbooks\Cloner\Cloner::$knownMedia
@see media_handle_sideload
@return int attachment ID, -1 if image is not hosted on the source Pb ... | [
"Load",
"remote",
"url",
"of",
"image",
"into",
"WP",
"using",
"media_handle_sideload",
"()",
"Will",
"return",
"-",
"1",
"if",
"image",
"is",
"not",
"hosted",
"on",
"the",
"source",
"Pb",
"network",
"or",
"0",
"if",
"something",
"went",
"wrong",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-downloads.php#L113-L192 |
pressbooks/pressbooks | inc/cloner/class-downloads.php | Downloads.createMediaPatch | public function createMediaPatch( $media ) {
return [
'title' => $media->title,
'meta' => $media->meta,
'description' => $media->description,
'caption' => $media->caption,
'alt_text' => $media->altText,
];
} | php | public function createMediaPatch( $media ) {
return [
'title' => $media->title,
'meta' => $media->meta,
'description' => $media->description,
'caption' => $media->caption,
'alt_text' => $media->altText,
];
} | [
"public",
"function",
"createMediaPatch",
"(",
"$",
"media",
")",
"{",
"return",
"[",
"'title'",
"=>",
"$",
"media",
"->",
"title",
",",
"'meta'",
"=>",
"$",
"media",
"->",
"meta",
",",
"'description'",
"=>",
"$",
"media",
"->",
"description",
",",
"'cap... | @param \Pressbooks\Entities\Cloner\Media $media
@return array | [
"@param",
"\\",
"Pressbooks",
"\\",
"Entities",
"\\",
"Cloner",
"\\",
"Media",
"$media"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-downloads.php#L224-L232 |
pressbooks/pressbooks | inc/cloner/class-downloads.php | Downloads.scrapeAndKneadMedia | public function scrapeAndKneadMedia( \DOMDocument $dom, $html5 ) {
$known_media = $this->cloner->getKnownMedia();
$dom_as_string = $html5->saveHTML( $dom );
$dom_as_string = \Pressbooks\Sanitize\strip_container_tags( $dom_as_string );
$attachments = [];
$changed = false;
foreach ( $known_media as $alt => ... | php | public function scrapeAndKneadMedia( \DOMDocument $dom, $html5 ) {
$known_media = $this->cloner->getKnownMedia();
$dom_as_string = $html5->saveHTML( $dom );
$dom_as_string = \Pressbooks\Sanitize\strip_container_tags( $dom_as_string );
$attachments = [];
$changed = false;
foreach ( $known_media as $alt => ... | [
"public",
"function",
"scrapeAndKneadMedia",
"(",
"\\",
"DOMDocument",
"$",
"dom",
",",
"$",
"html5",
")",
"{",
"$",
"known_media",
"=",
"$",
"this",
"->",
"cloner",
"->",
"getKnownMedia",
"(",
")",
";",
"$",
"dom_as_string",
"=",
"$",
"html5",
"->",
"sa... | Parse HTML snippet, save all found media using media_handle_sideload(), return the HTML with changed URLs.
Because we clone using WordPress raw format, we have to brute force against the text because the DOM
can't see shortcodes, text urls, hrefs with no identifying info, etc.
@param \DOMDocument $dom
@param \Masterm... | [
"Parse",
"HTML",
"snippet",
"save",
"all",
"found",
"media",
"using",
"media_handle_sideload",
"()",
"return",
"the",
"HTML",
"with",
"changed",
"URLs",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-downloads.php#L297-L331 |
pressbooks/pressbooks | inc/cloner/class-downloads.php | Downloads.fetchAndSaveUniqueMedia | public function fetchAndSaveUniqueMedia( $url ) {
if ( ! filter_var( $url, FILTER_VALIDATE_URL ) ) {
return 0;
}
if ( ! $this->sameAsSource( $url ) ) {
return -1;
}
$known_media = $this->cloner->getKnownMedia();
$filename = $this->basename( $url );
$attached_file = media_strip_baseurl( $url );
i... | php | public function fetchAndSaveUniqueMedia( $url ) {
if ( ! filter_var( $url, FILTER_VALIDATE_URL ) ) {
return 0;
}
if ( ! $this->sameAsSource( $url ) ) {
return -1;
}
$known_media = $this->cloner->getKnownMedia();
$filename = $this->basename( $url );
$attached_file = media_strip_baseurl( $url );
i... | [
"public",
"function",
"fetchAndSaveUniqueMedia",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"!",
"filter_var",
"(",
"$",
"url",
",",
"FILTER_VALIDATE_URL",
")",
")",
"{",
"return",
"0",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"sameAsSource",
"(",
"$",
... | Load remote media into WP using media_handle_sideload()
Will return -1 if media is not hosted on the source Pb network, or 0 if something went wrong.
@param string $url
@see \Pressbooks\Cloner\Cloner::$knownMedia
@see media_handle_sideload
@return int attachment ID, -1 if media is not hosted on the source Pb network... | [
"Load",
"remote",
"media",
"into",
"WP",
"using",
"media_handle_sideload",
"()",
"Will",
"return",
"-",
"1",
"if",
"media",
"is",
"not",
"hosted",
"on",
"the",
"source",
"Pb",
"network",
"or",
"0",
"if",
"something",
"went",
"wrong",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-downloads.php#L344-L402 |
pressbooks/pressbooks | inc/cloner/class-downloads.php | Downloads.h5p | public function h5p( $content ) {
$known_h5p = $this->cloner->getKnownH5P();
$new_h5p_ids = [];
$h5p_ids = $this->h5p->findAllShortcodeIds( $content );
foreach ( $h5p_ids as $h5p_id ) {
if ( ! isset( $this->H5PWasAlreadyDownloaded[ $h5p_id ] ) ) {
foreach ( $known_h5p as $h5p ) {
if ( absint( $h5p->... | php | public function h5p( $content ) {
$known_h5p = $this->cloner->getKnownH5P();
$new_h5p_ids = [];
$h5p_ids = $this->h5p->findAllShortcodeIds( $content );
foreach ( $h5p_ids as $h5p_id ) {
if ( ! isset( $this->H5PWasAlreadyDownloaded[ $h5p_id ] ) ) {
foreach ( $known_h5p as $h5p ) {
if ( absint( $h5p->... | [
"public",
"function",
"h5p",
"(",
"$",
"content",
")",
"{",
"$",
"known_h5p",
"=",
"$",
"this",
"->",
"cloner",
"->",
"getKnownH5P",
"(",
")",
";",
"$",
"new_h5p_ids",
"=",
"[",
"]",
";",
"$",
"h5p_ids",
"=",
"$",
"this",
"->",
"h5p",
"->",
"findAl... | Parse HTML snippet, download all found H5P, save transition states to change shortcodes in post processing step
@param string $content
@see \Pressbooks\Cloner\Cloner::$knownH5P
@return array | [
"Parse",
"HTML",
"snippet",
"download",
"all",
"found",
"H5P",
"save",
"transition",
"states",
"to",
"change",
"shortcodes",
"in",
"post",
"processing",
"step"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-downloads.php#L413-L436 |
pressbooks/pressbooks | inc/htmlbook/class-element.php | Element.setDataType | public function setDataType( string $data_type ) {
if ( ! in_array( $data_type, $this->dataTypes, true ) ) {
throw new \LogicException( "Unsupported DataType: {$data_type}, valid values are: " . rtrim( implode( ',', $this->dataTypes ), ',' ) );
}
$this->dataType = $data_type;
} | php | public function setDataType( string $data_type ) {
if ( ! in_array( $data_type, $this->dataTypes, true ) ) {
throw new \LogicException( "Unsupported DataType: {$data_type}, valid values are: " . rtrim( implode( ',', $this->dataTypes ), ',' ) );
}
$this->dataType = $data_type;
} | [
"public",
"function",
"setDataType",
"(",
"string",
"$",
"data_type",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"data_type",
",",
"$",
"this",
"->",
"dataTypes",
",",
"true",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"\"Unsupporte... | @param string $data_type
@throws \LogicException | [
"@param",
"string",
"$data_type"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/htmlbook/class-element.php#L196-L201 |
pressbooks/pressbooks | inc/htmlbook/class-element.php | Element.setContent | public function setContent( $content ) {
if ( ! is_array( $content ) ) {
$content = [ $content ];
}
foreach ( $content as $v ) {
if ( $this === $v ) {
throw new \LogicException( 'Recursion problem: cannot set self as content to self' );
}
}
$this->content = $content;
} | php | public function setContent( $content ) {
if ( ! is_array( $content ) ) {
$content = [ $content ];
}
foreach ( $content as $v ) {
if ( $this === $v ) {
throw new \LogicException( 'Recursion problem: cannot set self as content to self' );
}
}
$this->content = $content;
} | [
"public",
"function",
"setContent",
"(",
"$",
"content",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"content",
")",
")",
"{",
"$",
"content",
"=",
"[",
"$",
"content",
"]",
";",
"}",
"foreach",
"(",
"$",
"content",
"as",
"$",
"v",
")",
"{",
... | @param mixed $content
@throws \LogicException | [
"@param",
"mixed",
"$content"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/htmlbook/class-element.php#L246-L256 |
pressbooks/pressbooks | inc/htmlbook/class-element.php | Element.isInline | public function isInline( $var ) {
if ( is_object( $var ) ) {
if ( $var instanceof Element ) {
return ( in_array( $var->getTag(), $this->inline, true ) );
}
return ( strpos( get_class( $var ), 'Pressbooks\HTMLBook\Inline\\' ) !== false );
}
if ( is_string( $var ) ) {
$html5 = new HTML5();
$do... | php | public function isInline( $var ) {
if ( is_object( $var ) ) {
if ( $var instanceof Element ) {
return ( in_array( $var->getTag(), $this->inline, true ) );
}
return ( strpos( get_class( $var ), 'Pressbooks\HTMLBook\Inline\\' ) !== false );
}
if ( is_string( $var ) ) {
$html5 = new HTML5();
$do... | [
"public",
"function",
"isInline",
"(",
"$",
"var",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"var",
")",
")",
"{",
"if",
"(",
"$",
"var",
"instanceof",
"Element",
")",
"{",
"return",
"(",
"in_array",
"(",
"$",
"var",
"->",
"getTag",
"(",
")",
"... | @param mixed $var
@return bool | [
"@param",
"mixed",
"$var"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/htmlbook/class-element.php#L275-L294 |
pressbooks/pressbooks | inc/htmlbook/class-element.php | Element.isHeading | public function isHeading( $var ) {
$headings = [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ];
if ( is_object( $var ) ) {
if ( $var instanceof Element ) {
return ( in_array( $var->getTag(), $headings, true ) );
}
return is_subclass_of( $var, '\Pressbooks\HTMLBook\Heading\Headings' );
}
if ( is_string( ... | php | public function isHeading( $var ) {
$headings = [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ];
if ( is_object( $var ) ) {
if ( $var instanceof Element ) {
return ( in_array( $var->getTag(), $headings, true ) );
}
return is_subclass_of( $var, '\Pressbooks\HTMLBook\Heading\Headings' );
}
if ( is_string( ... | [
"public",
"function",
"isHeading",
"(",
"$",
"var",
")",
"{",
"$",
"headings",
"=",
"[",
"'h1'",
",",
"'h2'",
",",
"'h3'",
",",
"'h4'",
",",
"'h5'",
",",
"'h6'",
"]",
";",
"if",
"(",
"is_object",
"(",
"$",
"var",
")",
")",
"{",
"if",
"(",
"$",
... | @param mixed $var
@return bool | [
"@param",
"mixed",
"$var"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/htmlbook/class-element.php#L328-L349 |
pressbooks/pressbooks | inc/class-activation.php | Activation.init | static public function init() {
if ( is_null( self::$instance ) ) {
$taxonomy = Taxonomy::init();
self::$instance = new self( $taxonomy );
self::hooks( self::$instance );
}
return self::$instance;
} | php | static public function init() {
if ( is_null( self::$instance ) ) {
$taxonomy = Taxonomy::init();
self::$instance = new self( $taxonomy );
self::hooks( self::$instance );
}
return self::$instance;
} | [
"static",
"public",
"function",
"init",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"self",
"::",
"$",
"instance",
")",
")",
"{",
"$",
"taxonomy",
"=",
"Taxonomy",
"::",
"init",
"(",
")",
";",
"self",
"::",
"$",
"instance",
"=",
"new",
"self",
"(",
... | @since 5.0.0
@return Activation | [
"@since",
"5",
".",
"0",
".",
"0"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-activation.php#L48-L55 |
pressbooks/pressbooks | inc/class-activation.php | Activation.wpmuNewBlog | public function wpmuNewBlog( $new_site, $args ) {
$this->blog_id = (int) $new_site->id;
$this->user_id = (int) ( ! empty( $args['user_id'] ) ? $args['user_id'] : 0 );
switch_to_blog( $this->blog_id );
if ( ! $this->isBookSetup() ) {
$this->wpmuActivate();
array_walk(
$this->opts, function ( $v, $k ... | php | public function wpmuNewBlog( $new_site, $args ) {
$this->blog_id = (int) $new_site->id;
$this->user_id = (int) ( ! empty( $args['user_id'] ) ? $args['user_id'] : 0 );
switch_to_blog( $this->blog_id );
if ( ! $this->isBookSetup() ) {
$this->wpmuActivate();
array_walk(
$this->opts, function ( $v, $k ... | [
"public",
"function",
"wpmuNewBlog",
"(",
"$",
"new_site",
",",
"$",
"args",
")",
"{",
"$",
"this",
"->",
"blog_id",
"=",
"(",
"int",
")",
"$",
"new_site",
"->",
"id",
";",
"$",
"this",
"->",
"user_id",
"=",
"(",
"int",
")",
"(",
"!",
"empty",
"(... | Runs activation function and sets up default WP options for new blog,
a.k.a. when a registered user creates a new blog
@param \WP_Site $new_site New site object.
@param array $args Arguments for the initialization.
@see add_action( 'wp_initialize_site', ... ) | [
"Runs",
"activation",
"function",
"and",
"sets",
"up",
"default",
"WP",
"options",
"for",
"new",
"blog",
"a",
".",
"k",
".",
"a",
".",
"when",
"a",
"registered",
"user",
"creates",
"a",
"new",
"blog"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-activation.php#L85-L142 |
pressbooks/pressbooks | inc/class-activation.php | Activation.isBookSetup | private function isBookSetup() {
$act = get_option( 'pb_activated' );
$pof = get_option( 'page_on_front' );
$pop = get_option( 'page_for_posts' );
if ( empty( $act ) ) {
return false;
}
if ( ( get_option( 'template' ) !== 'pressbooks-book' ) || ( get_option( 'stylesheet' ) !== 'pressbooks-book' ) ) {
... | php | private function isBookSetup() {
$act = get_option( 'pb_activated' );
$pof = get_option( 'page_on_front' );
$pop = get_option( 'page_for_posts' );
if ( empty( $act ) ) {
return false;
}
if ( ( get_option( 'template' ) !== 'pressbooks-book' ) || ( get_option( 'stylesheet' ) !== 'pressbooks-book' ) ) {
... | [
"private",
"function",
"isBookSetup",
"(",
")",
"{",
"$",
"act",
"=",
"get_option",
"(",
"'pb_activated'",
")",
";",
"$",
"pof",
"=",
"get_option",
"(",
"'page_on_front'",
")",
";",
"$",
"pop",
"=",
"get_option",
"(",
"'page_for_posts'",
")",
";",
"if",
... | Determine if book is set up or not to avoid duplication
(i.e. if activation functions have run and default options set)
@return bool | [
"Determine",
"if",
"book",
"is",
"set",
"up",
"or",
"not",
"to",
"avoid",
"duplication",
"(",
"i",
".",
"e",
".",
"if",
"activation",
"functions",
"have",
"run",
"and",
"default",
"options",
"set",
")"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-activation.php#L151-L170 |
pressbooks/pressbooks | inc/class-activation.php | Activation.wpmuActivate | private function wpmuActivate() {
/** @var $wpdb \wpdb */
global $wpdb;
$this->taxonomy->insertTerms();
$posts = [
// Parts, Chapters, Front-Matter, Back-Matter
'main-body' => [
'post_title' => __( 'Main Body', 'pressbooks' ),
'post_name' => 'main-body',
'post_type' => 'part',
'menu_ord... | php | private function wpmuActivate() {
/** @var $wpdb \wpdb */
global $wpdb;
$this->taxonomy->insertTerms();
$posts = [
// Parts, Chapters, Front-Matter, Back-Matter
'main-body' => [
'post_title' => __( 'Main Body', 'pressbooks' ),
'post_name' => 'main-body',
'post_type' => 'part',
'menu_ord... | [
"private",
"function",
"wpmuActivate",
"(",
")",
"{",
"/** @var $wpdb \\wpdb */",
"global",
"$",
"wpdb",
";",
"$",
"this",
"->",
"taxonomy",
"->",
"insertTerms",
"(",
")",
";",
"$",
"posts",
"=",
"[",
"// Parts, Chapters, Front-Matter, Back-Matter",
"'main-body'",
... | Set up default terms for Front Matter and Back Matter
Insert default part, chapter, front matter, and back matter
Insert default pages (Authors, Cover, TOC, About, Buy, and Access Denied)
Remove content generated by wp_install_defaults
Anything which needs to run on blog activation must go in this function | [
"Set",
"up",
"default",
"terms",
"for",
"Front",
"Matter",
"and",
"Back",
"Matter",
"Insert",
"default",
"part",
"chapter",
"front",
"matter",
"and",
"back",
"matter",
"Insert",
"default",
"pages",
"(",
"Authors",
"Cover",
"TOC",
"About",
"Buy",
"and",
"Acce... | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-activation.php#L180-L412 |
pressbooks/pressbooks | inc/class-activation.php | Activation.forcePbColors | public function forcePbColors( $id, $user = null ) {
if ( is_numeric( $id ) ) {
$user_id = $id;
} elseif ( $user instanceof \WP_User ) {
$user_id = $user->ID;
} else {
return;
}
update_user_option( $user_id, 'admin_color', 'pb_colors', true );
} | php | public function forcePbColors( $id, $user = null ) {
if ( is_numeric( $id ) ) {
$user_id = $id;
} elseif ( $user instanceof \WP_User ) {
$user_id = $user->ID;
} else {
return;
}
update_user_option( $user_id, 'admin_color', 'pb_colors', true );
} | [
"public",
"function",
"forcePbColors",
"(",
"$",
"id",
",",
"$",
"user",
"=",
"null",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"id",
")",
")",
"{",
"$",
"user_id",
"=",
"$",
"id",
";",
"}",
"elseif",
"(",
"$",
"user",
"instanceof",
"\\",
"WP_... | Change [ Your Profile > Admin Color Scheme ] to Pressbooks default colors
@param int $id
@param object $user (optional) | [
"Change",
"[",
"Your",
"Profile",
">",
"Admin",
"Color",
"Scheme",
"]",
"to",
"Pressbooks",
"default",
"colors"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-activation.php#L420-L431 |
pressbooks/pressbooks | inc/modules/import/api/class-api.php | Api.isSourceCloneable | protected function isSourceCloneable( $section_id, $post_type ) {
$metadata = $this->cloner->retrieveSectionMetadata( $section_id, $post_type );
$is_source_clonable = $this->cloner->isSourceCloneable( $metadata['license'] ?? $this->cloner->getSourceBookMetadata()['license'] );
return $is_source_clonable;
} | php | protected function isSourceCloneable( $section_id, $post_type ) {
$metadata = $this->cloner->retrieveSectionMetadata( $section_id, $post_type );
$is_source_clonable = $this->cloner->isSourceCloneable( $metadata['license'] ?? $this->cloner->getSourceBookMetadata()['license'] );
return $is_source_clonable;
} | [
"protected",
"function",
"isSourceCloneable",
"(",
"$",
"section_id",
",",
"$",
"post_type",
")",
"{",
"$",
"metadata",
"=",
"$",
"this",
"->",
"cloner",
"->",
"retrieveSectionMetadata",
"(",
"$",
"section_id",
",",
"$",
"post_type",
")",
";",
"$",
"is_sourc... | Is the section license OK?
The global license is for the 'collection' and within that collection you have stuff with licenses that differ from the global one...
@param int $section_id The ID of the section within the source book.
@param string $post_type The post type of the section.
@return bool | [
"Is",
"the",
"section",
"license",
"OK?",
"The",
"global",
"license",
"is",
"for",
"the",
"collection",
"and",
"within",
"that",
"collection",
"you",
"have",
"stuff",
"with",
"licenses",
"that",
"differ",
"from",
"the",
"global",
"one",
"..."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/api/class-api.php#L232-L236 |
pressbooks/pressbooks | inc/modules/import/api/class-api.php | Api.updatePost | protected function updatePost( $post_id, $status ) {
$post = get_post( $post_id, 'ARRAY_A' );
if ( empty( $post ) ) {
return;
}
global $wpdb;
$menu_order = $wpdb->get_var(
$wpdb->prepare(
"SELECT MAX(menu_order) FROM {$wpdb->posts} WHERE post_type = %s AND post_parent = %d AND ID != %d ",
$pos... | php | protected function updatePost( $post_id, $status ) {
$post = get_post( $post_id, 'ARRAY_A' );
if ( empty( $post ) ) {
return;
}
global $wpdb;
$menu_order = $wpdb->get_var(
$wpdb->prepare(
"SELECT MAX(menu_order) FROM {$wpdb->posts} WHERE post_type = %s AND post_parent = %d AND ID != %d ",
$pos... | [
"protected",
"function",
"updatePost",
"(",
"$",
"post_id",
",",
"$",
"status",
")",
"{",
"$",
"post",
"=",
"get_post",
"(",
"$",
"post_id",
",",
"'ARRAY_A'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"post",
")",
")",
"{",
"return",
";",
"}",
"globa... | Update post status
@param int $post_id
@param string $status | [
"Update",
"post",
"status"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/import/api/class-api.php#L244-L267 |
pressbooks/pressbooks | inc/modules/export/odt/class-odt.php | Odt.convert | function convert() {
// Set logfile
$this->logfile = $this->createTmpFile();
// Set filename
$this->outputPath = $this->timestampedFileName( '.odt' );
// Set temp folder
$this->tmpDir = $this->createTmpDir();
$source = $this->tmpDir . '/source.xhtml';
if ( defined( 'WP_TESTS_MULTISITE' ) ) {
\Pre... | php | function convert() {
// Set logfile
$this->logfile = $this->createTmpFile();
// Set filename
$this->outputPath = $this->timestampedFileName( '.odt' );
// Set temp folder
$this->tmpDir = $this->createTmpDir();
$source = $this->tmpDir . '/source.xhtml';
if ( defined( 'WP_TESTS_MULTISITE' ) ) {
\Pre... | [
"function",
"convert",
"(",
")",
"{",
"// Set logfile",
"$",
"this",
"->",
"logfile",
"=",
"$",
"this",
"->",
"createTmpFile",
"(",
")",
";",
"// Set filename",
"$",
"this",
"->",
"outputPath",
"=",
"$",
"this",
"->",
"timestampedFileName",
"(",
"'.odt'",
... | Create $this->outputPath
@return bool | [
"Create",
"$this",
"-",
">",
"outputPath"
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/odt/class-odt.php#L87-L221 |
pressbooks/pressbooks | inc/modules/export/odt/class-odt.php | Odt.queryXhtml | protected function queryXhtml() {
$args = [
'timeout' => $this->timeout,
];
$response = wp_remote_get( $this->url, $args );
// WordPress error?
if ( is_wp_error( $response ) ) {
$this->logError( $response->get_error_message() );
return false;
}
// Server error?
if ( 200 !== wp_remote_retrie... | php | protected function queryXhtml() {
$args = [
'timeout' => $this->timeout,
];
$response = wp_remote_get( $this->url, $args );
// WordPress error?
if ( is_wp_error( $response ) ) {
$this->logError( $response->get_error_message() );
return false;
}
// Server error?
if ( 200 !== wp_remote_retrie... | [
"protected",
"function",
"queryXhtml",
"(",
")",
"{",
"$",
"args",
"=",
"[",
"'timeout'",
"=>",
"$",
"this",
"->",
"timeout",
",",
"]",
";",
"$",
"response",
"=",
"wp_remote_get",
"(",
"$",
"this",
"->",
"url",
",",
"$",
"args",
")",
";",
"// WordPre... | Query the access protected "format/xhtml" URL, return the results.
@return bool|string | [
"Query",
"the",
"access",
"protected",
"format",
"/",
"xhtml",
"URL",
"return",
"the",
"results",
"."
] | train | https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/odt/class-odt.php#L228-L250 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.