_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 33 8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q21300 | Debug.addStep | train | public function addStep($name, $level = null)
{
// if true : UP
if ($level === true) {
$this->level++;
}
$time = microtime(true);
$usage = memory_get_usage();
$peak = memory_get_peak_usage();
$type = ($level === true ? ' Begin' : ($level === fa... | php | {
"resource": ""
} |
q21301 | CssConverter.convertBackground | train | public function convertBackground($css, &$value)
{
// is there a image ?
$text = '/url\(([^)]*)\)/isU';
if (preg_match($text, $css, $match)) {
// get the image
$value['image'] = $this->convertBackgroundImage($match[0]);
// remove if from the css propertie... | php | {
"resource": ""
} |
q21302 | CssConverter.convertBackgroundColor | train | public function convertBackgroundColor($css)
{
$res = null;
if ($css === 'transparent') {
return null; | php | {
"resource": ""
} |
q21303 | CssConverter.convertBackgroundRepeat | train | public function convertBackgroundRepeat($css)
{
switch ($css) {
case 'repeat':
return array(true, true);
case 'repeat-x':
return array(true, false);
case 'repeat-y':
| php | {
"resource": ""
} |
q21304 | Html2Pdf.loadExtensions | train | protected function loadExtensions()
{
if ($this->extensionsLoaded) {
return;
}
foreach ($this->extensions as $extension) {
foreach ($extension->getTags() as $tag) {
if (!$tag instanceof TagInterface) {
| php | {
"resource": ""
} |
q21305 | Html2Pdf.addTagObject | train | protected function addTagObject(TagInterface $tagObject)
{
$tagName = strtolower($tagObject->getName());
| php | {
"resource": ""
} |
q21306 | Html2Pdf.getTagObject | train | protected function getTagObject($tagName)
{
if (!$this->extensionsLoaded) {
$this->loadExtensions();
}
if (!array_key_exists($tagName, $this->tagObjects)) {
return null;
}
| php | {
"resource": ""
} |
q21307 | Html2Pdf.setModeDebug | train | public function setModeDebug(DebugInterface $debugObject = null)
{
if (is_null($debugObject)) {
$this->debug = new Debug();
} else {
| php | {
"resource": ""
} |
q21308 | Html2Pdf.addFont | train | public function addFont($family, $style = '', $file = '')
{
| php | {
"resource": ""
} |
q21309 | Html2Pdf.createIndex | train | public function createIndex(
$titre = 'Index',
$sizeTitle = 20,
$sizeBookmark = 15,
$bookmarkTitle = true,
$displayPage = true,
$onPage = null,
$fontName = null,
$marginTop = null
) {
if ($fontName === null) {
$fontName = 'helvetica... | php | {
"resource": ""
} |
q21310 | Html2Pdf.writeHTML | train | public function writeHTML($html)
{
$html = $this->parsingHtml->prepareHtml($html);
$html = $this->parsingCss->extractStyle($html);
| php | {
"resource": ""
} |
q21311 | Html2Pdf.previewHTML | train | public function previewHTML($html)
{
$html = $this->parsingHtml->prepareHtml($html);
$html = preg_replace('/<page([^>]*)>/isU', '<hr>Page : $1<hr><div$1>', $html);
$html = preg_replace('/<page_header([^>]*)>/isU', '<hr>Page Header : $1<hr><div$1>', $html);
$html = preg_replace('/<pa... | php | {
"resource": ""
} |
q21312 | Html2Pdf.initSubHtml | train | public function initSubHtml($format, $orientation, $marge, $page, $defLIST, $myLastPageGroup, $myLastPageGroupNb)
{
$this->_isSubPart = true;
$this->parsingCss->setOnlyLeft();
$this->_setNewPage($format, $orientation, null, null, ($myLastPageGroup !== null));
$this->_saveMargin(0,... | php | {
"resource": ""
} |
q21313 | Html2Pdf.setDefaultMargins | train | protected function setDefaultMargins($margins)
{
if (!is_array($margins)) {
$margins = array($margins, $margins, $margins, $margins);
}
if (!isset($margins[2])) {
$margins[2] = $margins[0];
}
if (!isset($margins[3])) {
$margins[3] = 8;
... | php | {
"resource": ""
} |
q21314 | Html2Pdf.setMargins | train | 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 | {
"resource": ""
} |
q21315 | Html2Pdf._addMargins | train | 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 | {
"resource": ""
} |
q21316 | Html2Pdf._setPageHeader | train | 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 | {
"resource": ""
} |
q21317 | Html2Pdf._setPageFooter | train | 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 | {
"resource": ""
} |
q21318 | Html2Pdf._setNewLine | train | protected function _setNewLine($h, $curr = null)
{
| php | {
"resource": ""
} |
q21319 | Html2Pdf.createSubHTML | train | 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 | {
"resource": ""
} |
q21320 | Html2Pdf._listeArab2Rom | train | 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 | {
"resource": ""
} |
q21321 | Html2Pdf._listeGetLi | train | 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 | {
"resource": ""
} |
q21322 | Html2Pdf._listeAddLevel | train | 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 | {
"resource": ""
} |
q21323 | Html2Pdf._listeDelLevel | train | protected function _listeDelLevel()
{
if (count($this->_defList)) {
| php | {
"resource": ""
} |
q21324 | Html2Pdf._makeHTMLcode | train | 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 | {
"resource": ""
} |
q21325 | Html2Pdf._executeAction | train | 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 | {
"resource": ""
} |
q21326 | Html2Pdf._getElementY | train | protected function _getElementY($h)
{
if ($this->_subPart || $this->_isSubPart || | php | {
"resource": ""
} |
q21327 | Html2Pdf._makeBreakLine | train | 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 {
| php | {
"resource": ""
} |
q21328 | Html2Pdf._tag_close_PAGE_FOOTER_SUB | train | 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 | {
"resource": ""
} |
q21329 | Html2Pdf._INDEX_NewPage | train | 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;
| php | {
"resource": ""
} |
q21330 | MyPdf.Footer | train | 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 | {
"resource": ""
} |
q21331 | MyPdf.cloneFontFrom | train | 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 | {
"resource": ""
} |
q21332 | MyPdf.isLoadedFont | train | public function isLoadedFont($fontKey)
{
if (isset($this->fonts[$fontKey])) {
return true;
}
| php | {
"resource": ""
} |
q21333 | MyPdf.setWordSpacing | train | public function setWordSpacing($ws = 0.)
{
$this->ws = $ws;
| php | {
"resource": ""
} |
q21334 | MyPdf.setTranslate | train | 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
| php | {
"resource": ""
} |
q21335 | MyPdf.setRotation | train | 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 | {
"resource": ""
} |
q21336 | MyPdf.svgLine | train | public function svgLine($x1, $y1, $x2, $y2)
{
// get the Closing operator
$op='S';
// drawing
| php | {
"resource": ""
} |
q21337 | MyPdf.svgEllipse | train | public function svgEllipse($x0, $y0, $rx, $ry, $style)
{
// get the Closing operator from the PDF Style
if ($style === 'F') {
$op='f';
| php | {
"resource": ""
} |
q21338 | MyPdf.doTransform | train | 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 | {
"resource": ""
} |
q21339 | MyPdf.myBarcode | train | 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 | {
"resource": ""
} |
q21340 | MyPdf.getMyAliasNbPages | train | public function getMyAliasNbPages()
{
if ($this->_myLastPageGroupNb == 0) {
return $this->getAliasNbPages();
} else {
| php | {
"resource": ""
} |
q21341 | HtmlLexer.tokenize | train | 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 | {
"resource": ""
} |
q21342 | ExceptionFormatter.getAdditionalData | train | 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 | {
"resource": ""
} |
q21343 | ExceptionFormatter.buildTextMessage | train | 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 | {
"resource": ""
} |
q21344 | ExceptionFormatter.buildHtmlMessage | train | 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 | {
"resource": ""
} |
q21345 | Html.getCloneCodes | train | public function getCloneCodes()
{
$codes = array();
foreach ($this->code as $key => $code) {
| php | {
"resource": ""
} |
q21346 | Html.verifyMustContain | train | protected function verifyMustContain(&$actions, $mainTag, $mustTag)
{
$inMainTag = 0;
$foundMustTag = false;
foreach ($actions as $action) {
if ($action->getName() == $mainTag && !$action->isClose()) {
$inMainTag++;
$foundMustTag = false;
... | php | {
"resource": ""
} |
q21347 | Html.getTextAction | train | 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 | {
"resource": ""
} |
q21348 | Html.prepareHtml | train | 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 | {
"resource": ""
} |
q21349 | Html.getHtmlFromRealPage | train | 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 | {
"resource": ""
} |
q21350 | SEOMeta.generate | train | 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 | {
"resource": ""
} |
q21351 | SEOMeta.getDefaultTitle | train | public function getDefaultTitle()
{
if (empty($this->title_default)) { | php | {
"resource": ""
} |
q21352 | SEOMeta.getDescription | train | public function getDescription()
{
if (false === $this->description) {
| php | {
"resource": ""
} |
q21353 | SEOMeta.getCanonical | train | public function getCanonical()
{
$canonical_config = $this->config->get('defaults.canonical', false);
| php | {
"resource": ""
} |
q21354 | SEOMeta.loadWebMasterTags | train | protected function loadWebMasterTags()
{
foreach ($this->config->get('webmaster_tags', []) as $name => $value) {
| php | {
"resource": ""
} |
q21355 | SEOTools.setTitle | train | public function setTitle($title, $appendDefault = true)
{
$this->metatags()->setTitle($title, $appendDefault);
| php | {
"resource": ""
} |
q21356 | SEOTools.setDescription | train | public function setDescription($description)
{
$this->metatags()->setDescription($description);
$this->opengraph()->setDescription($description); | php | {
"resource": ""
} |
q21357 | SEOTools.getTitle | train | public function getTitle($session = false)
{
if ($session) {
| php | {
"resource": ""
} |
q21358 | SEOTools.generate | train | 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;
| php | {
"resource": ""
} |
q21359 | OpenGraph.generate | train | public function generate($minify = false)
{
$this->setupDefaults();
$output = $this->eachProperties($this->properties);
$props = [
'images' => ['image', true],
'articleProperties' => ['article', false],
'profileProperties... | php | {
"resource": ""
} |
q21360 | OpenGraph.eachProperties | train | 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 | {
"resource": ""
} |
q21361 | OpenGraph.makeTag | train | protected function makeTag($key = null, $value = null, $ogPrefix = false)
{
return sprintf(
'<meta property="%s%s" content="%s" />%s',
$ogPrefix ? $this->og_prefix | php | {
"resource": ""
} |
q21362 | OpenGraph.setupDefaults | train | 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 | {
"resource": ""
} |
q21363 | OpenGraph.addVideo | train | public function addVideo($source = null, $attributes = [])
{
$validKeys = [
'url',
'secure_url',
'type',
'width',
'height',
];
| php | {
"resource": ""
} |
q21364 | OpenGraph.addAudio | train | public function addAudio($source = null, $attributes = [])
{
$validKeys = [
'url',
'secure_url',
'type',
];
$this->audioProperties[] = [
| php | {
"resource": ""
} |
q21365 | OpenGraph.cleanProperties | train | protected function cleanProperties($attributes = [], $validKeys = [])
{
$array = [];
foreach ($attributes as $attribute => $value) {
if | php | {
"resource": ""
} |
q21366 | OpenGraph.addImage | train | public function addImage($source = null, $attributes = [])
{
$validKeys = [
'url',
'secure_url',
'type',
'width',
'height',
];
if (is_array($source)) {
$this->images[] = $this->cleanProperties($source, $validKeys);
... | php | {
"resource": ""
} |
q21367 | TwitterCards.eachValue | train | 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)):
| php | {
"resource": ""
} |
q21368 | Loader.choose_template | train | 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 | {
"resource": ""
} |
q21369 | Core.import | train | 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 ( | php | {
"resource": ""
} |
q21370 | URLHelper.is_external | train | public static function is_external( $url ) {
$has_http = strstr(strtolower($url), 'http') || strstr(strtolower($url), | php | {
"resource": ""
} |
q21371 | URLHelper.remove_url_component | train | public static function remove_url_component( $haystack, $needle ) {
$haystack = str_replace($needle, '', $haystack);
| php | {
"resource": ""
} |
q21372 | URLHelper.swap_protocol | train | public static function swap_protocol( $url ) {
if ( stristr($url, 'http:') ) {
return str_replace('http:', 'https:', $url);
}
if ( | php | {
"resource": ""
} |
q21373 | URLHelper.user_trailingslashit | train | 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 ( | php | {
"resource": ""
} |
q21374 | Twig.process_term_args | train | 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') ) { | php | {
"resource": ""
} |
q21375 | Twig.add_timber_escapers | train | 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 | {
"resource": ""
} |
q21376 | FunctionWrapper.add_to_twig | train | 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() );
} ) | php | {
"resource": ""
} |
q21377 | ImageHelper.resize | train | 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']; | php | {
"resource": ""
} |
q21378 | ImageHelper.find_wp_dimensions | train | 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 | {
"resource": ""
} |
q21379 | ImageHelper.retina_resize | train | public static function retina_resize( $src, $multiplier = 2, $force = false | php | {
"resource": ""
} |
q21380 | ImageHelper.is_animated_gif | train | 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 | {
"resource": ""
} |
q21381 | ImageHelper.is_svg | train | 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 | {
"resource": ""
} |
q21382 | ImageHelper.letterbox | train | public static function letterbox( $src, $w, $h, $color = false, $force = false ) {
$op = new | php | {
"resource": ""
} |
q21383 | ImageHelper.img_to_jpg | train | public static function img_to_jpg( $src, $bghex = '#FFFFFF', $force = false ) {
$op = new | php | {
"resource": ""
} |
q21384 | ImageHelper.img_to_webp | train | public static function img_to_webp( $src, $quality = 80, $force = false ) {
| php | {
"resource": ""
} |
q21385 | ImageHelper._delete_generated_if_image | train | public static function _delete_generated_if_image( $post_id ) {
if ( wp_attachment_is_image($post_id) ) | php | {
"resource": ""
} |
q21386 | ImageHelper.delete_generated_files | train | 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 | {
"resource": ""
} |
q21387 | ImageHelper.process_delete_generated_files | train | 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 | php | {
"resource": ""
} |
q21388 | ImageHelper.get_server_location | train | 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 | php | {
"resource": ""
} |
q21389 | ImageHelper.get_sideloaded_file_loc | train | 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 | php | {
"resource": ""
} |
q21390 | ImageHelper.sideload_image | train | 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 | {
"resource": ""
} |
q21391 | ImageHelper.analyze_url | train | 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 | {
"resource": ""
} |
q21392 | ImageHelper.theme_url_to_dir | train | 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;
| php | {
"resource": ""
} |
q21393 | ImageHelper.is_in_theme_dir | train | protected static function is_in_theme_dir( $path ) {
$root = realpath(get_stylesheet_directory());
if ( false === $root ) {
return false;
} | php | {
"resource": ""
} |
q21394 | ImageHelper._get_file_url | train | 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 | {
"resource": ""
} |
q21395 | ImageHelper._get_file_path | train | 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 | {
"resource": ""
} |
q21396 | PostQuery.pagination | train | public function pagination( $prefs = array() ) {
if ( !$this->pagination && is_a($this->queryIterator, | php | {
"resource": ""
} |
q21397 | Menu.find_parent_item_in_menu | train | public function find_parent_item_in_menu( $menu_items, $parent_id ) {
foreach ( $menu_items as &$item ) { | php | {
"resource": ""
} |
q21398 | Admin.in_plugin_update_message | train | 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 == | php | {
"resource": ""
} |
q21399 | TextHelper.trim_characters | train | public static function trim_characters( $text, $num_chars = 60, $more = '…' ) {
$text = wp_strip_all_tags($text);
| php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.