repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
pressbooks/pressbooks
inc/modules/themeoptions/class-pdfoptions.php
PDFOptions.renderRunningContentIntroductionRightField
function renderRunningContentIntroductionRightField( $args ) { unset( $args['label_for'], $args['class'] ); $this->renderCustomSelect( [ 'id' => 'running_content_introduction_right', 'name' => 'running_content_introduction_right', 'value' => getset( $this->options, 'running_content_introduction_right...
php
function renderRunningContentIntroductionRightField( $args ) { unset( $args['label_for'], $args['class'] ); $this->renderCustomSelect( [ 'id' => 'running_content_introduction_right', 'name' => 'running_content_introduction_right', 'value' => getset( $this->options, 'running_content_introduction_right...
[ "function", "renderRunningContentIntroductionRightField", "(", "$", "args", ")", "{", "unset", "(", "$", "args", "[", "'label_for'", "]", ",", "$", "args", "[", "'class'", "]", ")", ";", "$", "this", "->", "renderCustomSelect", "(", "[", "'id'", "=>", "'ru...
Render the running_content_introduction_right input. @param array $args
[ "Render", "the", "running_content_introduction_right", "input", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/themeoptions/class-pdfoptions.php#L1187-L1207
pressbooks/pressbooks
inc/modules/themeoptions/class-pdfoptions.php
PDFOptions.renderRunningContentPartLeftField
function renderRunningContentPartLeftField( $args ) { unset( $args['label_for'], $args['class'] ); $this->renderCustomSelect( [ 'id' => 'running_content_part_left', 'name' => 'running_content_part_left', 'value' => getset( $this->options, 'running_content_part_left' ), 'choices' => $args, ] ...
php
function renderRunningContentPartLeftField( $args ) { unset( $args['label_for'], $args['class'] ); $this->renderCustomSelect( [ 'id' => 'running_content_part_left', 'name' => 'running_content_part_left', 'value' => getset( $this->options, 'running_content_part_left' ), 'choices' => $args, ] ...
[ "function", "renderRunningContentPartLeftField", "(", "$", "args", ")", "{", "unset", "(", "$", "args", "[", "'label_for'", "]", ",", "$", "args", "[", "'class'", "]", ")", ";", "$", "this", "->", "renderCustomSelect", "(", "[", "'id'", "=>", "'running_con...
Render the running_content_part_left input. @param array $args
[ "Render", "the", "running_content_part_left", "input", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/themeoptions/class-pdfoptions.php#L1214-L1234
pressbooks/pressbooks
inc/modules/themeoptions/class-pdfoptions.php
PDFOptions.renderRunningContentPartRightField
function renderRunningContentPartRightField( $args ) { unset( $args['label_for'], $args['class'] ); $this->renderCustomSelect( [ 'id' => 'running_content_part_right', 'name' => 'running_content_part_right', 'value' => getset( $this->options, 'running_content_part_right' ), 'choices' => $args, ...
php
function renderRunningContentPartRightField( $args ) { unset( $args['label_for'], $args['class'] ); $this->renderCustomSelect( [ 'id' => 'running_content_part_right', 'name' => 'running_content_part_right', 'value' => getset( $this->options, 'running_content_part_right' ), 'choices' => $args, ...
[ "function", "renderRunningContentPartRightField", "(", "$", "args", ")", "{", "unset", "(", "$", "args", "[", "'label_for'", "]", ",", "$", "args", "[", "'class'", "]", ")", ";", "$", "this", "->", "renderCustomSelect", "(", "[", "'id'", "=>", "'running_co...
Render the running_content_part_right input. @param array $args
[ "Render", "the", "running_content_part_right", "input", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/themeoptions/class-pdfoptions.php#L1241-L1261
pressbooks/pressbooks
inc/modules/themeoptions/class-pdfoptions.php
PDFOptions.renderRunningContentChapterLeftField
function renderRunningContentChapterLeftField( $args ) { unset( $args['label_for'], $args['class'] ); $this->renderCustomSelect( [ 'id' => 'running_content_chapter_left', 'name' => 'running_content_chapter_left', 'value' => getset( $this->options, 'running_content_chapter_left' ), 'choices' => $a...
php
function renderRunningContentChapterLeftField( $args ) { unset( $args['label_for'], $args['class'] ); $this->renderCustomSelect( [ 'id' => 'running_content_chapter_left', 'name' => 'running_content_chapter_left', 'value' => getset( $this->options, 'running_content_chapter_left' ), 'choices' => $a...
[ "function", "renderRunningContentChapterLeftField", "(", "$", "args", ")", "{", "unset", "(", "$", "args", "[", "'label_for'", "]", ",", "$", "args", "[", "'class'", "]", ")", ";", "$", "this", "->", "renderCustomSelect", "(", "[", "'id'", "=>", "'running_...
Render the running_content_chapter_left input. @param array $args
[ "Render", "the", "running_content_chapter_left", "input", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/themeoptions/class-pdfoptions.php#L1268-L1288
pressbooks/pressbooks
inc/modules/themeoptions/class-pdfoptions.php
PDFOptions.renderRunningContentChapterRightField
function renderRunningContentChapterRightField( $args ) { unset( $args['label_for'], $args['class'] ); $this->renderCustomSelect( [ 'id' => 'running_content_chapter_right', 'name' => 'running_content_chapter_right', 'value' => getset( $this->options, 'running_content_chapter_right' ), 'choices' =...
php
function renderRunningContentChapterRightField( $args ) { unset( $args['label_for'], $args['class'] ); $this->renderCustomSelect( [ 'id' => 'running_content_chapter_right', 'name' => 'running_content_chapter_right', 'value' => getset( $this->options, 'running_content_chapter_right' ), 'choices' =...
[ "function", "renderRunningContentChapterRightField", "(", "$", "args", ")", "{", "unset", "(", "$", "args", "[", "'label_for'", "]", ",", "$", "args", "[", "'class'", "]", ")", ";", "$", "this", "->", "renderCustomSelect", "(", "[", "'id'", "=>", "'running...
Render the running_content_chapter_right input. @param array $args
[ "Render", "the", "running_content_chapter_right", "input", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/themeoptions/class-pdfoptions.php#L1295-L1315
pressbooks/pressbooks
inc/modules/themeoptions/class-pdfoptions.php
PDFOptions.renderRunningContentBackMatterLeftField
function renderRunningContentBackMatterLeftField( $args ) { unset( $args['label_for'], $args['class'] ); $this->renderCustomSelect( [ 'id' => 'running_content_back_matter_left', 'name' => 'running_content_back_matter_left', 'value' => getset( $this->options, 'running_content_back_matter_left' ), ...
php
function renderRunningContentBackMatterLeftField( $args ) { unset( $args['label_for'], $args['class'] ); $this->renderCustomSelect( [ 'id' => 'running_content_back_matter_left', 'name' => 'running_content_back_matter_left', 'value' => getset( $this->options, 'running_content_back_matter_left' ), ...
[ "function", "renderRunningContentBackMatterLeftField", "(", "$", "args", ")", "{", "unset", "(", "$", "args", "[", "'label_for'", "]", ",", "$", "args", "[", "'class'", "]", ")", ";", "$", "this", "->", "renderCustomSelect", "(", "[", "'id'", "=>", "'runni...
Render the running_content_back_matter_left input. @param array $args
[ "Render", "the", "running_content_back_matter_left", "input", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/themeoptions/class-pdfoptions.php#L1322-L1342
pressbooks/pressbooks
inc/modules/themeoptions/class-pdfoptions.php
PDFOptions.renderRunningContentBackMatterRightField
function renderRunningContentBackMatterRightField( $args ) { unset( $args['label_for'], $args['class'] ); $this->renderCustomSelect( [ 'id' => 'running_content_back_matter_right', 'name' => 'running_content_back_matter_right', 'value' => getset( $this->options, 'running_content_back_matter_right' ), ...
php
function renderRunningContentBackMatterRightField( $args ) { unset( $args['label_for'], $args['class'] ); $this->renderCustomSelect( [ 'id' => 'running_content_back_matter_right', 'name' => 'running_content_back_matter_right', 'value' => getset( $this->options, 'running_content_back_matter_right' ), ...
[ "function", "renderRunningContentBackMatterRightField", "(", "$", "args", ")", "{", "unset", "(", "$", "args", "[", "'label_for'", "]", ",", "$", "args", "[", "'class'", "]", ")", ";", "$", "this", "->", "renderCustomSelect", "(", "[", "'id'", "=>", "'runn...
Render the running_content_back_matter_right input. @param array $args
[ "Render", "the", "running_content_back_matter_right", "input", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/themeoptions/class-pdfoptions.php#L1349-L1369
pressbooks/pressbooks
inc/modules/themeoptions/class-pdfoptions.php
PDFOptions.renderFontSizeField
function renderFontSizeField( $args ) { unset( $args['label_for'], $args['class'] ); $this->renderCheckbox( [ 'id' => 'pdf_fontsize', 'name' => 'pressbooks_theme_options_' . $this->getSlug(), 'option' => 'pdf_fontsize', 'value' => getset( $this->options, 'pdf_fontsize' ), 'label' => $args[0],...
php
function renderFontSizeField( $args ) { unset( $args['label_for'], $args['class'] ); $this->renderCheckbox( [ 'id' => 'pdf_fontsize', 'name' => 'pressbooks_theme_options_' . $this->getSlug(), 'option' => 'pdf_fontsize', 'value' => getset( $this->options, 'pdf_fontsize' ), 'label' => $args[0],...
[ "function", "renderFontSizeField", "(", "$", "args", ")", "{", "unset", "(", "$", "args", "[", "'label_for'", "]", ",", "$", "args", "[", "'class'", "]", ")", ";", "$", "this", "->", "renderCheckbox", "(", "[", "'id'", "=>", "'pdf_fontsize'", ",", "'na...
Render the pdf_fontsize checkbox. @param array $args
[ "Render", "the", "pdf_fontsize", "checkbox", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/themeoptions/class-pdfoptions.php#L1376-L1387
pressbooks/pressbooks
inc/modules/themeoptions/class-pdfoptions.php
PDFOptions.filterDefaults
static function filterDefaults( $defaults ) { // SASS => WP $overrides = [ 'body-font-size' => 'pdf_body_font_size', 'body-line-height' => 'pdf_body_line_height', 'page-margin-top' => 'pdf_page_margin_top', 'page-margin-inside' => 'pdf_page_margin_inside', 'page-margin-bottom' => 'pdf_page_margin_bo...
php
static function filterDefaults( $defaults ) { // SASS => WP $overrides = [ 'body-font-size' => 'pdf_body_font_size', 'body-line-height' => 'pdf_body_line_height', 'page-margin-top' => 'pdf_page_margin_top', 'page-margin-inside' => 'pdf_page_margin_inside', 'page-margin-bottom' => 'pdf_page_margin_bo...
[ "static", "function", "filterDefaults", "(", "$", "defaults", ")", "{", "// SASS => WP", "$", "overrides", "=", "[", "'body-font-size'", "=>", "'pdf_body_font_size'", ",", "'body-line-height'", "=>", "'pdf_body_line_height'", ",", "'page-margin-top'", "=>", "'pdf_page_m...
Filter the array of default values for the PDF options tab. @param array $defaults @return array $defaults
[ "Filter", "the", "array", "of", "default", "values", "for", "the", "PDF", "options", "tab", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/themeoptions/class-pdfoptions.php#L1459-L1524
pressbooks/pressbooks
inc/modules/themeoptions/class-pdfoptions.php
PDFOptions.parseSassValue
static protected function parseSassValue( $val ) { if ( substr( $val, 0, 1 ) === '(' ) { // We think this is a Sass Map preg_match( '/prince:([^,]+)/', $val, $matches ); if ( ! empty( $matches[1] ) ) { return trim( $matches[1] ); } return ''; // Did not find prince mapping } if ( substr( $val...
php
static protected function parseSassValue( $val ) { if ( substr( $val, 0, 1 ) === '(' ) { // We think this is a Sass Map preg_match( '/prince:([^,]+)/', $val, $matches ); if ( ! empty( $matches[1] ) ) { return trim( $matches[1] ); } return ''; // Did not find prince mapping } if ( substr( $val...
[ "static", "protected", "function", "parseSassValue", "(", "$", "val", ")", "{", "if", "(", "substr", "(", "$", "val", ",", "0", ",", "1", ")", "===", "'('", ")", "{", "// We think this is a Sass Map", "preg_match", "(", "'/prince:([^,]+)/'", ",", "$", "val...
@param string $val @return string
[ "@param", "string", "$val" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/themeoptions/class-pdfoptions.php#L1531-L1553
pressbooks/pressbooks
inc/modules/themeoptions/class-pdfoptions.php
PDFOptions.scssOverrides
static function scssOverrides( $scss ) { $styles = Container::get( 'Styles' ); $v2_compatible = $styles->isCurrentThemeCompatible( 2 ); if ( ! $v2_compatible ) { $scss .= "/* Theme Options */\n"; } // -------------------------------------------------------------------- // Global Options $options = ...
php
static function scssOverrides( $scss ) { $styles = Container::get( 'Styles' ); $v2_compatible = $styles->isCurrentThemeCompatible( 2 ); if ( ! $v2_compatible ) { $scss .= "/* Theme Options */\n"; } // -------------------------------------------------------------------- // Global Options $options = ...
[ "static", "function", "scssOverrides", "(", "$", "scss", ")", "{", "$", "styles", "=", "Container", "::", "get", "(", "'Styles'", ")", ";", "$", "v2_compatible", "=", "$", "styles", "->", "isCurrentThemeCompatible", "(", "2", ")", ";", "if", "(", "!", ...
Apply overrides. @param string $scss @return string @since 3.9.8
[ "Apply", "overrides", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/themeoptions/class-pdfoptions.php#L1763-L2053
pressbooks/pressbooks
inc/htmlbook/class-validator.php
Validator.validate
public function validate( string $path ) { $command = PB_XMLLINT_COMMAND . ' --noout --schema ' . escapeshellcmd( $this->getSchemaPath() ) . ' ' . escapeshellcmd( $path ) . ' 2>&1'; // Execute command $this->errors = []; $output = []; $return_var = 0; exec( $command, $output, $return_var ); if ( isset(...
php
public function validate( string $path ) { $command = PB_XMLLINT_COMMAND . ' --noout --schema ' . escapeshellcmd( $this->getSchemaPath() ) . ' ' . escapeshellcmd( $path ) . ' 2>&1'; // Execute command $this->errors = []; $output = []; $return_var = 0; exec( $command, $output, $return_var ); if ( isset(...
[ "public", "function", "validate", "(", "string", "$", "path", ")", "{", "$", "command", "=", "PB_XMLLINT_COMMAND", ".", "' --noout --schema '", ".", "escapeshellcmd", "(", "$", "this", "->", "getSchemaPath", "(", ")", ")", ".", "' '", ".", "escapeshellcmd", ...
Validate an HTMLBook file @param string $path @return bool
[ "Validate", "an", "HTMLBook", "file" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/htmlbook/class-validator.php#L53-L69
pressbooks/pressbooks
inc/covergenerator/class-isbn.php
Isbn.createBarcode
public function createBarcode( $isbn_number ) { if ( ! $this->validateIsbnNumber( $isbn_number ) ) { \Pressbooks\add_error( __( 'There was a problem creating the barcode: Invalid ISBN number.', 'pressbooks' ) ); return false; } $this->isbnNumber = $this->fixIsbnNumber( $isbn_number ); $ps = \Pressbooks...
php
public function createBarcode( $isbn_number ) { if ( ! $this->validateIsbnNumber( $isbn_number ) ) { \Pressbooks\add_error( __( 'There was a problem creating the barcode: Invalid ISBN number.', 'pressbooks' ) ); return false; } $this->isbnNumber = $this->fixIsbnNumber( $isbn_number ); $ps = \Pressbooks...
[ "public", "function", "createBarcode", "(", "$", "isbn_number", ")", "{", "if", "(", "!", "$", "this", "->", "validateIsbnNumber", "(", "$", "isbn_number", ")", ")", "{", "\\", "Pressbooks", "\\", "add_error", "(", "__", "(", "'There was a problem creating the...
Create an ISBN png and sideload it into WordPress @param string $isbn_number @throws \Exception @return string
[ "Create", "an", "ISBN", "png", "and", "sideload", "it", "into", "WordPress" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/covergenerator/class-isbn.php#L59-L107
pressbooks/pressbooks
inc/covergenerator/class-isbn.php
Isbn.validateIsbnNumber
public function validateIsbnNumber( $isbn_number ) { // Regex to split a string only by the last whitespace character @list( $isbn_number, $addon ) = preg_split( '/\s+(?=\S*+$)/', trim( $isbn_number ) ); // @codingStandardsIgnoreLine $is_valid_isbn = ( new \Isbn\Isbn() )->validation->isbn( $isbn_number ); $is...
php
public function validateIsbnNumber( $isbn_number ) { // Regex to split a string only by the last whitespace character @list( $isbn_number, $addon ) = preg_split( '/\s+(?=\S*+$)/', trim( $isbn_number ) ); // @codingStandardsIgnoreLine $is_valid_isbn = ( new \Isbn\Isbn() )->validation->isbn( $isbn_number ); $is...
[ "public", "function", "validateIsbnNumber", "(", "$", "isbn_number", ")", "{", "// Regex to split a string only by the last whitespace character", "@", "list", "(", "$", "isbn_number", ",", "$", "addon", ")", "=", "preg_split", "(", "'/\\s+(?=\\S*+$)/'", ",", "trim", ...
Validate an ISBN string @param $isbn_number @return bool
[ "Validate", "an", "ISBN", "string" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/covergenerator/class-isbn.php#L117-L132
pressbooks/pressbooks
inc/covergenerator/class-isbn.php
Isbn.fixIsbnNumber
public function fixIsbnNumber( $isbn_number ) { // Regex to split a string only by the last whitespace character @list( $isbn_number, $addon ) = preg_split( '/\s+(?=\S*+$)/', trim( $isbn_number ) ); // @codingStandardsIgnoreLine $isbn_number = ( new \Isbn\Isbn() )->hyphens->fixHyphens( $isbn_number ); if ( $...
php
public function fixIsbnNumber( $isbn_number ) { // Regex to split a string only by the last whitespace character @list( $isbn_number, $addon ) = preg_split( '/\s+(?=\S*+$)/', trim( $isbn_number ) ); // @codingStandardsIgnoreLine $isbn_number = ( new \Isbn\Isbn() )->hyphens->fixHyphens( $isbn_number ); if ( $...
[ "public", "function", "fixIsbnNumber", "(", "$", "isbn_number", ")", "{", "// Regex to split a string only by the last whitespace character", "@", "list", "(", "$", "isbn_number", ",", "$", "addon", ")", "=", "preg_split", "(", "'/\\s+(?=\\S*+$)/'", ",", "trim", "(", ...
Fix an ISBN string @param $isbn_number @return string
[ "Fix", "an", "ISBN", "string" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/covergenerator/class-isbn.php#L141-L153
pressbooks/pressbooks
inc/covergenerator/class-isbn.php
Isbn.invocation
public function invocation( $isbn, $isbn_text_font, $isbn_text_size, $text_font, $text_size ) { $ps[] = "50 50 moveto ({$isbn}) (includetext isbntextfont={$isbn_text_font} isbntextsize={$isbn_text_size} textfont={$text_font} textsize={$text_size})"; $ps[] = '/isbn /uk.co.terryburton.bwipp findresource exec'; re...
php
public function invocation( $isbn, $isbn_text_font, $isbn_text_size, $text_font, $text_size ) { $ps[] = "50 50 moveto ({$isbn}) (includetext isbntextfont={$isbn_text_font} isbntextsize={$isbn_text_size} textfont={$text_font} textsize={$text_size})"; $ps[] = '/isbn /uk.co.terryburton.bwipp findresource exec'; re...
[ "public", "function", "invocation", "(", "$", "isbn", ",", "$", "isbn_text_font", ",", "$", "isbn_text_size", ",", "$", "text_font", ",", "$", "text_size", ")", "{", "$", "ps", "[", "]", "=", "\"50 50 moveto ({$isbn}) (includetext isbntextfont={$isbn_text_font} isbn...
ISBN Invocation Code. @see https://github.com/bwipp/postscriptbarcode/wiki/ISBN @see https://github.com/bwipp/postscriptbarcode/wiki/Symbol-Dimensions @see https://github.com/bwipp/postscriptbarcode/wiki/Text-Properties @param string $isbn @param string $isbn_text_font @param float $isbn_text_size @param string $text...
[ "ISBN", "Invocation", "Code", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/covergenerator/class-isbn.php#L171-L177
pressbooks/pressbooks
inc/covergenerator/class-isbn.php
Isbn.compile
public function compile( $path_to_ps ) { if ( empty( $this->isbnNumber ) ) { throw new \LogicException( '$this->isbnNumber is not set' ); } $isbn = \Pressbooks\Utility\get_contents( PB_PLUGIN_DIR . 'symbionts/postscriptbarcode/isbn.ps' ); $invocation = $this->invocation( $this->isbnNumber, $this->is...
php
public function compile( $path_to_ps ) { if ( empty( $this->isbnNumber ) ) { throw new \LogicException( '$this->isbnNumber is not set' ); } $isbn = \Pressbooks\Utility\get_contents( PB_PLUGIN_DIR . 'symbionts/postscriptbarcode/isbn.ps' ); $invocation = $this->invocation( $this->isbnNumber, $this->is...
[ "public", "function", "compile", "(", "$", "path_to_ps", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "isbnNumber", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "'$this->isbnNumber is not set'", ")", ";", "}", "$", "isbn", "=", "\...
Compile an ISBN Postscript file @param string $path_to_ps @throws \LogicException
[ "Compile", "an", "ISBN", "Postscript", "file" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/covergenerator/class-isbn.php#L187-L208
pressbooks/pressbooks
inc/covergenerator/class-isbn.php
Isbn.gs
public function gs( $input_path_to_ps, $output_path_to_png, $dpi ) { $dpi = (int) $dpi; $command = PB_GS_COMMAND . " -dQUIET -dNOPAUSE -dSAFER -dBATCH -sDEVICE=pnggray -r{$dpi} -sOutputFile=" . escapeshellarg( $output_path_to_png ) . ' ' . escapeshellarg( $input_path_to_ps ); // Execute command $output = []; ...
php
public function gs( $input_path_to_ps, $output_path_to_png, $dpi ) { $dpi = (int) $dpi; $command = PB_GS_COMMAND . " -dQUIET -dNOPAUSE -dSAFER -dBATCH -sDEVICE=pnggray -r{$dpi} -sOutputFile=" . escapeshellarg( $output_path_to_png ) . ' ' . escapeshellarg( $input_path_to_ps ); // Execute command $output = []; ...
[ "public", "function", "gs", "(", "$", "input_path_to_ps", ",", "$", "output_path_to_png", ",", "$", "dpi", ")", "{", "$", "dpi", "=", "(", "int", ")", "$", "dpi", ";", "$", "command", "=", "PB_GS_COMMAND", ".", "\" -dQUIET -dNOPAUSE -dSAFER -dBATCH -sDEVICE=pn...
Use Ghostscript to convert a PostScript file into a grayscale PNG file @param string $input_path_to_ps @param string $output_path_to_png @param int $dpi
[ "Use", "Ghostscript", "to", "convert", "a", "PostScript", "file", "into", "a", "grayscale", "PNG", "file" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/covergenerator/class-isbn.php#L218-L234
pressbooks/pressbooks
inc/covergenerator/class-isbn.php
Isbn.crop
public function crop( $path_to_png, $border = '20x20' ) { $command = PB_CONVERT_COMMAND . ' ' . escapeshellarg( $path_to_png ) . " -trim +repage -bordercolor white -border {$border} " . escapeshellarg( $path_to_png ); // Execute command $output = []; $return_var = 0; exec( $command, $output, $return_var ); ...
php
public function crop( $path_to_png, $border = '20x20' ) { $command = PB_CONVERT_COMMAND . ' ' . escapeshellarg( $path_to_png ) . " -trim +repage -bordercolor white -border {$border} " . escapeshellarg( $path_to_png ); // Execute command $output = []; $return_var = 0; exec( $command, $output, $return_var ); ...
[ "public", "function", "crop", "(", "$", "path_to_png", ",", "$", "border", "=", "'20x20'", ")", "{", "$", "command", "=", "PB_CONVERT_COMMAND", ".", "' '", ".", "escapeshellarg", "(", "$", "path_to_png", ")", ".", "\" -trim +repage -bordercolor white -border {$bor...
Use ImageMagick to automatically crop & pad a PNG file with a white border @param string $path_to_png @param string $border
[ "Use", "ImageMagick", "to", "automatically", "crop", "&", "pad", "a", "PNG", "file", "with", "a", "white", "border" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/covergenerator/class-isbn.php#L243-L258
pressbooks/pressbooks
inc/covergenerator/class-docraptorjpg.php
DocraptorJpg.generate
public function generate() { $tmp_pdf_path = create_tmp_file(); $this->generateWithDocraptor( $this->pdfProfile, $this->generateHtml(), $tmp_pdf_path ); $output_path = $this->timestampedFileName( 'jpg' ); $this->convert( $tmp_pdf_path, $output_path ); delete_transient( 'dirsize_cache' ); /** @see get_dirsize(...
php
public function generate() { $tmp_pdf_path = create_tmp_file(); $this->generateWithDocraptor( $this->pdfProfile, $this->generateHtml(), $tmp_pdf_path ); $output_path = $this->timestampedFileName( 'jpg' ); $this->convert( $tmp_pdf_path, $output_path ); delete_transient( 'dirsize_cache' ); /** @see get_dirsize(...
[ "public", "function", "generate", "(", ")", "{", "$", "tmp_pdf_path", "=", "create_tmp_file", "(", ")", ";", "$", "this", "->", "generateWithDocraptor", "(", "$", "this", "->", "pdfProfile", ",", "$", "this", "->", "generateHtml", "(", ")", ",", "$", "tm...
Generate Ebook JPG cover @throws \Exception @return string Output path
[ "Generate", "Ebook", "JPG", "cover" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/covergenerator/class-docraptorjpg.php#L77-L84
pressbooks/pressbooks
inc/covergenerator/class-docraptorjpg.php
DocraptorJpg.generateCss
protected function generateCss() { $styles = Container::get( 'Styles' ); $scss = $this->getScssVars(); if ( $styles->isCurrentThemeCompatible( 1 ) ) { $scss .= "@import 'fonts-prince'; \n"; } elseif ( $styles->isCurrentThemeCompatible( 2 ) ) { $scss .= "@import 'fonts'; \n"; } $scss .= \Pressbooks\Ut...
php
protected function generateCss() { $styles = Container::get( 'Styles' ); $scss = $this->getScssVars(); if ( $styles->isCurrentThemeCompatible( 1 ) ) { $scss .= "@import 'fonts-prince'; \n"; } elseif ( $styles->isCurrentThemeCompatible( 2 ) ) { $scss .= "@import 'fonts'; \n"; } $scss .= \Pressbooks\Ut...
[ "protected", "function", "generateCss", "(", ")", "{", "$", "styles", "=", "Container", "::", "get", "(", "'Styles'", ")", ";", "$", "scss", "=", "$", "this", "->", "getScssVars", "(", ")", ";", "if", "(", "$", "styles", "->", "isCurrentThemeCompatible",...
Generate CSS for Ebook JPG cover @return string the generated CSS
[ "Generate", "CSS", "for", "Ebook", "JPG", "cover" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/covergenerator/class-docraptorjpg.php#L92-L111
pressbooks/pressbooks
inc/covergenerator/class-docraptorjpg.php
DocraptorJpg.generateHtml
protected function generateHtml() { $vars = $this->getHtmlTemplateVars(); $vars['css'] = apply_filters( 'pb_epub_cover_css_override', $this->generateCss() ); $html = template( PB_PLUGIN_DIR . 'templates/covergenerator/jpg-cover.php', $vars ); return $html; }
php
protected function generateHtml() { $vars = $this->getHtmlTemplateVars(); $vars['css'] = apply_filters( 'pb_epub_cover_css_override', $this->generateCss() ); $html = template( PB_PLUGIN_DIR . 'templates/covergenerator/jpg-cover.php', $vars ); return $html; }
[ "protected", "function", "generateHtml", "(", ")", "{", "$", "vars", "=", "$", "this", "->", "getHtmlTemplateVars", "(", ")", ";", "$", "vars", "[", "'css'", "]", "=", "apply_filters", "(", "'pb_epub_cover_css_override'", ",", "$", "this", "->", "generateCss...
Generate HTML for Ebook JPG cover @return string the generated Html
[ "Generate", "HTML", "for", "Ebook", "JPG", "cover" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/covergenerator/class-docraptorjpg.php#L119-L124
pressbooks/pressbooks
inc/covergenerator/class-docraptorjpg.php
DocraptorJpg.convert
public function convert( $path_to_pdf, $path_to_jpg, $resize = '2500x3750' ) { // Convert using Imagemagick (TODO: fix jagged ugly fonts) // $command = PB_CONVERT_COMMAND . ' ' . escapeshellarg( $pathToPdf ) . " -density 96 -resize {$resize} -define jpeg:extent=2MB " . escapeshellarg( $pathToJpg ); // Convert u...
php
public function convert( $path_to_pdf, $path_to_jpg, $resize = '2500x3750' ) { // Convert using Imagemagick (TODO: fix jagged ugly fonts) // $command = PB_CONVERT_COMMAND . ' ' . escapeshellarg( $pathToPdf ) . " -density 96 -resize {$resize} -define jpeg:extent=2MB " . escapeshellarg( $pathToJpg ); // Convert u...
[ "public", "function", "convert", "(", "$", "path_to_pdf", ",", "$", "path_to_jpg", ",", "$", "resize", "=", "'2500x3750'", ")", "{", "// Convert using Imagemagick (TODO: fix jagged ugly fonts)", "// $command = PB_CONVERT_COMMAND . ' ' . escapeshellarg( $pathToPdf ) . \" -density 96...
Use ImageMagick to convert a PDF to a JPG (max 2MB) @param string $path_to_pdf Input path to PDF @param string $path_to_jpg Output path to JPG @param string $resize @throws \Exception
[ "Use", "ImageMagick", "to", "convert", "a", "PDF", "to", "a", "JPG", "(", "max", "2MB", ")" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/covergenerator/class-docraptorjpg.php#L140-L200
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.dependencies
public function dependencies( $h5p = null, $downloads = null, $contributors = null ) { $this->h5p = $h5p ? $h5p : \Pressbooks\Interactive\Content::init()->getH5P(); $this->downloads = $downloads ? $downloads : new Downloads( $this, $this->h5p ); $this->contributors = $contributors ? $contributors : new \Pressbook...
php
public function dependencies( $h5p = null, $downloads = null, $contributors = null ) { $this->h5p = $h5p ? $h5p : \Pressbooks\Interactive\Content::init()->getH5P(); $this->downloads = $downloads ? $downloads : new Downloads( $this, $this->h5p ); $this->contributors = $contributors ? $contributors : new \Pressbook...
[ "public", "function", "dependencies", "(", "$", "h5p", "=", "null", ",", "$", "downloads", "=", "null", ",", "$", "contributors", "=", "null", ")", "{", "$", "this", "->", "h5p", "=", "$", "h5p", "?", "$", "h5p", ":", "\\", "Pressbooks", "\\", "Int...
For testing, ability to mock objects @param null \Pressbooks\Interactive\H5P $h5p @param null Downloads $downloads @param null \Pressbooks\Contributors $contributors
[ "For", "testing", "ability", "to", "mock", "objects" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L278-L282
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.cloneBook
public function cloneBook() { try { foreach ( $this->cloneBookGenerator() as $percentage => $info ) { // Do nothing, this is a compatibility wrapper that makes the generator work like a regular function } } catch ( \Exception $e ) { return false; } return true; }
php
public function cloneBook() { try { foreach ( $this->cloneBookGenerator() as $percentage => $info ) { // Do nothing, this is a compatibility wrapper that makes the generator work like a regular function } } catch ( \Exception $e ) { return false; } return true; }
[ "public", "function", "cloneBook", "(", ")", "{", "try", "{", "foreach", "(", "$", "this", "->", "cloneBookGenerator", "(", ")", "as", "$", "percentage", "=>", "$", "info", ")", "{", "// Do nothing, this is a compatibility wrapper that makes the generator work like a ...
Clone a book in its entirety. @since 4.1.0 @return bool
[ "Clone", "a", "book", "in", "its", "entirety", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L376-L385
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.cloneBookGenerator
public function cloneBookGenerator() : \Generator { yield 1 => __( 'Looking up the source book', 'pressbooks' ); if ( ! $this->setupSource() ) { throw new \Exception( ! empty( $_SESSION['pb_errors'][0] ) ? $_SESSION['pb_errors'][0] : __( 'Failed to setup source', 'pressbooks' ) ); } // Create Book yield ...
php
public function cloneBookGenerator() : \Generator { yield 1 => __( 'Looking up the source book', 'pressbooks' ); if ( ! $this->setupSource() ) { throw new \Exception( ! empty( $_SESSION['pb_errors'][0] ) ? $_SESSION['pb_errors'][0] : __( 'Failed to setup source', 'pressbooks' ) ); } // Create Book yield ...
[ "public", "function", "cloneBookGenerator", "(", ")", ":", "\\", "Generator", "{", "yield", "1", "=>", "__", "(", "'Looking up the source book'", ",", "'pressbooks'", ")", ";", "if", "(", "!", "$", "this", "->", "setupSource", "(", ")", ")", "{", "throw", ...
Generator that yields values between 1-100, represents the percentage of progress when cloning a book in its entirety @since 5.7.0 @throws \Exception @return \Generator
[ "Generator", "that", "yields", "values", "between", "1", "-", "100", "represents", "the", "percentage", "of", "progress", "when", "cloning", "a", "book", "in", "its", "entirety" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L394-L486
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.setupSource
public function setupSource( $respect_book_license = true ) { if ( ! empty( $this->sourceBookId ) ) { // Local book switch_to_blog( $this->sourceBookId ); } elseif ( ! $this->isCompatible( $this->sourceBookUrl ) ) { // Remote is not compatible, bail. $_SESSION['pb_errors'][] = __( 'You can only clone fr...
php
public function setupSource( $respect_book_license = true ) { if ( ! empty( $this->sourceBookId ) ) { // Local book switch_to_blog( $this->sourceBookId ); } elseif ( ! $this->isCompatible( $this->sourceBookUrl ) ) { // Remote is not compatible, bail. $_SESSION['pb_errors'][] = __( 'You can only clone fr...
[ "public", "function", "setupSource", "(", "$", "respect_book_license", "=", "true", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "sourceBookId", ")", ")", "{", "// Local book", "switch_to_blog", "(", "$", "this", "->", "sourceBookId", ")", ";...
@since 5.0.0 @param bool $respect_book_license @return bool
[ "@since", "5", ".", "0", ".", "0" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L495-L568
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.cloneTerm
public function cloneTerm( $term_id ) { // Retrieve term foreach ( $this->sourceBookTerms as $k => $v ) { if ( $v['id'] === absint( $term_id ) ) { $term = $this->sourceBookTerms[ $k ]; break; } }; if ( empty( $term['slug'] ) || empty( $term['taxonomy'] ) ) { // Doing it wrong... return fals...
php
public function cloneTerm( $term_id ) { // Retrieve term foreach ( $this->sourceBookTerms as $k => $v ) { if ( $v['id'] === absint( $term_id ) ) { $term = $this->sourceBookTerms[ $k ]; break; } }; if ( empty( $term['slug'] ) || empty( $term['taxonomy'] ) ) { // Doing it wrong... return fals...
[ "public", "function", "cloneTerm", "(", "$", "term_id", ")", "{", "// Retrieve term", "foreach", "(", "$", "this", "->", "sourceBookTerms", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "$", "v", "[", "'id'", "]", "===", "absint", "(", "$", ...
Clone term from a source book to a target book. @since 4.1.0 @param int $term_id The ID of the term within the source book. @return bool | int False if creating a new term failed; the ID of the new term if it the clone succeeded or the ID of a matching term if it exists.
[ "Clone", "term", "from", "a", "source", "book", "to", "a", "target", "book", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L589-L634
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.clonePostProcess
public function clonePostProcess() { $this->fixInternalShortcodes(); // H5P if ( $this->sourceHasH5p === true && ( $this->sourceHasH5pApi === false || $this->targetHasH5pApi === false || $this->targetHasFetchedAllTheH5p === false ) ) { // Add a notice to the user indicating that the H5P could not be cloned ...
php
public function clonePostProcess() { $this->fixInternalShortcodes(); // H5P if ( $this->sourceHasH5p === true && ( $this->sourceHasH5pApi === false || $this->targetHasH5pApi === false || $this->targetHasFetchedAllTheH5p === false ) ) { // Add a notice to the user indicating that the H5P could not be cloned ...
[ "public", "function", "clonePostProcess", "(", ")", "{", "$", "this", "->", "fixInternalShortcodes", "(", ")", ";", "// H5P", "if", "(", "$", "this", "->", "sourceHasH5p", "===", "true", "&&", "(", "$", "this", "->", "sourceHasH5pApi", "===", "false", "||"...
Post-processor
[ "Post", "-", "processor" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L705-L712
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.buildListOfKnownMedia
public function buildListOfKnownMedia( $url ) { // Handle request (local or global) $params = [ 'per_page' => 100, ]; $response = $this->handleGetRequest( $url, 'wp/v2', 'media', $params ); // Handle errors if ( is_wp_error( $response ) ) { $_SESSION['pb_errors'][] = sprintf( '<p>%1$s</p><p>%2$s<...
php
public function buildListOfKnownMedia( $url ) { // Handle request (local or global) $params = [ 'per_page' => 100, ]; $response = $this->handleGetRequest( $url, 'wp/v2', 'media', $params ); // Handle errors if ( is_wp_error( $response ) ) { $_SESSION['pb_errors'][] = sprintf( '<p>%1$s</p><p>%2$s<...
[ "public", "function", "buildListOfKnownMedia", "(", "$", "url", ")", "{", "// Handle request (local or global)", "$", "params", "=", "[", "'per_page'", "=>", "100", ",", "]", ";", "$", "response", "=", "$", "this", "->", "handleGetRequest", "(", "$", "url", ...
Use media endpoint to build an array of known media @param string $url The URL of the book. @return bool|\Pressbooks\Entities\Cloner\Media[] False if the operation failed; known images assoc array if succeeded.
[ "Use", "media", "endpoint", "to", "build", "an", "array", "of", "known", "media" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L721-L753
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.buildListOfKnownH5P
public function buildListOfKnownH5P( $url ) { $response = $this->handleGetRequest( $url, 'h5p/v1', 'all' ); if ( is_wp_error( $response ) || @$response['data']['status'] >= 400 ) { // @codingStandardsIgnoreLine return false; } $known_h5p = []; foreach ( $response as $item ) { $known_h5p[] = $this->crea...
php
public function buildListOfKnownH5P( $url ) { $response = $this->handleGetRequest( $url, 'h5p/v1', 'all' ); if ( is_wp_error( $response ) || @$response['data']['status'] >= 400 ) { // @codingStandardsIgnoreLine return false; } $known_h5p = []; foreach ( $response as $item ) { $known_h5p[] = $this->crea...
[ "public", "function", "buildListOfKnownH5P", "(", "$", "url", ")", "{", "$", "response", "=", "$", "this", "->", "handleGetRequest", "(", "$", "url", ",", "'h5p/v1'", ",", "'all'", ")", ";", "if", "(", "is_wp_error", "(", "$", "response", ")", "||", "@...
@param $url @return bool|\Pressbooks\Entities\Cloner\H5P[] False if the operation failed; known H5P array if succeeded.
[ "@param", "$url" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L760-L771
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.createTransition
public function createTransition( $type, $old_id, $new_id ) { $transition = new \Pressbooks\Entities\Cloner\Transition(); $transition->type = $type; $transition->oldId = $old_id; $transition->newId = $new_id; $this->transitions[] = $transition; }
php
public function createTransition( $type, $old_id, $new_id ) { $transition = new \Pressbooks\Entities\Cloner\Transition(); $transition->type = $type; $transition->oldId = $old_id; $transition->newId = $new_id; $this->transitions[] = $transition; }
[ "public", "function", "createTransition", "(", "$", "type", ",", "$", "old_id", ",", "$", "new_id", ")", "{", "$", "transition", "=", "new", "\\", "Pressbooks", "\\", "Entities", "\\", "Cloner", "\\", "Transition", "(", ")", ";", "$", "transition", "->",...
When cloning from one book to another, the IDs change Use this method to add a transition, that we can do something with later, if needed @param string $type @param int $old_id @param int $new_id
[ "When", "cloning", "from", "one", "book", "to", "another", "the", "IDs", "change", "Use", "this", "method", "to", "add", "a", "transition", "that", "we", "can", "do", "something", "with", "later", "if", "needed" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L781-L787
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.getBookMetadata
public function getBookMetadata( $url ) { // Handle request (local or global) $response = $this->handleGetRequest( $url, 'pressbooks/v2', 'metadata' ); // Handle errors if ( is_wp_error( $response ) ) { $_SESSION['pb_errors'][] = sprintf( '<p>%1$s</p><p>%2$s</p>', __( 'The source book&rsquo;s metada...
php
public function getBookMetadata( $url ) { // Handle request (local or global) $response = $this->handleGetRequest( $url, 'pressbooks/v2', 'metadata' ); // Handle errors if ( is_wp_error( $response ) ) { $_SESSION['pb_errors'][] = sprintf( '<p>%1$s</p><p>%2$s</p>', __( 'The source book&rsquo;s metada...
[ "public", "function", "getBookMetadata", "(", "$", "url", ")", "{", "// Handle request (local or global)", "$", "response", "=", "$", "this", "->", "handleGetRequest", "(", "$", "url", ",", "'pressbooks/v2'", ",", "'metadata'", ")", ";", "// Handle errors", "if", ...
Fetch an array containing the metadata of a book. @since 4.1.0 @param string $url The URL of the book. @return bool | array False if the operation failed; the metadata array if it succeeded.
[ "Fetch", "an", "array", "containing", "the", "metadata", "of", "a", "book", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L798-L814
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.getBookTerms
public function getBookTerms( $url ) { $terms = []; foreach ( [ 'front-matter-type', 'chapter-type', 'back-matter-type', 'glossary-type' ] as $taxonomy ) { // Handle request (local or global) $response = $this->handleGetRequest( $url, 'pressbooks/v2', "$taxonomy", [ 'per_page' => 25, ] ); ...
php
public function getBookTerms( $url ) { $terms = []; foreach ( [ 'front-matter-type', 'chapter-type', 'back-matter-type', 'glossary-type' ] as $taxonomy ) { // Handle request (local or global) $response = $this->handleGetRequest( $url, 'pressbooks/v2', "$taxonomy", [ 'per_page' => 25, ] ); ...
[ "public", "function", "getBookTerms", "(", "$", "url", ")", "{", "$", "terms", "=", "[", "]", ";", "foreach", "(", "[", "'front-matter-type'", ",", "'chapter-type'", ",", "'back-matter-type'", ",", "'glossary-type'", "]", "as", "$", "taxonomy", ")", "{", "...
Fetch an array containing the terms of a book. @since 4.1.0 @param string $url The URL of the book. @return array
[ "Fetch", "an", "array", "containing", "the", "terms", "of", "a", "book", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L856-L883
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.isSourceCloneable
public function isSourceCloneable( $metadata_license ) { $restrictive_licenses = [ 'https://creativecommons.org/licenses/by-nd/4.0/', 'https://creativecommons.org/licenses/by-nc-nd/4.0/', 'https://choosealicense.com/no-license/', ]; if ( is_array( $metadata_license ) ) { $license_url = $metadata_lice...
php
public function isSourceCloneable( $metadata_license ) { $restrictive_licenses = [ 'https://creativecommons.org/licenses/by-nd/4.0/', 'https://creativecommons.org/licenses/by-nc-nd/4.0/', 'https://choosealicense.com/no-license/', ]; if ( is_array( $metadata_license ) ) { $license_url = $metadata_lice...
[ "public", "function", "isSourceCloneable", "(", "$", "metadata_license", ")", "{", "$", "restrictive_licenses", "=", "[", "'https://creativecommons.org/licenses/by-nd/4.0/'", ",", "'https://creativecommons.org/licenses/by-nc-nd/4.0/'", ",", "'https://choosealicense.com/no-license/'",...
Is the source book cloneable? @since 4.1.0 @param mixed $metadata_license @return bool Whether or not the book is public and licensed for cloning (or true if the current user is a network administrator and the book is in the current network).
[ "Is", "the", "source", "book", "cloneable?" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L917-L943
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.retrieveSectionMetadata
public function retrieveSectionMetadata( $section_id, $post_type ) { if ( in_array( $post_type, [ 'front-matter', 'back-matter' ], true ) ) { foreach ( $this->sourceBookStructure[ $post_type ] as $k => $v ) { if ( $v['id'] === absint( $section_id ) ) { return $v['metadata']; } } } elseif ( $post_...
php
public function retrieveSectionMetadata( $section_id, $post_type ) { if ( in_array( $post_type, [ 'front-matter', 'back-matter' ], true ) ) { foreach ( $this->sourceBookStructure[ $post_type ] as $k => $v ) { if ( $v['id'] === absint( $section_id ) ) { return $v['metadata']; } } } elseif ( $post_...
[ "public", "function", "retrieveSectionMetadata", "(", "$", "section_id", ",", "$", "post_type", ")", "{", "if", "(", "in_array", "(", "$", "post_type", ",", "[", "'front-matter'", ",", "'back-matter'", "]", ",", "true", ")", ")", "{", "foreach", "(", "$", ...
Retrieve metadata @since 5.0.0 @param int $section_id The ID of the section within the source book. @param string $post_type The post type of the section. @return array
[ "Retrieve", "metadata" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L955-L978
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.discoverWordPressApi
public function discoverWordPressApi( $url ) { // Use redirection because our servers redirect when missing a trailing slash $response = wp_safe_remote_head( $url, [ 'redirection' => 2, ] ); if ( is_wp_error( $response ) ) { return false; } $headers = wp_remote_retrieve_headers( $response ); ...
php
public function discoverWordPressApi( $url ) { // Use redirection because our servers redirect when missing a trailing slash $response = wp_safe_remote_head( $url, [ 'redirection' => 2, ] ); if ( is_wp_error( $response ) ) { return false; } $headers = wp_remote_retrieve_headers( $response ); ...
[ "public", "function", "discoverWordPressApi", "(", "$", "url", ")", "{", "// Use redirection because our servers redirect when missing a trailing slash", "$", "response", "=", "wp_safe_remote_head", "(", "$", "url", ",", "[", "'redirection'", "=>", "2", ",", "]", ")", ...
Discover WordPress API @see https://developer.wordpress.org/rest-api/using-the-rest-api/discovery/ @param string $url @return string|false Returns (corrected) URL on success, false on failure
[ "Discover", "WordPress", "API" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L989-L1026
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.isCompatible
public function isCompatible( $url ) { $new_url = $this->discoverWordPressApi( $url ); if ( $new_url ) { $url = $new_url; $this->sourceBookUrl = $new_url; } // Check for taxonomies introduced in Pressbooks 4.1 // We specifically check for 404 Not Found. // If we get another kind of error it will be ...
php
public function isCompatible( $url ) { $new_url = $this->discoverWordPressApi( $url ); if ( $new_url ) { $url = $new_url; $this->sourceBookUrl = $new_url; } // Check for taxonomies introduced in Pressbooks 4.1 // We specifically check for 404 Not Found. // If we get another kind of error it will be ...
[ "public", "function", "isCompatible", "(", "$", "url", ")", "{", "$", "new_url", "=", "$", "this", "->", "discoverWordPressApi", "(", "$", "url", ")", ";", "if", "(", "$", "new_url", ")", "{", "$", "url", "=", "$", "new_url", ";", "$", "this", "->"...
@param string $url @return bool
[ "@param", "string", "$url" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L1033-L1050
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.getBookId
public function getBookId( $url ) { return get_blog_id_from_url( wp_parse_url( $url, PHP_URL_HOST ), trailingslashit( wp_parse_url( $url, PHP_URL_PATH ) ) ); }
php
public function getBookId( $url ) { return get_blog_id_from_url( wp_parse_url( $url, PHP_URL_HOST ), trailingslashit( wp_parse_url( $url, PHP_URL_PATH ) ) ); }
[ "public", "function", "getBookId", "(", "$", "url", ")", "{", "return", "get_blog_id_from_url", "(", "wp_parse_url", "(", "$", "url", ",", "PHP_URL_HOST", ")", ",", "trailingslashit", "(", "wp_parse_url", "(", "$", "url", ",", "PHP_URL_PATH", ")", ")", ")", ...
Get a book ID from its URL. @since 4.1.0 @param string $url @return int 0 of no blog was found, or the ID of the matched book.
[ "Get", "a", "book", "ID", "from", "its", "URL", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L1061-L1066
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.getSubdomainOrSubDirectory
public function getSubdomainOrSubDirectory( $url ) { $url = untrailingslashit( $url ); $host = wp_parse_url( $url, PHP_URL_HOST ); $path = wp_parse_url( $url, PHP_URL_PATH ); if ( $path ) { return ltrim( $path, '/\\' ); } else { $host = explode( '.', $host ); $subdomain = array_shift( $host ); ret...
php
public function getSubdomainOrSubDirectory( $url ) { $url = untrailingslashit( $url ); $host = wp_parse_url( $url, PHP_URL_HOST ); $path = wp_parse_url( $url, PHP_URL_PATH ); if ( $path ) { return ltrim( $path, '/\\' ); } else { $host = explode( '.', $host ); $subdomain = array_shift( $host ); ret...
[ "public", "function", "getSubdomainOrSubDirectory", "(", "$", "url", ")", "{", "$", "url", "=", "untrailingslashit", "(", "$", "url", ")", ";", "$", "host", "=", "wp_parse_url", "(", "$", "url", ",", "PHP_URL_HOST", ")", ";", "$", "path", "=", "wp_parse_...
Given a URL, get the subdomain or subdirectory (depending on the type of multisite install). @since 4.1.0 @param string $url @return string
[ "Given", "a", "URL", "get", "the", "subdomain", "or", "subdirectory", "(", "depending", "on", "the", "type", "of", "multisite", "install", ")", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L1077-L1088
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.createMediaEntity
protected function createMediaEntity( $item ) { $m = new \Pressbooks\Entities\Cloner\Media(); if ( isset( $item['id'] ) ) { $m->id = $item['id']; } if ( isset( $item['title'], $item['title']['raw'] ) ) { $m->title = $item['title']['raw']; } if ( isset( $item['description'], $item['description']['raw']...
php
protected function createMediaEntity( $item ) { $m = new \Pressbooks\Entities\Cloner\Media(); if ( isset( $item['id'] ) ) { $m->id = $item['id']; } if ( isset( $item['title'], $item['title']['raw'] ) ) { $m->title = $item['title']['raw']; } if ( isset( $item['description'], $item['description']['raw']...
[ "protected", "function", "createMediaEntity", "(", "$", "item", ")", "{", "$", "m", "=", "new", "\\", "Pressbooks", "\\", "Entities", "\\", "Cloner", "\\", "Media", "(", ")", ";", "if", "(", "isset", "(", "$", "item", "[", "'id'", "]", ")", ")", "{...
@param array $item @return \Pressbooks\Entities\Cloner\Media
[ "@param", "array", "$item" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L1121-L1145
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.createH5PEntity
protected function createH5PEntity( $item ) { $h5p = new \Pressbooks\Entities\Cloner\H5P(); if ( isset( $item['id'] ) ) { $h5p->id = $item['id']; } if ( isset( $item['url'] ) ) { $h5p->url = $item['url']; } return $h5p; }
php
protected function createH5PEntity( $item ) { $h5p = new \Pressbooks\Entities\Cloner\H5P(); if ( isset( $item['id'] ) ) { $h5p->id = $item['id']; } if ( isset( $item['url'] ) ) { $h5p->url = $item['url']; } return $h5p; }
[ "protected", "function", "createH5PEntity", "(", "$", "item", ")", "{", "$", "h5p", "=", "new", "\\", "Pressbooks", "\\", "Entities", "\\", "Cloner", "\\", "H5P", "(", ")", ";", "if", "(", "isset", "(", "$", "item", "[", "'id'", "]", ")", ")", "{",...
@param array $item @return \Pressbooks\Entities\Cloner\H5P
[ "@param", "array", "$item" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L1152-L1161
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.checkInternalShortcodes
protected function checkInternalShortcodes( $post_id, $html ) { // Glossary if ( has_shortcode( $html, \Pressbooks\Shortcodes\Glossary\Glossary::SHORTCODE ) ) { $this->postsWithGlossaryShortcodesToFix[] = $post_id; } // Attachments if ( has_shortcode( $html, \Pressbooks\Shortcodes\Attributions\Attachments:...
php
protected function checkInternalShortcodes( $post_id, $html ) { // Glossary if ( has_shortcode( $html, \Pressbooks\Shortcodes\Glossary\Glossary::SHORTCODE ) ) { $this->postsWithGlossaryShortcodesToFix[] = $post_id; } // Attachments if ( has_shortcode( $html, \Pressbooks\Shortcodes\Attributions\Attachments:...
[ "protected", "function", "checkInternalShortcodes", "(", "$", "post_id", ",", "$", "html", ")", "{", "// Glossary", "if", "(", "has_shortcode", "(", "$", "html", ",", "\\", "Pressbooks", "\\", "Shortcodes", "\\", "Glossary", "\\", "Glossary", "::", "SHORTCODE"...
Check if post content contains shortcodes with references to internal IDs that we will need to fix @param int $post_id @param string $html
[ "Check", "if", "post", "content", "contains", "shortcodes", "with", "references", "to", "internal", "IDs", "that", "we", "will", "need", "to", "fix" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L1169-L1183
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.createBook
protected function createBook() { $host = wp_parse_url( network_home_url(), PHP_URL_HOST ); if ( is_subdomain_install() ) { $domain = $this->getSubdomainOrSubDirectory( $this->targetBookUrl ) . '.' . $host; $path = '/'; } else { $domain = $host; $path = '/' . $this->getSubdomainOrSubDirectory( $this->...
php
protected function createBook() { $host = wp_parse_url( network_home_url(), PHP_URL_HOST ); if ( is_subdomain_install() ) { $domain = $this->getSubdomainOrSubDirectory( $this->targetBookUrl ) . '.' . $host; $path = '/'; } else { $domain = $host; $path = '/' . $this->getSubdomainOrSubDirectory( $this->...
[ "protected", "function", "createBook", "(", ")", "{", "$", "host", "=", "wp_parse_url", "(", "network_home_url", "(", ")", ",", "PHP_URL_HOST", ")", ";", "if", "(", "is_subdomain_install", "(", ")", ")", "{", "$", "domain", "=", "$", "this", "->", "getSu...
Create target book if it doesn't already exist. @since 4.1.0 @return bool | int False if the creation failed; the ID of the new book if it succeeded.
[ "Create", "target", "book", "if", "it", "doesn", "t", "already", "exist", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L1245-L1276
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.cloneMetadata
protected function cloneMetadata() { $metadata_post_id = ( new \Pressbooks\Metadata )->getMetaPostId(); if ( ! $metadata_post_id ) { return false; } $book_information = schema_to_book_information( $this->sourceBookMetadata ); // Cover image if ( ! \Pressbooks\Image\is_default_cover( $book_information[...
php
protected function cloneMetadata() { $metadata_post_id = ( new \Pressbooks\Metadata )->getMetaPostId(); if ( ! $metadata_post_id ) { return false; } $book_information = schema_to_book_information( $this->sourceBookMetadata ); // Cover image if ( ! \Pressbooks\Image\is_default_cover( $book_information[...
[ "protected", "function", "cloneMetadata", "(", ")", "{", "$", "metadata_post_id", "=", "(", "new", "\\", "Pressbooks", "\\", "Metadata", ")", "->", "getMetaPostId", "(", ")", ";", "if", "(", "!", "$", "metadata_post_id", ")", "{", "return", "false", ";", ...
Clone book information to the target book. @since 4.1.0 @return bool | int False if the creation failed; the ID of the new book's book information post if it succeeded.
[ "Clone", "book", "information", "to", "the", "target", "book", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L1285-L1336
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.cloneSection
protected function cloneSection( $section_id, $post_type, $parent_id = null ) { // 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... $metadata = $this->retrieveSectionMetadata( $section_id, $post_typ...
php
protected function cloneSection( $section_id, $post_type, $parent_id = null ) { // 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... $metadata = $this->retrieveSectionMetadata( $section_id, $post_typ...
[ "protected", "function", "cloneSection", "(", "$", "section_id", ",", "$", "post_type", ",", "$", "parent_id", "=", "null", ")", "{", "// Is the section license OK?", "// The global license is for the 'collection' and within that collection you have stuff with licenses that differ ...
Clone a section (front matter, part, chapter, back matter, glossary) of a source book to a target book. @since 4.1.0 @param int $section_id The ID of the section within the source book. @param string $post_type The post type of the section. @param int $parent_id The ID of the part to which the chapter should be added...
[ "Clone", "a", "section", "(", "front", "matter", "part", "chapter", "back", "matter", "glossary", ")", "of", "a", "source", "book", "to", "a", "target", "book", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L1349-L1463
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.locateSection
protected function locateSection( $section_id, $post_type ) { if ( $post_type === 'glossary' ) { foreach ( $this->sourceBookGlossary as $k => $v ) { if ( $v['id'] === absint( $section_id ) ) { return $this->sourceBookGlossary[ $k ]; } } } else { foreach ( $this->sourceBookStructure['_embedded'...
php
protected function locateSection( $section_id, $post_type ) { if ( $post_type === 'glossary' ) { foreach ( $this->sourceBookGlossary as $k => $v ) { if ( $v['id'] === absint( $section_id ) ) { return $this->sourceBookGlossary[ $k ]; } } } else { foreach ( $this->sourceBookStructure['_embedded'...
[ "protected", "function", "locateSection", "(", "$", "section_id", ",", "$", "post_type", ")", "{", "if", "(", "$", "post_type", "===", "'glossary'", ")", "{", "foreach", "(", "$", "this", "->", "sourceBookGlossary", "as", "$", "k", "=>", "$", "v", ")", ...
@param int $section_id @param string $post_type @return mixed
[ "@param", "int", "$section_id", "@param", "string", "$post_type" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L1471-L1486
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.retrieveSectionContent
protected function retrieveSectionContent( $section ) { if ( array_key_exists( 'raw', $section['content'] ) ) { $source_content = $section['content']['raw']; } else { $source_content = $section['content']['rendered']; } // According to the html5 spec section 8.3: https://www.w3.org/TR/2013/CR-html5-20130...
php
protected function retrieveSectionContent( $section ) { if ( array_key_exists( 'raw', $section['content'] ) ) { $source_content = $section['content']['raw']; } else { $source_content = $section['content']['rendered']; } // According to the html5 spec section 8.3: https://www.w3.org/TR/2013/CR-html5-20130...
[ "protected", "function", "retrieveSectionContent", "(", "$", "section", ")", "{", "if", "(", "array_key_exists", "(", "'raw'", ",", "$", "section", "[", "'content'", "]", ")", ")", "{", "$", "source_content", "=", "$", "section", "[", "'content'", "]", "["...
Download media found in a section's `post_content` node, change the href links to point to newly downloaded media, etc @param array $section @return array{content: string, attachments: array}
[ "Download", "media", "found", "in", "a", "section", "s", "post_content", "node", "change", "the", "href", "links", "to", "point", "to", "newly", "downloaded", "media", "etc" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L1495-L1543
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.retrieveH5P
protected function retrieveH5P( $content ) { if ( $this->sourceHasH5pApi && $this->targetHasH5pApi ) { // Download H5P $h5p_ids = $this->downloads->h5p( $content ); foreach ( $h5p_ids as $h5p_id ) { if ( str_starts_with( $h5p_id, '#fixme' ) ) { // Flag problem, remove broken H5P shortcode $this...
php
protected function retrieveH5P( $content ) { if ( $this->sourceHasH5pApi && $this->targetHasH5pApi ) { // Download H5P $h5p_ids = $this->downloads->h5p( $content ); foreach ( $h5p_ids as $h5p_id ) { if ( str_starts_with( $h5p_id, '#fixme' ) ) { // Flag problem, remove broken H5P shortcode $this...
[ "protected", "function", "retrieveH5P", "(", "$", "content", ")", "{", "if", "(", "$", "this", "->", "sourceHasH5pApi", "&&", "$", "this", "->", "targetHasH5pApi", ")", "{", "// Download H5P", "$", "h5p_ids", "=", "$", "this", "->", "downloads", "->", "h5p...
@param string $content @return string
[ "@param", "string", "$content" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L1550-L1569
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.cloneSectionMetadata
protected function cloneSectionMetadata( $section_id, $post_type, $target_id ) { $book_schema = $this->sourceBookMetadata; if ( empty( $this->targetBookUrl ) ) { // If there's no target then that means this data is going into the current book. // Remove invalid $book_schema values so that $section_schema is ...
php
protected function cloneSectionMetadata( $section_id, $post_type, $target_id ) { $book_schema = $this->sourceBookMetadata; if ( empty( $this->targetBookUrl ) ) { // If there's no target then that means this data is going into the current book. // Remove invalid $book_schema values so that $section_schema is ...
[ "protected", "function", "cloneSectionMetadata", "(", "$", "section_id", ",", "$", "post_type", ",", "$", "target_id", ")", "{", "$", "book_schema", "=", "$", "this", "->", "sourceBookMetadata", ";", "if", "(", "empty", "(", "$", "this", "->", "targetBookUrl...
Clone metadata of a section (front matter, part, chapter, back matter) from a source book to a target book. @since 4.1.0 @param int $section_id The ID of the section within the source book. @param string $post_type The post type of the section. @param int $target_id The ID of the section within the target book. @ret...
[ "Clone", "metadata", "of", "a", "section", "(", "front", "matter", "part", "chapter", "back", "matter", ")", "from", "a", "source", "book", "to", "a", "target", "book", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L1582-L1612
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.handleGetRequest
protected function handleGetRequest( $url, $namespace, $endpoint, $params = [], $paginate = true, $previous_results = [] ) { global $blog_id; // Is the book local? If so, is it the current book? If not, switch to it. $local_book = $this->getBookId( $url ); if ( $local_book ) { $switch = ( $local_book !== $b...
php
protected function handleGetRequest( $url, $namespace, $endpoint, $params = [], $paginate = true, $previous_results = [] ) { global $blog_id; // Is the book local? If so, is it the current book? If not, switch to it. $local_book = $this->getBookId( $url ); if ( $local_book ) { $switch = ( $local_book !== $b...
[ "protected", "function", "handleGetRequest", "(", "$", "url", ",", "$", "namespace", ",", "$", "endpoint", ",", "$", "params", "=", "[", "]", ",", "$", "paginate", "=", "true", ",", "$", "previous_results", "=", "[", "]", ")", "{", "global", "$", "bl...
Handle a get request against the REST API using either rest_do_request() or wp_remote_get() as appropriate. @since 4.1.0 @param string $url The URL against which the request should be made (not including the REST base) @param string $namespace The namespace for the request, e.g. 'pressbooks/v2' @param string $endpoin...
[ "Handle", "a", "get", "request", "against", "the", "REST", "API", "using", "either", "rest_do_request", "()", "or", "wp_remote_get", "()", "as", "appropriate", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L1628-L1699
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.nextWebLink
protected function nextWebLink( $response ) { $header = $this->extractLinkHeader( $response ); $links = explode( ',', $header ); foreach ( $links as $link ) { $link = $this->parseLinkHeader( $link ); if ( isset( $link['rel'] ) && strtolower( $link['rel'] ) === 'next' ) { return $link['href']; } } ...
php
protected function nextWebLink( $response ) { $header = $this->extractLinkHeader( $response ); $links = explode( ',', $header ); foreach ( $links as $link ) { $link = $this->parseLinkHeader( $link ); if ( isset( $link['rel'] ) && strtolower( $link['rel'] ) === 'next' ) { return $link['href']; } } ...
[ "protected", "function", "nextWebLink", "(", "$", "response", ")", "{", "$", "header", "=", "$", "this", "->", "extractLinkHeader", "(", "$", "response", ")", ";", "$", "links", "=", "explode", "(", "','", ",", "$", "header", ")", ";", "foreach", "(", ...
Format: <http://pressbooks.dev/test/wp-json/wp/v2/media?media_type=image&page=2>; rel="next" Or: <http://pressbooks.dev/test/wp-json/wp/v2/media?media_type=image&page=1>; rel="prev", <http://pressbooks.dev/test/wp-json/wp/v2/media?media_type=image&page=3>; rel="next" @param \WP_REST_Response|array $response @return s...
[ "Format", ":", "<http", ":", "//", "pressbooks", ".", "dev", "/", "test", "/", "wp", "-", "json", "/", "wp", "/", "v2", "/", "media?media_type", "=", "image&page", "=", "2", ">", ";", "rel", "=", "next", "Or", ":", "<http", ":", "//", "pressbooks",...
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L1709-L1719
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.extractLinkHeader
protected function extractLinkHeader( $response ) { if ( is_object( $response ) && property_exists( $response, 'headers' ) && is_array( $response->headers ) && isset( $response->headers['Link'] ) ) { return $response->headers['Link']; } if ( is_array( $response ) && isset( $response['headers'], $response['head...
php
protected function extractLinkHeader( $response ) { if ( is_object( $response ) && property_exists( $response, 'headers' ) && is_array( $response->headers ) && isset( $response->headers['Link'] ) ) { return $response->headers['Link']; } if ( is_array( $response ) && isset( $response['headers'], $response['head...
[ "protected", "function", "extractLinkHeader", "(", "$", "response", ")", "{", "if", "(", "is_object", "(", "$", "response", ")", "&&", "property_exists", "(", "$", "response", ",", "'headers'", ")", "&&", "is_array", "(", "$", "response", "->", "headers", ...
@param \WP_REST_Response|array $response @return string
[ "@param", "\\", "WP_REST_Response|array", "$response" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L1726-L1734
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.parseLinkHeader
protected function parseLinkHeader( $link ) { $parts = explode( ';', $link ); $attrs = [ 'href' => trim( array_shift( $parts ), '<>' ), ]; foreach ( $parts as $part ) { if ( ! strpos( $part, '=' ) ) { continue; } list( $key, $value ) = explode( '=', $part, 2 ); $key = trim( $key ); $value ...
php
protected function parseLinkHeader( $link ) { $parts = explode( ';', $link ); $attrs = [ 'href' => trim( array_shift( $parts ), '<>' ), ]; foreach ( $parts as $part ) { if ( ! strpos( $part, '=' ) ) { continue; } list( $key, $value ) = explode( '=', $part, 2 ); $key = trim( $key ); $value ...
[ "protected", "function", "parseLinkHeader", "(", "$", "link", ")", "{", "$", "parts", "=", "explode", "(", "';'", ",", "$", "link", ")", ";", "$", "attrs", "=", "[", "'href'", "=>", "trim", "(", "array_shift", "(", "$", "parts", ")", ",", "'<>'", "...
Parse a Link header into attributes. @param string $link Link header from the response. @return array Map of attribute key => attribute value, with link href in `href` key.
[ "Parse", "a", "Link", "header", "into", "attributes", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L1743-L1758
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.fixInternalLinks
protected function fixInternalLinks( $dom ) { // Setup $source_path = $this->getSubdomainOrSubdirectory( $this->sourceBookUrl ); $target_path = $this->getSubdomainOrSubdirectory( $this->targetBookUrl ); $is_subdomain_install = is_subdomain_install(); // Get links, loop through $links = $dom->getElementsByT...
php
protected function fixInternalLinks( $dom ) { // Setup $source_path = $this->getSubdomainOrSubdirectory( $this->sourceBookUrl ); $target_path = $this->getSubdomainOrSubdirectory( $this->targetBookUrl ); $is_subdomain_install = is_subdomain_install(); // Get links, loop through $links = $dom->getElementsByT...
[ "protected", "function", "fixInternalLinks", "(", "$", "dom", ")", "{", "// Setup", "$", "source_path", "=", "$", "this", "->", "getSubdomainOrSubdirectory", "(", "$", "this", "->", "sourceBookUrl", ")", ";", "$", "target_path", "=", "$", "this", "->", "getS...
@param \DOMDocument $dom @return \DOMDocument
[ "@param", "\\", "DOMDocument", "$dom" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L1765-L1801
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.validateNewBookName
public static function validateNewBookName( $blogname ) { global $wpdb, $domain; $current_network = get_network(); $base = $current_network->path; $illegal_names = get_site_option( 'illegal_names' ); $minimum_site_name_length = apply_filters( 'minimum_site_name_length', 4 ); if ( is_subdomain_install() ) ...
php
public static function validateNewBookName( $blogname ) { global $wpdb, $domain; $current_network = get_network(); $base = $current_network->path; $illegal_names = get_site_option( 'illegal_names' ); $minimum_site_name_length = apply_filters( 'minimum_site_name_length', 4 ); if ( is_subdomain_install() ) ...
[ "public", "static", "function", "validateNewBookName", "(", "$", "blogname", ")", "{", "global", "$", "wpdb", ",", "$", "domain", ";", "$", "current_network", "=", "get_network", "(", ")", ";", "$", "base", "=", "$", "current_network", "->", "path", ";", ...
Given a book name, see if we can use it to create a new book. Sort of like wpmu_validate_blog_signup(). @since 4.1.0 @param string $blogname @return string|\WP_Error
[ "Given", "a", "book", "name", "see", "if", "we", "can", "use", "it", "to", "create", "a", "new", "book", ".", "Sort", "of", "like", "wpmu_validate_blog_signup", "()", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L1812-L1849
pressbooks/pressbooks
inc/cloner/class-cloner.php
Cloner.isEnabled
public static function isEnabled() { $enable_cloning = get_site_option( 'pressbooks_sharingandprivacy_options', [] ); $enable_cloning = isset( $enable_cloning['enable_cloning'] ) ? $enable_cloning['enable_cloning'] : SharingAndPrivacyOptions::getDefaults()['enable_cloning']; return (bool) $enable_cloning; }
php
public static function isEnabled() { $enable_cloning = get_site_option( 'pressbooks_sharingandprivacy_options', [] ); $enable_cloning = isset( $enable_cloning['enable_cloning'] ) ? $enable_cloning['enable_cloning'] : SharingAndPrivacyOptions::getDefaults()['enable_cloning']; return (bool) $enable_cloning; }
[ "public", "static", "function", "isEnabled", "(", ")", "{", "$", "enable_cloning", "=", "get_site_option", "(", "'pressbooks_sharingandprivacy_options'", ",", "[", "]", ")", ";", "$", "enable_cloning", "=", "isset", "(", "$", "enable_cloning", "[", "'enable_clonin...
Is clonning feature enabled for this network? @return bool
[ "Is", "clonning", "feature", "enabled", "for", "this", "network?" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/cloner/class-cloner.php#L1856-L1860
pressbooks/pressbooks
inc/class-contributors.php
Contributors.getAll
public function getAll( $post_id, $as_strings = true ) { $contributors = []; foreach ( $this->valid as $contributor_type ) { if ( $as_strings ) { $contributors[ $contributor_type ] = $this->get( $post_id, $contributor_type ); } else { $contributors[ $contributor_type ] = $this->getArray( $post_id, $co...
php
public function getAll( $post_id, $as_strings = true ) { $contributors = []; foreach ( $this->valid as $contributor_type ) { if ( $as_strings ) { $contributors[ $contributor_type ] = $this->get( $post_id, $contributor_type ); } else { $contributors[ $contributor_type ] = $this->getArray( $post_id, $co...
[ "public", "function", "getAll", "(", "$", "post_id", ",", "$", "as_strings", "=", "true", ")", "{", "$", "contributors", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "valid", "as", "$", "contributor_type", ")", "{", "if", "(", "$", "as_stri...
Retrieve all author/editor/etc lists for a given Post ID @param int $post_id @param bool $as_strings @return array
[ "Retrieve", "all", "author", "/", "editor", "/", "etc", "lists", "for", "a", "given", "Post", "ID" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-contributors.php#L72-L82
pressbooks/pressbooks
inc/class-contributors.php
Contributors.get
public function get( $post_id, $contributor_type ) { $contributors = $this->getArray( $post_id, $contributor_type ); return \Pressbooks\Utility\oxford_comma( $contributors ); }
php
public function get( $post_id, $contributor_type ) { $contributors = $this->getArray( $post_id, $contributor_type ); return \Pressbooks\Utility\oxford_comma( $contributors ); }
[ "public", "function", "get", "(", "$", "post_id", ",", "$", "contributor_type", ")", "{", "$", "contributors", "=", "$", "this", "->", "getArray", "(", "$", "post_id", ",", "$", "contributor_type", ")", ";", "return", "\\", "Pressbooks", "\\", "Utility", ...
Retrieve author/editor/etc lists for a given Post ID and Contributor type, returns string @param int $post_id @param string $contributor_type @return string
[ "Retrieve", "author", "/", "editor", "/", "etc", "lists", "for", "a", "given", "Post", "ID", "and", "Contributor", "type", "returns", "string" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-contributors.php#L92-L95
pressbooks/pressbooks
inc/class-contributors.php
Contributors.getArray
public function getArray( $post_id, $contributor_type ) { if ( ! str_starts_with( $contributor_type, 'pb_' ) ) { $contributor_type = 'pb_' . $contributor_type; } if ( ! $this->isValid( $contributor_type ) ) { return []; } // Look if contributors exist as taxonomies (new data model) $contributors = []...
php
public function getArray( $post_id, $contributor_type ) { if ( ! str_starts_with( $contributor_type, 'pb_' ) ) { $contributor_type = 'pb_' . $contributor_type; } if ( ! $this->isValid( $contributor_type ) ) { return []; } // Look if contributors exist as taxonomies (new data model) $contributors = []...
[ "public", "function", "getArray", "(", "$", "post_id", ",", "$", "contributor_type", ")", "{", "if", "(", "!", "str_starts_with", "(", "$", "contributor_type", ",", "'pb_'", ")", ")", "{", "$", "contributor_type", "=", "'pb_'", ".", "$", "contributor_type", ...
Retrieve author/editor/etc lists for a given Post ID and Contributor type, returns array @param int $post_id @param string $contributor_type @return array
[ "Retrieve", "author", "/", "editor", "/", "etc", "lists", "for", "a", "given", "Post", "ID", "and", "Contributor", "type", "returns", "array" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-contributors.php#L105-L154
pressbooks/pressbooks
inc/class-contributors.php
Contributors.insert
public function insert( $full_name, $post_id = 0, $contributor_type = 'pb_authors' ) { $full_name = trim( $full_name ); $slug = sanitize_title_with_dashes( remove_accents( $full_name ), '', 'save' ); $term = get_term_by( 'slug', $slug, self::TAXONOMY ); if ( $term ) { $results = [ 'term_id' => $term->ter...
php
public function insert( $full_name, $post_id = 0, $contributor_type = 'pb_authors' ) { $full_name = trim( $full_name ); $slug = sanitize_title_with_dashes( remove_accents( $full_name ), '', 'save' ); $term = get_term_by( 'slug', $slug, self::TAXONOMY ); if ( $term ) { $results = [ 'term_id' => $term->ter...
[ "public", "function", "insert", "(", "$", "full_name", ",", "$", "post_id", "=", "0", ",", "$", "contributor_type", "=", "'pb_authors'", ")", "{", "$", "full_name", "=", "trim", "(", "$", "full_name", ")", ";", "$", "slug", "=", "sanitize_title_with_dashes...
@param string $full_name @param int $post_id (optional) @param string $contributor_type (optional) @return array|false An array containing the `term_id` and `term_taxonomy_id`, false otherwise.
[ "@param", "string", "$full_name", "@param", "int", "$post_id", "(", "optional", ")", "@param", "string", "$contributor_type", "(", "optional", ")" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-contributors.php#L163-L185
pressbooks/pressbooks
inc/class-contributors.php
Contributors.link
public function link( $term_id, $post_id, $contributor_type = 'pb_authors' ) { global $wpdb; if ( ! str_starts_with( $contributor_type, 'pb_' ) ) { $contributor_type = 'pb_' . $contributor_type; } if ( $this->isValid( $contributor_type ) ) { if ( preg_match( '/\d+/', $term_id ) ) { $term = get_term( $...
php
public function link( $term_id, $post_id, $contributor_type = 'pb_authors' ) { global $wpdb; if ( ! str_starts_with( $contributor_type, 'pb_' ) ) { $contributor_type = 'pb_' . $contributor_type; } if ( $this->isValid( $contributor_type ) ) { if ( preg_match( '/\d+/', $term_id ) ) { $term = get_term( $...
[ "public", "function", "link", "(", "$", "term_id", ",", "$", "post_id", ",", "$", "contributor_type", "=", "'pb_authors'", ")", "{", "global", "$", "wpdb", ";", "if", "(", "!", "str_starts_with", "(", "$", "contributor_type", ",", "'pb_'", ")", ")", "{",...
Associate a Contributor's Term ID to a Post ID (Taxonomy + Meta) Technically we are assigning the Term Slug to the Post ID. This function handles either. @param int|string $term_id @param int $post_id @param string $contributor_type @return bool
[ "Associate", "a", "Contributor", "s", "Term", "ID", "to", "a", "Post", "ID", "(", "Taxonomy", "+", "Meta", ")", "Technically", "we", "are", "assigning", "the", "Term", "Slug", "to", "the", "Post", "ID", ".", "This", "function", "handles", "either", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-contributors.php#L197-L218
pressbooks/pressbooks
inc/class-contributors.php
Contributors.unlink
public function unlink( $term_id, $post_id, $contributor_type = 'pb_authors' ) { if ( ! str_starts_with( $contributor_type, 'pb_' ) ) { $contributor_type = 'pb_' . $contributor_type; } if ( $this->isValid( $contributor_type ) ) { if ( preg_match( '/\d+/', $term_id ) ) { $term = get_term( $term_id, self:...
php
public function unlink( $term_id, $post_id, $contributor_type = 'pb_authors' ) { if ( ! str_starts_with( $contributor_type, 'pb_' ) ) { $contributor_type = 'pb_' . $contributor_type; } if ( $this->isValid( $contributor_type ) ) { if ( preg_match( '/\d+/', $term_id ) ) { $term = get_term( $term_id, self:...
[ "public", "function", "unlink", "(", "$", "term_id", ",", "$", "post_id", ",", "$", "contributor_type", "=", "'pb_authors'", ")", "{", "if", "(", "!", "str_starts_with", "(", "$", "contributor_type", ",", "'pb_'", ")", ")", "{", "$", "contributor_type", "=...
Disassociate a Contributor's Term ID to a Post ID (Taxonomy + Meta) @param int|string $term_id @param int $post_id @param string $contributor_type @return bool
[ "Disassociate", "a", "Contributor", "s", "Term", "ID", "to", "a", "Post", "ID", "(", "Taxonomy", "+", "Meta", ")" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-contributors.php#L229-L246
pressbooks/pressbooks
inc/class-contributors.php
Contributors.addBlogUser
public function addBlogUser( $user_id ) { $user = get_userdata( $user_id ); if ( $user && user_can( $user, 'edit_posts' ) ) { $slug = $user->user_nicename; $name = trim( "{$user->first_name} {$user->last_name}" ); if ( empty( $name ) ) { $name = $user->display_name; if ( empty( $name ) ) { $na...
php
public function addBlogUser( $user_id ) { $user = get_userdata( $user_id ); if ( $user && user_can( $user, 'edit_posts' ) ) { $slug = $user->user_nicename; $name = trim( "{$user->first_name} {$user->last_name}" ); if ( empty( $name ) ) { $name = $user->display_name; if ( empty( $name ) ) { $na...
[ "public", "function", "addBlogUser", "(", "$", "user_id", ")", "{", "$", "user", "=", "get_userdata", "(", "$", "user_id", ")", ";", "if", "(", "$", "user", "&&", "user_can", "(", "$", "user", ",", "'edit_posts'", ")", ")", "{", "$", "slug", "=", "...
Create a matching Contributor term for a given User ID. Used when a user is added to a blog. @param int $user_id @return array|false An array containing the `term_id` and `term_taxonomy_id`, false otherwise.
[ "Create", "a", "matching", "Contributor", "term", "for", "a", "given", "User", "ID", ".", "Used", "when", "a", "user", "is", "added", "to", "a", "blog", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-contributors.php#L255-L278
pressbooks/pressbooks
inc/class-contributors.php
Contributors.updateBlogUser
public function updateBlogUser( $user_id, $old_user_data ) { $user = get_userdata( $user_id ); if ( $user && user_can( $user, 'edit_posts' ) ) { $slug = $user->user_nicename; $name = trim( "{$user->first_name} {$user->last_name}" ); if ( empty( $name ) ) { $name = $user->display_name; if ( empty( $...
php
public function updateBlogUser( $user_id, $old_user_data ) { $user = get_userdata( $user_id ); if ( $user && user_can( $user, 'edit_posts' ) ) { $slug = $user->user_nicename; $name = trim( "{$user->first_name} {$user->last_name}" ); if ( empty( $name ) ) { $name = $user->display_name; if ( empty( $...
[ "public", "function", "updateBlogUser", "(", "$", "user_id", ",", "$", "old_user_data", ")", "{", "$", "user", "=", "get_userdata", "(", "$", "user_id", ")", ";", "if", "(", "$", "user", "&&", "user_can", "(", "$", "user", ",", "'edit_posts'", ")", ")"...
Update a matching Contributor term given a User ID. Used when a blog user is updated @param int $user_id @param \WP_User $old_user_data @return array|false An array containing the `term_id` and `term_taxonomy_id`, false otherwise.
[ "Update", "a", "matching", "Contributor", "term", "given", "a", "User", "ID", ".", "Used", "when", "a", "blog", "user", "is", "updated" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-contributors.php#L288-L323
pressbooks/pressbooks
inc/class-contributors.php
Contributors.personalName
public function personalName( $slug ) { init_book_data_models(); $name = ''; $term = get_term_by( 'slug', $slug, self::TAXONOMY ); if ( $term ) { $first_name = get_term_meta( $term->term_id, 'contributor_first_name', true ); $last_name = get_term_meta( $term->term_id, 'contributor_last_name', true ); i...
php
public function personalName( $slug ) { init_book_data_models(); $name = ''; $term = get_term_by( 'slug', $slug, self::TAXONOMY ); if ( $term ) { $first_name = get_term_meta( $term->term_id, 'contributor_first_name', true ); $last_name = get_term_meta( $term->term_id, 'contributor_last_name', true ); i...
[ "public", "function", "personalName", "(", "$", "slug", ")", "{", "init_book_data_models", "(", ")", ";", "$", "name", "=", "''", ";", "$", "term", "=", "get_term_by", "(", "'slug'", ",", "$", "slug", ",", "self", "::", "TAXONOMY", ")", ";", "if", "(...
Get personal name based on available data Returns empty string is we can't find anything useful A personal name is the set of names by which an individual is known and that can be recited as a word-group, with the understanding that, taken together, they all relate to that one individual. In many cultures, the term i...
[ "Get", "personal", "name", "based", "on", "available", "data" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-contributors.php#L338-L352
pressbooks/pressbooks
inc/class-contributors.php
Contributors.convert
public function convert( $old_slug, $names, $post_id ) { $new_slug = $this->maybeUpgradeSlug( $old_slug ); if ( $new_slug === $old_slug ) { return false; // Nothing to convert } if ( ! is_array( $names ) ) { $names = [ $names ]; } $result = false; foreach ( $names as $contributors ) { $values ...
php
public function convert( $old_slug, $names, $post_id ) { $new_slug = $this->maybeUpgradeSlug( $old_slug ); if ( $new_slug === $old_slug ) { return false; // Nothing to convert } if ( ! is_array( $names ) ) { $names = [ $names ]; } $result = false; foreach ( $names as $contributors ) { $values ...
[ "public", "function", "convert", "(", "$", "old_slug", ",", "$", "names", ",", "$", "post_id", ")", "{", "$", "new_slug", "=", "$", "this", "->", "maybeUpgradeSlug", "(", "$", "old_slug", ")", ";", "if", "(", "$", "new_slug", "===", "$", "old_slug", ...
@param string $old_slug @param string|array $names @param int $post_id @return array|false An array containing `term_id` and `term_taxonomy_id`, false otherwise.
[ "@param", "string", "$old_slug", "@param", "string|array", "$names", "@param", "int", "$post_id" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-contributors.php#L381-L401
pressbooks/pressbooks
inc/modules/themeoptions/class-weboptions.php
WebOptions.init
function init() { $_option = 'pressbooks_theme_options_' . $this->getSlug(); $_page = $_option; $_section = $this->getSlug() . '_options_section'; $meta = new Metadata(); if ( false === get_option( $_option ) ) { add_option( $_option, $this->defaults ); } add_settings_section( $_section, $this-...
php
function init() { $_option = 'pressbooks_theme_options_' . $this->getSlug(); $_page = $_option; $_section = $this->getSlug() . '_options_section'; $meta = new Metadata(); if ( false === get_option( $_option ) ) { add_option( $_option, $this->defaults ); } add_settings_section( $_section, $this-...
[ "function", "init", "(", ")", "{", "$", "_option", "=", "'pressbooks_theme_options_'", ".", "$", "this", "->", "getSlug", "(", ")", ";", "$", "_page", "=", "$", "_option", ";", "$", "_section", "=", "$", "this", "->", "getSlug", "(", ")", ".", "'_opt...
Configure the web options tab using the settings API.
[ "Configure", "the", "web", "options", "tab", "using", "the", "settings", "API", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/themeoptions/class-weboptions.php#L60-L167
pressbooks/pressbooks
inc/modules/themeoptions/class-weboptions.php
WebOptions.doInitialUpgrade
function doInitialUpgrade() { $_option = $this->getSlug(); $options = get_option( 'pressbooks_theme_options_' . $_option, $this->defaults ); $deprecated = [ 'toc_collapse', 'accessibility_fontsize', ]; foreach ( $options as $key => $value ) { if ( in_array( $key, $deprecated, true ) ) { unset( $...
php
function doInitialUpgrade() { $_option = $this->getSlug(); $options = get_option( 'pressbooks_theme_options_' . $_option, $this->defaults ); $deprecated = [ 'toc_collapse', 'accessibility_fontsize', ]; foreach ( $options as $key => $value ) { if ( in_array( $key, $deprecated, true ) ) { unset( $...
[ "function", "doInitialUpgrade", "(", ")", "{", "$", "_option", "=", "$", "this", "->", "getSlug", "(", ")", ";", "$", "options", "=", "get_option", "(", "'pressbooks_theme_options_'", ".", "$", "_option", ",", "$", "this", "->", "defaults", ")", ";", "$"...
Remove deprecated keys from web options.
[ "Remove", "deprecated", "keys", "from", "web", "options", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/themeoptions/class-weboptions.php#L196-L211
pressbooks/pressbooks
inc/modules/themeoptions/class-weboptions.php
WebOptions.renderSocialMediaField
function renderSocialMediaField( $args ) { unset( $args['label_for'], $args['class'] ); $this->renderCheckbox( [ 'id' => 'social_media', 'name' => 'pressbooks_theme_options_' . $this->getSlug(), 'option' => 'social_media', 'value' => ( isset( $this->options['social_media'] ) ) ? $this->options['s...
php
function renderSocialMediaField( $args ) { unset( $args['label_for'], $args['class'] ); $this->renderCheckbox( [ 'id' => 'social_media', 'name' => 'pressbooks_theme_options_' . $this->getSlug(), 'option' => 'social_media', 'value' => ( isset( $this->options['social_media'] ) ) ? $this->options['s...
[ "function", "renderSocialMediaField", "(", "$", "args", ")", "{", "unset", "(", "$", "args", "[", "'label_for'", "]", ",", "$", "args", "[", "'class'", "]", ")", ";", "$", "this", "->", "renderCheckbox", "(", "[", "'id'", "=>", "'social_media'", ",", "...
Render the social_media checkbox. @param array $args
[ "Render", "the", "social_media", "checkbox", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/themeoptions/class-weboptions.php#L218-L229
pressbooks/pressbooks
inc/modules/themeoptions/class-weboptions.php
WebOptions.renderWebbookWidthField
function renderWebbookWidthField( $args ) { unset( $args['label_for'], $args['class'] ); $this->renderSelect( [ 'id' => 'webbook_width', 'name' => 'pressbooks_theme_options_' . $this->getSlug(), 'option' => 'webbook_width', 'value' => ( isset( $this->options['webbook_width'] ) ) ? $this->options[...
php
function renderWebbookWidthField( $args ) { unset( $args['label_for'], $args['class'] ); $this->renderSelect( [ 'id' => 'webbook_width', 'name' => 'pressbooks_theme_options_' . $this->getSlug(), 'option' => 'webbook_width', 'value' => ( isset( $this->options['webbook_width'] ) ) ? $this->options[...
[ "function", "renderWebbookWidthField", "(", "$", "args", ")", "{", "unset", "(", "$", "args", "[", "'label_for'", "]", ",", "$", "args", "[", "'class'", "]", ")", ";", "$", "this", "->", "renderSelect", "(", "[", "'id'", "=>", "'webbook_width'", ",", "...
Render the webbook_width dropdown. @param array $args
[ "Render", "the", "webbook_width", "dropdown", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/themeoptions/class-weboptions.php#L236-L247
pressbooks/pressbooks
inc/modules/themeoptions/class-weboptions.php
WebOptions.renderPartTitle
function renderPartTitle( $args ) { unset( $args['label_for'], $args['class'] ); $this->renderCheckbox( [ 'id' => 'part_title', 'name' => 'pressbooks_theme_options_' . $this->getSlug(), 'option' => 'part_title', 'value' => ( isset( $this->options['part_title'] ) ) ? $this->options['part_title'] :...
php
function renderPartTitle( $args ) { unset( $args['label_for'], $args['class'] ); $this->renderCheckbox( [ 'id' => 'part_title', 'name' => 'pressbooks_theme_options_' . $this->getSlug(), 'option' => 'part_title', 'value' => ( isset( $this->options['part_title'] ) ) ? $this->options['part_title'] :...
[ "function", "renderPartTitle", "(", "$", "args", ")", "{", "unset", "(", "$", "args", "[", "'label_for'", "]", ",", "$", "args", "[", "'class'", "]", ")", ";", "$", "this", "->", "renderCheckbox", "(", "[", "'id'", "=>", "'part_title'", ",", "'name'", ...
Render the part_title checkbox. @param array $args
[ "Render", "the", "part_title", "checkbox", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/themeoptions/class-weboptions.php#L272-L283
pressbooks/pressbooks
inc/modules/themeoptions/class-weboptions.php
WebOptions.renderCollapseSections
function renderCollapseSections( $args ) { unset( $args['label_for'], $args['class'] ); $this->renderCheckbox( [ 'id' => 'collapse_sections', 'name' => 'pressbooks_theme_options_' . $this->getSlug(), 'option' => 'collapse_sections', 'value' => ( isset( $this->options['part_title'] ) ) ? $this->op...
php
function renderCollapseSections( $args ) { unset( $args['label_for'], $args['class'] ); $this->renderCheckbox( [ 'id' => 'collapse_sections', 'name' => 'pressbooks_theme_options_' . $this->getSlug(), 'option' => 'collapse_sections', 'value' => ( isset( $this->options['part_title'] ) ) ? $this->op...
[ "function", "renderCollapseSections", "(", "$", "args", ")", "{", "unset", "(", "$", "args", "[", "'label_for'", "]", ",", "$", "args", "[", "'class'", "]", ")", ";", "$", "this", "->", "renderCheckbox", "(", "[", "'id'", "=>", "'collapse_sections'", ","...
Render the collapse_sections checkbox. @param array $args
[ "Render", "the", "collapse_sections", "checkbox", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/themeoptions/class-weboptions.php#L290-L301
pressbooks/pressbooks
inc/modules/themeoptions/class-weboptions.php
WebOptions.renderEnableSourceComparison
function renderEnableSourceComparison( $args ) { unset( $args['label_for'], $args['class'] ); $this->renderCheckbox( [ 'id' => 'enable_source_comparison', 'name' => 'pressbooks_theme_options_' . $this->getSlug(), 'option' => 'enable_source_comparison', 'value' => ( isset( $this->options['enable_s...
php
function renderEnableSourceComparison( $args ) { unset( $args['label_for'], $args['class'] ); $this->renderCheckbox( [ 'id' => 'enable_source_comparison', 'name' => 'pressbooks_theme_options_' . $this->getSlug(), 'option' => 'enable_source_comparison', 'value' => ( isset( $this->options['enable_s...
[ "function", "renderEnableSourceComparison", "(", "$", "args", ")", "{", "unset", "(", "$", "args", "[", "'label_for'", "]", ",", "$", "args", "[", "'class'", "]", ")", ";", "$", "this", "->", "renderCheckbox", "(", "[", "'id'", "=>", "'enable_source_compar...
Render the allow_comparison checkbox. @param array $args
[ "Render", "the", "allow_comparison", "checkbox", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/themeoptions/class-weboptions.php#L308-L320
pressbooks/pressbooks
inc/modules/themeoptions/class-weboptions.php
WebOptions.scssOverrides
static function scssOverrides( $scss ) { $styles = Container::get( 'Styles' ); $v2_compatible = $styles->isCurrentThemeCompatible( 2 ); // Global Options $options = get_option( 'pressbooks_theme_options_global' ); // Textbox colours. if ( $v2_compatible ) { foreach ( [ 'edu_textbox_examples_heade...
php
static function scssOverrides( $scss ) { $styles = Container::get( 'Styles' ); $v2_compatible = $styles->isCurrentThemeCompatible( 2 ); // Global Options $options = get_option( 'pressbooks_theme_options_global' ); // Textbox colours. if ( $v2_compatible ) { foreach ( [ 'edu_textbox_examples_heade...
[ "static", "function", "scssOverrides", "(", "$", "scss", ")", "{", "$", "styles", "=", "Container", "::", "get", "(", "'Styles'", ")", ";", "$", "v2_compatible", "=", "$", "styles", "->", "isCurrentThemeCompatible", "(", "2", ")", ";", "// Global Options", ...
Apply overrides. @param string $scss @return string @since 3.9.8
[ "Apply", "overrides", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/themeoptions/class-weboptions.php#L475-L539
pressbooks/pressbooks
inc/modules/export/prince/class-pdf.php
Pdf.convert
function convert() { // Sanity check if ( empty( $this->exportStylePath ) || ! is_file( $this->exportStylePath ) ) { $this->logError( '$this->exportStylePath must be set before calling convert().' ); return false; } // Set logfile $this->logfile = $this->createTmpFile(); // Set filename $filename...
php
function convert() { // Sanity check if ( empty( $this->exportStylePath ) || ! is_file( $this->exportStylePath ) ) { $this->logError( '$this->exportStylePath must be set before calling convert().' ); return false; } // Set logfile $this->logfile = $this->createTmpFile(); // Set filename $filename...
[ "function", "convert", "(", ")", "{", "// Sanity check", "if", "(", "empty", "(", "$", "this", "->", "exportStylePath", ")", "||", "!", "is_file", "(", "$", "this", "->", "exportStylePath", ")", ")", "{", "$", "this", "->", "logError", "(", "'$this->expo...
Create $this->outputPath @return bool
[ "Create", "$this", "-", ">", "outputPath" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/prince/class-pdf.php#L94-L148
pressbooks/pressbooks
inc/modules/export/prince/class-pdf.php
Pdf.kneadCss
protected function kneadCss() { $styles = Container::get( 'Styles' ); $scss = \Pressbooks\Utility\get_contents( $this->exportStylePath ); $custom_styles = $styles->getPrincePost(); if ( $custom_styles && ! empty( $custom_styles->post_content ) ) { // append the user's custom styles to the theme stylesheet...
php
protected function kneadCss() { $styles = Container::get( 'Styles' ); $scss = \Pressbooks\Utility\get_contents( $this->exportStylePath ); $custom_styles = $styles->getPrincePost(); if ( $custom_styles && ! empty( $custom_styles->post_content ) ) { // append the user's custom styles to the theme stylesheet...
[ "protected", "function", "kneadCss", "(", ")", "{", "$", "styles", "=", "Container", "::", "get", "(", "'Styles'", ")", ";", "$", "scss", "=", "\\", "Pressbooks", "\\", "Utility", "\\", "get_contents", "(", "$", "this", "->", "exportStylePath", ")", ";",...
Return kneaded CSS string @return string
[ "Return", "kneaded", "CSS", "string" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/prince/class-pdf.php#L224-L245
pressbooks/pressbooks
inc/modules/export/prince/class-pdf.php
Pdf.urlPath
protected function urlPath() { $dir = str_replace( Container::get( 'Styles' )->getDir(), '', pathinfo( $this->exportStylePath, PATHINFO_DIRNAME ) ); $dir = ltrim( $dir, '/' ); $url_path = trailingslashit( get_stylesheet_directory_uri() ) . $dir; $url_path = set_url_scheme( $url_path ); return $url_path; }
php
protected function urlPath() { $dir = str_replace( Container::get( 'Styles' )->getDir(), '', pathinfo( $this->exportStylePath, PATHINFO_DIRNAME ) ); $dir = ltrim( $dir, '/' ); $url_path = trailingslashit( get_stylesheet_directory_uri() ) . $dir; $url_path = set_url_scheme( $url_path ); return $url_path; }
[ "protected", "function", "urlPath", "(", ")", "{", "$", "dir", "=", "str_replace", "(", "Container", "::", "get", "(", "'Styles'", ")", "->", "getDir", "(", ")", ",", "''", ",", "pathinfo", "(", "$", "this", "->", "exportStylePath", ",", "PATHINFO_DIRNAM...
Convert the directory containing `$this->exportStylePath` to a URL that can be used by services like DocRaptor Useful for sending assets like images/asterisk.png, images/em-dash.png, ... @return string
[ "Convert", "the", "directory", "containing", "$this", "-", ">", "exportStylePath", "to", "a", "URL", "that", "can", "be", "used", "by", "services", "like", "DocRaptor", "Useful", "for", "sending", "assets", "like", "images", "/", "asterisk", ".", "png", "ima...
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/prince/class-pdf.php#L253-L260
pressbooks/pressbooks
inc/modules/export/prince/class-pdf.php
Pdf.themeOptionsOverrides
protected function themeOptionsOverrides() { // -------------------------------------------------------------------- // CSS $scss = ''; $scss = apply_filters( 'pb_pdf_css_override', $scss ) . "\n"; // Copyright // Please be kind, help Pressbooks grow by leaving this on! if ( empty( $GLOBALS['PB_SECRET_...
php
protected function themeOptionsOverrides() { // -------------------------------------------------------------------- // CSS $scss = ''; $scss = apply_filters( 'pb_pdf_css_override', $scss ) . "\n"; // Copyright // Please be kind, help Pressbooks grow by leaving this on! if ( empty( $GLOBALS['PB_SECRET_...
[ "protected", "function", "themeOptionsOverrides", "(", ")", "{", "// --------------------------------------------------------------------", "// CSS", "$", "scss", "=", "''", ";", "$", "scss", "=", "apply_filters", "(", "'pb_pdf_css_override'", ",", "$", "scss", ")", "."...
Override based on Theme Options
[ "Override", "based", "on", "Theme", "Options" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/prince/class-pdf.php#L266-L294
pressbooks/pressbooks
inc/modules/export/prince/class-pdf.php
Pdf.fixLatexDpi
protected function fixLatexDpi() { $fix = false; if ( ! $fix && ! empty( $_GET['optimize-for-print'] ) ) { $fix = true; } if ( ! $fix && strpos( $this->url, 'optimize-for-print=1' ) !== false ) { $fix = true; } if ( ! $fix && stripos( get_class( $this ), 'print' ) !== false ) { $fix = true; } ...
php
protected function fixLatexDpi() { $fix = false; if ( ! $fix && ! empty( $_GET['optimize-for-print'] ) ) { $fix = true; } if ( ! $fix && strpos( $this->url, 'optimize-for-print=1' ) !== false ) { $fix = true; } if ( ! $fix && stripos( get_class( $this ), 'print' ) !== false ) { $fix = true; } ...
[ "protected", "function", "fixLatexDpi", "(", ")", "{", "$", "fix", "=", "false", ";", "if", "(", "!", "$", "fix", "&&", "!", "empty", "(", "$", "_GET", "[", "'optimize-for-print'", "]", ")", ")", "{", "$", "fix", "=", "true", ";", "}", "if", "(",...
Increase PB-LaTeX resolution to ~300 dpi @see symbionts/pressbooks-latex/automattic-latex-wpcom.php
[ "Increase", "PB", "-", "LaTeX", "resolution", "to", "~300", "dpi" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/modules/export/prince/class-pdf.php#L301-L317
pressbooks/pressbooks
inc/class-catalog.php
Catalog.get
function get() { /** @var $wpdb \wpdb */ global $wpdb; $sql = "SELECT * FROM {$this->dbTable} WHERE users_id = %d AND deleted = 0 "; return $wpdb->get_results( $wpdb->prepare( $sql, $this->userId ), ARRAY_A ); // @codingStandardsIgnoreLine }
php
function get() { /** @var $wpdb \wpdb */ global $wpdb; $sql = "SELECT * FROM {$this->dbTable} WHERE users_id = %d AND deleted = 0 "; return $wpdb->get_results( $wpdb->prepare( $sql, $this->userId ), ARRAY_A ); // @codingStandardsIgnoreLine }
[ "function", "get", "(", ")", "{", "/** @var $wpdb \\wpdb */", "global", "$", "wpdb", ";", "$", "sql", "=", "\"SELECT * FROM {$this->dbTable} WHERE users_id = %d AND deleted = 0 \"", ";", "return", "$", "wpdb", "->", "get_results", "(", "$", "wpdb", "->", "prepare", ...
Get an entire catalog. @return array
[ "Get", "an", "entire", "catalog", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L125-L132
pressbooks/pressbooks
inc/class-catalog.php
Catalog.getAggregate
function getAggregate() { // ----------------------------------------------------------------------------- // Is cached? // ----------------------------------------------------------------------------- $cache_id = "cat-{$this->userId}"; $data = wp_cache_get( $cache_id, 'pb' ); if ( $data ) { return $da...
php
function getAggregate() { // ----------------------------------------------------------------------------- // Is cached? // ----------------------------------------------------------------------------- $cache_id = "cat-{$this->userId}"; $data = wp_cache_get( $cache_id, 'pb' ); if ( $data ) { return $da...
[ "function", "getAggregate", "(", ")", "{", "// -----------------------------------------------------------------------------", "// Is cached?", "// -----------------------------------------------------------------------------", "$", "cache_id", "=", "\"cat-{$this->userId}\"", ";", "$", "...
Get all data for an entire catalog, cached @return array
[ "Get", "all", "data", "for", "an", "entire", "catalog", "cached" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L140-L326
pressbooks/pressbooks
inc/class-catalog.php
Catalog.getByTagId
function getByTagId( $tag_group, $tag_id ) { /** @var $wpdb \wpdb */ global $wpdb; $sql = "SELECT DISTINCT {$this->dbTable}.* FROM {$this->dbTable} INNER JOIN {$this->dbLinkTable} ON {$this->dbLinkTable}.blogs_id = {$this->dbTable}.blogs_id INNER JOIN {$this->dbTagsTable} ON {$this->dbTagsTable}.id = {...
php
function getByTagId( $tag_group, $tag_id ) { /** @var $wpdb \wpdb */ global $wpdb; $sql = "SELECT DISTINCT {$this->dbTable}.* FROM {$this->dbTable} INNER JOIN {$this->dbLinkTable} ON {$this->dbLinkTable}.blogs_id = {$this->dbTable}.blogs_id INNER JOIN {$this->dbTagsTable} ON {$this->dbTagsTable}.id = {...
[ "function", "getByTagId", "(", "$", "tag_group", ",", "$", "tag_id", ")", "{", "/** @var $wpdb \\wpdb */", "global", "$", "wpdb", ";", "$", "sql", "=", "\"SELECT DISTINCT {$this->dbTable}.* FROM {$this->dbTable}\n\t\t\t\tINNER JOIN {$this->dbLinkTable} ON {$this->dbLinkTable}.blo...
Get catalog by tag id @param int $tag_group @param int $tag_id @return array
[ "Get", "catalog", "by", "tag", "id" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L337-L348
pressbooks/pressbooks
inc/class-catalog.php
Catalog.save
function save( array $items ) { foreach ( $items as $item ) { if ( isset( $item['blogs_id'] ) ) { $this->saveBook( $this->userId, $item ); } } }
php
function save( array $items ) { foreach ( $items as $item ) { if ( isset( $item['blogs_id'] ) ) { $this->saveBook( $this->userId, $item ); } } }
[ "function", "save", "(", "array", "$", "items", ")", "{", "foreach", "(", "$", "items", "as", "$", "item", ")", "{", "if", "(", "isset", "(", "$", "item", "[", "'blogs_id'", "]", ")", ")", "{", "$", "this", "->", "saveBook", "(", "$", "this", "...
Save an entire catalog. @param array $items
[ "Save", "an", "entire", "catalog", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L356-L363
pressbooks/pressbooks
inc/class-catalog.php
Catalog.delete
function delete( $for_real = false ) { /** @var $wpdb \wpdb */ global $wpdb; if ( $for_real ) { return $wpdb->delete( $this->dbTable, [ 'users_id' => $this->userId, ], [ '%d' ] ); } else { return $wpdb->update( $this->dbTable, [ 'deleted' => 1, ], [ 'users_id' => $this-...
php
function delete( $for_real = false ) { /** @var $wpdb \wpdb */ global $wpdb; if ( $for_real ) { return $wpdb->delete( $this->dbTable, [ 'users_id' => $this->userId, ], [ '%d' ] ); } else { return $wpdb->update( $this->dbTable, [ 'deleted' => 1, ], [ 'users_id' => $this-...
[ "function", "delete", "(", "$", "for_real", "=", "false", ")", "{", "/** @var $wpdb \\wpdb */", "global", "$", "wpdb", ";", "if", "(", "$", "for_real", ")", "{", "return", "$", "wpdb", "->", "delete", "(", "$", "this", "->", "dbTable", ",", "[", "'user...
Delete an entire catalog. @param bool $for_real (optional) @return int|false
[ "Delete", "an", "entire", "catalog", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L373-L393
pressbooks/pressbooks
inc/class-catalog.php
Catalog.getBook
function getBook( $blog_id ) { /** @var $wpdb \wpdb */ global $wpdb; $sql = "SELECT * FROM {$this->dbTable} WHERE users_id = %d AND blogs_id = %d AND deleted = 0 "; return $wpdb->get_row( $wpdb->prepare( $sql, $this->userId, $blog_id ), ARRAY_A ); // @codingStandardsIgnoreLine }
php
function getBook( $blog_id ) { /** @var $wpdb \wpdb */ global $wpdb; $sql = "SELECT * FROM {$this->dbTable} WHERE users_id = %d AND blogs_id = %d AND deleted = 0 "; return $wpdb->get_row( $wpdb->prepare( $sql, $this->userId, $blog_id ), ARRAY_A ); // @codingStandardsIgnoreLine }
[ "function", "getBook", "(", "$", "blog_id", ")", "{", "/** @var $wpdb \\wpdb */", "global", "$", "wpdb", ";", "$", "sql", "=", "\"SELECT * FROM {$this->dbTable} WHERE users_id = %d AND blogs_id = %d AND deleted = 0 \"", ";", "return", "$", "wpdb", "->", "get_row", "(", ...
Get a book from a user catalog. @param int $blog_id @return array
[ "Get", "a", "book", "from", "a", "user", "catalog", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L403-L411
pressbooks/pressbooks
inc/class-catalog.php
Catalog.getBookIds
function getBookIds() { /** @var $wpdb \wpdb */ global $wpdb; $sql = "SELECT blogs_id FROM {$this->dbTable} WHERE users_id = %d AND deleted = 0 "; return $wpdb->get_col( $wpdb->prepare( $sql, $this->userId ) ); // @codingStandardsIgnoreLine }
php
function getBookIds() { /** @var $wpdb \wpdb */ global $wpdb; $sql = "SELECT blogs_id FROM {$this->dbTable} WHERE users_id = %d AND deleted = 0 "; return $wpdb->get_col( $wpdb->prepare( $sql, $this->userId ) ); // @codingStandardsIgnoreLine }
[ "function", "getBookIds", "(", ")", "{", "/** @var $wpdb \\wpdb */", "global", "$", "wpdb", ";", "$", "sql", "=", "\"SELECT blogs_id FROM {$this->dbTable} WHERE users_id = %d AND deleted = 0 \"", ";", "return", "$", "wpdb", "->", "get_col", "(", "$", "wpdb", "->", "pr...
Get only blog IDs. @return array
[ "Get", "only", "blog", "IDs", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L419-L427
pressbooks/pressbooks
inc/class-catalog.php
Catalog.saveBook
function saveBook( $blog_id, array $item ) { /** @var $wpdb \wpdb */ global $wpdb; unset( $item['users_id'], $item['blogs_id'], $item['deleted'] ); // Don't allow spoofing $data = [ 'users_id' => $this->userId, 'blogs_id' => $blog_id, 'deleted' => 0, ]; $format = [ 'users_id' => $this->dbColu...
php
function saveBook( $blog_id, array $item ) { /** @var $wpdb \wpdb */ global $wpdb; unset( $item['users_id'], $item['blogs_id'], $item['deleted'] ); // Don't allow spoofing $data = [ 'users_id' => $this->userId, 'blogs_id' => $blog_id, 'deleted' => 0, ]; $format = [ 'users_id' => $this->dbColu...
[ "function", "saveBook", "(", "$", "blog_id", ",", "array", "$", "item", ")", "{", "/** @var $wpdb \\wpdb */", "global", "$", "wpdb", ";", "unset", "(", "$", "item", "[", "'users_id'", "]", ",", "$", "item", "[", "'blogs_id'", "]", ",", "$", "item", "["...
Save a book to a user catalog. @param $blog_id @param array $item @return int|false
[ "Save", "a", "book", "to", "a", "user", "catalog", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L438-L494
pressbooks/pressbooks
inc/class-catalog.php
Catalog.getTags
function getTags( $tag_group, $show_hidden_tags = true ) { /** @var $wpdb \wpdb */ global $wpdb; $sql = "SELECT DISTINCT {$this->dbTagsTable}.id, {$this->dbTagsTable}.tag FROM {$this->dbTagsTable} INNER JOIN {$this->dbLinkTable} ON {$this->dbLinkTable}.tags_id = {$this->dbTagsTable}.id INNER JOIN {$th...
php
function getTags( $tag_group, $show_hidden_tags = true ) { /** @var $wpdb \wpdb */ global $wpdb; $sql = "SELECT DISTINCT {$this->dbTagsTable}.id, {$this->dbTagsTable}.tag FROM {$this->dbTagsTable} INNER JOIN {$this->dbLinkTable} ON {$this->dbLinkTable}.tags_id = {$this->dbTagsTable}.id INNER JOIN {$th...
[ "function", "getTags", "(", "$", "tag_group", ",", "$", "show_hidden_tags", "=", "true", ")", "{", "/** @var $wpdb \\wpdb */", "global", "$", "wpdb", ";", "$", "sql", "=", "\"SELECT DISTINCT {$this->dbTagsTable}.id, {$this->dbTagsTable}.tag FROM {$this->dbTagsTable}\n \t\t\t\...
Get tags @param int $tag_group @param bool $show_hidden_tags (optional) @return array
[ "Get", "tags" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L538-L554
pressbooks/pressbooks
inc/class-catalog.php
Catalog.getTagsByBook
function getTagsByBook( $blog_id, $tag_group ) { /** @var $wpdb \wpdb */ global $wpdb; $sql = "SELECT DISTINCT {$this->dbTagsTable}.id, {$this->dbTagsTable}.tag FROM {$this->dbTagsTable} INNER JOIN {$this->dbLinkTable} ON {$this->dbLinkTable}.tags_id = {$this->dbTagsTable}.id INNER JOIN {$this->dbTabl...
php
function getTagsByBook( $blog_id, $tag_group ) { /** @var $wpdb \wpdb */ global $wpdb; $sql = "SELECT DISTINCT {$this->dbTagsTable}.id, {$this->dbTagsTable}.tag FROM {$this->dbTagsTable} INNER JOIN {$this->dbLinkTable} ON {$this->dbLinkTable}.tags_id = {$this->dbTagsTable}.id INNER JOIN {$this->dbTabl...
[ "function", "getTagsByBook", "(", "$", "blog_id", ",", "$", "tag_group", ")", "{", "/** @var $wpdb \\wpdb */", "global", "$", "wpdb", ";", "$", "sql", "=", "\"SELECT DISTINCT {$this->dbTagsTable}.id, {$this->dbTagsTable}.tag FROM {$this->dbTagsTable}\n \t\t\t\tINNER JOIN {$this->...
Get all tags for a book @param int $blog_id @param int $tag_group @return array
[ "Get", "all", "tags", "for", "a", "book" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L565-L577
pressbooks/pressbooks
inc/class-catalog.php
Catalog.saveTag
function saveTag( $tag, $blog_id, $tag_group ) { /** @var $wpdb \wpdb */ global $wpdb; $tag = strip_tags( $tag ); $tag = trim( $tag ); // INSERT ... ON DUPLICATE KEY UPDATE // @see http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html $sql = "INSERT INTO {$this->dbTagsTable} ( users_id, tag ...
php
function saveTag( $tag, $blog_id, $tag_group ) { /** @var $wpdb \wpdb */ global $wpdb; $tag = strip_tags( $tag ); $tag = trim( $tag ); // INSERT ... ON DUPLICATE KEY UPDATE // @see http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html $sql = "INSERT INTO {$this->dbTagsTable} ( users_id, tag ...
[ "function", "saveTag", "(", "$", "tag", ",", "$", "blog_id", ",", "$", "tag_group", ")", "{", "/** @var $wpdb \\wpdb */", "global", "$", "wpdb", ";", "$", "tag", "=", "strip_tags", "(", "$", "tag", ")", ";", "$", "tag", "=", "trim", "(", "$", "tag", ...
Save tag @param string $tag @param int $blog_id @param int $tag_group @return int|false
[ "Save", "tag" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L589-L614
pressbooks/pressbooks
inc/class-catalog.php
Catalog.deleteTag
function deleteTag( $tag, $blog_id, $tag_group, $for_real = false ) { /** @var $wpdb \wpdb */ global $wpdb; // Get ID $sql = "SELECT id FROM {$this->dbTagsTable} WHERE tag = %s "; $tag_id = $wpdb->get_var( $wpdb->prepare( $sql, $tag ) ); // @codingStandardsIgnoreLine if ( ! $tag_id ) { return false; ...
php
function deleteTag( $tag, $blog_id, $tag_group, $for_real = false ) { /** @var $wpdb \wpdb */ global $wpdb; // Get ID $sql = "SELECT id FROM {$this->dbTagsTable} WHERE tag = %s "; $tag_id = $wpdb->get_var( $wpdb->prepare( $sql, $tag ) ); // @codingStandardsIgnoreLine if ( ! $tag_id ) { return false; ...
[ "function", "deleteTag", "(", "$", "tag", ",", "$", "blog_id", ",", "$", "tag_group", ",", "$", "for_real", "=", "false", ")", "{", "/** @var $wpdb \\wpdb */", "global", "$", "wpdb", ";", "// Get ID", "$", "sql", "=", "\"SELECT id FROM {$this->dbTagsTable} WHERE...
Delete a tag. IMPORTANT: The 'for_real' option is extremely destructive. Do not use unless you know what you are doing. @param string $tag @param int $blog_id @param int $tag_group @param bool $for_real (optional) @return int|false
[ "Delete", "a", "tag", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L629-L673
pressbooks/pressbooks
inc/class-catalog.php
Catalog.deleteTags
function deleteTags( $blog_id, $tag_group ) { /** @var $wpdb \wpdb */ global $wpdb; $result = $wpdb->delete( $this->dbLinkTable, [ 'users_id' => $this->userId, 'blogs_id' => $blog_id, 'tags_group' => $tag_group, ], [ '%d', '%d', '%d' ] ); // TODO: // Optimize the links table: $wpdb->que...
php
function deleteTags( $blog_id, $tag_group ) { /** @var $wpdb \wpdb */ global $wpdb; $result = $wpdb->delete( $this->dbLinkTable, [ 'users_id' => $this->userId, 'blogs_id' => $blog_id, 'tags_group' => $tag_group, ], [ '%d', '%d', '%d' ] ); // TODO: // Optimize the links table: $wpdb->que...
[ "function", "deleteTags", "(", "$", "blog_id", ",", "$", "tag_group", ")", "{", "/** @var $wpdb \\wpdb */", "global", "$", "wpdb", ";", "$", "result", "=", "$", "wpdb", "->", "delete", "(", "$", "this", "->", "dbLinkTable", ",", "[", "'users_id'", "=>", ...
Delete all tags from a user catalog Note: Doesn't actually delete a tag, just removes the association in dbLinkTable @param $blog_id @param $tag_group @return int|false
[ "Delete", "all", "tags", "from", "a", "user", "catalog" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L686-L704
pressbooks/pressbooks
inc/class-catalog.php
Catalog.getProfile
function getProfile() { $profile['users_id'] = $this->userId; foreach ( $this->profileMetaKeys as $key => $type ) { $profile[ $key ] = get_user_meta( $this->userId, $key, true ); } return $profile; }
php
function getProfile() { $profile['users_id'] = $this->userId; foreach ( $this->profileMetaKeys as $key => $type ) { $profile[ $key ] = get_user_meta( $this->userId, $key, true ); } return $profile; }
[ "function", "getProfile", "(", ")", "{", "$", "profile", "[", "'users_id'", "]", "=", "$", "this", "->", "userId", ";", "foreach", "(", "$", "this", "->", "profileMetaKeys", "as", "$", "key", "=>", "$", "type", ")", "{", "$", "profile", "[", "$", "...
Get catalog profile. @return array
[ "Get", "catalog", "profile", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L721-L729
pressbooks/pressbooks
inc/class-catalog.php
Catalog.saveProfile
function saveProfile( array $item ) { // Sanitize $item = array_intersect_key( $item, $this->profileMetaKeys ); foreach ( $item as $key => $val ) { if ( 'pb_catalog_logo' === $key ) { continue; // Skip, dev should use uploadLogo() instead } if ( 'pb_catalog_url' === $key && $val ) { $val = \P...
php
function saveProfile( array $item ) { // Sanitize $item = array_intersect_key( $item, $this->profileMetaKeys ); foreach ( $item as $key => $val ) { if ( 'pb_catalog_logo' === $key ) { continue; // Skip, dev should use uploadLogo() instead } if ( 'pb_catalog_url' === $key && $val ) { $val = \P...
[ "function", "saveProfile", "(", "array", "$", "item", ")", "{", "// Sanitize", "$", "item", "=", "array_intersect_key", "(", "$", "item", ",", "$", "this", "->", "profileMetaKeys", ")", ";", "foreach", "(", "$", "item", "as", "$", "key", "=>", "$", "va...
Save catalog profile @param array $item
[ "Save", "catalog", "profile" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L737-L762
pressbooks/pressbooks
inc/class-catalog.php
Catalog.deleteCacheByBookId
function deleteCacheByBookId( $book_id ) { /** @var $wpdb \wpdb */ global $wpdb; $sql = "SELECT users_id FROM {$this->dbTable} WHERE blogs_id = %d "; $results = $wpdb->get_col( $wpdb->prepare( $sql, $book_id ) ); // @codingStandardsIgnoreLine foreach ( $results as $user_id ) { wp_cache_delete( "cat-$use...
php
function deleteCacheByBookId( $book_id ) { /** @var $wpdb \wpdb */ global $wpdb; $sql = "SELECT users_id FROM {$this->dbTable} WHERE blogs_id = %d "; $results = $wpdb->get_col( $wpdb->prepare( $sql, $book_id ) ); // @codingStandardsIgnoreLine foreach ( $results as $user_id ) { wp_cache_delete( "cat-$use...
[ "function", "deleteCacheByBookId", "(", "$", "book_id", ")", "{", "/** @var $wpdb \\wpdb */", "global", "$", "wpdb", ";", "$", "sql", "=", "\"SELECT users_id FROM {$this->dbTable} WHERE blogs_id = %d \"", ";", "$", "results", "=", "$", "wpdb", "->", "get_col", "(", ...
Delete the cache(s) by Book ID @param int $book_id
[ "Delete", "the", "cache", "(", "s", ")", "by", "Book", "ID" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L845-L856
pressbooks/pressbooks
inc/class-catalog.php
Catalog.createOrUpdateTables
protected function createOrUpdateTables() { require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); $sql = "CREATE TABLE {$this->dbTable} ( users_id INT(11) NOT null, blogs_id INT(11) NOT null, deleted TINYINT(1) NOT null, featured INT(11) DEFAULT 0 NOT null , PRIMARY KEY (users_id...
php
protected function createOrUpdateTables() { require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); $sql = "CREATE TABLE {$this->dbTable} ( users_id INT(11) NOT null, blogs_id INT(11) NOT null, deleted TINYINT(1) NOT null, featured INT(11) DEFAULT 0 NOT null , PRIMARY KEY (users_id...
[ "protected", "function", "createOrUpdateTables", "(", ")", "{", "require_once", "(", "ABSPATH", ".", "'wp-admin/includes/upgrade.php'", ")", ";", "$", "sql", "=", "\"CREATE TABLE {$this->dbTable} (\n\t\t\t\tusers_id INT(11) NOT null,\n \t\t\t\tblogs_id INT(11) NOT null,\n \t\t\t\td...
DB Delta the initial Catalog tables. If you change this, then don't forget to also change $this->dbColumns @see dbColumns @see http://codex.wordpress.org/Creating_Tables_with_Plugins#Creating_or_Updating_the_Table
[ "DB", "Delta", "the", "initial", "Catalog", "tables", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L885-L916
pressbooks/pressbooks
inc/class-catalog.php
Catalog.stringToTags
static function stringToTags( $tags ) { $tags = mb_split( ',', $tags ); foreach ( $tags as $key => &$val ) { $val = strip_tags( $val ); $val = mb_convert_case( $val, MB_CASE_TITLE, 'UTF-8' ); $val = mb_split( '\W', $val ); // Split on negated \w $val = implode( ' ', $val ); // Put back together with s...
php
static function stringToTags( $tags ) { $tags = mb_split( ',', $tags ); foreach ( $tags as $key => &$val ) { $val = strip_tags( $val ); $val = mb_convert_case( $val, MB_CASE_TITLE, 'UTF-8' ); $val = mb_split( '\W', $val ); // Split on negated \w $val = implode( ' ', $val ); // Put back together with s...
[ "static", "function", "stringToTags", "(", "$", "tags", ")", "{", "$", "tags", "=", "mb_split", "(", "','", ",", "$", "tags", ")", ";", "foreach", "(", "$", "tags", "as", "$", "key", "=>", "&", "$", "val", ")", "{", "$", "val", "=", "strip_tags",...
Return an array of tags from a comma delimited string @param string $tags @return array
[ "Return", "an", "array", "of", "tags", "from", "a", "comma", "delimited", "string" ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L931-L947
pressbooks/pressbooks
inc/class-catalog.php
Catalog.tagsToString
static function tagsToString( array $tags ) { $tags = wp_list_sort( $tags, 'tag', 'asc' ); $str = ''; foreach ( $tags as $tag ) { $str .= $tag['tag'] . ', '; } return rtrim( $str, ', ' ); }
php
static function tagsToString( array $tags ) { $tags = wp_list_sort( $tags, 'tag', 'asc' ); $str = ''; foreach ( $tags as $tag ) { $str .= $tag['tag'] . ', '; } return rtrim( $str, ', ' ); }
[ "static", "function", "tagsToString", "(", "array", "$", "tags", ")", "{", "$", "tags", "=", "wp_list_sort", "(", "$", "tags", ",", "'tag'", ",", "'asc'", ")", ";", "$", "str", "=", "''", ";", "foreach", "(", "$", "tags", "as", "$", "tag", ")", "...
Return a comma delimited string from an SQL array of tags, in alphabetical order. @param array $tags @return string
[ "Return", "a", "comma", "delimited", "string", "from", "an", "SQL", "array", "of", "tags", "in", "alphabetical", "order", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L957-L967
pressbooks/pressbooks
inc/class-catalog.php
Catalog.thumbnailFromUserId
static function thumbnailFromUserId( $user_id, $size ) { $image_url = get_user_meta( $user_id, 'pb_catalog_logo', true ); $book = get_active_blog_for_user( $user_id ); if ( $book ) { switch_to_blog( $book->blog_id ); $image_url = \Pressbooks\Image\thumbnail_from_url( $image_url, $size ); restore_current...
php
static function thumbnailFromUserId( $user_id, $size ) { $image_url = get_user_meta( $user_id, 'pb_catalog_logo', true ); $book = get_active_blog_for_user( $user_id ); if ( $book ) { switch_to_blog( $book->blog_id ); $image_url = \Pressbooks\Image\thumbnail_from_url( $image_url, $size ); restore_current...
[ "static", "function", "thumbnailFromUserId", "(", "$", "user_id", ",", "$", "size", ")", "{", "$", "image_url", "=", "get_user_meta", "(", "$", "user_id", ",", "'pb_catalog_logo'", ",", "true", ")", ";", "$", "book", "=", "get_active_blog_for_user", "(", "$"...
Catalog image is stored in user's active Media Library. @param int $user_id @param string $size @return string
[ "Catalog", "image", "is", "stored", "in", "user", "s", "active", "Media", "Library", "." ]
train
https://github.com/pressbooks/pressbooks/blob/1a2294414a3abb7b97c5b669cee72470a8fb5806/inc/class-catalog.php#L978-L989