repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
spipu/html2pdf | src/Html2Pdf.php | Html2Pdf.setMargins | protected function setMargins()
{
// prepare the margins
$this->_margeLeft = $this->_defaultLeft + (isset($this->_background['left']) ? $this->_background['left'] : 0);
$this->_margeRight = $this->_defaultRight + (isset($this->_background['right']) ? $this->_background['right'] :... | php | protected function setMargins()
{
// prepare the margins
$this->_margeLeft = $this->_defaultLeft + (isset($this->_background['left']) ? $this->_background['left'] : 0);
$this->_margeRight = $this->_defaultRight + (isset($this->_background['right']) ? $this->_background['right'] :... | [
"protected",
"function",
"setMargins",
"(",
")",
"{",
"// prepare the margins",
"$",
"this",
"->",
"_margeLeft",
"=",
"$",
"this",
"->",
"_defaultLeft",
"+",
"(",
"isset",
"(",
"$",
"this",
"->",
"_background",
"[",
"'left'",
"]",
")",
"?",
"$",
"this",
... | set the real margin, using the default margins and the page margins | [
"set",
"the",
"real",
"margin",
"using",
"the",
"default",
"margins",
"and",
"the",
"page",
"margins"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Html2Pdf.php#L762-L781 | train |
spipu/html2pdf | src/Html2Pdf.php | Html2Pdf._addMargins | protected function _addMargins($float, $xLeft, $yTop, $xRight, $yBottom)
{
// get the current float margins, for top and bottom
$oldTop = $this->_getMargins($yTop);
$oldBottom = $this->_getMargins($yBottom);
// update the top float margin
if ($float === 'left' && $oldTop... | php | protected function _addMargins($float, $xLeft, $yTop, $xRight, $yBottom)
{
// get the current float margins, for top and bottom
$oldTop = $this->_getMargins($yTop);
$oldBottom = $this->_getMargins($yBottom);
// update the top float margin
if ($float === 'left' && $oldTop... | [
"protected",
"function",
"_addMargins",
"(",
"$",
"float",
",",
"$",
"xLeft",
",",
"$",
"yTop",
",",
"$",
"xRight",
",",
"$",
"yBottom",
")",
"{",
"// get the current float margins, for top and bottom",
"$",
"oldTop",
"=",
"$",
"this",
"->",
"_getMargins",
"("... | Add margins, for a float
@access protected
@param string $float (left / right)
@param float $xLeft
@param float $yTop
@param float $xRight
@param float $yBottom | [
"Add",
"margins",
"for",
"a",
"float"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Html2Pdf.php#L815-L857 | train |
spipu/html2pdf | src/Html2Pdf.php | Html2Pdf._setPageHeader | protected function _setPageHeader()
{
if (!count($this->_subHEADER)) {
return false;
}
if (in_array($this->pdf->getPage(), $this->_hideHeader)) {
return false;
}
$oldParsePos = $this->_parsePos;
$oldParseCode = $this->parsingHtml->code;
... | php | protected function _setPageHeader()
{
if (!count($this->_subHEADER)) {
return false;
}
if (in_array($this->pdf->getPage(), $this->_hideHeader)) {
return false;
}
$oldParsePos = $this->_parsePos;
$oldParseCode = $this->parsingHtml->code;
... | [
"protected",
"function",
"_setPageHeader",
"(",
")",
"{",
"if",
"(",
"!",
"count",
"(",
"$",
"this",
"->",
"_subHEADER",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"this",
"->",
"pdf",
"->",
"getPage",
"(",
")",
",... | draw the PDF header with the HTML in page_header
@access protected | [
"draw",
"the",
"PDF",
"header",
"with",
"the",
"HTML",
"in",
"page_header"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Html2Pdf.php#L946-L965 | train |
spipu/html2pdf | src/Html2Pdf.php | Html2Pdf._setPageFooter | protected function _setPageFooter()
{
if (!count($this->_subFOOTER)) {
return false;
}
if (in_array($this->pdf->getPage(), $this->_hideFooter)) {
return false;
}
$oldParsePos = $this->_parsePos;
$oldParseCode = $this->parsingHtml->code;
... | php | protected function _setPageFooter()
{
if (!count($this->_subFOOTER)) {
return false;
}
if (in_array($this->pdf->getPage(), $this->_hideFooter)) {
return false;
}
$oldParsePos = $this->_parsePos;
$oldParseCode = $this->parsingHtml->code;
... | [
"protected",
"function",
"_setPageFooter",
"(",
")",
"{",
"if",
"(",
"!",
"count",
"(",
"$",
"this",
"->",
"_subFOOTER",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"this",
"->",
"pdf",
"->",
"getPage",
"(",
")",
",... | draw the PDF footer with the HTML in page_footer
@access protected | [
"draw",
"the",
"PDF",
"footer",
"with",
"the",
"HTML",
"in",
"page_footer"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Html2Pdf.php#L972-L993 | train |
spipu/html2pdf | src/Html2Pdf.php | Html2Pdf._setNewLine | protected function _setNewLine($h, $curr = null)
{
$this->pdf->Ln($h);
$this->_setNewPositionForNewLine($curr);
} | php | protected function _setNewLine($h, $curr = null)
{
$this->pdf->Ln($h);
$this->_setNewPositionForNewLine($curr);
} | [
"protected",
"function",
"_setNewLine",
"(",
"$",
"h",
",",
"$",
"curr",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"pdf",
"->",
"Ln",
"(",
"$",
"h",
")",
";",
"$",
"this",
"->",
"_setNewPositionForNewLine",
"(",
"$",
"curr",
")",
";",
"}"
] | new line, with a specific height
@access protected
@param float $h
@param integer $curr real current position in the text, if new line in the write of a text | [
"new",
"line",
"with",
"a",
"specific",
"height"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Html2Pdf.php#L1002-L1006 | train |
spipu/html2pdf | src/Html2Pdf.php | Html2Pdf.createSubHTML | protected function createSubHTML()
{
// prepare the subObject, if never prepare before
if (self::$_subobj === null) {
$this->_prepareSubObj();
}
// calculate the width to use
if ($this->parsingCss->value['width']) {
$marge = $this->parsingCss->value['... | php | protected function createSubHTML()
{
// prepare the subObject, if never prepare before
if (self::$_subobj === null) {
$this->_prepareSubObj();
}
// calculate the width to use
if ($this->parsingCss->value['width']) {
$marge = $this->parsingCss->value['... | [
"protected",
"function",
"createSubHTML",
"(",
")",
"{",
"// prepare the subObject, if never prepare before",
"if",
"(",
"self",
"::",
"$",
"_subobj",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"_prepareSubObj",
"(",
")",
";",
"}",
"// calculate the width to use",
... | create a sub Html2Pdf, to calculate the multi-tables
@return Html2Pdf | [
"create",
"a",
"sub",
"Html2Pdf",
"to",
"calculate",
"the",
"multi",
"-",
"tables"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Html2Pdf.php#L1128-L1162 | train |
spipu/html2pdf | src/Html2Pdf.php | Html2Pdf._listeArab2Rom | protected function _listeArab2Rom($nbArabic)
{
$nbBaseTen = array('I','X','C','M');
$nbBaseFive = array('V','L','D');
$nbRoman = '';
if ($nbArabic<1) {
return $nbArabic;
}
if ($nbArabic>3999) {
return $nbArabic;
}
for ($i=... | php | protected function _listeArab2Rom($nbArabic)
{
$nbBaseTen = array('I','X','C','M');
$nbBaseFive = array('V','L','D');
$nbRoman = '';
if ($nbArabic<1) {
return $nbArabic;
}
if ($nbArabic>3999) {
return $nbArabic;
}
for ($i=... | [
"protected",
"function",
"_listeArab2Rom",
"(",
"$",
"nbArabic",
")",
"{",
"$",
"nbBaseTen",
"=",
"array",
"(",
"'I'",
",",
"'X'",
",",
"'C'",
",",
"'M'",
")",
";",
"$",
"nbBaseFive",
"=",
"array",
"(",
"'V'",
",",
"'L'",
",",
"'D'",
")",
";",
"$",... | Convert an arabic number into a roman number
@access protected
@param integer $nbArabic
@return string $nbRoman | [
"Convert",
"an",
"arabic",
"number",
"into",
"a",
"roman",
"number"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Html2Pdf.php#L1182-L1216 | train |
spipu/html2pdf | src/Html2Pdf.php | Html2Pdf._listeGetLi | protected function _listeGetLi()
{
$im = $this->_defList[count($this->_defList)-1]['img'];
$st = $this->_defList[count($this->_defList)-1]['style'];
$nb = $this->_defList[count($this->_defList)-1]['nb'];
$up = (substr($st, 0, 6) === 'upper-');
if ($im) {
return a... | php | protected function _listeGetLi()
{
$im = $this->_defList[count($this->_defList)-1]['img'];
$st = $this->_defList[count($this->_defList)-1]['style'];
$nb = $this->_defList[count($this->_defList)-1]['nb'];
$up = (substr($st, 0, 6) === 'upper-');
if ($im) {
return a... | [
"protected",
"function",
"_listeGetLi",
"(",
")",
"{",
"$",
"im",
"=",
"$",
"this",
"->",
"_defList",
"[",
"count",
"(",
"$",
"this",
"->",
"_defList",
")",
"-",
"1",
"]",
"[",
"'img'",
"]",
";",
"$",
"st",
"=",
"$",
"this",
"->",
"_defList",
"["... | get the information of the li on the current level
@access protected
@return array(fontName, small size, string) | [
"get",
"the",
"information",
"of",
"the",
"li",
"on",
"the",
"current",
"level"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Html2Pdf.php#L1256-L1301 | train |
spipu/html2pdf | src/Html2Pdf.php | Html2Pdf._listeAddLevel | protected function _listeAddLevel($type = 'ul', $style = '', $img = null, $start = null)
{
// get the url of the image, if we want to use a image
if ($img) {
if (preg_match('/^url\(([^)]+)\)$/isU', trim($img), $match)) {
$img = $match[1];
} else {
... | php | protected function _listeAddLevel($type = 'ul', $style = '', $img = null, $start = null)
{
// get the url of the image, if we want to use a image
if ($img) {
if (preg_match('/^url\(([^)]+)\)$/isU', trim($img), $match)) {
$img = $match[1];
} else {
... | [
"protected",
"function",
"_listeAddLevel",
"(",
"$",
"type",
"=",
"'ul'",
",",
"$",
"style",
"=",
"''",
",",
"$",
"img",
"=",
"null",
",",
"$",
"start",
"=",
"null",
")",
"{",
"// get the url of the image, if we want to use a image",
"if",
"(",
"$",
"img",
... | add a level to the list
@access protected
@param string $type : ul, ol
@param string $style : lower-alpha, ...
@param string $img | [
"add",
"a",
"level",
"to",
"the",
"list"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Html2Pdf.php#L1311-L1348 | train |
spipu/html2pdf | src/Html2Pdf.php | Html2Pdf._listeDelLevel | protected function _listeDelLevel()
{
if (count($this->_defList)) {
unset($this->_defList[count($this->_defList)-1]);
$this->_defList = array_values($this->_defList);
}
} | php | protected function _listeDelLevel()
{
if (count($this->_defList)) {
unset($this->_defList[count($this->_defList)-1]);
$this->_defList = array_values($this->_defList);
}
} | [
"protected",
"function",
"_listeDelLevel",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"_defList",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_defList",
"[",
"count",
"(",
"$",
"this",
"->",
"_defList",
")",
"-",
"1",
"]",
")",... | remove a level from the list
@access protected | [
"remove",
"a",
"level",
"from",
"the",
"list"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Html2Pdf.php#L1355-L1361 | train |
spipu/html2pdf | src/Html2Pdf.php | Html2Pdf._makeHTMLcode | protected function _makeHTMLcode()
{
$amountHtmlCode = count($this->parsingHtml->code);
// foreach elements of the parsing
for ($this->_parsePos=0; $this->_parsePos<$amountHtmlCode; $this->_parsePos++) {
// get the action to do
$action = $this->parsingHtml->code[$th... | php | protected function _makeHTMLcode()
{
$amountHtmlCode = count($this->parsingHtml->code);
// foreach elements of the parsing
for ($this->_parsePos=0; $this->_parsePos<$amountHtmlCode; $this->_parsePos++) {
// get the action to do
$action = $this->parsingHtml->code[$th... | [
"protected",
"function",
"_makeHTMLcode",
"(",
")",
"{",
"$",
"amountHtmlCode",
"=",
"count",
"(",
"$",
"this",
"->",
"parsingHtml",
"->",
"code",
")",
";",
"// foreach elements of the parsing",
"for",
"(",
"$",
"this",
"->",
"_parsePos",
"=",
"0",
";",
"$",... | execute the actions to convert the html
@access protected | [
"execute",
"the",
"actions",
"to",
"convert",
"the",
"html"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Html2Pdf.php#L1368-L1409 | train |
spipu/html2pdf | src/Html2Pdf.php | Html2Pdf._executeAction | protected function _executeAction(Node $action)
{
$name = strtoupper($action->getName());
if ($this->_firstPage && $name !== 'PAGE' && !$action->isClose()) {
$this->_setNewPage();
}
// properties of the action
$properties = $action->getParams();
// name... | php | protected function _executeAction(Node $action)
{
$name = strtoupper($action->getName());
if ($this->_firstPage && $name !== 'PAGE' && !$action->isClose()) {
$this->_setNewPage();
}
// properties of the action
$properties = $action->getParams();
// name... | [
"protected",
"function",
"_executeAction",
"(",
"Node",
"$",
"action",
")",
"{",
"$",
"name",
"=",
"strtoupper",
"(",
"$",
"action",
"->",
"getName",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_firstPage",
"&&",
"$",
"name",
"!==",
"'PAGE'",
... | execute the action from the parsing
@param Node $action | [
"execute",
"the",
"action",
"from",
"the",
"parsing"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Html2Pdf.php#L1416-L1455 | train |
spipu/html2pdf | src/Html2Pdf.php | Html2Pdf._getElementY | protected function _getElementY($h)
{
if ($this->_subPart || $this->_isSubPart || !$this->_currentH || $this->_currentH<$h) {
return 0;
}
return ($this->_currentH-$h)*0.8;
} | php | protected function _getElementY($h)
{
if ($this->_subPart || $this->_isSubPart || !$this->_currentH || $this->_currentH<$h) {
return 0;
}
return ($this->_currentH-$h)*0.8;
} | [
"protected",
"function",
"_getElementY",
"(",
"$",
"h",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_subPart",
"||",
"$",
"this",
"->",
"_isSubPart",
"||",
"!",
"$",
"this",
"->",
"_currentH",
"||",
"$",
"this",
"->",
"_currentH",
"<",
"$",
"h",
")",
... | get the position of the element on the current line, depending on its height
@access protected
@param float $h
@return float | [
"get",
"the",
"position",
"of",
"the",
"element",
"on",
"the",
"current",
"line",
"depending",
"on",
"its",
"height"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Html2Pdf.php#L1464-L1471 | train |
spipu/html2pdf | src/Html2Pdf.php | Html2Pdf._makeBreakLine | protected function _makeBreakLine($h, $curr = null)
{
if ($h) {
if (($this->pdf->GetY()+$h<$this->pdf->getH() - $this->pdf->getbMargin()) || $this->_isInOverflow || $this->_isInFooter) {
$this->_setNewLine($h, $curr);
} else {
$this->_setNewPage(null, ... | php | protected function _makeBreakLine($h, $curr = null)
{
if ($h) {
if (($this->pdf->GetY()+$h<$this->pdf->getH() - $this->pdf->getbMargin()) || $this->_isInOverflow || $this->_isInFooter) {
$this->_setNewLine($h, $curr);
} else {
$this->_setNewPage(null, ... | [
"protected",
"function",
"_makeBreakLine",
"(",
"$",
"h",
",",
"$",
"curr",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"h",
")",
"{",
"if",
"(",
"(",
"$",
"this",
"->",
"pdf",
"->",
"GetY",
"(",
")",
"+",
"$",
"h",
"<",
"$",
"this",
"->",
"pdf",
... | make a break line
@access protected
@param float $h current line height
@param integer $curr real current position in the text, if new line in the write of a text | [
"make",
"a",
"break",
"line"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Html2Pdf.php#L1480-L1494 | train |
spipu/html2pdf | src/Html2Pdf.php | Html2Pdf._tag_close_PAGE_FOOTER_SUB | protected function _tag_close_PAGE_FOOTER_SUB($param)
{
if ($this->_isForOneLine) {
return false;
}
$this->parsingCss->load();
$this->parsingCss->value = $this->_subSTATES['s'];
$this->parsingCss->table = $this->_subSTATES['t'];
... | php | protected function _tag_close_PAGE_FOOTER_SUB($param)
{
if ($this->_isForOneLine) {
return false;
}
$this->parsingCss->load();
$this->parsingCss->value = $this->_subSTATES['s'];
$this->parsingCss->table = $this->_subSTATES['t'];
... | [
"protected",
"function",
"_tag_close_PAGE_FOOTER_SUB",
"(",
"$",
"param",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_isForOneLine",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"parsingCss",
"->",
"load",
"(",
")",
";",
"$",
"this",
"->",
"... | It is not a real tag. Do not use it directly
@param array $param
@return boolean | [
"It",
"is",
"not",
"a",
"real",
"tag",
".",
"Do",
"not",
"use",
"it",
"directly"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Html2Pdf.php#L2984-L3007 | train |
spipu/html2pdf | src/Html2Pdf.php | Html2Pdf._INDEX_NewPage | public function _INDEX_NewPage(&$page)
{
if ($page) {
$oldPage = $this->pdf->getPage();
$this->pdf->setPage($page);
$this->pdf->SetXY($this->_margeLeft, $this->_margeTop);
$this->_maxH = 0;
$page++;
return $oldPage;
} else {
... | php | public function _INDEX_NewPage(&$page)
{
if ($page) {
$oldPage = $this->pdf->getPage();
$this->pdf->setPage($page);
$this->pdf->SetXY($this->_margeLeft, $this->_margeTop);
$this->_maxH = 0;
$page++;
return $oldPage;
} else {
... | [
"public",
"function",
"_INDEX_NewPage",
"(",
"&",
"$",
"page",
")",
"{",
"if",
"(",
"$",
"page",
")",
"{",
"$",
"oldPage",
"=",
"$",
"this",
"->",
"pdf",
"->",
"getPage",
"(",
")",
";",
"$",
"this",
"->",
"pdf",
"->",
"setPage",
"(",
"$",
"page",... | new page for the automatic Index, do not use this method. Only myPdf could use it !!!!
@param &int $page
@return integer $oldPage | [
"new",
"page",
"for",
"the",
"automatic",
"Index",
"do",
"not",
"use",
"this",
"method",
".",
"Only",
"myPdf",
"could",
"use",
"it",
"!!!!"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Html2Pdf.php#L6419-L6432 | train |
spipu/html2pdf | src/MyPdf.php | MyPdf.Footer | public function Footer()
{
// prepare the text from the tranlated text
$txt = '';
if ($this->_footerParam['form']) {
$txt = Locale::get('pdf05');
}
if ($this->_footerParam['date'] && $this->_footerParam['time']) {
$txt.= ($txt ? ' - ' : '').Locale::get... | php | public function Footer()
{
// prepare the text from the tranlated text
$txt = '';
if ($this->_footerParam['form']) {
$txt = Locale::get('pdf05');
}
if ($this->_footerParam['date'] && $this->_footerParam['time']) {
$txt.= ($txt ? ' - ' : '').Locale::get... | [
"public",
"function",
"Footer",
"(",
")",
"{",
"// prepare the text from the tranlated text",
"$",
"txt",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"_footerParam",
"[",
"'form'",
"]",
")",
"{",
"$",
"txt",
"=",
"Locale",
"::",
"get",
"(",
"'pdf05'",
... | This function is call automatically by TCPDF at the end of a page
It takes no parameters
@access public | [
"This",
"function",
"is",
"call",
"automatically",
"by",
"TCPDF",
"at",
"the",
"end",
"of",
"a",
"page",
"It",
"takes",
"no",
"parameters"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/MyPdf.php#L93-L132 | train |
spipu/html2pdf | src/MyPdf.php | MyPdf.cloneFontFrom | public function cloneFontFrom(&$pdf)
{
$this->n = &$pdf->getN();
$this->fonts = &$pdf->getFonts();
$this->FontFiles = &$pdf->getFontFiles();
$this->diffs = &$pdf->getDiffs();
$this->fontlist = &$pdf->getFontList();
$... | php | public function cloneFontFrom(&$pdf)
{
$this->n = &$pdf->getN();
$this->fonts = &$pdf->getFonts();
$this->FontFiles = &$pdf->getFontFiles();
$this->diffs = &$pdf->getDiffs();
$this->fontlist = &$pdf->getFontList();
$... | [
"public",
"function",
"cloneFontFrom",
"(",
"&",
"$",
"pdf",
")",
"{",
"$",
"this",
"->",
"n",
"=",
"&",
"$",
"pdf",
"->",
"getN",
"(",
")",
";",
"$",
"this",
"->",
"fonts",
"=",
"&",
"$",
"pdf",
"->",
"getFonts",
"(",
")",
";",
"$",
"this",
... | after cloning a object, we does not want to clone all the front informations
because it take a lot a time and a lot of memory => we use reference
@param myPdf &$pdf
@access public | [
"after",
"cloning",
"a",
"object",
"we",
"does",
"not",
"want",
"to",
"clone",
"all",
"the",
"front",
"informations",
"because",
"it",
"take",
"a",
"lot",
"a",
"time",
"and",
"a",
"lot",
"of",
"memory",
"=",
">",
"we",
"use",
"reference"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/MyPdf.php#L141-L152 | train |
spipu/html2pdf | src/MyPdf.php | MyPdf.isLoadedFont | public function isLoadedFont($fontKey)
{
if (isset($this->fonts[$fontKey])) {
return true;
}
if (isset($this->CoreFonts[$fontKey])) {
return true;
}
return false;
} | php | public function isLoadedFont($fontKey)
{
if (isset($this->fonts[$fontKey])) {
return true;
}
if (isset($this->CoreFonts[$fontKey])) {
return true;
}
return false;
} | [
"public",
"function",
"isLoadedFont",
"(",
"$",
"fontKey",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"fonts",
"[",
"$",
"fontKey",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"CoreFonts",
... | Verify that a Font is already loaded
@param string Font Key
@return boolean
@access public | [
"Verify",
"that",
"a",
"Font",
"is",
"already",
"loaded"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/MyPdf.php#L205-L216 | train |
spipu/html2pdf | src/MyPdf.php | MyPdf.setWordSpacing | public function setWordSpacing($ws = 0.)
{
$this->ws = $ws;
$this->_out(sprintf('%.3F Tw', $ws*$this->k));
} | php | public function setWordSpacing($ws = 0.)
{
$this->ws = $ws;
$this->_out(sprintf('%.3F Tw', $ws*$this->k));
} | [
"public",
"function",
"setWordSpacing",
"(",
"$",
"ws",
"=",
"0.",
")",
"{",
"$",
"this",
"->",
"ws",
"=",
"$",
"ws",
";",
"$",
"this",
"->",
"_out",
"(",
"sprintf",
"(",
"'%.3F Tw'",
",",
"$",
"ws",
"*",
"$",
"this",
"->",
"k",
")",
")",
";",
... | set the Word Spacing
@param float word spacing
@access public | [
"set",
"the",
"Word",
"Spacing"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/MyPdf.php#L235-L239 | train |
spipu/html2pdf | src/MyPdf.php | MyPdf.setTranslate | public function setTranslate($xT, $yT)
{
// Matrix for Translate
$tm[0]=1;
$tm[1]=0;
$tm[2]=0;
$tm[3]=1;
$tm[4]=$xT*$this->k;
$tm[5]=-$yT*$this->k;
// apply the Transform Matric
$this->_out(sprintf('%.3F %.3F %.3F %.3F %.3F %.3F cm', $tm[0], $... | php | public function setTranslate($xT, $yT)
{
// Matrix for Translate
$tm[0]=1;
$tm[1]=0;
$tm[2]=0;
$tm[3]=1;
$tm[4]=$xT*$this->k;
$tm[5]=-$yT*$this->k;
// apply the Transform Matric
$this->_out(sprintf('%.3F %.3F %.3F %.3F %.3F %.3F cm', $tm[0], $... | [
"public",
"function",
"setTranslate",
"(",
"$",
"xT",
",",
"$",
"yT",
")",
"{",
"// Matrix for Translate",
"$",
"tm",
"[",
"0",
"]",
"=",
"1",
";",
"$",
"tm",
"[",
"1",
"]",
"=",
"0",
";",
"$",
"tm",
"[",
"2",
"]",
"=",
"0",
";",
"$",
"tm",
... | add a Translate transformation
@param float $Tx
@param float $Ty
@access public | [
"add",
"a",
"Translate",
"transformation"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/MyPdf.php#L541-L553 | train |
spipu/html2pdf | src/MyPdf.php | MyPdf.setRotation | public function setRotation($angle, $xC = null, $yC = null)
{
// if no center, rotate around the current posiition
if ($xC === null) {
$xC=$this->x;
}
if ($yC === null) {
$yC=$this->y;
}
// prepare the coordinate
$yC=($this->h-$yC)*$th... | php | public function setRotation($angle, $xC = null, $yC = null)
{
// if no center, rotate around the current posiition
if ($xC === null) {
$xC=$this->x;
}
if ($yC === null) {
$yC=$this->y;
}
// prepare the coordinate
$yC=($this->h-$yC)*$th... | [
"public",
"function",
"setRotation",
"(",
"$",
"angle",
",",
"$",
"xC",
"=",
"null",
",",
"$",
"yC",
"=",
"null",
")",
"{",
"// if no center, rotate around the current posiition",
"if",
"(",
"$",
"xC",
"===",
"null",
")",
"{",
"$",
"xC",
"=",
"$",
"this"... | add a Rotate transformation
@param float $angle
@param float $Cx
@param float $Cy
@access public | [
"add",
"a",
"Rotate",
"transformation"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/MyPdf.php#L563-L587 | train |
spipu/html2pdf | src/MyPdf.php | MyPdf.svgLine | public function svgLine($x1, $y1, $x2, $y2)
{
// get the Closing operator
$op='S';
// drawing
$this->_Point($x1, $y1, true);
$this->_Line($x2, $y2, true);
$this->_out($op);
} | php | public function svgLine($x1, $y1, $x2, $y2)
{
// get the Closing operator
$op='S';
// drawing
$this->_Point($x1, $y1, true);
$this->_Line($x2, $y2, true);
$this->_out($op);
} | [
"public",
"function",
"svgLine",
"(",
"$",
"x1",
",",
"$",
"y1",
",",
"$",
"x2",
",",
"$",
"y2",
")",
"{",
"// get the Closing operator",
"$",
"op",
"=",
"'S'",
";",
"// drawing",
"$",
"this",
"->",
"_Point",
"(",
"$",
"x1",
",",
"$",
"y1",
",",
... | SVG - make a Line
@param float $x1
@param float $y1
@param float $x2
@param float $y2
@access public | [
"SVG",
"-",
"make",
"a",
"Line"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/MyPdf.php#L776-L785 | train |
spipu/html2pdf | src/MyPdf.php | MyPdf.svgEllipse | public function svgEllipse($x0, $y0, $rx, $ry, $style)
{
// get the Closing operator from the PDF Style
if ($style === 'F') {
$op='f';
} elseif ($style === 'FD' || $style === 'DF') {
$op='B';
} else {
$op='S';
}
// drawing
... | php | public function svgEllipse($x0, $y0, $rx, $ry, $style)
{
// get the Closing operator from the PDF Style
if ($style === 'F') {
$op='f';
} elseif ($style === 'FD' || $style === 'DF') {
$op='B';
} else {
$op='S';
}
// drawing
... | [
"public",
"function",
"svgEllipse",
"(",
"$",
"x0",
",",
"$",
"y0",
",",
"$",
"rx",
",",
"$",
"ry",
",",
"$",
"style",
")",
"{",
"// get the Closing operator from the PDF Style",
"if",
"(",
"$",
"style",
"===",
"'F'",
")",
"{",
"$",
"op",
"=",
"'f'",
... | SVG - make a Ellipse
@param float $x0 x Center
@param float $y0 y Center
@param float $rx x radius
@param float $ry y radius
@param string $style PDF Style
@access public | [
"SVG",
"-",
"make",
"a",
"Ellipse"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/MyPdf.php#L797-L811 | train |
spipu/html2pdf | src/MyPdf.php | MyPdf.doTransform | public function doTransform($n = null)
{
// get the last Transformation Matrix
$nb = count($this->_transf);
if ($nb) {
$m = $this->_transf[$nb-1];
} else {
$m = array(1,0,0,1,0,0);
}
// if no transform, get the Identity Matrix
if (!$n)... | php | public function doTransform($n = null)
{
// get the last Transformation Matrix
$nb = count($this->_transf);
if ($nb) {
$m = $this->_transf[$nb-1];
} else {
$m = array(1,0,0,1,0,0);
}
// if no transform, get the Identity Matrix
if (!$n)... | [
"public",
"function",
"doTransform",
"(",
"$",
"n",
"=",
"null",
")",
"{",
"// get the last Transformation Matrix",
"$",
"nb",
"=",
"count",
"(",
"$",
"this",
"->",
"_transf",
")",
";",
"if",
"(",
"$",
"nb",
")",
"{",
"$",
"m",
"=",
"$",
"this",
"->"... | SVG - add a transformation Matric
@param array $n matrix
@access public | [
"SVG",
"-",
"add",
"a",
"transformation",
"Matric"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/MyPdf.php#L1285-L1309 | train |
spipu/html2pdf | src/MyPdf.php | MyPdf.myBarcode | public function myBarcode($code, $type, $x, $y, $w, $h, $labelFontsize, $color, $dimension = '1D')
{
// the style of the barcode
$style = array(
'position' => 'S',
'text' => ($labelFontsize ? true : false),
'fgcolor' => $color,
'bgcolor' => false,
... | php | public function myBarcode($code, $type, $x, $y, $w, $h, $labelFontsize, $color, $dimension = '1D')
{
// the style of the barcode
$style = array(
'position' => 'S',
'text' => ($labelFontsize ? true : false),
'fgcolor' => $color,
'bgcolor' => false,
... | [
"public",
"function",
"myBarcode",
"(",
"$",
"code",
",",
"$",
"type",
",",
"$",
"x",
",",
"$",
"y",
",",
"$",
"w",
",",
"$",
"h",
",",
"$",
"labelFontsize",
",",
"$",
"color",
",",
"$",
"dimension",
"=",
"'1D'",
")",
"{",
"// the style of the barc... | Convert a Html2Pdf barcode in a TCPDF barcode
@param string $code code to print
@param string $type type of barcode (see tcpdf/barcodes.php for supported formats)
@param int $x x position in user units
@param int $y y position in user units
@param int $w width in user units
@param int $h height in user units
@param in... | [
"Convert",
"a",
"Html2Pdf",
"barcode",
"in",
"a",
"TCPDF",
"barcode"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/MyPdf.php#L1335-L1360 | train |
spipu/html2pdf | src/MyPdf.php | MyPdf.getMyAliasNbPages | public function getMyAliasNbPages()
{
if ($this->_myLastPageGroupNb == 0) {
return $this->getAliasNbPages();
} else {
$old = $this->currpagegroup;
$this->currpagegroup = '{nb'.$this->_myLastPageGroupNb.'}';
$new = $this->getPageGroupAlias();
... | php | public function getMyAliasNbPages()
{
if ($this->_myLastPageGroupNb == 0) {
return $this->getAliasNbPages();
} else {
$old = $this->currpagegroup;
$this->currpagegroup = '{nb'.$this->_myLastPageGroupNb.'}';
$new = $this->getPageGroupAlias();
... | [
"public",
"function",
"getMyAliasNbPages",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_myLastPageGroupNb",
"==",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"getAliasNbPages",
"(",
")",
";",
"}",
"else",
"{",
"$",
"old",
"=",
"$",
"this",
"->",
"c... | Returns the string alias used for the total number of pages.
@access public
@return string;
@see TCPDF::getAliasNbPages(), TCPDF::getPageGroupAlias() | [
"Returns",
"the",
"string",
"alias",
"used",
"for",
"the",
"total",
"number",
"of",
"pages",
"."
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/MyPdf.php#L1455-L1467 | train |
spipu/html2pdf | src/Parsing/HtmlLexer.php | HtmlLexer.tokenize | public function tokenize($html)
{
// initialise the array
$tokens = array();
// regexp to separate the tags from the texts
$reg = '/(<\/?\w[^<>]*>)|([^<]+|<)/is';
$commentRegex = '/(<!--.*-->)/isU';
// last match found
$str = '';
$offset = 0;
... | php | public function tokenize($html)
{
// initialise the array
$tokens = array();
// regexp to separate the tags from the texts
$reg = '/(<\/?\w[^<>]*>)|([^<]+|<)/is';
$commentRegex = '/(<!--.*-->)/isU';
// last match found
$str = '';
$offset = 0;
... | [
"public",
"function",
"tokenize",
"(",
"$",
"html",
")",
"{",
"// initialise the array",
"$",
"tokens",
"=",
"array",
"(",
")",
";",
"// regexp to separate the tags from the texts",
"$",
"reg",
"=",
"'/(<\\/?\\w[^<>]*>)|([^<]+|<)/is'",
";",
"$",
"commentRegex",
"=",
... | Tokenize the HTML code
@param string $html HTML code to tokenize
@return Token[] | [
"Tokenize",
"the",
"HTML",
"code"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Parsing/HtmlLexer.php#L26-L80 | train |
spipu/html2pdf | src/Exception/ExceptionFormatter.php | ExceptionFormatter.getAdditionalData | protected function getAdditionalData(Html2PdfException $e)
{
$data = array();
// read the error
switch ($e->getCode()) {
case HtmlParsingException::ERROR_CODE:
/** @var HtmlParsingException $e */
$data['invalid tag'] = $e->getInvalidTag();
... | php | protected function getAdditionalData(Html2PdfException $e)
{
$data = array();
// read the error
switch ($e->getCode()) {
case HtmlParsingException::ERROR_CODE:
/** @var HtmlParsingException $e */
$data['invalid tag'] = $e->getInvalidTag();
... | [
"protected",
"function",
"getAdditionalData",
"(",
"Html2PdfException",
"$",
"e",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"// read the error",
"switch",
"(",
"$",
"e",
"->",
"getCode",
"(",
")",
")",
"{",
"case",
"HtmlParsingException",
"::",
"... | get the additional data from the exception
@param Html2PdfException $e the exception to display
@return array | [
"get",
"the",
"additional",
"data",
"from",
"the",
"exception"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Exception/ExceptionFormatter.php#L74-L105 | train |
spipu/html2pdf | src/Exception/ExceptionFormatter.php | ExceptionFormatter.buildTextMessage | protected function buildTextMessage(Html2PdfException $e, $data)
{
$this->message = 'Html2Pdf Error ['.$e->getCode().']'."\n";
$this->message.= $e->getMessage()."\n";
$this->message.= ' File: '.$e->getFile()."\n";
$this->message.= ' Line: '.$e->getLine()."\n";
if (!empty($da... | php | protected function buildTextMessage(Html2PdfException $e, $data)
{
$this->message = 'Html2Pdf Error ['.$e->getCode().']'."\n";
$this->message.= $e->getMessage()."\n";
$this->message.= ' File: '.$e->getFile()."\n";
$this->message.= ' Line: '.$e->getLine()."\n";
if (!empty($da... | [
"protected",
"function",
"buildTextMessage",
"(",
"Html2PdfException",
"$",
"e",
",",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"message",
"=",
"'Html2Pdf Error ['",
".",
"$",
"e",
"->",
"getCode",
"(",
")",
".",
"']'",
".",
"\"\\n\"",
";",
"$",
"this",
... | Build the text message
@param Html2PdfException $e the exception of the error
@param array $data additionnal data
@return void | [
"Build",
"the",
"text",
"message"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Exception/ExceptionFormatter.php#L115-L127 | train |
spipu/html2pdf | src/Exception/ExceptionFormatter.php | ExceptionFormatter.buildHtmlMessage | protected function buildHtmlMessage(Html2PdfException $e, $data)
{
$this->htmlMessage = '<span style="color: #A00; font-weight: bold;">';
$this->htmlMessage.= 'Html2Pdf Error ['.$e->getCode().']';
$this->htmlMessage.= '</span><br />'."\n";
$this->htmlMessage.= htmlentities($e->getMes... | php | protected function buildHtmlMessage(Html2PdfException $e, $data)
{
$this->htmlMessage = '<span style="color: #A00; font-weight: bold;">';
$this->htmlMessage.= 'Html2Pdf Error ['.$e->getCode().']';
$this->htmlMessage.= '</span><br />'."\n";
$this->htmlMessage.= htmlentities($e->getMes... | [
"protected",
"function",
"buildHtmlMessage",
"(",
"Html2PdfException",
"$",
"e",
",",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"htmlMessage",
"=",
"'<span style=\"color: #A00; font-weight: bold;\">'",
";",
"$",
"this",
"->",
"htmlMessage",
".=",
"'Html2Pdf Error ['",... | build the html message
@param Html2PdfException $e the exception of the error
@param array $data additional data
@return void | [
"build",
"the",
"html",
"message"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Exception/ExceptionFormatter.php#L137-L151 | train |
spipu/html2pdf | src/Parsing/Html.php | Html.getCloneCodes | public function getCloneCodes()
{
$codes = array();
foreach ($this->code as $key => $code) {
$codes[$key] = clone $code;
}
return $codes;
} | php | public function getCloneCodes()
{
$codes = array();
foreach ($this->code as $key => $code) {
$codes[$key] = clone $code;
}
return $codes;
} | [
"public",
"function",
"getCloneCodes",
"(",
")",
"{",
"$",
"codes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"code",
"as",
"$",
"key",
"=>",
"$",
"code",
")",
"{",
"$",
"codes",
"[",
"$",
"key",
"]",
"=",
"clone",
"$",
"c... | Get the list of the codes, but cloned
@return Node[] | [
"Get",
"the",
"list",
"of",
"the",
"codes",
"but",
"cloned"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Parsing/Html.php#L62-L69 | train |
spipu/html2pdf | src/Parsing/Html.php | Html.verifyMustContain | protected function verifyMustContain(&$actions, $mainTag, $mustTag)
{
$inMainTag = 0;
$foundMustTag = false;
foreach ($actions as $action) {
if ($action->getName() == $mainTag && !$action->isClose()) {
$inMainTag++;
$foundMustTag = false;
... | php | protected function verifyMustContain(&$actions, $mainTag, $mustTag)
{
$inMainTag = 0;
$foundMustTag = false;
foreach ($actions as $action) {
if ($action->getName() == $mainTag && !$action->isClose()) {
$inMainTag++;
$foundMustTag = false;
... | [
"protected",
"function",
"verifyMustContain",
"(",
"&",
"$",
"actions",
",",
"$",
"mainTag",
",",
"$",
"mustTag",
")",
"{",
"$",
"inMainTag",
"=",
"0",
";",
"$",
"foundMustTag",
"=",
"false",
";",
"foreach",
"(",
"$",
"actions",
"as",
"$",
"action",
")... | Verify some tags that must contain other tags
@param Node[] $actions
@param string $mainTag
@param string $mustTag
@return bool
@throws HtmlParsingException | [
"Verify",
"some",
"tags",
"that",
"must",
"contain",
"other",
"tags"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Parsing/Html.php#L195-L224 | train |
spipu/html2pdf | src/Parsing/Html.php | Html.getTextAction | protected function getTextAction(Token $token)
{
// action to use for each line of the content of a <pre> Tag
$tagPreBr = new Node('br', array('style' => array(), 'num' => 0), false);
$actions = array();
// if we are not in a <pre> tag
if (!$this->tagPreIn) {
//... | php | protected function getTextAction(Token $token)
{
// action to use for each line of the content of a <pre> Tag
$tagPreBr = new Node('br', array('style' => array(), 'num' => 0), false);
$actions = array();
// if we are not in a <pre> tag
if (!$this->tagPreIn) {
//... | [
"protected",
"function",
"getTextAction",
"(",
"Token",
"$",
"token",
")",
"{",
"// action to use for each line of the content of a <pre> Tag",
"$",
"tagPreBr",
"=",
"new",
"Node",
"(",
"'br'",
",",
"array",
"(",
"'style'",
"=>",
"array",
"(",
")",
",",
"'num'",
... | get the Text action
@param Token $token
@return array | [
"get",
"the",
"Text",
"action"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Parsing/Html.php#L304-L336 | train |
spipu/html2pdf | src/Parsing/Html.php | Html.prepareHtml | public function prepareHtml($html)
{
// if it is a real html page, we have to convert it
if (preg_match('/<body/isU', $html)) {
$html = $this->getHtmlFromRealPage($html);
}
// replace some constants
$html = str_replace('[[date_y]]', date('Y'), $html);
$ht... | php | public function prepareHtml($html)
{
// if it is a real html page, we have to convert it
if (preg_match('/<body/isU', $html)) {
$html = $this->getHtmlFromRealPage($html);
}
// replace some constants
$html = str_replace('[[date_y]]', date('Y'), $html);
$ht... | [
"public",
"function",
"prepareHtml",
"(",
"$",
"html",
")",
"{",
"// if it is a real html page, we have to convert it",
"if",
"(",
"preg_match",
"(",
"'/<body/isU'",
",",
"$",
"html",
")",
")",
"{",
"$",
"html",
"=",
"$",
"this",
"->",
"getHtmlFromRealPage",
"("... | prepare the HTML
@param string $html
@return string | [
"prepare",
"the",
"HTML"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Parsing/Html.php#L418-L435 | train |
spipu/html2pdf | src/Parsing/Html.php | Html.getHtmlFromRealPage | protected function getHtmlFromRealPage($html)
{
// set body tag to lower case
$html = str_replace('<BODY', '<body', $html);
$html = str_replace('</BODY', '</body', $html);
// explode from the body tag. If no body tag => end
$res = explode('<body', $html);
// the htm... | php | protected function getHtmlFromRealPage($html)
{
// set body tag to lower case
$html = str_replace('<BODY', '<body', $html);
$html = str_replace('</BODY', '</body', $html);
// explode from the body tag. If no body tag => end
$res = explode('<body', $html);
// the htm... | [
"protected",
"function",
"getHtmlFromRealPage",
"(",
"$",
"html",
")",
"{",
"// set body tag to lower case",
"$",
"html",
"=",
"str_replace",
"(",
"'<BODY'",
",",
"'<body'",
",",
"$",
"html",
")",
";",
"$",
"html",
"=",
"str_replace",
"(",
"'</BODY'",
",",
"... | convert the HTML of a real page, to a code adapted to Html2Pdf
@param string $html HTML code of a real page
@return string HTML adapted to Html2Pdf | [
"convert",
"the",
"HTML",
"of",
"a",
"real",
"page",
"to",
"a",
"code",
"adapted",
"to",
"Html2Pdf"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Parsing/Html.php#L443-L472 | train |
artesaos/seotools | src/SEOTools/SEOMeta.php | SEOMeta.generate | public function generate($minify = false)
{
$this->loadWebMasterTags();
$title = $this->getTitle();
$description = $this->getDescription();
$keywords = $this->getKeywords();
$metatags = $this->getMetatags();
$canonical = $this->getCanonical();
$amphtml = $thi... | php | public function generate($minify = false)
{
$this->loadWebMasterTags();
$title = $this->getTitle();
$description = $this->getDescription();
$keywords = $this->getKeywords();
$metatags = $this->getMetatags();
$canonical = $this->getCanonical();
$amphtml = $thi... | [
"public",
"function",
"generate",
"(",
"$",
"minify",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"loadWebMasterTags",
"(",
")",
";",
"$",
"title",
"=",
"$",
"this",
"->",
"getTitle",
"(",
")",
";",
"$",
"description",
"=",
"$",
"this",
"->",
"getDesc... | Generates meta tags.
@param bool $minify
@return string | [
"Generates",
"meta",
"tags",
"."
] | 041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9 | https://github.com/artesaos/seotools/blob/041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9/src/SEOTools/SEOMeta.php#L134-L201 | train |
artesaos/seotools | src/SEOTools/SEOMeta.php | SEOMeta.getDefaultTitle | public function getDefaultTitle()
{
if (empty($this->title_default)) {
return $this->config->get('defaults.title', null);
}
return $this->title_default;
} | php | public function getDefaultTitle()
{
if (empty($this->title_default)) {
return $this->config->get('defaults.title', null);
}
return $this->title_default;
} | [
"public",
"function",
"getDefaultTitle",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"title_default",
")",
")",
"{",
"return",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'defaults.title'",
",",
"null",
")",
";",
"}",
"return",
"$",
... | Takes the default title.
@return string | [
"Takes",
"the",
"default",
"title",
"."
] | 041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9 | https://github.com/artesaos/seotools/blob/041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9/src/SEOTools/SEOMeta.php#L463-L470 | train |
artesaos/seotools | src/SEOTools/SEOMeta.php | SEOMeta.getDescription | public function getDescription()
{
if (false === $this->description) {
return;
}
return $this->description ?: $this->config->get('defaults.description', null);
} | php | public function getDescription()
{
if (false === $this->description) {
return;
}
return $this->description ?: $this->config->get('defaults.description', null);
} | [
"public",
"function",
"getDescription",
"(",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"description",
")",
"{",
"return",
";",
"}",
"return",
"$",
"this",
"->",
"description",
"?",
":",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'d... | Get the Meta description.
@return string|null | [
"Get",
"the",
"Meta",
"description",
"."
] | 041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9 | https://github.com/artesaos/seotools/blob/041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9/src/SEOTools/SEOMeta.php#L517-L524 | train |
artesaos/seotools | src/SEOTools/SEOMeta.php | SEOMeta.getCanonical | public function getCanonical()
{
$canonical_config = $this->config->get('defaults.canonical', false);
return $this->canonical ?: (($canonical_config === null) ? app('url')->full() : $canonical_config);
} | php | public function getCanonical()
{
$canonical_config = $this->config->get('defaults.canonical', false);
return $this->canonical ?: (($canonical_config === null) ? app('url')->full() : $canonical_config);
} | [
"public",
"function",
"getCanonical",
"(",
")",
"{",
"$",
"canonical_config",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'defaults.canonical'",
",",
"false",
")",
";",
"return",
"$",
"this",
"->",
"canonical",
"?",
":",
"(",
"(",
"$",
"canonica... | Get the canonical URL.
@return string | [
"Get",
"the",
"canonical",
"URL",
"."
] | 041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9 | https://github.com/artesaos/seotools/blob/041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9/src/SEOTools/SEOMeta.php#L531-L536 | train |
artesaos/seotools | src/SEOTools/SEOMeta.php | SEOMeta.loadWebMasterTags | protected function loadWebMasterTags()
{
foreach ($this->config->get('webmaster_tags', []) as $name => $value) {
if (!empty($value)) {
$meta = array_get($this->webmasterTags, $name, $name);
$this->addMeta($meta, $value);
}
}
} | php | protected function loadWebMasterTags()
{
foreach ($this->config->get('webmaster_tags', []) as $name => $value) {
if (!empty($value)) {
$meta = array_get($this->webmasterTags, $name, $name);
$this->addMeta($meta, $value);
}
}
} | [
"protected",
"function",
"loadWebMasterTags",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'webmaster_tags'",
",",
"[",
"]",
")",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
... | Load webmaster tags from configuration. | [
"Load",
"webmaster",
"tags",
"from",
"configuration",
"."
] | 041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9 | https://github.com/artesaos/seotools/blob/041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9/src/SEOTools/SEOMeta.php#L624-L632 | train |
artesaos/seotools | src/SEOTools/SEOTools.php | SEOTools.setTitle | public function setTitle($title, $appendDefault = true)
{
$this->metatags()->setTitle($title, $appendDefault);
$this->opengraph()->setTitle($title);
$this->twitter()->setTitle($title);
$this->jsonLd()->setTitle($title);
return $this;
} | php | public function setTitle($title, $appendDefault = true)
{
$this->metatags()->setTitle($title, $appendDefault);
$this->opengraph()->setTitle($title);
$this->twitter()->setTitle($title);
$this->jsonLd()->setTitle($title);
return $this;
} | [
"public",
"function",
"setTitle",
"(",
"$",
"title",
",",
"$",
"appendDefault",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"metatags",
"(",
")",
"->",
"setTitle",
"(",
"$",
"title",
",",
"$",
"appendDefault",
")",
";",
"$",
"this",
"->",
"opengraph",
... | Setup title for all seo providers.
@param string $title
@param bool $appendDefault
@return \Artesaos\SEOTools\Contracts\SEOTools | [
"Setup",
"title",
"for",
"all",
"seo",
"providers",
"."
] | 041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9 | https://github.com/artesaos/seotools/blob/041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9/src/SEOTools/SEOTools.php#L50-L58 | train |
artesaos/seotools | src/SEOTools/SEOTools.php | SEOTools.setDescription | public function setDescription($description)
{
$this->metatags()->setDescription($description);
$this->opengraph()->setDescription($description);
$this->twitter()->setDescription($description);
$this->jsonLd()->setDescription($description);
return $this;
} | php | public function setDescription($description)
{
$this->metatags()->setDescription($description);
$this->opengraph()->setDescription($description);
$this->twitter()->setDescription($description);
$this->jsonLd()->setDescription($description);
return $this;
} | [
"public",
"function",
"setDescription",
"(",
"$",
"description",
")",
"{",
"$",
"this",
"->",
"metatags",
"(",
")",
"->",
"setDescription",
"(",
"$",
"description",
")",
";",
"$",
"this",
"->",
"opengraph",
"(",
")",
"->",
"setDescription",
"(",
"$",
"de... | Setup description for all seo providers.
@param $description
@return \Artesaos\SEOTools\Contracts\SEOTools | [
"Setup",
"description",
"for",
"all",
"seo",
"providers",
"."
] | 041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9 | https://github.com/artesaos/seotools/blob/041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9/src/SEOTools/SEOTools.php#L67-L75 | train |
artesaos/seotools | src/SEOTools/SEOTools.php | SEOTools.getTitle | public function getTitle($session = false)
{
if ($session) {
return $this->metatags()->getTitleSession();
}
return $this->metatags()->getTitle();
} | php | public function getTitle($session = false)
{
if ($session) {
return $this->metatags()->getTitleSession();
}
return $this->metatags()->getTitle();
} | [
"public",
"function",
"getTitle",
"(",
"$",
"session",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"session",
")",
"{",
"return",
"$",
"this",
"->",
"metatags",
"(",
")",
"->",
"getTitleSession",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"metatags... | Get current title from metatags.
@param bool $session
@return string | [
"Get",
"current",
"title",
"from",
"metatags",
"."
] | 041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9 | https://github.com/artesaos/seotools/blob/041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9/src/SEOTools/SEOTools.php#L118-L125 | train |
artesaos/seotools | src/SEOTools/SEOTools.php | SEOTools.generate | public function generate($minify = false)
{
$html = $this->metatags()->generate();
$html .= PHP_EOL;
$html .= $this->opengraph()->generate();
$html .= PHP_EOL;
$html .= $this->twitter()->generate();
$html .= PHP_EOL;
$html .= $this->jsonLd()->generate();
... | php | public function generate($minify = false)
{
$html = $this->metatags()->generate();
$html .= PHP_EOL;
$html .= $this->opengraph()->generate();
$html .= PHP_EOL;
$html .= $this->twitter()->generate();
$html .= PHP_EOL;
$html .= $this->jsonLd()->generate();
... | [
"public",
"function",
"generate",
"(",
"$",
"minify",
"=",
"false",
")",
"{",
"$",
"html",
"=",
"$",
"this",
"->",
"metatags",
"(",
")",
"->",
"generate",
"(",
")",
";",
"$",
"html",
".=",
"PHP_EOL",
";",
"$",
"html",
".=",
"$",
"this",
"->",
"op... | Generate from all seo providers.
@param bool $minify
@return string | [
"Generate",
"from",
"all",
"seo",
"providers",
"."
] | 041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9 | https://github.com/artesaos/seotools/blob/041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9/src/SEOTools/SEOTools.php#L134-L145 | train |
artesaos/seotools | src/SEOTools/OpenGraph.php | OpenGraph.generate | public function generate($minify = false)
{
$this->setupDefaults();
$output = $this->eachProperties($this->properties);
$props = [
'images' => ['image', true],
'articleProperties' => ['article', false],
'profileProperties... | php | public function generate($minify = false)
{
$this->setupDefaults();
$output = $this->eachProperties($this->properties);
$props = [
'images' => ['image', true],
'articleProperties' => ['article', false],
'profileProperties... | [
"public",
"function",
"generate",
"(",
"$",
"minify",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"setupDefaults",
"(",
")",
";",
"$",
"output",
"=",
"$",
"this",
"->",
"eachProperties",
"(",
"$",
"this",
"->",
"properties",
")",
";",
"$",
"props",
"=... | Generates open graph tags.
@param bool $minify
@return string | [
"Generates",
"open",
"graph",
"tags",
"."
] | 041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9 | https://github.com/artesaos/seotools/blob/041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9/src/SEOTools/OpenGraph.php#L161-L195 | train |
artesaos/seotools | src/SEOTools/OpenGraph.php | OpenGraph.eachProperties | protected function eachProperties(
array $properties,
$prefix = null,
$ogPrefix = true
) {
$html = [];
foreach ($properties as $property => $value) {
// multiple properties
if (is_array($value)) {
$subListPrefix = (is_string($property)... | php | protected function eachProperties(
array $properties,
$prefix = null,
$ogPrefix = true
) {
$html = [];
foreach ($properties as $property => $value) {
// multiple properties
if (is_array($value)) {
$subListPrefix = (is_string($property)... | [
"protected",
"function",
"eachProperties",
"(",
"array",
"$",
"properties",
",",
"$",
"prefix",
"=",
"null",
",",
"$",
"ogPrefix",
"=",
"true",
")",
"{",
"$",
"html",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"property",
"=>",
... | Make list of open graph tags.
@param array $properties array of properties
@param null|string $prefix prefix of property
@param bool $ogPrefix opengraph prefix
@return string | [
"Make",
"list",
"of",
"open",
"graph",
"tags",
"."
] | 041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9 | https://github.com/artesaos/seotools/blob/041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9/src/SEOTools/OpenGraph.php#L206-L239 | train |
artesaos/seotools | src/SEOTools/OpenGraph.php | OpenGraph.makeTag | protected function makeTag($key = null, $value = null, $ogPrefix = false)
{
return sprintf(
'<meta property="%s%s" content="%s" />%s',
$ogPrefix ? $this->og_prefix : '',
strip_tags($key),
strip_tags($value),
PHP_EOL
);
} | php | protected function makeTag($key = null, $value = null, $ogPrefix = false)
{
return sprintf(
'<meta property="%s%s" content="%s" />%s',
$ogPrefix ? $this->og_prefix : '',
strip_tags($key),
strip_tags($value),
PHP_EOL
);
} | [
"protected",
"function",
"makeTag",
"(",
"$",
"key",
"=",
"null",
",",
"$",
"value",
"=",
"null",
",",
"$",
"ogPrefix",
"=",
"false",
")",
"{",
"return",
"sprintf",
"(",
"'<meta property=\"%s%s\" content=\"%s\" />%s'",
",",
"$",
"ogPrefix",
"?",
"$",
"this",... | Make a og tag.
@param string $key meta property key
@param string $value meta property value
@param bool $ogPrefix opengraph prefix
@return string | [
"Make",
"a",
"og",
"tag",
"."
] | 041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9 | https://github.com/artesaos/seotools/blob/041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9/src/SEOTools/OpenGraph.php#L250-L259 | train |
artesaos/seotools | src/SEOTools/OpenGraph.php | OpenGraph.setupDefaults | protected function setupDefaults()
{
$defaults = (isset($this->config['defaults'])) ?
$this->config['defaults'] :
[];
foreach ($defaults as $key => $value) {
if ($key == 'images') {
if (empty($this->images)) {
$this->images = $... | php | protected function setupDefaults()
{
$defaults = (isset($this->config['defaults'])) ?
$this->config['defaults'] :
[];
foreach ($defaults as $key => $value) {
if ($key == 'images') {
if (empty($this->images)) {
$this->images = $... | [
"protected",
"function",
"setupDefaults",
"(",
")",
"{",
"$",
"defaults",
"=",
"(",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"'defaults'",
"]",
")",
")",
"?",
"$",
"this",
"->",
"config",
"[",
"'defaults'",
"]",
":",
"[",
"]",
";",
"foreach",
... | Add or update property.
@return void | [
"Add",
"or",
"update",
"property",
"."
] | 041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9 | https://github.com/artesaos/seotools/blob/041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9/src/SEOTools/OpenGraph.php#L266-L283 | train |
artesaos/seotools | src/SEOTools/OpenGraph.php | OpenGraph.addVideo | public function addVideo($source = null, $attributes = [])
{
$validKeys = [
'url',
'secure_url',
'type',
'width',
'height',
];
$this->videoProperties[] = [
$source,
$this->cleanProperties($attributes, $valid... | php | public function addVideo($source = null, $attributes = [])
{
$validKeys = [
'url',
'secure_url',
'type',
'width',
'height',
];
$this->videoProperties[] = [
$source,
$this->cleanProperties($attributes, $valid... | [
"public",
"function",
"addVideo",
"(",
"$",
"source",
"=",
"null",
",",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"$",
"validKeys",
"=",
"[",
"'url'",
",",
"'secure_url'",
",",
"'type'",
",",
"'width'",
",",
"'height'",
",",
"]",
";",
"$",
"this",
... | Add video properties.
@param string $source url of video source
@param array $attributes opengraph video attributes
@return OpenGraphContract | [
"Add",
"video",
"properties",
"."
] | 041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9 | https://github.com/artesaos/seotools/blob/041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9/src/SEOTools/OpenGraph.php#L603-L619 | train |
artesaos/seotools | src/SEOTools/OpenGraph.php | OpenGraph.addAudio | public function addAudio($source = null, $attributes = [])
{
$validKeys = [
'url',
'secure_url',
'type',
];
$this->audioProperties[] = [
$source,
$this->cleanProperties($attributes, $validKeys),
];
return $this;
... | php | public function addAudio($source = null, $attributes = [])
{
$validKeys = [
'url',
'secure_url',
'type',
];
$this->audioProperties[] = [
$source,
$this->cleanProperties($attributes, $validKeys),
];
return $this;
... | [
"public",
"function",
"addAudio",
"(",
"$",
"source",
"=",
"null",
",",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"$",
"validKeys",
"=",
"[",
"'url'",
",",
"'secure_url'",
",",
"'type'",
",",
"]",
";",
"$",
"this",
"->",
"audioProperties",
"[",
"]"... | Add audio properties.
@param string $source url for audio source
@param array $attributes opengraph audio attributes
@return OpenGraphContract | [
"Add",
"audio",
"properties",
"."
] | 041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9 | https://github.com/artesaos/seotools/blob/041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9/src/SEOTools/OpenGraph.php#L629-L643 | train |
artesaos/seotools | src/SEOTools/OpenGraph.php | OpenGraph.cleanProperties | protected function cleanProperties($attributes = [], $validKeys = [])
{
$array = [];
foreach ($attributes as $attribute => $value) {
if (in_array($attribute, $validKeys)) {
$array[$attribute] = $value;
}
}
return $array;
} | php | protected function cleanProperties($attributes = [], $validKeys = [])
{
$array = [];
foreach ($attributes as $attribute => $value) {
if (in_array($attribute, $validKeys)) {
$array[$attribute] = $value;
}
}
return $array;
} | [
"protected",
"function",
"cleanProperties",
"(",
"$",
"attributes",
"=",
"[",
"]",
",",
"$",
"validKeys",
"=",
"[",
"]",
")",
"{",
"$",
"array",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"attribute",
"=>",
"$",
"value",
")",
... | Clean invalid properties.
@param array $attributes attributes input
@param string[] $validKeys keys that are allowed
@return array | [
"Clean",
"invalid",
"properties",
"."
] | 041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9 | https://github.com/artesaos/seotools/blob/041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9/src/SEOTools/OpenGraph.php#L705-L716 | train |
artesaos/seotools | src/SEOTools/OpenGraph.php | OpenGraph.addImage | public function addImage($source = null, $attributes = [])
{
$validKeys = [
'url',
'secure_url',
'type',
'width',
'height',
];
if (is_array($source)) {
$this->images[] = $this->cleanProperties($source, $validKeys);
... | php | public function addImage($source = null, $attributes = [])
{
$validKeys = [
'url',
'secure_url',
'type',
'width',
'height',
];
if (is_array($source)) {
$this->images[] = $this->cleanProperties($source, $validKeys);
... | [
"public",
"function",
"addImage",
"(",
"$",
"source",
"=",
"null",
",",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"$",
"validKeys",
"=",
"[",
"'url'",
",",
"'secure_url'",
",",
"'type'",
",",
"'width'",
",",
"'height'",
",",
"]",
";",
"if",
"(",
... | Add image to properties.
@param mixed $source URL of image source
@param array $attributes Object type attributes
@return OpenGraphContract | [
"Add",
"image",
"to",
"properties",
"."
] | 041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9 | https://github.com/artesaos/seotools/blob/041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9/src/SEOTools/OpenGraph.php#L765-L785 | train |
artesaos/seotools | src/SEOTools/TwitterCards.php | TwitterCards.eachValue | protected function eachValue(array $values, $prefix = null)
{
foreach ($values as $key => $value):
if (is_array($value)):
$this->eachValue($value, $key); else:
if (is_numeric($key)):
$key = $prefix.$key; elseif (is_string($prefix)):
... | php | protected function eachValue(array $values, $prefix = null)
{
foreach ($values as $key => $value):
if (is_array($value)):
$this->eachValue($value, $key); else:
if (is_numeric($key)):
$key = $prefix.$key; elseif (is_string($prefix)):
... | [
"protected",
"function",
"eachValue",
"(",
"array",
"$",
"values",
",",
"$",
"prefix",
"=",
"null",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
":",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
":",
... | Make tags.
@param array $values
@param null|string $prefix
@internal param array $properties | [
"Make",
"tags",
"."
] | 041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9 | https://github.com/artesaos/seotools/blob/041576cfbe6c1f7aba9164bbe9d3a261fdcaf8d9/src/SEOTools/TwitterCards.php#L58-L71 | train |
timber/timber | lib/Loader.php | Loader.choose_template | public function choose_template( $templates ) {
// Change $templates into array, if needed
if ( !is_array($templates) ) {
$templates = (array) $templates;
}
// Get Twig loader
$loader = $this->get_loader();
// Run through template array
foreach ( $templates as $template ) {
// Remove any whitespa... | php | public function choose_template( $templates ) {
// Change $templates into array, if needed
if ( !is_array($templates) ) {
$templates = (array) $templates;
}
// Get Twig loader
$loader = $this->get_loader();
// Run through template array
foreach ( $templates as $template ) {
// Remove any whitespa... | [
"public",
"function",
"choose_template",
"(",
"$",
"templates",
")",
"{",
"// Change $templates into array, if needed",
"if",
"(",
"!",
"is_array",
"(",
"$",
"templates",
")",
")",
"{",
"$",
"templates",
"=",
"(",
"array",
")",
"$",
"templates",
";",
"}",
"/... | Get first existing template.
@param array|string $templates Name(s) of the Twig template(s) to choose from.
@return string|bool Name of chosen template, otherwise false. | [
"Get",
"first",
"existing",
"template",
"."
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/Loader.php#L95-L118 | train |
timber/timber | lib/Core.php | Core.import | public function import( $info, $force = false ) {
if ( is_object($info) ) {
$info = get_object_vars($info);
}
if ( is_array($info) ) {
foreach ( $info as $key => $value ) {
if ( $key === '' || ord($key[0]) === 0 ) {
continue;
}
if ( !empty($key) && $force ) {
$this->$key = $value;
... | php | public function import( $info, $force = false ) {
if ( is_object($info) ) {
$info = get_object_vars($info);
}
if ( is_array($info) ) {
foreach ( $info as $key => $value ) {
if ( $key === '' || ord($key[0]) === 0 ) {
continue;
}
if ( !empty($key) && $force ) {
$this->$key = $value;
... | [
"public",
"function",
"import",
"(",
"$",
"info",
",",
"$",
"force",
"=",
"false",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"info",
")",
")",
"{",
"$",
"info",
"=",
"get_object_vars",
"(",
"$",
"info",
")",
";",
"}",
"if",
"(",
"is_array",
"("... | Takes an array or object and adds the properties to the parent object
@example
```php
$data = array('airplane' => '757-200', 'flight' => '5316');
$post = new Timber\Post()
$post->import(data);
echo $post->airplane; //757-200
```
@param array|object $info an object or array you want to grab data from to attach to the Ti... | [
"Takes",
"an",
"array",
"or",
"object",
"and",
"adds",
"the",
"properties",
"to",
"the",
"parent",
"object"
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/Core.php#L59-L75 | train |
timber/timber | lib/URLHelper.php | URLHelper.is_external | public static function is_external( $url ) {
$has_http = strstr(strtolower($url), 'http') || strstr(strtolower($url), '//');
$on_domain = strstr($url, self::get_host());
if ( $has_http && ! $on_domain ) {
return true;
}
return false;
} | php | public static function is_external( $url ) {
$has_http = strstr(strtolower($url), 'http') || strstr(strtolower($url), '//');
$on_domain = strstr($url, self::get_host());
if ( $has_http && ! $on_domain ) {
return true;
}
return false;
} | [
"public",
"static",
"function",
"is_external",
"(",
"$",
"url",
")",
"{",
"$",
"has_http",
"=",
"strstr",
"(",
"strtolower",
"(",
"$",
"url",
")",
",",
"'http'",
")",
"||",
"strstr",
"(",
"strtolower",
"(",
"$",
"url",
")",
",",
"'//'",
")",
";",
"... | Checks if URL is external or internal.
Works with domains, subdomains and protocol relative domains.
@param string $url Url.
@return bool true if $path is an external url, false if relative or local.
true if it's a subdomain (http://cdn.example.org = true) | [
"Checks",
"if",
"URL",
"is",
"external",
"or",
"internal",
".",
"Works",
"with",
"domains",
"subdomains",
"and",
"protocol",
"relative",
"domains",
"."
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/URLHelper.php#L325-L332 | train |
timber/timber | lib/URLHelper.php | URLHelper.remove_url_component | public static function remove_url_component( $haystack, $needle ) {
$haystack = str_replace($needle, '', $haystack);
$needle = self::swap_protocol($needle);
return str_replace($needle, '', $haystack);
} | php | public static function remove_url_component( $haystack, $needle ) {
$haystack = str_replace($needle, '', $haystack);
$needle = self::swap_protocol($needle);
return str_replace($needle, '', $haystack);
} | [
"public",
"static",
"function",
"remove_url_component",
"(",
"$",
"haystack",
",",
"$",
"needle",
")",
"{",
"$",
"haystack",
"=",
"str_replace",
"(",
"$",
"needle",
",",
"''",
",",
"$",
"haystack",
")",
";",
"$",
"needle",
"=",
"self",
"::",
"swap_protoc... | Removes the subcomponent of a URL regardless of protocol
@since 1.3.3
@author jarednova
@param string $haystack ex: http://example.org/wp-content/uploads/dog.jpg
@param string $needle ex: http://example.org/wp-content
@return string | [
"Removes",
"the",
"subcomponent",
"of",
"a",
"URL",
"regardless",
"of",
"protocol"
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/URLHelper.php#L355-L359 | train |
timber/timber | lib/URLHelper.php | URLHelper.swap_protocol | public static function swap_protocol( $url ) {
if ( stristr($url, 'http:') ) {
return str_replace('http:', 'https:', $url);
}
if ( stristr($url, 'https:') ) {
return str_replace('https:', 'http:', $url);
}
return $url;
} | php | public static function swap_protocol( $url ) {
if ( stristr($url, 'http:') ) {
return str_replace('http:', 'https:', $url);
}
if ( stristr($url, 'https:') ) {
return str_replace('https:', 'http:', $url);
}
return $url;
} | [
"public",
"static",
"function",
"swap_protocol",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"stristr",
"(",
"$",
"url",
",",
"'http:'",
")",
")",
"{",
"return",
"str_replace",
"(",
"'http:'",
",",
"'https:'",
",",
"$",
"url",
")",
";",
"}",
"if",
"(",
"... | Swaps whatever protocol of a URL is sent. http becomes https and vice versa
@since 1.3.3
@author jarednova
@param string $url ex: http://example.org/wp-content/uploads/dog.jpg
@return string ex: https://example.org/wp-content/uploads/dog.jpg | [
"Swaps",
"whatever",
"protocol",
"of",
"a",
"URL",
"is",
"sent",
".",
"http",
"becomes",
"https",
"and",
"vice",
"versa"
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/URLHelper.php#L369-L377 | train |
timber/timber | lib/URLHelper.php | URLHelper.user_trailingslashit | public static function user_trailingslashit( $link ) {
$link_parts = parse_url($link);
if ( !$link_parts ) {
return $link;
}
if ( isset($link_parts['path']) && $link_parts['path'] != '/' ) {
$new_path = user_trailingslashit($link_parts['path']);
if ( $new_path != $link_parts['path'] ) {
$link = ... | php | public static function user_trailingslashit( $link ) {
$link_parts = parse_url($link);
if ( !$link_parts ) {
return $link;
}
if ( isset($link_parts['path']) && $link_parts['path'] != '/' ) {
$new_path = user_trailingslashit($link_parts['path']);
if ( $new_path != $link_parts['path'] ) {
$link = ... | [
"public",
"static",
"function",
"user_trailingslashit",
"(",
"$",
"link",
")",
"{",
"$",
"link_parts",
"=",
"parse_url",
"(",
"$",
"link",
")",
";",
"if",
"(",
"!",
"$",
"link_parts",
")",
"{",
"return",
"$",
"link",
";",
"}",
"if",
"(",
"isset",
"("... | Pass links through user_trailingslashit handling query strings properly
@param string $link
@return string | [
"Pass",
"links",
"through",
"user_trailingslashit",
"handling",
"query",
"strings",
"properly"
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/URLHelper.php#L385-L400 | train |
timber/timber | lib/Twig.php | Twig.process_term_args | protected static function process_term_args( $maybe_taxonomy, $TermClass ) {
// A user could be sending a TermClass in the first arg, let's test for that ...
if ( class_exists($maybe_taxonomy) ) {
$tc = new $maybe_taxonomy;
if ( is_subclass_of($tc, 'Timber\Term') ) {
return array('taxonomy' => '', 'TermCl... | php | protected static function process_term_args( $maybe_taxonomy, $TermClass ) {
// A user could be sending a TermClass in the first arg, let's test for that ...
if ( class_exists($maybe_taxonomy) ) {
$tc = new $maybe_taxonomy;
if ( is_subclass_of($tc, 'Timber\Term') ) {
return array('taxonomy' => '', 'TermCl... | [
"protected",
"static",
"function",
"process_term_args",
"(",
"$",
"maybe_taxonomy",
",",
"$",
"TermClass",
")",
"{",
"// A user could be sending a TermClass in the first arg, let's test for that ...",
"if",
"(",
"class_exists",
"(",
"$",
"maybe_taxonomy",
")",
")",
"{",
"... | Process the arguments for handle_term_object to determine what arguments the user is sending
@since 1.5.1
@author @jarednova
@param string $maybe_taxonomy probably a taxonomy, but it could be a Timber\Term subclass
@param string $TermClass a string for the Timber\Term subclass
@return array of processed arguments | [
"Process",
"the",
"arguments",
"for",
"handle_term_object",
"to",
"determine",
"what",
"arguments",
"the",
"user",
"is",
"sending"
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/Twig.php#L165-L174 | train |
timber/timber | lib/Twig.php | Twig.add_timber_escapers | public function add_timber_escapers( $twig ) {
$twig->getExtension('Twig_Extension_Core')->setEscaper('esc_url', function( \Twig_Environment $env, $string ) {
return esc_url($string);
});
$twig->getExtension('Twig_Extension_Core')->setEscaper('wp_kses_post', function( \Twig_Environment $env, $string ) {
re... | php | public function add_timber_escapers( $twig ) {
$twig->getExtension('Twig_Extension_Core')->setEscaper('esc_url', function( \Twig_Environment $env, $string ) {
return esc_url($string);
});
$twig->getExtension('Twig_Extension_Core')->setEscaper('wp_kses_post', function( \Twig_Environment $env, $string ) {
re... | [
"public",
"function",
"add_timber_escapers",
"(",
"$",
"twig",
")",
"{",
"$",
"twig",
"->",
"getExtension",
"(",
"'Twig_Extension_Core'",
")",
"->",
"setEscaper",
"(",
"'esc_url'",
",",
"function",
"(",
"\\",
"Twig_Environment",
"$",
"env",
",",
"$",
"string",... | Adds escapers to Twig.
@param \Twig\Environment $twig The Twig Environment.
@return \Twig\Environment | [
"Adds",
"escapers",
"to",
"Twig",
"."
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/Twig.php#L246-L265 | train |
timber/timber | lib/FunctionWrapper.php | FunctionWrapper.add_to_twig | public function add_to_twig( $twig ) {
$wrapper = $this;
try {
$twig->addFunction( new Twig_Function( $this->_function, function() use ( $wrapper ) {
return call_user_func_array( array( $wrapper, 'call' ), func_get_args() );
} ) );
// Use empty 'catch' block and not 'finally', because finally needs PH... | php | public function add_to_twig( $twig ) {
$wrapper = $this;
try {
$twig->addFunction( new Twig_Function( $this->_function, function() use ( $wrapper ) {
return call_user_func_array( array( $wrapper, 'call' ), func_get_args() );
} ) );
// Use empty 'catch' block and not 'finally', because finally needs PH... | [
"public",
"function",
"add_to_twig",
"(",
"$",
"twig",
")",
"{",
"$",
"wrapper",
"=",
"$",
"this",
";",
"try",
"{",
"$",
"twig",
"->",
"addFunction",
"(",
"new",
"Twig_Function",
"(",
"$",
"this",
"->",
"_function",
",",
"function",
"(",
")",
"use",
... | Make function available in Twig.
When a function is added more than once, addFunction() will throw a LogicException that states that the function
is already registered. By catching this exception, we can prevent a fatal error.
@see Twig_Extension_Staging::addFunction()
@deprecated since 1.3.0
@todo remove in 1.4.0
@p... | [
"Make",
"function",
"available",
"in",
"Twig",
"."
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/FunctionWrapper.php#L71-L83 | train |
timber/timber | lib/ImageHelper.php | ImageHelper.resize | public static function resize( $src, $w, $h = 0, $crop = 'default', $force = false ) {
if ( !is_numeric($w) && is_string($w) ) {
if ( $sizes = self::find_wp_dimensions($w) ) {
$w = $sizes['w'];
$h = $sizes['h'];
} else {
return $src;
}
}
$op = new Image\Operation\Resize($w, $h, $crop);
retu... | php | public static function resize( $src, $w, $h = 0, $crop = 'default', $force = false ) {
if ( !is_numeric($w) && is_string($w) ) {
if ( $sizes = self::find_wp_dimensions($w) ) {
$w = $sizes['w'];
$h = $sizes['h'];
} else {
return $src;
}
}
$op = new Image\Operation\Resize($w, $h, $crop);
retu... | [
"public",
"static",
"function",
"resize",
"(",
"$",
"src",
",",
"$",
"w",
",",
"$",
"h",
"=",
"0",
",",
"$",
"crop",
"=",
"'default'",
",",
"$",
"force",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"w",
")",
"&&",
"is_string... | Generates a new image with the specified dimensions.
New dimensions are achieved by cropping to maintain ratio.
@api
@param string $src an URL (absolute or relative) to the original image
@param int|string $w target width(int) or WordPress image size (WP-set or user-defined).
@param int $h target height (igno... | [
"Generates",
"a",
"new",
"image",
"with",
"the",
"specified",
"dimensions",
".",
"New",
"dimensions",
"are",
"achieved",
"by",
"cropping",
"to",
"maintain",
"ratio",
"."
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/ImageHelper.php#L61-L72 | train |
timber/timber | lib/ImageHelper.php | ImageHelper.find_wp_dimensions | private static function find_wp_dimensions( $size ) {
global $_wp_additional_image_sizes;
if ( isset($_wp_additional_image_sizes[$size]) ) {
$w = $_wp_additional_image_sizes[$size]['width'];
$h = $_wp_additional_image_sizes[$size]['height'];
} else if ( in_array($size, array('thumbnail', 'medium', 'large'))... | php | private static function find_wp_dimensions( $size ) {
global $_wp_additional_image_sizes;
if ( isset($_wp_additional_image_sizes[$size]) ) {
$w = $_wp_additional_image_sizes[$size]['width'];
$h = $_wp_additional_image_sizes[$size]['height'];
} else if ( in_array($size, array('thumbnail', 'medium', 'large'))... | [
"private",
"static",
"function",
"find_wp_dimensions",
"(",
"$",
"size",
")",
"{",
"global",
"$",
"_wp_additional_image_sizes",
";",
"if",
"(",
"isset",
"(",
"$",
"_wp_additional_image_sizes",
"[",
"$",
"size",
"]",
")",
")",
"{",
"$",
"w",
"=",
"$",
"_wp_... | Find the sizes of an image based on a defined image size
@param string $size the image size to search for
can be WordPress-defined ("medium")
or user-defined ("my-awesome-size")
@return false|array {
@type int w
@type int h
} | [
"Find",
"the",
"sizes",
"of",
"an",
"image",
"based",
"on",
"a",
"defined",
"image",
"size"
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/ImageHelper.php#L84-L97 | train |
timber/timber | lib/ImageHelper.php | ImageHelper.retina_resize | public static function retina_resize( $src, $multiplier = 2, $force = false ) {
$op = new Image\Operation\Retina($multiplier);
return self::_operate($src, $op, $force);
} | php | public static function retina_resize( $src, $multiplier = 2, $force = false ) {
$op = new Image\Operation\Retina($multiplier);
return self::_operate($src, $op, $force);
} | [
"public",
"static",
"function",
"retina_resize",
"(",
"$",
"src",
",",
"$",
"multiplier",
"=",
"2",
",",
"$",
"force",
"=",
"false",
")",
"{",
"$",
"op",
"=",
"new",
"Image",
"\\",
"Operation",
"\\",
"Retina",
"(",
"$",
"multiplier",
")",
";",
"retur... | Generates a new image with increased size, for display on Retina screens.
@param string $src
@param float $multiplier
@param boolean $force
@return string url to the new image | [
"Generates",
"a",
"new",
"image",
"with",
"increased",
"size",
"for",
"display",
"on",
"Retina",
"screens",
"."
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/ImageHelper.php#L108-L111 | train |
timber/timber | lib/ImageHelper.php | ImageHelper.is_animated_gif | public static function is_animated_gif( $file ) {
if ( strpos(strtolower($file), '.gif') === false ) {
//doesn't have .gif, bail
return false;
}
//its a gif so test
if ( !($fh = @fopen($file, 'rb')) ) {
return false;
}
$count = 0;
//an animated gif contains multiple "frames", with each frame ha... | php | public static function is_animated_gif( $file ) {
if ( strpos(strtolower($file), '.gif') === false ) {
//doesn't have .gif, bail
return false;
}
//its a gif so test
if ( !($fh = @fopen($file, 'rb')) ) {
return false;
}
$count = 0;
//an animated gif contains multiple "frames", with each frame ha... | [
"public",
"static",
"function",
"is_animated_gif",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"strpos",
"(",
"strtolower",
"(",
"$",
"file",
")",
",",
"'.gif'",
")",
"===",
"false",
")",
"{",
"//doesn't have .gif, bail",
"return",
"false",
";",
"}",
"//its a g... | checks to see if the given file is an aimated gif
@param string $file local filepath to a file, not a URL
@return boolean true if it's an animated gif, false if not | [
"checks",
"to",
"see",
"if",
"the",
"given",
"file",
"is",
"an",
"aimated",
"gif"
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/ImageHelper.php#L118-L143 | train |
timber/timber | lib/ImageHelper.php | ImageHelper.is_svg | public static function is_svg( $file_path ) {
if ( ! isset( $file_path ) || '' === $file_path || ! file_exists( $file_path ) ) {
return false;
}
if ( TextHelper::ends_with( strtolower($file_path), '.svg' ) ) {
return true;
}
/**
* Try reading mime type.
*
* SVG images are not allowed by defau... | php | public static function is_svg( $file_path ) {
if ( ! isset( $file_path ) || '' === $file_path || ! file_exists( $file_path ) ) {
return false;
}
if ( TextHelper::ends_with( strtolower($file_path), '.svg' ) ) {
return true;
}
/**
* Try reading mime type.
*
* SVG images are not allowed by defau... | [
"public",
"static",
"function",
"is_svg",
"(",
"$",
"file_path",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"file_path",
")",
"||",
"''",
"===",
"$",
"file_path",
"||",
"!",
"file_exists",
"(",
"$",
"file_path",
")",
")",
"{",
"return",
"false",
";... | Checks if file is an SVG.
@param string $file_path File path to check.
@return bool True if SVG, false if not SVG or file doesn't exist. | [
"Checks",
"if",
"file",
"is",
"an",
"SVG",
"."
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/ImageHelper.php#L151-L176 | train |
timber/timber | lib/ImageHelper.php | ImageHelper.letterbox | public static function letterbox( $src, $w, $h, $color = false, $force = false ) {
$op = new Letterbox($w, $h, $color);
return self::_operate($src, $op, $force);
} | php | public static function letterbox( $src, $w, $h, $color = false, $force = false ) {
$op = new Letterbox($w, $h, $color);
return self::_operate($src, $op, $force);
} | [
"public",
"static",
"function",
"letterbox",
"(",
"$",
"src",
",",
"$",
"w",
",",
"$",
"h",
",",
"$",
"color",
"=",
"false",
",",
"$",
"force",
"=",
"false",
")",
"{",
"$",
"op",
"=",
"new",
"Letterbox",
"(",
"$",
"w",
",",
"$",
"h",
",",
"$"... | Generate a new image with the specified dimensions.
New dimensions are achieved by adding colored bands to maintain ratio.
@param string $src
@param int $w
@param int $h
@param string $color
@param bool $force
@return string | [
"Generate",
"a",
"new",
"image",
"with",
"the",
"specified",
"dimensions",
".",
"New",
"dimensions",
"are",
"achieved",
"by",
"adding",
"colored",
"bands",
"to",
"maintain",
"ratio",
"."
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/ImageHelper.php#L189-L192 | train |
timber/timber | lib/ImageHelper.php | ImageHelper.img_to_jpg | public static function img_to_jpg( $src, $bghex = '#FFFFFF', $force = false ) {
$op = new Image\Operation\ToJpg($bghex);
return self::_operate($src, $op, $force);
} | php | public static function img_to_jpg( $src, $bghex = '#FFFFFF', $force = false ) {
$op = new Image\Operation\ToJpg($bghex);
return self::_operate($src, $op, $force);
} | [
"public",
"static",
"function",
"img_to_jpg",
"(",
"$",
"src",
",",
"$",
"bghex",
"=",
"'#FFFFFF'",
",",
"$",
"force",
"=",
"false",
")",
"{",
"$",
"op",
"=",
"new",
"Image",
"\\",
"Operation",
"\\",
"ToJpg",
"(",
"$",
"bghex",
")",
";",
"return",
... | Generates a new image by converting the source GIF or PNG into JPG
@param string $src a url or path to the image (http://example.org/wp-content/uploads/2014/image.jpg) or (/wp-content/uploads/2014/image.jpg)
@param string $bghex
@return string | [
"Generates",
"a",
"new",
"image",
"by",
"converting",
"the",
"source",
"GIF",
"or",
"PNG",
"into",
"JPG"
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/ImageHelper.php#L201-L204 | train |
timber/timber | lib/ImageHelper.php | ImageHelper.img_to_webp | public static function img_to_webp( $src, $quality = 80, $force = false ) {
$op = new Image\Operation\ToWebp($quality);
return self::_operate($src, $op, $force);
} | php | public static function img_to_webp( $src, $quality = 80, $force = false ) {
$op = new Image\Operation\ToWebp($quality);
return self::_operate($src, $op, $force);
} | [
"public",
"static",
"function",
"img_to_webp",
"(",
"$",
"src",
",",
"$",
"quality",
"=",
"80",
",",
"$",
"force",
"=",
"false",
")",
"{",
"$",
"op",
"=",
"new",
"Image",
"\\",
"Operation",
"\\",
"ToWebp",
"(",
"$",
"quality",
")",
";",
"return",
"... | Generates a new image by converting the source into WEBP if supported by the server
@param string $src a url or path to the image (http://example.org/wp-content/uploads/2014/image.webp)
or (/wp-content/uploads/2014/image.jpg)
If webp is not supported, a jpeg image will be generated
@param int $quality range... | [
"Generates",
"a",
"new",
"image",
"by",
"converting",
"the",
"source",
"into",
"WEBP",
"if",
"supported",
"by",
"the",
"server"
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/ImageHelper.php#L215-L218 | train |
timber/timber | lib/ImageHelper.php | ImageHelper._delete_generated_if_image | public static function _delete_generated_if_image( $post_id ) {
if ( wp_attachment_is_image($post_id) ) {
$attachment = new Image($post_id);
if ( $attachment->file_loc ) {
ImageHelper::delete_generated_files($attachment->file_loc);
}
}
} | php | public static function _delete_generated_if_image( $post_id ) {
if ( wp_attachment_is_image($post_id) ) {
$attachment = new Image($post_id);
if ( $attachment->file_loc ) {
ImageHelper::delete_generated_files($attachment->file_loc);
}
}
} | [
"public",
"static",
"function",
"_delete_generated_if_image",
"(",
"$",
"post_id",
")",
"{",
"if",
"(",
"wp_attachment_is_image",
"(",
"$",
"post_id",
")",
")",
"{",
"$",
"attachment",
"=",
"new",
"Image",
"(",
"$",
"post_id",
")",
";",
"if",
"(",
"$",
"... | Checks if attachment is an image before deleting generated files
@param int $post_id an attachment post id | [
"Checks",
"if",
"attachment",
"is",
"an",
"image",
"before",
"deleting",
"generated",
"files"
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/ImageHelper.php#L265-L272 | train |
timber/timber | lib/ImageHelper.php | ImageHelper.delete_generated_files | static function delete_generated_files( $local_file ) {
if ( URLHelper::is_absolute($local_file) ) {
$local_file = URLHelper::url_to_file_system($local_file);
}
$info = pathinfo($local_file);
$dir = $info['dirname'];
$ext = $info['extension'];
$filename = $info['filename'];
self::process_delete_generat... | php | static function delete_generated_files( $local_file ) {
if ( URLHelper::is_absolute($local_file) ) {
$local_file = URLHelper::url_to_file_system($local_file);
}
$info = pathinfo($local_file);
$dir = $info['dirname'];
$ext = $info['extension'];
$filename = $info['filename'];
self::process_delete_generat... | [
"static",
"function",
"delete_generated_files",
"(",
"$",
"local_file",
")",
"{",
"if",
"(",
"URLHelper",
"::",
"is_absolute",
"(",
"$",
"local_file",
")",
")",
"{",
"$",
"local_file",
"=",
"URLHelper",
"::",
"url_to_file_system",
"(",
"$",
"local_file",
")",
... | Deletes the auto-generated files for resize and letterboxing created by Timber
@param string $local_file ex: /var/www/wp-content/uploads/2015/my-pic.jpg
or: http://example.org/wp-content/uploads/2015/my-pic.jpg | [
"Deletes",
"the",
"auto",
"-",
"generated",
"files",
"for",
"resize",
"and",
"letterboxing",
"created",
"by",
"Timber"
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/ImageHelper.php#L280-L292 | train |
timber/timber | lib/ImageHelper.php | ImageHelper.process_delete_generated_files | protected static function process_delete_generated_files( $filename, $ext, $dir, $search_pattern, $match_pattern = null ) {
$searcher = '/'.$filename.$search_pattern;
$files = glob($dir.$searcher);
if ( $files === false || empty($files) ) {
return;
}
foreach ( $files as $found_file ) {
$pattern = '/'.pr... | php | protected static function process_delete_generated_files( $filename, $ext, $dir, $search_pattern, $match_pattern = null ) {
$searcher = '/'.$filename.$search_pattern;
$files = glob($dir.$searcher);
if ( $files === false || empty($files) ) {
return;
}
foreach ( $files as $found_file ) {
$pattern = '/'.pr... | [
"protected",
"static",
"function",
"process_delete_generated_files",
"(",
"$",
"filename",
",",
"$",
"ext",
",",
"$",
"dir",
",",
"$",
"search_pattern",
",",
"$",
"match_pattern",
"=",
"null",
")",
"{",
"$",
"searcher",
"=",
"'/'",
".",
"$",
"filename",
".... | Deletes resized versions of the supplied file name.
So if passed a value like my-pic.jpg, this function will delete my-pic-500x200-c-left.jpg, my-pic-400x400-c-default.jpg, etc.
keeping these here so I know what the hell we're matching
$match = preg_match("/\/srv\/www\/wordpress-develop\/src\/wp-content\/uploads\/2014... | [
"Deletes",
"resized",
"versions",
"of",
"the",
"supplied",
"file",
"name",
".",
"So",
"if",
"passed",
"a",
"value",
"like",
"my",
"-",
"pic",
".",
"jpg",
"this",
"function",
"will",
"delete",
"my",
"-",
"pic",
"-",
"500x200",
"-",
"c",
"-",
"left",
"... | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/ImageHelper.php#L308-L321 | train |
timber/timber | lib/ImageHelper.php | ImageHelper.get_server_location | public static function get_server_location( $url ) {
// if we're already an absolute dir, just return.
if ( 0 === strpos($url, ABSPATH) ) {
return $url;
}
// otherwise, analyze URL then build mapping path
$au = self::analyze_url($url);
$result = self::_get_file_path($au['base'], $au['subdir'], $au['basen... | php | public static function get_server_location( $url ) {
// if we're already an absolute dir, just return.
if ( 0 === strpos($url, ABSPATH) ) {
return $url;
}
// otherwise, analyze URL then build mapping path
$au = self::analyze_url($url);
$result = self::_get_file_path($au['base'], $au['subdir'], $au['basen... | [
"public",
"static",
"function",
"get_server_location",
"(",
"$",
"url",
")",
"{",
"// if we're already an absolute dir, just return.",
"if",
"(",
"0",
"===",
"strpos",
"(",
"$",
"url",
",",
"ABSPATH",
")",
")",
"{",
"return",
"$",
"url",
";",
"}",
"// otherwis... | Determines the filepath corresponding to a given URL
@param string $url
@return string | [
"Determines",
"the",
"filepath",
"corresponding",
"to",
"a",
"given",
"URL"
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/ImageHelper.php#L329-L338 | train |
timber/timber | lib/ImageHelper.php | ImageHelper.get_sideloaded_file_loc | public static function get_sideloaded_file_loc( $file ) {
$upload = wp_upload_dir();
$dir = $upload['path'];
$filename = $file;
$file = parse_url($file);
$path_parts = pathinfo($file['path']);
$basename = md5($filename);
$ext = 'jpg';
if ( isset($path_parts['extension']) ) {
$ext = $path_parts['exten... | php | public static function get_sideloaded_file_loc( $file ) {
$upload = wp_upload_dir();
$dir = $upload['path'];
$filename = $file;
$file = parse_url($file);
$path_parts = pathinfo($file['path']);
$basename = md5($filename);
$ext = 'jpg';
if ( isset($path_parts['extension']) ) {
$ext = $path_parts['exten... | [
"public",
"static",
"function",
"get_sideloaded_file_loc",
"(",
"$",
"file",
")",
"{",
"$",
"upload",
"=",
"wp_upload_dir",
"(",
")",
";",
"$",
"dir",
"=",
"$",
"upload",
"[",
"'path'",
"]",
";",
"$",
"filename",
"=",
"$",
"file",
";",
"$",
"file",
"... | Determines the filepath where a given external file will be stored.
@param string $file
@return string | [
"Determines",
"the",
"filepath",
"where",
"a",
"given",
"external",
"file",
"will",
"be",
"stored",
"."
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/ImageHelper.php#L346-L358 | train |
timber/timber | lib/ImageHelper.php | ImageHelper.sideload_image | public static function sideload_image( $file ) {
$loc = self::get_sideloaded_file_loc($file);
if ( file_exists($loc) ) {
return URLHelper::file_system_to_url($loc);
}
// Download file to temp location
if ( !function_exists('download_url') ) {
require_once ABSPATH.'/wp-admin/includes/file.php';
}
$tm... | php | public static function sideload_image( $file ) {
$loc = self::get_sideloaded_file_loc($file);
if ( file_exists($loc) ) {
return URLHelper::file_system_to_url($loc);
}
// Download file to temp location
if ( !function_exists('download_url') ) {
require_once ABSPATH.'/wp-admin/includes/file.php';
}
$tm... | [
"public",
"static",
"function",
"sideload_image",
"(",
"$",
"file",
")",
"{",
"$",
"loc",
"=",
"self",
"::",
"get_sideloaded_file_loc",
"(",
"$",
"file",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"loc",
")",
")",
"{",
"return",
"URLHelper",
"::",
"... | downloads an external image to the server and stores it on the server
@param string $file the URL to the original file
@return string the URL to the downloaded file | [
"downloads",
"an",
"external",
"image",
"to",
"the",
"server",
"and",
"stores",
"it",
"on",
"the",
"server"
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/ImageHelper.php#L366-L389 | train |
timber/timber | lib/ImageHelper.php | ImageHelper.analyze_url | public static function analyze_url( $url ) {
$result = array(
'url' => $url, // the initial url
'absolute' => URLHelper::is_absolute($url), // is the url absolute or relative (to home_url)
'base' => 0, // is the image in uploads dir, or in content dir (theme or plugin)
'subdir' => '', // the path between ... | php | public static function analyze_url( $url ) {
$result = array(
'url' => $url, // the initial url
'absolute' => URLHelper::is_absolute($url), // is the url absolute or relative (to home_url)
'base' => 0, // is the image in uploads dir, or in content dir (theme or plugin)
'subdir' => '', // the path between ... | [
"public",
"static",
"function",
"analyze_url",
"(",
"$",
"url",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'url'",
"=>",
"$",
"url",
",",
"// the initial url",
"'absolute'",
"=>",
"URLHelper",
"::",
"is_absolute",
"(",
"$",
"url",
")",
",",
"// is the ur... | Takes in an URL and breaks it into components,
that will then be used in the different steps of image processing.
The image is expected to be either part of a theme, plugin, or an upload.
@param string $url an URL (absolute or relative) pointing to an image
@return array an array (see keys in code below) | [
"Takes",
"in",
"an",
"URL",
"and",
"breaks",
"it",
"into",
"components",
"that",
"will",
"then",
"be",
"used",
"in",
"the",
"different",
"steps",
"of",
"image",
"processing",
".",
"The",
"image",
"is",
"expected",
"to",
"be",
"either",
"part",
"of",
"a",... | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/ImageHelper.php#L399-L441 | train |
timber/timber | lib/ImageHelper.php | ImageHelper.theme_url_to_dir | static function theme_url_to_dir( $src ) {
$site_root = trailingslashit(get_theme_root_uri()).get_stylesheet();
$tmp = str_replace($site_root, '', $src);
//$tmp = trailingslashit(get_theme_root()).get_stylesheet().$tmp;
$tmp = get_stylesheet_directory().$tmp;
if ( realpath($tmp) ) {
return realpath($tmp);... | php | static function theme_url_to_dir( $src ) {
$site_root = trailingslashit(get_theme_root_uri()).get_stylesheet();
$tmp = str_replace($site_root, '', $src);
//$tmp = trailingslashit(get_theme_root()).get_stylesheet().$tmp;
$tmp = get_stylesheet_directory().$tmp;
if ( realpath($tmp) ) {
return realpath($tmp);... | [
"static",
"function",
"theme_url_to_dir",
"(",
"$",
"src",
")",
"{",
"$",
"site_root",
"=",
"trailingslashit",
"(",
"get_theme_root_uri",
"(",
")",
")",
".",
"get_stylesheet",
"(",
")",
";",
"$",
"tmp",
"=",
"str_replace",
"(",
"$",
"site_root",
",",
"''",... | Converts a URL located in a theme directory into the raw file path
@param string $src a URL (http://example.org/wp-content/themes/twentysixteen/images/home.jpg)
@return string full path to the file in question | [
"Converts",
"a",
"URL",
"located",
"in",
"a",
"theme",
"directory",
"into",
"the",
"raw",
"file",
"path"
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/ImageHelper.php#L448-L457 | train |
timber/timber | lib/ImageHelper.php | ImageHelper.is_in_theme_dir | protected static function is_in_theme_dir( $path ) {
$root = realpath(get_stylesheet_directory());
if ( false === $root ) {
return false;
}
if ( 0 === strpos($path, (string) $root) ) {
return true;
} else {
return false;
}
} | php | protected static function is_in_theme_dir( $path ) {
$root = realpath(get_stylesheet_directory());
if ( false === $root ) {
return false;
}
if ( 0 === strpos($path, (string) $root) ) {
return true;
} else {
return false;
}
} | [
"protected",
"static",
"function",
"is_in_theme_dir",
"(",
"$",
"path",
")",
"{",
"$",
"root",
"=",
"realpath",
"(",
"get_stylesheet_directory",
"(",
")",
")",
";",
"if",
"(",
"false",
"===",
"$",
"root",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(... | Checks if uploaded image is located in theme.
@param string $path image path.
@return bool If the image is located in the theme directory it returns true.
If not or $path doesn't exits it returns false. | [
"Checks",
"if",
"uploaded",
"image",
"is",
"located",
"in",
"theme",
"."
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/ImageHelper.php#L466-L478 | train |
timber/timber | lib/ImageHelper.php | ImageHelper._get_file_url | private static function _get_file_url( $base, $subdir, $filename, $absolute ) {
$url = '';
if ( self::BASE_UPLOADS == $base ) {
$upload_dir = wp_upload_dir();
$url = $upload_dir['baseurl'];
}
if ( self::BASE_CONTENT == $base ) {
$url = content_url();
}
if ( !empty($subdir) ) {
$url .= $subdir;
... | php | private static function _get_file_url( $base, $subdir, $filename, $absolute ) {
$url = '';
if ( self::BASE_UPLOADS == $base ) {
$upload_dir = wp_upload_dir();
$url = $upload_dir['baseurl'];
}
if ( self::BASE_CONTENT == $base ) {
$url = content_url();
}
if ( !empty($subdir) ) {
$url .= $subdir;
... | [
"private",
"static",
"function",
"_get_file_url",
"(",
"$",
"base",
",",
"$",
"subdir",
",",
"$",
"filename",
",",
"$",
"absolute",
")",
"{",
"$",
"url",
"=",
"''",
";",
"if",
"(",
"self",
"::",
"BASE_UPLOADS",
"==",
"$",
"base",
")",
"{",
"$",
"up... | Builds the public URL of a file based on its different components
@param int $base one of self::BASE_UPLOADS, self::BASE_CONTENT to indicate if file is an upload or a content (theme or plugin)
@param string $subdir subdirectory in which file is stored, relative to $base root folder
@param string $filename ... | [
"Builds",
"the",
"public",
"URL",
"of",
"a",
"file",
"based",
"on",
"its",
"different",
"components"
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/ImageHelper.php#L489-L507 | train |
timber/timber | lib/ImageHelper.php | ImageHelper._get_file_path | private static function _get_file_path( $base, $subdir, $filename ) {
if ( URLHelper::is_url($subdir) ) {
$subdir = URLHelper::url_to_file_system($subdir);
}
$subdir = self::maybe_realpath($subdir);
$path = '';
if ( self::BASE_UPLOADS == $base ) {
//it is in the Uploads directory
$upload_dir = wp_up... | php | private static function _get_file_path( $base, $subdir, $filename ) {
if ( URLHelper::is_url($subdir) ) {
$subdir = URLHelper::url_to_file_system($subdir);
}
$subdir = self::maybe_realpath($subdir);
$path = '';
if ( self::BASE_UPLOADS == $base ) {
//it is in the Uploads directory
$upload_dir = wp_up... | [
"private",
"static",
"function",
"_get_file_path",
"(",
"$",
"base",
",",
"$",
"subdir",
",",
"$",
"filename",
")",
"{",
"if",
"(",
"URLHelper",
"::",
"is_url",
"(",
"$",
"subdir",
")",
")",
"{",
"$",
"subdir",
"=",
"URLHelper",
"::",
"url_to_file_system... | Builds the absolute file system location of a file based on its different components
@param int $base one of self::BASE_UPLOADS, self::BASE_CONTENT to indicate if file is an upload or a content (theme or plugin)
@param string $subdir subdirectory in which file is stored, relative to $base root folder
@param... | [
"Builds",
"the",
"absolute",
"file",
"system",
"location",
"of",
"a",
"file",
"based",
"on",
"its",
"different",
"components"
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/ImageHelper.php#L530-L555 | train |
timber/timber | lib/PostQuery.php | PostQuery.pagination | public function pagination( $prefs = array() ) {
if ( !$this->pagination && is_a($this->queryIterator, 'Timber\QueryIterator') ) {
$this->pagination = $this->queryIterator->get_pagination($prefs, $this->get_query());
}
return $this->pagination;
} | php | public function pagination( $prefs = array() ) {
if ( !$this->pagination && is_a($this->queryIterator, 'Timber\QueryIterator') ) {
$this->pagination = $this->queryIterator->get_pagination($prefs, $this->get_query());
}
return $this->pagination;
} | [
"public",
"function",
"pagination",
"(",
"$",
"prefs",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"pagination",
"&&",
"is_a",
"(",
"$",
"this",
"->",
"queryIterator",
",",
"'Timber\\QueryIterator'",
")",
")",
"{",
"$",
"this",... | Set pagination for the collection. Optionally could be used to get pagination with custom preferences.
@param array $prefs
@return Timber\Pagination object | [
"Set",
"pagination",
"for",
"the",
"collection",
".",
"Optionally",
"could",
"be",
"used",
"to",
"get",
"pagination",
"with",
"custom",
"preferences",
"."
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/PostQuery.php#L49-L54 | train |
timber/timber | lib/Menu.php | Menu.find_parent_item_in_menu | public function find_parent_item_in_menu( $menu_items, $parent_id ) {
foreach ( $menu_items as &$item ) {
if ( $item->ID == $parent_id ) {
return $item;
}
}
} | php | public function find_parent_item_in_menu( $menu_items, $parent_id ) {
foreach ( $menu_items as &$item ) {
if ( $item->ID == $parent_id ) {
return $item;
}
}
} | [
"public",
"function",
"find_parent_item_in_menu",
"(",
"$",
"menu_items",
",",
"$",
"parent_id",
")",
"{",
"foreach",
"(",
"$",
"menu_items",
"as",
"&",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"->",
"ID",
"==",
"$",
"parent_id",
")",
"{",
"retur... | Find a parent menu item in a set of menu items.
@api
@param array $menu_items An array of menu items.
@param int $parent_id The parent ID to look for.
@return \Timber\MenuItem|bool A menu item. False if no parent was found. | [
"Find",
"a",
"parent",
"menu",
"item",
"in",
"a",
"set",
"of",
"menu",
"items",
"."
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/Menu.php#L234-L240 | train |
timber/timber | lib/Admin.php | Admin.in_plugin_update_message | public static function in_plugin_update_message( $plugin_data, $r ) {
$current_version = $plugin_data['Version'];
$new_version = $plugin_data['new_version'];
$upgrade_magnitude = self::get_upgrade_magnitude($current_version, $new_version);
if ( $upgrade_magnitude == 'milestone' ) {
$message = self::update_me... | php | public static function in_plugin_update_message( $plugin_data, $r ) {
$current_version = $plugin_data['Version'];
$new_version = $plugin_data['new_version'];
$upgrade_magnitude = self::get_upgrade_magnitude($current_version, $new_version);
if ( $upgrade_magnitude == 'milestone' ) {
$message = self::update_me... | [
"public",
"static",
"function",
"in_plugin_update_message",
"(",
"$",
"plugin_data",
",",
"$",
"r",
")",
"{",
"$",
"current_version",
"=",
"$",
"plugin_data",
"[",
"'Version'",
"]",
";",
"$",
"new_version",
"=",
"$",
"plugin_data",
"[",
"'new_version'",
"]",
... | Displays an update message for plugin list screens.
Shows only the version updates from the current until the newest version
@codeCoverageIgnore
@type function
@date 4/22/16
@param {array} $plugin_data
@param {object} $r | [
"Displays",
"an",
"update",
"message",
"for",
"plugin",
"list",
"screens",
".",
"Shows",
"only",
"the",
"version",
"updates",
"from",
"the",
"current",
"until",
"the",
"newest",
"version"
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/Admin.php#L103-L121 | train |
timber/timber | lib/TextHelper.php | TextHelper.trim_characters | public static function trim_characters( $text, $num_chars = 60, $more = '…' ) {
$text = wp_strip_all_tags($text);
$text = mb_strimwidth($text, 0, $num_chars, $more);
return $text;
} | php | public static function trim_characters( $text, $num_chars = 60, $more = '…' ) {
$text = wp_strip_all_tags($text);
$text = mb_strimwidth($text, 0, $num_chars, $more);
return $text;
} | [
"public",
"static",
"function",
"trim_characters",
"(",
"$",
"text",
",",
"$",
"num_chars",
"=",
"60",
",",
"$",
"more",
"=",
"'…'",
")",
"{",
"$",
"text",
"=",
"wp_strip_all_tags",
"(",
"$",
"text",
")",
";",
"$",
"text",
"=",
"mb_strimwidth",
... | Trims text to a certain number of characters.
This function can be useful for excerpt of the post
As opposed to wp_trim_words trims characters that makes text to
take the same amount of space in each post for example
@since 1.2.0
@author @CROSP
@param string $text Text to trim.
@param int $num_chars Num... | [
"Trims",
"text",
"to",
"a",
"certain",
"number",
"of",
"characters",
".",
"This",
"function",
"can",
"be",
"useful",
"for",
"excerpt",
"of",
"the",
"post",
"As",
"opposed",
"to",
"wp_trim_words",
"trims",
"characters",
"that",
"makes",
"text",
"to",
"take",
... | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/TextHelper.php#L24-L28 | train |
timber/timber | lib/LocationManager.php | LocationManager.get_calling_script_file | public static function get_calling_script_file( $offset = 0 ) {
$callers = array();
$backtrace = debug_backtrace();
foreach ( $backtrace as $trace ) {
if ( array_key_exists('file', $trace) && $trace['file'] != __FILE__ ) {
$callers[] = $trace['file'];
}
}
$callers = array_unique($callers);
$call... | php | public static function get_calling_script_file( $offset = 0 ) {
$callers = array();
$backtrace = debug_backtrace();
foreach ( $backtrace as $trace ) {
if ( array_key_exists('file', $trace) && $trace['file'] != __FILE__ ) {
$callers[] = $trace['file'];
}
}
$callers = array_unique($callers);
$call... | [
"public",
"static",
"function",
"get_calling_script_file",
"(",
"$",
"offset",
"=",
"0",
")",
"{",
"$",
"callers",
"=",
"array",
"(",
")",
";",
"$",
"backtrace",
"=",
"debug_backtrace",
"(",
")",
";",
"foreach",
"(",
"$",
"backtrace",
"as",
"$",
"trace",... | Get calling script file.
@api
@param int $offset
@return string|null | [
"Get",
"calling",
"script",
"file",
"."
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/LocationManager.php#L63-L74 | train |
timber/timber | lib/LocationManager.php | LocationManager.get_calling_script_dir | public static function get_calling_script_dir( $offset = 0 ) {
$caller = self::get_calling_script_file($offset);
if ( !is_null($caller) ) {
$pathinfo = pathinfo($caller);
$dir = $pathinfo['dirname'];
return $dir;
}
} | php | public static function get_calling_script_dir( $offset = 0 ) {
$caller = self::get_calling_script_file($offset);
if ( !is_null($caller) ) {
$pathinfo = pathinfo($caller);
$dir = $pathinfo['dirname'];
return $dir;
}
} | [
"public",
"static",
"function",
"get_calling_script_dir",
"(",
"$",
"offset",
"=",
"0",
")",
"{",
"$",
"caller",
"=",
"self",
"::",
"get_calling_script_file",
"(",
"$",
"offset",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"caller",
")",
")",
"{",
"... | Get calling script dir.
@api
@return string | [
"Get",
"calling",
"script",
"dir",
"."
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/LocationManager.php#L81-L88 | train |
timber/timber | lib/Image/Operation/Retina.php | Retina.filename | public function filename( $src_filename, $src_extension ) {
$newbase = $src_filename.'@'.$this->factor.'x'; // add @2x, @3x, @1.5x, etc.
$new_name = $newbase.'.'.$src_extension;
return $new_name;
} | php | public function filename( $src_filename, $src_extension ) {
$newbase = $src_filename.'@'.$this->factor.'x'; // add @2x, @3x, @1.5x, etc.
$new_name = $newbase.'.'.$src_extension;
return $new_name;
} | [
"public",
"function",
"filename",
"(",
"$",
"src_filename",
",",
"$",
"src_extension",
")",
"{",
"$",
"newbase",
"=",
"$",
"src_filename",
".",
"'@'",
".",
"$",
"this",
"->",
"factor",
".",
"'x'",
";",
"// add @2x, @3x, @1.5x, etc.",
"$",
"new_name",
"=",
... | Generates the final filename based on the source's name and extension
@param string $src_filename the basename of the file (ex: my-awesome-pic)
@param string $src_extension the extension (ex: .jpg)
@return string the final filename to be used (ex: my-awesome-pic@2x.jpg) | [
"Generates",
"the",
"final",
"filename",
"based",
"on",
"the",
"source",
"s",
"name",
"and",
"extension"
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/Image/Operation/Retina.php#L38-L42 | train |
timber/timber | lib/Timber.php | Timber.get_sites | public static function get_sites( $blog_ids = false ) {
if ( !is_array($blog_ids) ) {
global $wpdb;
$blog_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs ORDER BY blog_id ASC");
}
$return = array();
foreach ( $blog_ids as $blog_id ) {
$return[] = new Site($blog_id);
}
return $return;
} | php | public static function get_sites( $blog_ids = false ) {
if ( !is_array($blog_ids) ) {
global $wpdb;
$blog_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs ORDER BY blog_id ASC");
}
$return = array();
foreach ( $blog_ids as $blog_id ) {
$return[] = new Site($blog_id);
}
return $return;
} | [
"public",
"static",
"function",
"get_sites",
"(",
"$",
"blog_ids",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"blog_ids",
")",
")",
"{",
"global",
"$",
"wpdb",
";",
"$",
"blog_ids",
"=",
"$",
"wpdb",
"->",
"get_col",
"(",
"\"SELECT... | Get sites.
@api
@param array|bool $blog_ids
@return array | [
"Get",
"sites",
"."
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/Timber.php#L212-L222 | train |
timber/timber | lib/Timber.php | Timber.compile | public static function compile( $filenames, $data = array(), $expires = false, $cache_mode = Loader::CACHE_USE_DEFAULT, $via_render = false ) {
if ( !defined('TIMBER_LOADED') ) {
self::init();
}
$caller = LocationManager::get_calling_script_dir(1);
$loader = new Loader($caller);
$file = $loader->choose_tem... | php | public static function compile( $filenames, $data = array(), $expires = false, $cache_mode = Loader::CACHE_USE_DEFAULT, $via_render = false ) {
if ( !defined('TIMBER_LOADED') ) {
self::init();
}
$caller = LocationManager::get_calling_script_dir(1);
$loader = new Loader($caller);
$file = $loader->choose_tem... | [
"public",
"static",
"function",
"compile",
"(",
"$",
"filenames",
",",
"$",
"data",
"=",
"array",
"(",
")",
",",
"$",
"expires",
"=",
"false",
",",
"$",
"cache_mode",
"=",
"Loader",
"::",
"CACHE_USE_DEFAULT",
",",
"$",
"via_render",
"=",
"false",
")",
... | Compile a Twig file.
Passes data to a Twig file and returns the output.
@api
@example
```php
$data = array(
'firstname' => 'Jane',
'lastname' => 'Doe',
'email' => 'jane.doe@example.org',
);
$team_member = Timber::compile( 'team-member.twig', $data );
```
@param array|string $filenames Name of the Twig file to rende... | [
"Compile",
"a",
"Twig",
"file",
"."
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/Timber.php#L303-L338 | train |
timber/timber | lib/Timber.php | Timber.compile_string | public static function compile_string( $string, $data = array() ) {
$dummy_loader = new Loader();
$twig = $dummy_loader->get_twig();
$template = $twig->createTemplate($string);
return $template->render($data);
} | php | public static function compile_string( $string, $data = array() ) {
$dummy_loader = new Loader();
$twig = $dummy_loader->get_twig();
$template = $twig->createTemplate($string);
return $template->render($data);
} | [
"public",
"static",
"function",
"compile_string",
"(",
"$",
"string",
",",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"$",
"dummy_loader",
"=",
"new",
"Loader",
"(",
")",
";",
"$",
"twig",
"=",
"$",
"dummy_loader",
"->",
"get_twig",
"(",
")",
";"... | Compile a string.
@api
@example
```php
$data = array(
'username' => 'Jane Doe',
);
$welcome = Timber::compile_string( 'Hi {{ username }}, I’m a string with a custom Twig variable', $data );
```
@param string $string A string with Twig variables.
@param array $data Optional. An array of data to use in Twig template... | [
"Compile",
"a",
"string",
"."
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/Timber.php#L356-L361 | train |
timber/timber | lib/Timber.php | Timber.fetch | public static function fetch( $filenames, $data = array(), $expires = false, $cache_mode = Loader::CACHE_USE_DEFAULT ) {
$output = self::compile($filenames, $data, $expires, $cache_mode, true);
$output = apply_filters('timber_compile_result', $output);
return $output;
} | php | public static function fetch( $filenames, $data = array(), $expires = false, $cache_mode = Loader::CACHE_USE_DEFAULT ) {
$output = self::compile($filenames, $data, $expires, $cache_mode, true);
$output = apply_filters('timber_compile_result', $output);
return $output;
} | [
"public",
"static",
"function",
"fetch",
"(",
"$",
"filenames",
",",
"$",
"data",
"=",
"array",
"(",
")",
",",
"$",
"expires",
"=",
"false",
",",
"$",
"cache_mode",
"=",
"Loader",
"::",
"CACHE_USE_DEFAULT",
")",
"{",
"$",
"output",
"=",
"self",
"::",
... | Fetch function.
@api
@param array|string $filenames Name of the Twig file to render. If this is an array of files, Timber will
render the first file that exists.
@param array $data Optional. An array of data to use in Twig template.
@param bool|int $expires Optional. In seconds. Use false to disab... | [
"Fetch",
"function",
"."
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/Timber.php#L376-L380 | train |
timber/timber | lib/Timber.php | Timber.render_string | public static function render_string( $string, $data = array() ) {
$compiled = self::compile_string($string, $data);
echo $compiled;
return $compiled;
} | php | public static function render_string( $string, $data = array() ) {
$compiled = self::compile_string($string, $data);
echo $compiled;
return $compiled;
} | [
"public",
"static",
"function",
"render_string",
"(",
"$",
"string",
",",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"$",
"compiled",
"=",
"self",
"::",
"compile_string",
"(",
"$",
"string",
",",
"$",
"data",
")",
";",
"echo",
"$",
"compiled",
";... | Render a string with Twig variables.
@api
@example
```php
$data = array(
'username' => 'Jane Doe',
);
Timber::render_string( 'Hi {{ username }}, I’m a string with a custom Twig variable', $data );
```
@param string $string A string with Twig variables.
@param array $data An array of data to use in Twig template.
@... | [
"Render",
"a",
"string",
"with",
"Twig",
"variables",
"."
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/Timber.php#L425-L429 | train |
timber/timber | lib/Timber.php | Timber.get_sidebar | public static function get_sidebar( $sidebar = 'sidebar.php', $data = array() ) {
if ( strstr(strtolower($sidebar), '.php') ) {
return self::get_sidebar_from_php($sidebar, $data);
}
return self::compile($sidebar, $data);
} | php | public static function get_sidebar( $sidebar = 'sidebar.php', $data = array() ) {
if ( strstr(strtolower($sidebar), '.php') ) {
return self::get_sidebar_from_php($sidebar, $data);
}
return self::compile($sidebar, $data);
} | [
"public",
"static",
"function",
"get_sidebar",
"(",
"$",
"sidebar",
"=",
"'sidebar.php'",
",",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"strstr",
"(",
"strtolower",
"(",
"$",
"sidebar",
")",
",",
"'.php'",
")",
")",
"{",
"return",
"s... | Get sidebar.
@api
@param string $sidebar
@param array $data
@return bool|string | [
"Get",
"sidebar",
"."
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/Timber.php#L442-L447 | train |
timber/timber | lib/Timber.php | Timber.get_sidebar_from_php | public static function get_sidebar_from_php( $sidebar = '', $data ) {
$caller = LocationManager::get_calling_script_dir(1);
$uris = LocationManager::get_locations($caller);
ob_start();
$found = false;
foreach ( $uris as $uri ) {
if ( file_exists(trailingslashit($uri).$sidebar) ) {
include trailingslash... | php | public static function get_sidebar_from_php( $sidebar = '', $data ) {
$caller = LocationManager::get_calling_script_dir(1);
$uris = LocationManager::get_locations($caller);
ob_start();
$found = false;
foreach ( $uris as $uri ) {
if ( file_exists(trailingslashit($uri).$sidebar) ) {
include trailingslash... | [
"public",
"static",
"function",
"get_sidebar_from_php",
"(",
"$",
"sidebar",
"=",
"''",
",",
"$",
"data",
")",
"{",
"$",
"caller",
"=",
"LocationManager",
"::",
"get_calling_script_dir",
"(",
"1",
")",
";",
"$",
"uris",
"=",
"LocationManager",
"::",
"get_loc... | Get sidebar from PHP
@api
@param string $sidebar
@param array $data
@return string | [
"Get",
"sidebar",
"from",
"PHP"
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/Timber.php#L456-L474 | train |
timber/timber | lib/Image/Operation.php | Operation.hexrgb | public static function hexrgb( $hexstr ) {
if ( !strstr($hexstr, '#') ) {
$hexstr = '#'.$hexstr;
}
if ( strlen($hexstr) == 4 ) {
$hexstr = '#'.$hexstr[1].$hexstr[1].$hexstr[2].$hexstr[2].$hexstr[3].$hexstr[3];
}
$int = hexdec($hexstr);
return array("red" => 0xFF & ($int >> 0x10), "green" => 0xFF & ($i... | php | public static function hexrgb( $hexstr ) {
if ( !strstr($hexstr, '#') ) {
$hexstr = '#'.$hexstr;
}
if ( strlen($hexstr) == 4 ) {
$hexstr = '#'.$hexstr[1].$hexstr[1].$hexstr[2].$hexstr[2].$hexstr[3].$hexstr[3];
}
$int = hexdec($hexstr);
return array("red" => 0xFF & ($int >> 0x10), "green" => 0xFF & ($i... | [
"public",
"static",
"function",
"hexrgb",
"(",
"$",
"hexstr",
")",
"{",
"if",
"(",
"!",
"strstr",
"(",
"$",
"hexstr",
",",
"'#'",
")",
")",
"{",
"$",
"hexstr",
"=",
"'#'",
".",
"$",
"hexstr",
";",
"}",
"if",
"(",
"strlen",
"(",
"$",
"hexstr",
"... | Helper method to convert hex string to rgb array
@param string $hexstr hex color string (like '#FF1455')
@return array array('red', 'green', 'blue') to int
ex: array('red' => 255, 'green' => 20, 'blue' => 85); | [
"Helper",
"method",
"to",
"convert",
"hex",
"string",
"to",
"rgb",
"array"
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/Image/Operation.php#L43-L52 | train |
timber/timber | lib/Term.php | Term.get_posts | public function get_posts( $numberposts_or_args = 10, $post_type_or_class = 'any', $post_class = '' ) {
if ( !strlen($post_class) ) {
$post_class = $this->PostClass;
}
$default_tax_query = array(array(
'field' => 'term_id',
'terms' => $this->ID,
'taxonomy' => $this->taxonomy,
));
if ( is_string(... | php | public function get_posts( $numberposts_or_args = 10, $post_type_or_class = 'any', $post_class = '' ) {
if ( !strlen($post_class) ) {
$post_class = $this->PostClass;
}
$default_tax_query = array(array(
'field' => 'term_id',
'terms' => $this->ID,
'taxonomy' => $this->taxonomy,
));
if ( is_string(... | [
"public",
"function",
"get_posts",
"(",
"$",
"numberposts_or_args",
"=",
"10",
",",
"$",
"post_type_or_class",
"=",
"'any'",
",",
"$",
"post_class",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"strlen",
"(",
"$",
"post_class",
")",
")",
"{",
"$",
"post_class",
... | Get posts that have the current term assigned.
@internal
@param int|array $numberposts_or_args Optional. Either the number of posts or an array of
arguments for the post query that this method is going.
to perform. Default `10`.
@param string $post_type_or_class Optional. Either the post type to get or the name of... | [
"Get",
"posts",
"that",
"have",
"the",
"current",
"term",
"assigned",
"."
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/Term.php#L264-L306 | train |
timber/timber | lib/QueryIterator.php | QueryIterator.fix_number_posts_wp_quirk | public static function fix_number_posts_wp_quirk( $query ) {
if ( isset($query->query) && isset($query->query['numberposts'])
&& !isset($query->query['posts_per_page']) ) {
$query->set('posts_per_page', $query->query['numberposts']);
}
return $query;
} | php | public static function fix_number_posts_wp_quirk( $query ) {
if ( isset($query->query) && isset($query->query['numberposts'])
&& !isset($query->query['posts_per_page']) ) {
$query->set('posts_per_page', $query->query['numberposts']);
}
return $query;
} | [
"public",
"static",
"function",
"fix_number_posts_wp_quirk",
"(",
"$",
"query",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"query",
"->",
"query",
")",
"&&",
"isset",
"(",
"$",
"query",
"->",
"query",
"[",
"'numberposts'",
"]",
")",
"&&",
"!",
"isset",
"(... | get_posts users numberposts | [
"get_posts",
"users",
"numberposts"
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/QueryIterator.php#L149-L155 | train |
timber/timber | lib/QueryIterator.php | QueryIterator.fix_cat_wp_quirk | public static function fix_cat_wp_quirk( $query ) {
if ( isset($query->query) && isset($query->query['category'])
&& !isset($query->query['cat']) ) {
$query->set('cat', $query->query['category']);
unset($query->query['category']);
}
return $query;
} | php | public static function fix_cat_wp_quirk( $query ) {
if ( isset($query->query) && isset($query->query['category'])
&& !isset($query->query['cat']) ) {
$query->set('cat', $query->query['category']);
unset($query->query['category']);
}
return $query;
} | [
"public",
"static",
"function",
"fix_cat_wp_quirk",
"(",
"$",
"query",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"query",
"->",
"query",
")",
"&&",
"isset",
"(",
"$",
"query",
"->",
"query",
"[",
"'category'",
"]",
")",
"&&",
"!",
"isset",
"(",
"$",
... | get_posts uses category, WP_Query uses cat. Why? who knows... | [
"get_posts",
"uses",
"category",
"WP_Query",
"uses",
"cat",
".",
"Why?",
"who",
"knows",
"..."
] | baaa1960193cffb5fa7c43c09114d6831764eede | https://github.com/timber/timber/blob/baaa1960193cffb5fa7c43c09114d6831764eede/lib/QueryIterator.php#L158-L165 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.