repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
TYPO3/Surf
src/Task/TYPO3/CMS/SetUpExtensionsTask.php
SetUpExtensionsTask.execute
public function execute(Node $node, Application $application, Deployment $deployment, array $options = []) { $this->ensureApplicationIsTypo3Cms($application); try { $scriptFileName = $this->getConsoleScriptFileName($node, $application, $deployment, $options); } catch (InvalidCon...
php
public function execute(Node $node, Application $application, Deployment $deployment, array $options = []) { $this->ensureApplicationIsTypo3Cms($application); try { $scriptFileName = $this->getConsoleScriptFileName($node, $application, $deployment, $options); } catch (InvalidCon...
[ "public", "function", "execute", "(", "Node", "$", "node", ",", "Application", "$", "application", ",", "Deployment", "$", "deployment", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "ensureApplicationIsTypo3Cms", "(", "$", "app...
Execute this task @param \TYPO3\Surf\Domain\Model\Node $node @param CMS|\TYPO3\Surf\Domain\Model\Application $application @param \TYPO3\Surf\Domain\Model\Deployment $deployment @param array $options @throws \TYPO3\Surf\Exception\InvalidConfigurationException
[ "Execute", "this", "task" ]
train
https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/TYPO3/CMS/SetUpExtensionsTask.php#L35-L63
TYPO3/Surf
src/Application/Neos/Flow.php
Flow.registerTasks
public function registerTasks(Workflow $workflow, Deployment $deployment) { parent::registerTasks($workflow, $deployment); $workflow ->addTask(CreateDirectoriesTask::class, 'initialize', $this) ->afterStage('update', [ SymlinkDataTask::class, ...
php
public function registerTasks(Workflow $workflow, Deployment $deployment) { parent::registerTasks($workflow, $deployment); $workflow ->addTask(CreateDirectoriesTask::class, 'initialize', $this) ->afterStage('update', [ SymlinkDataTask::class, ...
[ "public", "function", "registerTasks", "(", "Workflow", "$", "workflow", ",", "Deployment", "$", "deployment", ")", "{", "parent", "::", "registerTasks", "(", "$", "workflow", ",", "$", "deployment", ")", ";", "$", "workflow", "->", "addTask", "(", "CreateDi...
Register tasks for this application @param Workflow $workflow @param Deployment $deployment
[ "Register", "tasks", "for", "this", "application" ]
train
https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Application/Neos/Flow.php#L54-L67
TYPO3/Surf
src/Application/Neos/Flow.php
Flow.registerTasksForUpdateMethod
protected function registerTasksForUpdateMethod(Workflow $workflow, $updateMethod) { switch ($updateMethod) { case 'composer': $workflow->addTask(InstallTask::class, 'update', $this); break; default: parent::registerTasksForUpdateMethod...
php
protected function registerTasksForUpdateMethod(Workflow $workflow, $updateMethod) { switch ($updateMethod) { case 'composer': $workflow->addTask(InstallTask::class, 'update', $this); break; default: parent::registerTasksForUpdateMethod...
[ "protected", "function", "registerTasksForUpdateMethod", "(", "Workflow", "$", "workflow", ",", "$", "updateMethod", ")", "{", "switch", "(", "$", "updateMethod", ")", "{", "case", "'composer'", ":", "$", "workflow", "->", "addTask", "(", "InstallTask", "::", ...
Add support for updateMethod "composer" @param Workflow $workflow @param string $updateMethod
[ "Add", "support", "for", "updateMethod", "composer" ]
train
https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Application/Neos/Flow.php#L75-L85
TYPO3/Surf
src/Application/Neos/Flow.php
Flow.buildCommand
public function buildCommand($targetPath, $command, array $arguments = []) { return 'cd ' . $targetPath . ' && FLOW_CONTEXT=' . $this->getContext() . ' ./' . $this->getFlowScriptName() . ' ' . $this->getCommandPackageKey($command) . ':' . $command . ' ' . implode(' ', array_map('esca...
php
public function buildCommand($targetPath, $command, array $arguments = []) { return 'cd ' . $targetPath . ' && FLOW_CONTEXT=' . $this->getContext() . ' ./' . $this->getFlowScriptName() . ' ' . $this->getCommandPackageKey($command) . ':' . $command . ' ' . implode(' ', array_map('esca...
[ "public", "function", "buildCommand", "(", "$", "targetPath", ",", "$", "command", ",", "array", "$", "arguments", "=", "[", "]", ")", "{", "return", "'cd '", ".", "$", "targetPath", ".", "' && FLOW_CONTEXT='", ".", "$", "this", "->", "getContext", "(", ...
Returns a executable flow command including the context @param string $targetPath the path where the command should be executed @param string $command the actual command for example `cache:flush` @param array $arguments list of arguments which will be appended to the command @return string
[ "Returns", "a", "executable", "flow", "command", "including", "the", "context" ]
train
https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Application/Neos/Flow.php#L180-L185
TYPO3/Surf
src/Task/LocalShellTask.php
LocalShellTask.execute
public function execute(Node $node, Application $application, Deployment $deployment, array $options = []) { $replacePaths = []; $replacePaths['{workspacePath}'] = escapeshellarg($deployment->getWorkspacePath($application)); if (!isset($options['command'])) { throw new InvalidCo...
php
public function execute(Node $node, Application $application, Deployment $deployment, array $options = []) { $replacePaths = []; $replacePaths['{workspacePath}'] = escapeshellarg($deployment->getWorkspacePath($application)); if (!isset($options['command'])) { throw new InvalidCo...
[ "public", "function", "execute", "(", "Node", "$", "node", ",", "Application", "$", "application", ",", "Deployment", "$", "deployment", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "replacePaths", "=", "[", "]", ";", "$", "replacePaths", ...
Execute this task @param \TYPO3\Surf\Domain\Model\Node $node @param \TYPO3\Surf\Domain\Model\Application $application @param \TYPO3\Surf\Domain\Model\Deployment $deployment @param array $options @throws \TYPO3\Surf\Exception\InvalidConfigurationException
[ "Execute", "this", "task" ]
train
https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/LocalShellTask.php#L50-L68
TYPO3/Surf
src/Task/LocalShellTask.php
LocalShellTask.rollback
public function rollback(Node $node, Application $application, Deployment $deployment, array $options = []) { $replacePaths = []; $replacePaths['{workspacePath}'] = escapeshellarg($deployment->getWorkspacePath($application)); if (!isset($options['rollbackCommand'])) { return; ...
php
public function rollback(Node $node, Application $application, Deployment $deployment, array $options = []) { $replacePaths = []; $replacePaths['{workspacePath}'] = escapeshellarg($deployment->getWorkspacePath($application)); if (!isset($options['rollbackCommand'])) { return; ...
[ "public", "function", "rollback", "(", "Node", "$", "node", ",", "Application", "$", "application", ",", "Deployment", "$", "deployment", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "replacePaths", "=", "[", "]", ";", "$", "replacePaths",...
Rollback this task @param \TYPO3\Surf\Domain\Model\Node $node @param \TYPO3\Surf\Domain\Model\Application $application @param \TYPO3\Surf\Domain\Model\Deployment $deployment @param array $options
[ "Rollback", "this", "task" ]
train
https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/LocalShellTask.php#L91-L106
TYPO3/Surf
src/Task/Generic/CreateSymlinksTask.php
CreateSymlinksTask.execute
public function execute(Node $node, Application $application, Deployment $deployment, array $options = []) { $options = $this->configureOptions($options); if (empty($options['symlinks'])) { return; } $baseDirectory = $options['genericSymlinksBaseDir'] ?: $deployment->ge...
php
public function execute(Node $node, Application $application, Deployment $deployment, array $options = []) { $options = $this->configureOptions($options); if (empty($options['symlinks'])) { return; } $baseDirectory = $options['genericSymlinksBaseDir'] ?: $deployment->ge...
[ "public", "function", "execute", "(", "Node", "$", "node", ",", "Application", "$", "application", ",", "Deployment", "$", "deployment", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "=", "$", "this", "->", "configureOptions", "(...
Execute this task @param \TYPO3\Surf\Domain\Model\Node $node @param \TYPO3\Surf\Domain\Model\Application $application @param \TYPO3\Surf\Domain\Model\Deployment $deployment @param array $options
[ "Execute", "this", "task" ]
train
https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/Generic/CreateSymlinksTask.php#L47-L66
TYPO3/Surf
src/Task/CreateDirectoriesTask.php
CreateDirectoriesTask.execute
public function execute(Node $node, Application $application, Deployment $deployment, array $options = []) { $deploymentPath = $application->getDeploymentPath(); $sharedPath = $application->getSharedPath(); $releasesPath = $application->getReleasesPath(); $releaseIdentifier = $deploy...
php
public function execute(Node $node, Application $application, Deployment $deployment, array $options = []) { $deploymentPath = $application->getDeploymentPath(); $sharedPath = $application->getSharedPath(); $releasesPath = $application->getReleasesPath(); $releaseIdentifier = $deploy...
[ "public", "function", "execute", "(", "Node", "$", "node", ",", "Application", "$", "application", ",", "Deployment", "$", "deployment", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "deploymentPath", "=", "$", "application", "->", "getDeploy...
Executes this task @param \TYPO3\Surf\Domain\Model\Node $node @param \TYPO3\Surf\Domain\Model\Application $application @param \TYPO3\Surf\Domain\Model\Deployment $deployment @param array $options @throws \TYPO3\Surf\Exception\TaskExecutionException
[ "Executes", "this", "task" ]
train
https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/CreateDirectoriesTask.php#L44-L62
TYPO3/Surf
src/Task/Composer/AbstractComposerTask.php
AbstractComposerTask.buildComposerCommands
protected function buildComposerCommands($manifestPath, array $options) { if (!isset($options['composerCommandPath'])) { throw new TaskExecutionException('Composer command not found. Set the composerCommandPath option.', 1349163257); } $additionalArguments = []; if (isse...
php
protected function buildComposerCommands($manifestPath, array $options) { if (!isset($options['composerCommandPath'])) { throw new TaskExecutionException('Composer command not found. Set the composerCommandPath option.', 1349163257); } $additionalArguments = []; if (isse...
[ "protected", "function", "buildComposerCommands", "(", "$", "manifestPath", ",", "array", "$", "options", ")", "{", "if", "(", "!", "isset", "(", "$", "options", "[", "'composerCommandPath'", "]", ")", ")", "{", "throw", "new", "TaskExecutionException", "(", ...
Build the composer command in the given $path. @param string $manifestPath @param array $options @return array @throws \TYPO3\Surf\Exception\TaskExecutionException
[ "Build", "the", "composer", "command", "in", "the", "given", "$path", "." ]
train
https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/Composer/AbstractComposerTask.php#L101-L124
TYPO3/Surf
src/Task/Composer/AbstractComposerTask.php
AbstractComposerTask.composerManifestExists
protected function composerManifestExists($path, Node $node, Deployment $deployment) { // In dry run mode, no checkout is there, this we must not assume a composer.json is there! if ($deployment->isDryRun()) { return false; } $composerJsonPath = Files::concatenatePaths([$...
php
protected function composerManifestExists($path, Node $node, Deployment $deployment) { // In dry run mode, no checkout is there, this we must not assume a composer.json is there! if ($deployment->isDryRun()) { return false; } $composerJsonPath = Files::concatenatePaths([$...
[ "protected", "function", "composerManifestExists", "(", "$", "path", ",", "Node", "$", "node", ",", "Deployment", "$", "deployment", ")", "{", "// In dry run mode, no checkout is there, this we must not assume a composer.json is there!", "if", "(", "$", "deployment", "->", ...
Checks if a composer manifest exists in the directory at the given path. If no manifest exists, a log message is recorded. @param string $path @param \TYPO3\Surf\Domain\Model\Node $node @param \TYPO3\Surf\Domain\Model\Deployment $deployment @return bool
[ "Checks", "if", "a", "composer", "manifest", "exists", "in", "the", "directory", "at", "the", "given", "path", "." ]
train
https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/Composer/AbstractComposerTask.php#L136-L150
TYPO3/Surf
src/Cli/Symfony/Logger/ConsoleFormatter.php
ConsoleFormatter.format
public function format(array $record) { if ($record['level'] >= Logger::ERROR) { $record['start_tag'] = '<error>'; $record['end_tag'] = '</error>'; } elseif ($record['level'] >= Logger::NOTICE) { $record['start_tag'] = '<comment>'; $record['end_tag'] =...
php
public function format(array $record) { if ($record['level'] >= Logger::ERROR) { $record['start_tag'] = '<error>'; $record['end_tag'] = '</error>'; } elseif ($record['level'] >= Logger::NOTICE) { $record['start_tag'] = '<comment>'; $record['end_tag'] =...
[ "public", "function", "format", "(", "array", "$", "record", ")", "{", "if", "(", "$", "record", "[", "'level'", "]", ">=", "Logger", "::", "ERROR", ")", "{", "$", "record", "[", "'start_tag'", "]", "=", "'<error>'", ";", "$", "record", "[", "'end_ta...
{@inheritdoc}
[ "{" ]
train
https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Cli/Symfony/Logger/ConsoleFormatter.php#L27-L44
TYPO3/Surf
src/Task/Git/TagTask.php
TagTask.execute
public function execute(Node $node, Application $application, Deployment $deployment, array $options = []) { $this->validateOptions($options); $options = $this->processOptions($options, $deployment); $targetPath = $deployment->getApplicationReleasePath($application); $this->shell->e...
php
public function execute(Node $node, Application $application, Deployment $deployment, array $options = []) { $this->validateOptions($options); $options = $this->processOptions($options, $deployment); $targetPath = $deployment->getApplicationReleasePath($application); $this->shell->e...
[ "public", "function", "execute", "(", "Node", "$", "node", ",", "Application", "$", "application", ",", "Deployment", "$", "deployment", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "validateOptions", "(", "$", "options", ")"...
Execute this task @param \TYPO3\Surf\Domain\Model\Node $node @param \TYPO3\Surf\Domain\Model\Application $application @param \TYPO3\Surf\Domain\Model\Deployment $deployment @param array $options @throws \TYPO3\Surf\Exception\InvalidConfigurationException
[ "Execute", "this", "task" ]
train
https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/Git/TagTask.php#L53-L72
TYPO3/Surf
src/Task/Git/TagTask.php
TagTask.processOptions
protected function processOptions(array $options, Deployment $deployment) { foreach (['tagName', 'description'] as $optionName) { $options[$optionName] = str_replace( [ '{releaseIdentifier}', '{deploymentName}' ], ...
php
protected function processOptions(array $options, Deployment $deployment) { foreach (['tagName', 'description'] as $optionName) { $options[$optionName] = str_replace( [ '{releaseIdentifier}', '{deploymentName}' ], ...
[ "protected", "function", "processOptions", "(", "array", "$", "options", ",", "Deployment", "$", "deployment", ")", "{", "foreach", "(", "[", "'tagName'", ",", "'description'", "]", "as", "$", "optionName", ")", "{", "$", "options", "[", "$", "optionName", ...
Replace placeholders in option values and set default values @param array $options @param \TYPO3\Surf\Domain\Model\Deployment $deployment @return array
[ "Replace", "placeholders", "in", "option", "values", "and", "set", "default", "values" ]
train
https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/Git/TagTask.php#L109-L134
TYPO3/Surf
src/Task/Php/WebOpcacheResetExecuteTask.php
WebOpcacheResetExecuteTask.execute
public function execute(Node $node, Application $application, Deployment $deployment, array $options = []) { $options = $this->configureOptions($options); $scriptUrl = sprintf('%s/surf-opcache-reset-%s.php', $options['baseUrl'], $options['scriptIdentifier']); $result = $this->filesystem->g...
php
public function execute(Node $node, Application $application, Deployment $deployment, array $options = []) { $options = $this->configureOptions($options); $scriptUrl = sprintf('%s/surf-opcache-reset-%s.php', $options['baseUrl'], $options['scriptIdentifier']); $result = $this->filesystem->g...
[ "public", "function", "execute", "(", "Node", "$", "node", ",", "Application", "$", "application", ",", "Deployment", "$", "deployment", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "=", "$", "this", "->", "configureOptions", "(...
Execute this task @param \TYPO3\Surf\Domain\Model\Node $node @param \TYPO3\Surf\Domain\Model\Application $application @param \TYPO3\Surf\Domain\Model\Deployment $deployment @param array $options Supported options: "baseUrl" (required) and "scriptIdentifier" (is passed by the create script task) @throws \TYPO3\Surf\Ex...
[ "Execute", "this", "task" ]
train
https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/Php/WebOpcacheResetExecuteTask.php#L77-L92
larapack/voyager-hooks
src/VoyagerHooksServiceProvider.php
VoyagerHooksServiceProvider.register
public function register() { $configPath = dirname(__DIR__).'/publishable/config/voyager-hooks.php'; $this->mergeConfigFrom($configPath, 'voyager-hooks'); // Register the HooksServiceProvider $this->app->register(HooksServiceProvider::class); if (!$this->enabled()) { ...
php
public function register() { $configPath = dirname(__DIR__).'/publishable/config/voyager-hooks.php'; $this->mergeConfigFrom($configPath, 'voyager-hooks'); // Register the HooksServiceProvider $this->app->register(HooksServiceProvider::class); if (!$this->enabled()) { ...
[ "public", "function", "register", "(", ")", "{", "$", "configPath", "=", "dirname", "(", "__DIR__", ")", ".", "'/publishable/config/voyager-hooks.php'", ";", "$", "this", "->", "mergeConfigFrom", "(", "$", "configPath", ",", "'voyager-hooks'", ")", ";", "// Regi...
Register the application services.
[ "Register", "the", "application", "services", "." ]
train
https://github.com/larapack/voyager-hooks/blob/5de5a5f06c8359c7f09fb1bb9acd84b3f5379506/src/VoyagerHooksServiceProvider.php#L19-L41
larapack/voyager-hooks
src/VoyagerHooksServiceProvider.php
VoyagerHooksServiceProvider.boot
public function boot(Dispatcher $events) { if (!$this->enabled()) { return; } if (config('voyager-hooks.add-route', true)) { $events->listen('voyager.admin.routing', [$this, 'addHookRoute']); } if (config('voyager-hooks.add-hook-menu-item', true)) { ...
php
public function boot(Dispatcher $events) { if (!$this->enabled()) { return; } if (config('voyager-hooks.add-route', true)) { $events->listen('voyager.admin.routing', [$this, 'addHookRoute']); } if (config('voyager-hooks.add-hook-menu-item', true)) { ...
[ "public", "function", "boot", "(", "Dispatcher", "$", "events", ")", "{", "if", "(", "!", "$", "this", "->", "enabled", "(", ")", ")", "{", "return", ";", "}", "if", "(", "config", "(", "'voyager-hooks.add-route'", ",", "true", ")", ")", "{", "$", ...
Bootstrap the application services. @param \Illuminate\Events\Dispatcher $events
[ "Bootstrap", "the", "application", "services", "." ]
train
https://github.com/larapack/voyager-hooks/blob/5de5a5f06c8359c7f09fb1bb9acd84b3f5379506/src/VoyagerHooksServiceProvider.php#L48-L69
tuupola/base62
src/Base62/BcmathEncoder.php
BcmathEncoder.baseConvert
public function baseConvert(array $source, int $sourceBase, int $targetBase): array { $result = []; while ($count = count($source)) { $quotient = []; $remainder = "0"; $sourceBase = (string) $sourceBase; $targetBase = (string) $targetBase; ...
php
public function baseConvert(array $source, int $sourceBase, int $targetBase): array { $result = []; while ($count = count($source)) { $quotient = []; $remainder = "0"; $sourceBase = (string) $sourceBase; $targetBase = (string) $targetBase; ...
[ "public", "function", "baseConvert", "(", "array", "$", "source", ",", "int", "$", "sourceBase", ",", "int", "$", "targetBase", ")", ":", "array", "{", "$", "result", "=", "[", "]", ";", "while", "(", "$", "count", "=", "count", "(", "$", "source", ...
Convert an integer between artbitrary bases @see http://codegolf.stackexchange.com/a/21672
[ "Convert", "an", "integer", "between", "artbitrary", "bases" ]
train
https://github.com/tuupola/base62/blob/7ffb639cb8031cf75953eda943494fc609ed67b3/src/Base62/BcmathEncoder.php#L47-L68
tuupola/base62
src/Base62/BaseEncoder.php
BaseEncoder.encode
public function encode(string $data): string { $data = str_split($data); $data = array_map("ord", $data); $leadingZeroes = 0; while (!empty($data) && 0 === $data[0]) { $leadingZeroes++; array_shift($data); } $converted = $this->baseConvert($da...
php
public function encode(string $data): string { $data = str_split($data); $data = array_map("ord", $data); $leadingZeroes = 0; while (!empty($data) && 0 === $data[0]) { $leadingZeroes++; array_shift($data); } $converted = $this->baseConvert($da...
[ "public", "function", "encode", "(", "string", "$", "data", ")", ":", "string", "{", "$", "data", "=", "str_split", "(", "$", "data", ")", ";", "$", "data", "=", "array_map", "(", "\"ord\"", ",", "$", "data", ")", ";", "$", "leadingZeroes", "=", "0...
Encode given data to a base62 string
[ "Encode", "given", "data", "to", "a", "base62", "string" ]
train
https://github.com/tuupola/base62/blob/7ffb639cb8031cf75953eda943494fc609ed67b3/src/Base62/BaseEncoder.php#L58-L78
tuupola/base62
src/Base62/BaseEncoder.php
BaseEncoder.decode
public function decode(string $data): string { $this->validateInput($data); $data = str_split($data); $data = array_map(function ($character) { return strpos($this->options["characters"], $character); }, $data); $leadingZeroes = 0; while (!empty($data) &...
php
public function decode(string $data): string { $this->validateInput($data); $data = str_split($data); $data = array_map(function ($character) { return strpos($this->options["characters"], $character); }, $data); $leadingZeroes = 0; while (!empty($data) &...
[ "public", "function", "decode", "(", "string", "$", "data", ")", ":", "string", "{", "$", "this", "->", "validateInput", "(", "$", "data", ")", ";", "$", "data", "=", "str_split", "(", "$", "data", ")", ";", "$", "data", "=", "array_map", "(", "fun...
Decode given a base62 string back to data
[ "Decode", "given", "a", "base62", "string", "back", "to", "data" ]
train
https://github.com/tuupola/base62/blob/7ffb639cb8031cf75953eda943494fc609ed67b3/src/Base62/BaseEncoder.php#L83-L108
tuupola/base62
src/Base62/BaseEncoder.php
BaseEncoder.encodeInteger
public function encodeInteger(int $data): string { $data = [$data]; $converted = $this->baseConvert($data, 256, 62); return implode("", array_map(function ($index) { return $this->options["characters"][$index]; }, $converted)); }
php
public function encodeInteger(int $data): string { $data = [$data]; $converted = $this->baseConvert($data, 256, 62); return implode("", array_map(function ($index) { return $this->options["characters"][$index]; }, $converted)); }
[ "public", "function", "encodeInteger", "(", "int", "$", "data", ")", ":", "string", "{", "$", "data", "=", "[", "$", "data", "]", ";", "$", "converted", "=", "$", "this", "->", "baseConvert", "(", "$", "data", ",", "256", ",", "62", ")", ";", "re...
Encode given integer to a base62 string
[ "Encode", "given", "integer", "to", "a", "base62", "string" ]
train
https://github.com/tuupola/base62/blob/7ffb639cb8031cf75953eda943494fc609ed67b3/src/Base62/BaseEncoder.php#L127-L136
tuupola/base62
src/Base62/BaseEncoder.php
BaseEncoder.decodeInteger
public function decodeInteger(string $data): int { $this->validateInput($data); $data = str_split($data); $data = array_map(function ($character) { return strpos($this->options["characters"], $character); }, $data); $converted = $this->baseConvert($data, 62, 10)...
php
public function decodeInteger(string $data): int { $this->validateInput($data); $data = str_split($data); $data = array_map(function ($character) { return strpos($this->options["characters"], $character); }, $data); $converted = $this->baseConvert($data, 62, 10)...
[ "public", "function", "decodeInteger", "(", "string", "$", "data", ")", ":", "int", "{", "$", "this", "->", "validateInput", "(", "$", "data", ")", ";", "$", "data", "=", "str_split", "(", "$", "data", ")", ";", "$", "data", "=", "array_map", "(", ...
Decode given base62 string back to an integer
[ "Decode", "given", "base62", "string", "back", "to", "an", "integer" ]
train
https://github.com/tuupola/base62/blob/7ffb639cb8031cf75953eda943494fc609ed67b3/src/Base62/BaseEncoder.php#L141-L152
tuupola/base62
src/Base62/PhpEncoder.php
PhpEncoder.baseConvert
public function baseConvert(array $source, int $sourceBase, int $targetBase): array { $result = []; while ($count = count($source)) { $quotient = []; $remainder = 0; for ($i = 0; $i !== $count; $i++) { $accumulator = $source[$i] + $remainder * $sou...
php
public function baseConvert(array $source, int $sourceBase, int $targetBase): array { $result = []; while ($count = count($source)) { $quotient = []; $remainder = 0; for ($i = 0; $i !== $count; $i++) { $accumulator = $source[$i] + $remainder * $sou...
[ "public", "function", "baseConvert", "(", "array", "$", "source", ",", "int", "$", "sourceBase", ",", "int", "$", "targetBase", ")", ":", "array", "{", "$", "result", "=", "[", "]", ";", "while", "(", "$", "count", "=", "count", "(", "$", "source", ...
Convert an integer between artbitrary bases @see http://codegolf.stackexchange.com/a/21672
[ "Convert", "an", "integer", "between", "artbitrary", "bases" ]
train
https://github.com/tuupola/base62/blob/7ffb639cb8031cf75953eda943494fc609ed67b3/src/Base62/PhpEncoder.php#L47-L67
justintadlock/hybrid-core
src/View/ViewServiceProvider.php
ViewServiceProvider.register
public function register() { $this->app->bind( ViewContract::class, View::class ); $this->app->alias( ViewContract::class, 'view' ); }
php
public function register() { $this->app->bind( ViewContract::class, View::class ); $this->app->alias( ViewContract::class, 'view' ); }
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "ViewContract", "::", "class", ",", "View", "::", "class", ")", ";", "$", "this", "->", "app", "->", "alias", "(", "ViewContract", "::", "class", ",", "'vie...
Binds the implementation of the view contract to the container. @since 5.0.0 @access public @return void
[ "Binds", "the", "implementation", "of", "the", "view", "contract", "to", "the", "container", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/View/ViewServiceProvider.php#L37-L42
justintadlock/hybrid-core
src/View/View.php
View.hierarchy
protected function hierarchy() { // Uses the slugs to build a hierarchy. foreach ( $this->slugs as $slug ) { $templates[] = "{$this->name}/{$slug}.php"; } // Add in a `default.php` template. if ( ! in_array( 'default', $this->slugs ) ) { $templates[] = "{$this->name}/default.php"; } // Fallback...
php
protected function hierarchy() { // Uses the slugs to build a hierarchy. foreach ( $this->slugs as $slug ) { $templates[] = "{$this->name}/{$slug}.php"; } // Add in a `default.php` template. if ( ! in_array( 'default', $this->slugs ) ) { $templates[] = "{$this->name}/default.php"; } // Fallback...
[ "protected", "function", "hierarchy", "(", ")", "{", "// Uses the slugs to build a hierarchy.", "foreach", "(", "$", "this", "->", "slugs", "as", "$", "slug", ")", "{", "$", "templates", "[", "]", "=", "\"{$this->name}/{$slug}.php\"", ";", "}", "// Add in a `defau...
Uses the array of template slugs to build a hierarchy of potential templates that can be used. @since 5.0.0 @access protected @return array
[ "Uses", "the", "array", "of", "template", "slugs", "to", "build", "a", "hierarchy", "of", "potential", "templates", "that", "can", "be", "used", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/View/View.php#L117-L136
justintadlock/hybrid-core
src/View/View.php
View.template
public function template() { if ( is_null( $this->template ) ) { $this->template = $this->locate(); } return $this->template; }
php
public function template() { if ( is_null( $this->template ) ) { $this->template = $this->locate(); } return $this->template; }
[ "public", "function", "template", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "template", ")", ")", "{", "$", "this", "->", "template", "=", "$", "this", "->", "locate", "(", ")", ";", "}", "return", "$", "this", "->", "template", ...
Returns the located template. @since 5.0.0 @access public @return string
[ "Returns", "the", "located", "template", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/View/View.php#L157-L164
justintadlock/hybrid-core
src/View/View.php
View.display
public function display() { // Compatibility with core WP's template parts. $this->templatePartCompat(); if ( $this->template() ) { // Maybe remove core WP's `prepend_attachment`. $this->maybeShiftAttachment(); // Make the `$data` variable available to the template. $data = $this->data; // Ext...
php
public function display() { // Compatibility with core WP's template parts. $this->templatePartCompat(); if ( $this->template() ) { // Maybe remove core WP's `prepend_attachment`. $this->maybeShiftAttachment(); // Make the `$data` variable available to the template. $data = $this->data; // Ext...
[ "public", "function", "display", "(", ")", "{", "// Compatibility with core WP's template parts.", "$", "this", "->", "templatePartCompat", "(", ")", ";", "if", "(", "$", "this", "->", "template", "(", ")", ")", "{", "// Maybe remove core WP's `prepend_attachment`.", ...
Sets up data to be passed to the template and renders it. @since 5.0.0 @access public @return void
[ "Sets", "up", "data", "to", "be", "passed", "to", "the", "template", "and", "renders", "it", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/View/View.php#L173-L195
justintadlock/hybrid-core
src/View/View.php
View.templatePartCompat
protected function templatePartCompat() { // The slug is a string in WP and we have an array. So, we're // just going to use the first item of the array in this case. $slug = $this->slugs ? reset( $this->slugs ) : null; // Compat with `get_header|footer|sidebar()`. if ( in_array( $this->name, [ 'header', 'f...
php
protected function templatePartCompat() { // The slug is a string in WP and we have an array. So, we're // just going to use the first item of the array in this case. $slug = $this->slugs ? reset( $this->slugs ) : null; // Compat with `get_header|footer|sidebar()`. if ( in_array( $this->name, [ 'header', 'f...
[ "protected", "function", "templatePartCompat", "(", ")", "{", "// The slug is a string in WP and we have an array. So, we're", "// just going to use the first item of the array in this case.", "$", "slug", "=", "$", "this", "->", "slugs", "?", "reset", "(", "$", "this", "->",...
Fires the core WP action hooks for template parts. Note that WP refers to `$name` and `$slug` differently than we do. They're the opposite of what we use in our function. @since 5.0.0 @access protected @return void
[ "Fires", "the", "core", "WP", "action", "hooks", "for", "template", "parts", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/View/View.php#L221-L237
justintadlock/hybrid-core
src/View/View.php
View.maybeShiftAttachment
protected function maybeShiftAttachment() { if ( ! in_the_loop() || 'attachment' !== get_post_type() ) { return; } if ( in_array( $this->name, [ 'entry', 'post', 'entry/archive', 'entry/single' ] ) ) { remove_filter( 'the_content', 'prepend_attachment' ); } elseif ( 'embed' === $this->name ) { rem...
php
protected function maybeShiftAttachment() { if ( ! in_the_loop() || 'attachment' !== get_post_type() ) { return; } if ( in_array( $this->name, [ 'entry', 'post', 'entry/archive', 'entry/single' ] ) ) { remove_filter( 'the_content', 'prepend_attachment' ); } elseif ( 'embed' === $this->name ) { rem...
[ "protected", "function", "maybeShiftAttachment", "(", ")", "{", "if", "(", "!", "in_the_loop", "(", ")", "||", "'attachment'", "!==", "get_post_type", "(", ")", ")", "{", "return", ";", "}", "if", "(", "in_array", "(", "$", "this", "->", "name", ",", "...
Removes core WP's `prepend_attachment` filter whenever a theme is building custom attachment templates. We'll assume that the theme author will handle the appropriate output in the template itself. @since 5.0.0 @access protected @return void
[ "Removes", "core", "WP", "s", "prepend_attachment", "filter", "whenever", "a", "theme", "is", "building", "custom", "attachment", "templates", ".", "We", "ll", "assume", "that", "the", "theme", "author", "will", "handle", "the", "appropriate", "output", "in", ...
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/View/View.php#L248-L263
justintadlock/hybrid-core
src/Attr/Attr.php
Attr.render
public function render() { $html = ''; foreach ( $this->all() as $name => $value ) { $esc_value = ''; // If the value is a link `href`, use `esc_url()`. if ( $value !== false && 'href' === $name ) { $esc_value = esc_url( $value ); } elseif ( $value !== false ) { $esc_value = esc_attr( $valu...
php
public function render() { $html = ''; foreach ( $this->all() as $name => $value ) { $esc_value = ''; // If the value is a link `href`, use `esc_url()`. if ( $value !== false && 'href' === $name ) { $esc_value = esc_url( $value ); } elseif ( $value !== false ) { $esc_value = esc_attr( $valu...
[ "public", "function", "render", "(", ")", "{", "$", "html", "=", "''", ";", "foreach", "(", "$", "this", "->", "all", "(", ")", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "esc_value", "=", "''", ";", "// If the value is a link `href`, use `e...
Returns an escaped string of attributes for use in HTML. @since 5.0.0 @access public @return string
[ "Returns", "an", "escaped", "string", "of", "attributes", "for", "use", "in", "HTML", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Attr/Attr.php#L114-L134
justintadlock/hybrid-core
src/Attr/Attr.php
Attr.get
public function get( $name ) { $attr = $this->all(); return isset( $attr[ $name ] ) ? $attr[ $name ] : ''; }
php
public function get( $name ) { $attr = $this->all(); return isset( $attr[ $name ] ) ? $attr[ $name ] : ''; }
[ "public", "function", "get", "(", "$", "name", ")", "{", "$", "attr", "=", "$", "this", "->", "all", "(", ")", ";", "return", "isset", "(", "$", "attr", "[", "$", "name", "]", ")", "?", "$", "attr", "[", "$", "name", "]", ":", "''", ";", "}...
Returns a single, unescaped attribute's value. @since 5.0.0 @access public @param string $name @return string
[ "Returns", "a", "single", "unescaped", "attribute", "s", "value", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Attr/Attr.php#L144-L149
justintadlock/hybrid-core
src/Attr/Attr.php
Attr.all
public function all() { // If we already have attributes, let's return them and bail. if ( $this->attr ) { return $this->attr; } $defaults = []; // If the a class was input, we want to go ahead and set that as // the default class. That way, filters can know early on that // a class has already bee...
php
public function all() { // If we already have attributes, let's return them and bail. if ( $this->attr ) { return $this->attr; } $defaults = []; // If the a class was input, we want to go ahead and set that as // the default class. That way, filters can know early on that // a class has already bee...
[ "public", "function", "all", "(", ")", "{", "// If we already have attributes, let's return them and bail.", "if", "(", "$", "this", "->", "attr", ")", "{", "return", "$", "this", "->", "attr", ";", "}", "$", "defaults", "=", "[", "]", ";", "// If the a class ...
Filters and returns the array of attributes. @since 5.0.0 @access protected @return void
[ "Filters", "and", "returns", "the", "array", "of", "attributes", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Attr/Attr.php#L158-L214
justintadlock/hybrid-core
src/Attr/Attr.php
Attr.html
protected function html( $attr ) { $attr = []; $parts = wp_kses_hair( get_language_attributes(), [ 'http', 'https' ] ); if ( $parts ) { foreach ( $parts as $part ) { $attr[ $part['name'] ] = $part['value']; } } return $attr; }
php
protected function html( $attr ) { $attr = []; $parts = wp_kses_hair( get_language_attributes(), [ 'http', 'https' ] ); if ( $parts ) { foreach ( $parts as $part ) { $attr[ $part['name'] ] = $part['value']; } } return $attr; }
[ "protected", "function", "html", "(", "$", "attr", ")", "{", "$", "attr", "=", "[", "]", ";", "$", "parts", "=", "wp_kses_hair", "(", "get_language_attributes", "(", ")", ",", "[", "'http'", ",", "'https'", "]", ")", ";", "if", "(", "$", "parts", "...
`<html>` element attributes. @since 5.0.0 @access protected @param array $attr @return array
[ "<html", ">", "element", "attributes", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Attr/Attr.php#L224-L239
justintadlock/hybrid-core
src/Attr/Attr.php
Attr.body
protected function body( $attr ) { $class = isset( $attr['class'] ) && 'body' !== $attr['class'] ? $attr['class'] : ''; $attr['class'] = join( ' ', get_body_class( $class ) ); $attr['dir'] = is_rtl() ? 'rtl' : 'ltr'; return $attr; }
php
protected function body( $attr ) { $class = isset( $attr['class'] ) && 'body' !== $attr['class'] ? $attr['class'] : ''; $attr['class'] = join( ' ', get_body_class( $class ) ); $attr['dir'] = is_rtl() ? 'rtl' : 'ltr'; return $attr; }
[ "protected", "function", "body", "(", "$", "attr", ")", "{", "$", "class", "=", "isset", "(", "$", "attr", "[", "'class'", "]", ")", "&&", "'body'", "!==", "$", "attr", "[", "'class'", "]", "?", "$", "attr", "[", "'class'", "]", ":", "''", ";", ...
`<body>` element attributes. @since 5.0.0 @access protected @param array $attr @return array
[ "<body", ">", "element", "attributes", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Attr/Attr.php#L249-L257
justintadlock/hybrid-core
src/Attr/Attr.php
Attr.post
protected function post( $attr ) { $post = get_post(); $class = isset( $attr['class'] ) ? $attr['class'] : ''; $attr['id'] = ! empty( $post ) ? sprintf( 'post-%d', get_the_ID() ) : 'post-0'; $attr['class'] = join( ' ', get_post_class( $class ) ); return $attr; }
php
protected function post( $attr ) { $post = get_post(); $class = isset( $attr['class'] ) ? $attr['class'] : ''; $attr['id'] = ! empty( $post ) ? sprintf( 'post-%d', get_the_ID() ) : 'post-0'; $attr['class'] = join( ' ', get_post_class( $class ) ); return $attr; }
[ "protected", "function", "post", "(", "$", "attr", ")", "{", "$", "post", "=", "get_post", "(", ")", ";", "$", "class", "=", "isset", "(", "$", "attr", "[", "'class'", "]", ")", "?", "$", "attr", "[", "'class'", "]", ":", "''", ";", "$", "attr"...
Post `<article>` element attributes. @since 5.0.0 @access protected @param array $attr @return array
[ "Post", "<article", ">", "element", "attributes", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Attr/Attr.php#L267-L276
justintadlock/hybrid-core
src/Attr/Attr.php
Attr.comment
protected function comment( $attr ) { $class = isset( $attr['class'] ) ? $attr['class'] : ''; $attr['id'] = 'comment-' . get_comment_ID(); $attr['class'] = join( ' ', get_comment_class( $class ) ); return $attr; }
php
protected function comment( $attr ) { $class = isset( $attr['class'] ) ? $attr['class'] : ''; $attr['id'] = 'comment-' . get_comment_ID(); $attr['class'] = join( ' ', get_comment_class( $class ) ); return $attr; }
[ "protected", "function", "comment", "(", "$", "attr", ")", "{", "$", "class", "=", "isset", "(", "$", "attr", "[", "'class'", "]", ")", "?", "$", "attr", "[", "'class'", "]", ":", "''", ";", "$", "attr", "[", "'id'", "]", "=", "'comment-'", ".", ...
Comment wrapper attributes. @since 5.0.0 @access protected @param array $attr @return array
[ "Comment", "wrapper", "attributes", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Attr/Attr.php#L299-L307
justintadlock/hybrid-core
src/Util/Title.php
Title.current
public static function current() { $title = ''; if ( is_front_page() ) { $title = static::frontPage(); } elseif ( is_home() || is_singular() ) { $title = static::post(); } elseif ( is_archive() ) { $title = static::archive(); } elseif ( is_search() ) { $title = static::search(); } elseif (...
php
public static function current() { $title = ''; if ( is_front_page() ) { $title = static::frontPage(); } elseif ( is_home() || is_singular() ) { $title = static::post(); } elseif ( is_archive() ) { $title = static::archive(); } elseif ( is_search() ) { $title = static::search(); } elseif (...
[ "public", "static", "function", "current", "(", ")", "{", "$", "title", "=", "''", ";", "if", "(", "is_front_page", "(", ")", ")", "{", "$", "title", "=", "static", "::", "frontPage", "(", ")", ";", "}", "elseif", "(", "is_home", "(", ")", "||", ...
Retrieve the current page title. @since 5.0.0 @access public @return string
[ "Retrieve", "the", "current", "page", "title", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Util/Title.php#L33-L54
justintadlock/hybrid-core
src/Util/Title.php
Title.archive
public static function archive() { $title = ''; if ( is_category() || is_tag() || is_tax() ) { $title = static::term(); } elseif ( is_post_type_archive() ) { $title = static::postTypeArchive(); } elseif ( is_author() ) { $title = static::author(); } elseif ( get_query_var( 'minute' ) && get_quer...
php
public static function archive() { $title = ''; if ( is_category() || is_tag() || is_tax() ) { $title = static::term(); } elseif ( is_post_type_archive() ) { $title = static::postTypeArchive(); } elseif ( is_author() ) { $title = static::author(); } elseif ( get_query_var( 'minute' ) && get_quer...
[ "public", "static", "function", "archive", "(", ")", "{", "$", "title", "=", "''", ";", "if", "(", "is_category", "(", ")", "||", "is_tag", "(", ")", "||", "is_tax", "(", ")", ")", "{", "$", "title", "=", "static", "::", "term", "(", ")", ";", ...
Retrieve the general archive title. @since 5.0.0 @access public @return string
[ "Retrieve", "the", "general", "archive", "title", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Util/Title.php#L63-L101
justintadlock/hybrid-core
src/Media/Grabber.php
Grabber.locate
protected function locate() { // Don't return a link if embeds don't work. Need media or nothing at all. add_filter( 'embed_maybe_make_link', '__return_false' ); // Get the media if the post type is an attachment. if ( 'attachment' === get_post_type( $this->post_id ) ) { $this->media = $this->locateSelfMed...
php
protected function locate() { // Don't return a link if embeds don't work. Need media or nothing at all. add_filter( 'embed_maybe_make_link', '__return_false' ); // Get the media if the post type is an attachment. if ( 'attachment' === get_post_type( $this->post_id ) ) { $this->media = $this->locateSelfMed...
[ "protected", "function", "locate", "(", ")", "{", "// Don't return a link if embeds don't work. Need media or nothing at all.", "add_filter", "(", "'embed_maybe_make_link'", ",", "'__return_false'", ")", ";", "// Get the media if the post type is an attachment.", "if", "(", "'attac...
Tries several methods to find media related to the post. Returns the found media. @since 5.0.0 @access protected @return string
[ "Tries", "several", "methods", "to", "find", "media", "related", "to", "the", "post", ".", "Returns", "the", "found", "media", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Media/Grabber.php#L282-L328
justintadlock/hybrid-core
src/Media/Grabber.php
Grabber.locateSelfMedia
protected function locateSelfMedia() { $url = esc_url( wp_get_attachment_url( $this->post_id ) ); $mime = get_post_mime_type( $this->post_id ); list( $type, $subtype ) = false !== strpos( $mime, '/' ) ? explode( '/', $mime ) : [ $mime, '' ]; return in_array( $type, [ 'audio', 'video' ] ) ? call_use...
php
protected function locateSelfMedia() { $url = esc_url( wp_get_attachment_url( $this->post_id ) ); $mime = get_post_mime_type( $this->post_id ); list( $type, $subtype ) = false !== strpos( $mime, '/' ) ? explode( '/', $mime ) : [ $mime, '' ]; return in_array( $type, [ 'audio', 'video' ] ) ? call_use...
[ "protected", "function", "locateSelfMedia", "(", ")", "{", "$", "url", "=", "esc_url", "(", "wp_get_attachment_url", "(", "$", "this", "->", "post_id", ")", ")", ";", "$", "mime", "=", "get_post_mime_type", "(", "$", "this", "->", "post_id", ")", ";", "l...
If the post type itself is an attachment, call the shortcode wrapper function for handling the media. @since 5.0.0 @access protected @return string
[ "If", "the", "post", "type", "itself", "is", "an", "attachment", "call", "the", "shortcode", "wrapper", "function", "for", "handling", "the", "media", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Media/Grabber.php#L338-L348
justintadlock/hybrid-core
src/Media/Grabber.php
Grabber.locateShortcodeMedia
protected function locateShortcodeMedia() { // Finds matches for shortcodes in the content. preg_match_all( '/' . get_shortcode_regex() . '/s', $this->content, $matches, PREG_SET_ORDER ); if ( empty( $matches ) ) { return ''; } // Create a list of allowed shortcodes. $shortcodes = is_array( $this->sho...
php
protected function locateShortcodeMedia() { // Finds matches for shortcodes in the content. preg_match_all( '/' . get_shortcode_regex() . '/s', $this->content, $matches, PREG_SET_ORDER ); if ( empty( $matches ) ) { return ''; } // Create a list of allowed shortcodes. $shortcodes = is_array( $this->sho...
[ "protected", "function", "locateShortcodeMedia", "(", ")", "{", "// Finds matches for shortcodes in the content.", "preg_match_all", "(", "'/'", ".", "get_shortcode_regex", "(", ")", ".", "'/s'", ",", "$", "this", "->", "content", ",", "$", "matches", ",", "PREG_SET...
Searches for shortcodes in the post content and sets the generated shortcode output if one is found. @since 5.0.0 @access protected @return string
[ "Searches", "for", "shortcodes", "in", "the", "post", "content", "and", "sets", "the", "generated", "shortcode", "output", "if", "one", "is", "found", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Media/Grabber.php#L358-L397
justintadlock/hybrid-core
src/Media/Grabber.php
Grabber.locateAutoembedMedia
protected function locateAutoembedMedia() { // Searches for URLs on a line by themselves in the post content. preg_match_all( '|^\s*(https?://[^\s"]+)\s*$|im', $this->content, $matches, PREG_SET_ORDER ); if ( empty( $matches ) || ! is_array( $matches ) ) { return ''; } foreach ( $matches as $value ) { ...
php
protected function locateAutoembedMedia() { // Searches for URLs on a line by themselves in the post content. preg_match_all( '|^\s*(https?://[^\s"]+)\s*$|im', $this->content, $matches, PREG_SET_ORDER ); if ( empty( $matches ) || ! is_array( $matches ) ) { return ''; } foreach ( $matches as $value ) { ...
[ "protected", "function", "locateAutoembedMedia", "(", ")", "{", "// Searches for URLs on a line by themselves in the post content.", "preg_match_all", "(", "'|^\\s*(https?://[^\\s\"]+)\\s*$|im'", ",", "$", "this", "->", "content", ",", "$", "matches", ",", "PREG_SET_ORDER", "...
Uses WordPress' autoembed feature to automatically to handle media that's just input as a URL. @since 5.0.0 @access protected @return string
[ "Uses", "WordPress", "autoembed", "feature", "to", "automatically", "to", "handle", "media", "that", "s", "just", "input", "as", "a", "URL", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Media/Grabber.php#L407-L434
justintadlock/hybrid-core
src/Media/Grabber.php
Grabber.locatedEmbeddedMedia
protected function locatedEmbeddedMedia() { $embedded_media = get_media_embedded_in_content( $this->content ); if ( $embedded_media ) { return $this->original_media = array_shift( $embedded_media ); } return ''; }
php
protected function locatedEmbeddedMedia() { $embedded_media = get_media_embedded_in_content( $this->content ); if ( $embedded_media ) { return $this->original_media = array_shift( $embedded_media ); } return ''; }
[ "protected", "function", "locatedEmbeddedMedia", "(", ")", "{", "$", "embedded_media", "=", "get_media_embedded_in_content", "(", "$", "this", "->", "content", ")", ";", "if", "(", "$", "embedded_media", ")", "{", "return", "$", "this", "->", "original_media", ...
Grabs media embbeded into the content within <iframe>, <object>, <embed>, and other HTML methods for embedding media. @since 5.0.0 @access protected @return string
[ "Grabs", "media", "embbeded", "into", "the", "content", "within", "<iframe", ">", "<object", ">", "<embed", ">", "and", "other", "HTML", "methods", "for", "embedding", "media", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Media/Grabber.php#L444-L453
justintadlock/hybrid-core
src/Media/Grabber.php
Grabber.locateAttachedMedia
protected function locateAttachedMedia() { // Gets media attached to the post by mime type. $attached_media = get_attached_media( $this->type, $this->post_id ); // If media is found. if ( $attached_media ) { // Get the first attachment/post object found for the post. $post = array_shift( $attached_medi...
php
protected function locateAttachedMedia() { // Gets media attached to the post by mime type. $attached_media = get_attached_media( $this->type, $this->post_id ); // If media is found. if ( $attached_media ) { // Get the first attachment/post object found for the post. $post = array_shift( $attached_medi...
[ "protected", "function", "locateAttachedMedia", "(", ")", "{", "// Gets media attached to the post by mime type.", "$", "attached_media", "=", "get_attached_media", "(", "$", "this", "->", "type", ",", "$", "this", "->", "post_id", ")", ";", "// If media is found.", "...
Gets media attached to the post. Then, uses the WordPress [audio] or [video] shortcode to handle the HTML output of the media. @since 5.0.0 @access protected @return string
[ "Gets", "media", "attached", "to", "the", "post", ".", "Then", "uses", "the", "WordPress", "[", "audio", "]", "or", "[", "video", "]", "shortcode", "to", "handle", "the", "HTML", "output", "of", "the", "media", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Media/Grabber.php#L463-L486
justintadlock/hybrid-core
src/Media/Grabber.php
Grabber.doShortcode
protected function doShortcode( $tag, $shortcode ) { if ( 'embed' === $tag ) { return $GLOBALS['wp_embed']->run_shortcode( $shortcode ); } elseif ( 'video' === $tag ) { // Need to filter dimensions here to overwrite WP's // `<div>` surrounding the [video] shortcode. return do_shortcode( $this->filte...
php
protected function doShortcode( $tag, $shortcode ) { if ( 'embed' === $tag ) { return $GLOBALS['wp_embed']->run_shortcode( $shortcode ); } elseif ( 'video' === $tag ) { // Need to filter dimensions here to overwrite WP's // `<div>` surrounding the [video] shortcode. return do_shortcode( $this->filte...
[ "protected", "function", "doShortcode", "(", "$", "tag", ",", "$", "shortcode", ")", "{", "if", "(", "'embed'", "===", "$", "tag", ")", "{", "return", "$", "GLOBALS", "[", "'wp_embed'", "]", "->", "run_shortcode", "(", "$", "shortcode", ")", ";", "}", ...
Helper function for running a shortcode. @since 5.0.0 @access protected @param string $tag @param string $shortcode @return string
[ "Helper", "function", "for", "running", "a", "shortcode", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Media/Grabber.php#L497-L511
justintadlock/hybrid-core
src/Media/Grabber.php
Grabber.split
public function split( $content ) { if ( get_the_ID() === (int) $this->post_id ) { $content = str_replace( $this->original_media, '', $content ); $content = wp_kses_post( $content ); } return $content; }
php
public function split( $content ) { if ( get_the_ID() === (int) $this->post_id ) { $content = str_replace( $this->original_media, '', $content ); $content = wp_kses_post( $content ); } return $content; }
[ "public", "function", "split", "(", "$", "content", ")", "{", "if", "(", "get_the_ID", "(", ")", "===", "(", "int", ")", "$", "this", "->", "post_id", ")", "{", "$", "content", "=", "str_replace", "(", "$", "this", "->", "original_media", ",", "''", ...
Removes the found media from the content. The purpose of this is so that themes can retrieve the media from the content and display it elsewhere on the page based on its design. @since 5.0.0 @access public @param string $content @return string
[ "Removes", "the", "found", "media", "from", "the", "content", ".", "The", "purpose", "of", "this", "is", "so", "that", "themes", "can", "retrieve", "the", "media", "from", "the", "content", "and", "display", "it", "elsewhere", "on", "the", "page", "based",...
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Media/Grabber.php#L523-L532
justintadlock/hybrid-core
src/Media/Grabber.php
Grabber.filterDimensions
protected function filterDimensions( $html ) { $media_atts = []; $_html = strip_tags( $html, '<object><embed><iframe><video>' ); // Find the attributes of the media. $atts = wp_kses_hair( $_html, [ 'http', 'https' ] ); // Loop through the media attributes and add them in key/value pairs. foreach ( $...
php
protected function filterDimensions( $html ) { $media_atts = []; $_html = strip_tags( $html, '<object><embed><iframe><video>' ); // Find the attributes of the media. $atts = wp_kses_hair( $_html, [ 'http', 'https' ] ); // Loop through the media attributes and add them in key/value pairs. foreach ( $...
[ "protected", "function", "filterDimensions", "(", "$", "html", ")", "{", "$", "media_atts", "=", "[", "]", ";", "$", "_html", "=", "strip_tags", "(", "$", "html", ",", "'<object><embed><iframe><video>'", ")", ";", "// Find the attributes of the media.", "$", "at...
Method for filtering the media's 'width' and 'height' attributes so that the theme can handle the dimensions how it sees fit. @since 5.0.0 @access protected @param string $html @return string
[ "Method", "for", "filtering", "the", "media", "s", "width", "and", "height", "attributes", "so", "that", "the", "theme", "can", "handle", "the", "dimensions", "how", "it", "sees", "fit", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Media/Grabber.php#L543-L607
justintadlock/hybrid-core
src/Media/Grabber.php
Grabber.spotifyDimensions
protected function spotifyDimensions( $media_atts ) { $max_width = $media_atts['width']; $max_height = $media_atts['height']; if ( 80 == $media_atts['height'] ) { $max_width = $this->width; } return [ $max_width, $max_height ]; }
php
protected function spotifyDimensions( $media_atts ) { $max_width = $media_atts['width']; $max_height = $media_atts['height']; if ( 80 == $media_atts['height'] ) { $max_width = $this->width; } return [ $max_width, $max_height ]; }
[ "protected", "function", "spotifyDimensions", "(", "$", "media_atts", ")", "{", "$", "max_width", "=", "$", "media_atts", "[", "'width'", "]", ";", "$", "max_height", "=", "$", "media_atts", "[", "'height'", "]", ";", "if", "(", "80", "==", "$", "media_a...
Fix for Spotify embeds because they're the only embeddable service that doesn't work that well with custom-sized embeds. So, we need to adjust this the best we can. Right now, the only embed size that works for full-width embeds is the "compact" player (height of 80). @since 5.0.0 @access protected @param array ...
[ "Fix", "for", "Spotify", "embeds", "because", "they", "re", "the", "only", "embeddable", "service", "that", "doesn", "t", "work", "that", "well", "with", "custom", "-", "sized", "embeds", ".", "So", "we", "need", "to", "adjust", "this", "the", "best", "w...
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Media/Grabber.php#L620-L630
justintadlock/hybrid-core
src/Attr/AttrServiceProvider.php
AttrServiceProvider.register
public function register() { $this->app->bind( Attributes::class, Attr::class ); $this->app->alias( Attributes::class, 'attr' ); }
php
public function register() { $this->app->bind( Attributes::class, Attr::class ); $this->app->alias( Attributes::class, 'attr' ); }
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "Attributes", "::", "class", ",", "Attr", "::", "class", ")", ";", "$", "this", "->", "app", "->", "alias", "(", "Attributes", "::", "class", ",", "'attr'",...
Binds the implementation of the attributes contract to the container. @since 5.0.0 @access public @return void
[ "Binds", "the", "implementation", "of", "the", "attributes", "contract", "to", "the", "container", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Attr/AttrServiceProvider.php#L37-L42
justintadlock/hybrid-core
src/Pagination/Pagination.php
Pagination.postsArgs
protected function postsArgs() { global $wp_query, $wp_rewrite; // Setting up default values based on the current URL. $pagenum_link = html_entity_decode( get_pagenum_link() ); $this->url_parts = explode( '?', $pagenum_link ); // Get total number of pages. $total = isset( $wp_query->max_num_pages ) ? $...
php
protected function postsArgs() { global $wp_query, $wp_rewrite; // Setting up default values based on the current URL. $pagenum_link = html_entity_decode( get_pagenum_link() ); $this->url_parts = explode( '?', $pagenum_link ); // Get total number of pages. $total = isset( $wp_query->max_num_pages ) ? $...
[ "protected", "function", "postsArgs", "(", ")", "{", "global", "$", "wp_query", ",", "$", "wp_rewrite", ";", "// Setting up default values based on the current URL.", "$", "pagenum_link", "=", "html_entity_decode", "(", "get_pagenum_link", "(", ")", ")", ";", "$", "...
Returns custom arguments for normal, posts pagination. @since 5.0.0 @access protected @global object $wp_query @global object $wp_rewrite @return array
[ "Returns", "custom", "arguments", "for", "normal", "posts", "pagination", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Pagination/Pagination.php#L225-L251
justintadlock/hybrid-core
src/Pagination/Pagination.php
Pagination.postArgs
protected function postArgs() { global $page, $numpages, $more, $wp_rewrite; // Split the current URL between the base and query string. $this->url_parts = explode( '?', html_entity_decode( get_permalink() ) ); // Build the base without the query string. $base = trailingslashit( $this->url_parts[0] ) . '%_%...
php
protected function postArgs() { global $page, $numpages, $more, $wp_rewrite; // Split the current URL between the base and query string. $this->url_parts = explode( '?', html_entity_decode( get_permalink() ) ); // Build the base without the query string. $base = trailingslashit( $this->url_parts[0] ) . '%_%...
[ "protected", "function", "postArgs", "(", ")", "{", "global", "$", "page", ",", "$", "numpages", ",", "$", "more", ",", "$", "wp_rewrite", ";", "// Split the current URL between the base and query string.", "$", "this", "->", "url_parts", "=", "explode", "(", "'...
Returns custom arguments for singular post pagination. @since 5.0.0 @access protected @global int $page @global int $numpages @global bool $more @global object $wp_rewrite @return array
[ "Returns", "custom", "arguments", "for", "singular", "post", "pagination", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Pagination/Pagination.php#L264-L283
justintadlock/hybrid-core
src/Pagination/Pagination.php
Pagination.commentsArgs
protected function commentsArgs() { global $wp_rewrite; $base = add_query_arg( 'cpage', '%#%' ); // Split the current URL between the base and query string. $this->url_parts = explode( '?', html_entity_decode( get_pagenum_link() ) ); if ( $wp_rewrite->using_permalinks() ) { $base = user_trailingslashit(...
php
protected function commentsArgs() { global $wp_rewrite; $base = add_query_arg( 'cpage', '%#%' ); // Split the current URL between the base and query string. $this->url_parts = explode( '?', html_entity_decode( get_pagenum_link() ) ); if ( $wp_rewrite->using_permalinks() ) { $base = user_trailingslashit(...
[ "protected", "function", "commentsArgs", "(", ")", "{", "global", "$", "wp_rewrite", ";", "$", "base", "=", "add_query_arg", "(", "'cpage'", ",", "'%#%'", ")", ";", "// Split the current URL between the base and query string.", "$", "this", "->", "url_parts", "=", ...
Returns custom arguments for comments pagination. @since 5.0.0 @access protected @global object $wp_rewrite @return array
[ "Returns", "custom", "arguments", "for", "comments", "pagination", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Pagination/Pagination.php#L292-L311
justintadlock/hybrid-core
src/Pagination/Pagination.php
Pagination.render
public function render() { $title = $list = $template = ''; if ( $this->items ) { // If there's title text, format it. if ( $this->args['title_text'] ) { $title = sprintf( '<%1$s class="%2$s">%3$s</%1$s>', tag_escape( $this->args['title_tag'] ), esc_attr( $this->args['title_class'] ), ...
php
public function render() { $title = $list = $template = ''; if ( $this->items ) { // If there's title text, format it. if ( $this->args['title_text'] ) { $title = sprintf( '<%1$s class="%2$s">%3$s</%1$s>', tag_escape( $this->args['title_tag'] ), esc_attr( $this->args['title_class'] ), ...
[ "public", "function", "render", "(", ")", "{", "$", "title", "=", "$", "list", "=", "$", "template", "=", "''", ";", "if", "(", "$", "this", "->", "items", ")", "{", "// If there's title text, format it.", "if", "(", "$", "this", "->", "args", "[", "...
Returns the pagination output. @since 5.0.0 @access public @return string
[ "Returns", "the", "pagination", "output", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Pagination/Pagination.php#L332-L375
justintadlock/hybrid-core
src/Pagination/Pagination.php
Pagination.make
public function make() { if ( 2 <= $this->total ) { $this->prevItem(); for ( $n = 1; $n <= $this->total; $n++ ) { $this->pageItem( $n ); } $this->nextItem(); } return $this; }
php
public function make() { if ( 2 <= $this->total ) { $this->prevItem(); for ( $n = 1; $n <= $this->total; $n++ ) { $this->pageItem( $n ); } $this->nextItem(); } return $this; }
[ "public", "function", "make", "(", ")", "{", "if", "(", "2", "<=", "$", "this", "->", "total", ")", "{", "$", "this", "->", "prevItem", "(", ")", ";", "for", "(", "$", "n", "=", "1", ";", "$", "n", "<=", "$", "this", "->", "total", ";", "$"...
Builds the pagination `$items` array. @since 5.0.0 @access public @return PaginationContract
[ "Builds", "the", "pagination", "$items", "array", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Pagination/Pagination.php#L384-L398
justintadlock/hybrid-core
src/Pagination/Pagination.php
Pagination.formatItem
private function formatItem( $item ) { $is_link = isset( $item['url'] ); $attr = []; $esc_attr = ''; // Add the anchor/span class attribute. $attr['class'] = sprintf( $this->args['anchor_class'], $is_link ? 'link' : $item['type'] ); // If this is a link, add the URL. if ( $is_link ) { $...
php
private function formatItem( $item ) { $is_link = isset( $item['url'] ); $attr = []; $esc_attr = ''; // Add the anchor/span class attribute. $attr['class'] = sprintf( $this->args['anchor_class'], $is_link ? 'link' : $item['type'] ); // If this is a link, add the URL. if ( $is_link ) { $...
[ "private", "function", "formatItem", "(", "$", "item", ")", "{", "$", "is_link", "=", "isset", "(", "$", "item", "[", "'url'", "]", ")", ";", "$", "attr", "=", "[", "]", ";", "$", "esc_attr", "=", "''", ";", "// Add the anchor/span class attribute.", "...
Format an item's HTML output. @since 5.0.0 @access private @param array $item @return string
[ "Format", "an", "item", "s", "HTML", "output", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Pagination/Pagination.php#L408-L449
justintadlock/hybrid-core
src/Pagination/Pagination.php
Pagination.prevItem
protected function prevItem() { if ( $this->args['prev_next'] && $this->current && 1 < $this->current ) { $this->items[] = [ 'type' => 'prev', 'url' => $this->buildUrl( 2 == $this->current ? '' : $this->args['format'], $this->current - 1 ), 'content' => $this->args['prev_text'] ]; } }
php
protected function prevItem() { if ( $this->args['prev_next'] && $this->current && 1 < $this->current ) { $this->items[] = [ 'type' => 'prev', 'url' => $this->buildUrl( 2 == $this->current ? '' : $this->args['format'], $this->current - 1 ), 'content' => $this->args['prev_text'] ]; } }
[ "protected", "function", "prevItem", "(", ")", "{", "if", "(", "$", "this", "->", "args", "[", "'prev_next'", "]", "&&", "$", "this", "->", "current", "&&", "1", "<", "$", "this", "->", "current", ")", "{", "$", "this", "->", "items", "[", "]", "...
Builds the previous item. @since 5.0.0 @access protected @return void
[ "Builds", "the", "previous", "item", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Pagination/Pagination.php#L458-L468
justintadlock/hybrid-core
src/Pagination/Pagination.php
Pagination.nextItem
protected function nextItem() { if ( $this->args['prev_next'] && $this->current && $this->current < $this->total ) { $this->items[] = [ 'type' => 'next', 'url' => $this->buildUrl( $this->args['format'], $this->current + 1 ), 'content' => $this->args['next_text'] ]; } }
php
protected function nextItem() { if ( $this->args['prev_next'] && $this->current && $this->current < $this->total ) { $this->items[] = [ 'type' => 'next', 'url' => $this->buildUrl( $this->args['format'], $this->current + 1 ), 'content' => $this->args['next_text'] ]; } }
[ "protected", "function", "nextItem", "(", ")", "{", "if", "(", "$", "this", "->", "args", "[", "'prev_next'", "]", "&&", "$", "this", "->", "current", "&&", "$", "this", "->", "current", "<", "$", "this", "->", "total", ")", "{", "$", "this", "->",...
Builds the next item. @since 5.0.0 @access protected @return void
[ "Builds", "the", "next", "item", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Pagination/Pagination.php#L477-L487
justintadlock/hybrid-core
src/Pagination/Pagination.php
Pagination.pageItem
protected function pageItem( $n ) { // If the current item we're building is for the current page // being viewed. if ( $n === $this->current ) { $this->items[] = [ 'type' => 'current', 'content' => $this->args['before_page_number'] . number_format_i18n( $n ) . $this->args['after_page_number'] ...
php
protected function pageItem( $n ) { // If the current item we're building is for the current page // being viewed. if ( $n === $this->current ) { $this->items[] = [ 'type' => 'current', 'content' => $this->args['before_page_number'] . number_format_i18n( $n ) . $this->args['after_page_number'] ...
[ "protected", "function", "pageItem", "(", "$", "n", ")", "{", "// If the current item we're building is for the current page", "// being viewed.", "if", "(", "$", "n", "===", "$", "this", "->", "current", ")", "{", "$", "this", "->", "items", "[", "]", "=", "[...
Builds the numeric page link, current item, and dots item. @since 5.0.0 @access protected @return void
[ "Builds", "the", "numeric", "page", "link", "current", "item", "and", "dots", "item", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Pagination/Pagination.php#L496-L532
justintadlock/hybrid-core
src/Pagination/Pagination.php
Pagination.buildUrl
protected function buildUrl( $format, $number ) { $link = str_replace( '%_%', $format, $this->args['base'] ); $link = str_replace( '%#%', $number, $link ); // Adds any existing or new query vars to the URL. if ( $this->args['add_args'] ) { $link = add_query_arg( $this->args['add_args'], $link ); } // ...
php
protected function buildUrl( $format, $number ) { $link = str_replace( '%_%', $format, $this->args['base'] ); $link = str_replace( '%#%', $number, $link ); // Adds any existing or new query vars to the URL. if ( $this->args['add_args'] ) { $link = add_query_arg( $this->args['add_args'], $link ); } // ...
[ "protected", "function", "buildUrl", "(", "$", "format", ",", "$", "number", ")", "{", "$", "link", "=", "str_replace", "(", "'%_%'", ",", "$", "format", ",", "$", "this", "->", "args", "[", "'base'", "]", ")", ";", "$", "link", "=", "str_replace", ...
Builds and formats a page link URL. @since 5.0.0 @access protected @param string $format @param int $number @return string
[ "Builds", "and", "formats", "a", "page", "link", "URL", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Pagination/Pagination.php#L543-L558
justintadlock/hybrid-core
src/Core/Application.php
Application.registerDefaultBindings
protected function registerDefaultBindings() { // Add the instance of this application. $this->instance( 'app', $this ); // Adds the directory path for the framework. $this->instance( 'path', untrailingslashit( HYBRID_DIR ) ); // Add the version for the framework. $this->instance( 'version', static::VER...
php
protected function registerDefaultBindings() { // Add the instance of this application. $this->instance( 'app', $this ); // Adds the directory path for the framework. $this->instance( 'path', untrailingslashit( HYBRID_DIR ) ); // Add the version for the framework. $this->instance( 'version', static::VER...
[ "protected", "function", "registerDefaultBindings", "(", ")", "{", "// Add the instance of this application.", "$", "this", "->", "instance", "(", "'app'", ",", "$", "this", ")", ";", "// Adds the directory path for the framework.", "$", "this", "->", "instance", "(", ...
Registers the default bindings we need to run the framework. @since 5.0.0 @access protected @return void
[ "Registers", "the", "default", "bindings", "we", "need", "to", "run", "the", "framework", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Core/Application.php#L103-L113
justintadlock/hybrid-core
src/Core/Application.php
Application.registerDefaultProviders
protected function registerDefaultProviders() { array_map( function( $provider ) { $this->provider( $provider ); }, [ AttrServiceProvider::class, LanguageServiceProvider::class, MetaServiceProvider::class, TemplatesServiceProvider::class, HierarchyServiceProvider::class, ViewServiceProvider::c...
php
protected function registerDefaultProviders() { array_map( function( $provider ) { $this->provider( $provider ); }, [ AttrServiceProvider::class, LanguageServiceProvider::class, MetaServiceProvider::class, TemplatesServiceProvider::class, HierarchyServiceProvider::class, ViewServiceProvider::c...
[ "protected", "function", "registerDefaultProviders", "(", ")", "{", "array_map", "(", "function", "(", "$", "provider", ")", "{", "$", "this", "->", "provider", "(", "$", "provider", ")", ";", "}", ",", "[", "AttrServiceProvider", "::", "class", ",", "Lang...
Adds the default service providers for the framework. @since 5.0.0 @access protected @return void
[ "Adds", "the", "default", "service", "providers", "for", "the", "framework", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Core/Application.php#L122-L134
justintadlock/hybrid-core
src/Core/Application.php
Application.provider
public function provider( $provider ) { if ( is_string( $provider ) ) { $provider = $this->resolveProvider( $provider ); } $this->providers[] = $provider; }
php
public function provider( $provider ) { if ( is_string( $provider ) ) { $provider = $this->resolveProvider( $provider ); } $this->providers[] = $provider; }
[ "public", "function", "provider", "(", "$", "provider", ")", "{", "if", "(", "is_string", "(", "$", "provider", ")", ")", "{", "$", "provider", "=", "$", "this", "->", "resolveProvider", "(", "$", "provider", ")", ";", "}", "$", "this", "->", "provid...
Adds a service provider. @since 5.0.0 @access public @param string|object $provider @return void
[ "Adds", "a", "service", "provider", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Core/Application.php#L168-L175
justintadlock/hybrid-core
src/Core/Application.php
Application.registerProxies
protected function registerProxies() { Proxy::setContainer( $this ); foreach ( $this->proxies as $class => $alias ) { class_alias( $class, $alias ); } }
php
protected function registerProxies() { Proxy::setContainer( $this ); foreach ( $this->proxies as $class => $alias ) { class_alias( $class, $alias ); } }
[ "protected", "function", "registerProxies", "(", ")", "{", "Proxy", "::", "setContainer", "(", "$", "this", ")", ";", "foreach", "(", "$", "this", "->", "proxies", "as", "$", "class", "=>", "$", "alias", ")", "{", "class_alias", "(", "$", "class", ",",...
Registers the static proxy classes. @since 5.0.0 @access protected @return void
[ "Registers", "the", "static", "proxy", "classes", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Core/Application.php#L282-L289
justintadlock/hybrid-core
src/Lang/Language.php
Language.boot
public function boot() { // Load the locale functions files. add_action( 'after_setup_theme', [ $this, 'loadLocaleFunctions' ], ~PHP_INT_MAX ); // Load framework textdomain. add_action( 'after_setup_theme', [ $this, 'loadTextdomain' ], 95 ); // Overrides the load textdomain function for the 'hybrid-core' d...
php
public function boot() { // Load the locale functions files. add_action( 'after_setup_theme', [ $this, 'loadLocaleFunctions' ], ~PHP_INT_MAX ); // Load framework textdomain. add_action( 'after_setup_theme', [ $this, 'loadTextdomain' ], 95 ); // Overrides the load textdomain function for the 'hybrid-core' d...
[ "public", "function", "boot", "(", ")", "{", "// Load the locale functions files.", "add_action", "(", "'after_setup_theme'", ",", "[", "$", "this", ",", "'loadLocaleFunctions'", "]", ",", "~", "PHP_INT_MAX", ")", ";", "// Load framework textdomain.", "add_action", "(...
Adds the class' actions and filters. @since 5.0.0 @access public @return void
[ "Adds", "the", "class", "actions", "and", "filters", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Lang/Language.php#L96-L109
justintadlock/hybrid-core
src/Lang/Language.php
Language.loadLocaleFunctions
public function loadLocaleFunctions() { // Get the site's locale. $locale = is_admin() ? get_user_locale() : get_locale(); $locale = strtolower( str_replace( '_', '-', $locale ) ); // Define locale functions files. $child_func = $this->childPath( "{$locale}.php" ); $theme_func = $this->parentPath( "{$loc...
php
public function loadLocaleFunctions() { // Get the site's locale. $locale = is_admin() ? get_user_locale() : get_locale(); $locale = strtolower( str_replace( '_', '-', $locale ) ); // Define locale functions files. $child_func = $this->childPath( "{$locale}.php" ); $theme_func = $this->parentPath( "{$loc...
[ "public", "function", "loadLocaleFunctions", "(", ")", "{", "// Get the site's locale.", "$", "locale", "=", "is_admin", "(", ")", "?", "get_user_locale", "(", ")", ":", "get_locale", "(", ")", ";", "$", "locale", "=", "strtolower", "(", "str_replace", "(", ...
Loads a `/{$langpath}/{$locale}.php` file for specific locales. `$locale` should be an all lowercase and hyphenated (as opposed to an underscore) file name. So, an `en_US` locale would be `en-us.php`. Also note that the child theme locale file will load **before** the parent theme locale file. This is standard practi...
[ "Loads", "a", "/", "{", "$langpath", "}", "/", "{", "$locale", "}", ".", "php", "file", "for", "specific", "locales", ".", "$locale", "should", "be", "an", "all", "lowercase", "and", "hyphenated", "(", "as", "opposed", "to", "an", "underscore", ")", "f...
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Lang/Language.php#L181-L200
justintadlock/hybrid-core
src/Lang/Language.php
Language.overrideLoadTextdomain
public function overrideLoadTextdomain( $override, $domain, $mofile ) { global $l10n; // Check if the domain is one of our framework domains. if ( 'hybrid-core' === $domain ) { // Get the theme's textdomain. $theme_textdomain = $this->parentTextdomain(); // If the theme's textdomain is loaded, use its...
php
public function overrideLoadTextdomain( $override, $domain, $mofile ) { global $l10n; // Check if the domain is one of our framework domains. if ( 'hybrid-core' === $domain ) { // Get the theme's textdomain. $theme_textdomain = $this->parentTextdomain(); // If the theme's textdomain is loaded, use its...
[ "public", "function", "overrideLoadTextdomain", "(", "$", "override", ",", "$", "domain", ",", "$", "mofile", ")", "{", "global", "$", "l10n", ";", "// Check if the domain is one of our framework domains.", "if", "(", "'hybrid-core'", "===", "$", "domain", ")", "{...
Overrides the load textdomain functionality when `hybrid-core` is the domain in use. The purpose of this is to allow theme translations to handle the framework's strings. What this function does is sets the `hybrid-core` domain's translations to the theme's. That way, we're not loading multiple of the same MO files. ...
[ "Overrides", "the", "load", "textdomain", "functionality", "when", "hybrid", "-", "core", "is", "the", "domain", "in", "use", ".", "The", "purpose", "of", "this", "is", "to", "allow", "theme", "translations", "to", "handle", "the", "framework", "s", "strings...
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Lang/Language.php#L231-L251
justintadlock/hybrid-core
src/Lang/Language.php
Language.loadTextdomainMofile
public function loadTextdomainMofile( $mofile, $domain ) { // If the `$domain` is for the parent or child theme, search for // a `$domain-$locale.mo` file. if ( $domain == $this->parentTextdomain() || $domain == $this->childTextdomain() ) { // Get the locale. $locale = is_admin() ? get_user_locale() : get...
php
public function loadTextdomainMofile( $mofile, $domain ) { // If the `$domain` is for the parent or child theme, search for // a `$domain-$locale.mo` file. if ( $domain == $this->parentTextdomain() || $domain == $this->childTextdomain() ) { // Get the locale. $locale = is_admin() ? get_user_locale() : get...
[ "public", "function", "loadTextdomainMofile", "(", "$", "mofile", ",", "$", "domain", ")", "{", "// If the `$domain` is for the parent or child theme, search for", "// a `$domain-$locale.mo` file.", "if", "(", "$", "domain", "==", "$", "this", "->", "parentTextdomain", "(...
Filters the `load_textdomain_mofile` filter hook so that we can prepend the theme textdomain to the mofile filename. This also allows child themes to house a copy of the parent theme translations so that it doesn't get overwritten when a parent theme is updated. @since 5.0.0 @access public @param string $mofile File...
[ "Filters", "the", "load_textdomain_mofile", "filter", "hook", "so", "that", "we", "can", "prepend", "the", "theme", "textdomain", "to", "the", "mofile", "filename", ".", "This", "also", "allows", "child", "themes", "to", "house", "a", "copy", "of", "the", "p...
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Lang/Language.php#L265-L290
justintadlock/hybrid-core
src/Template/HierarchyServiceProvider.php
HierarchyServiceProvider.register
public function register() { $this->app->singleton( TemplateHierarchy::class, Hierarchy::class ); $this->app->alias( TemplateHierarchy::class, 'template/hierarchy' ); }
php
public function register() { $this->app->singleton( TemplateHierarchy::class, Hierarchy::class ); $this->app->alias( TemplateHierarchy::class, 'template/hierarchy' ); }
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "TemplateHierarchy", "::", "class", ",", "Hierarchy", "::", "class", ")", ";", "$", "this", "->", "app", "->", "alias", "(", "TemplateHierarchy", "::", "cl...
Registration callback that adds a single instance of the template hierarchy to the container. @since 5.0.0 @access public @return void
[ "Registration", "callback", "that", "adds", "a", "single", "instance", "of", "the", "template", "hierarchy", "to", "the", "container", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Template/HierarchyServiceProvider.php#L36-L41
justintadlock/hybrid-core
src/Container/Container.php
Container.bind
public function bind( $abstract, $concrete = null, $shared = false ) { unset( $this->instances[ $abstract ] ); if ( is_null( $concrete ) ) { $concrete = $abstract; } $this->bindings[ $abstract ] = compact( 'concrete', 'shared' ); $this->extensions[ $abstract ] = []; }
php
public function bind( $abstract, $concrete = null, $shared = false ) { unset( $this->instances[ $abstract ] ); if ( is_null( $concrete ) ) { $concrete = $abstract; } $this->bindings[ $abstract ] = compact( 'concrete', 'shared' ); $this->extensions[ $abstract ] = []; }
[ "public", "function", "bind", "(", "$", "abstract", ",", "$", "concrete", "=", "null", ",", "$", "shared", "=", "false", ")", "{", "unset", "(", "$", "this", "->", "instances", "[", "$", "abstract", "]", ")", ";", "if", "(", "is_null", "(", "$", ...
Add a binding. The abstract should be a key, abstract class name, or interface name. The concrete should be the concrete implementation of the abstract. If no concrete is given, its assumed the abstract handles the concrete implementation. @since 5.0.0 @access public @param string $abstract @param mixed $concret...
[ "Add", "a", "binding", ".", "The", "abstract", "should", "be", "a", "key", "abstract", "class", "name", "or", "interface", "name", ".", "The", "concrete", "should", "be", "the", "concrete", "implementation", "of", "the", "abstract", ".", "If", "no", "concr...
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Container/Container.php#L98-L108
justintadlock/hybrid-core
src/Container/Container.php
Container.resolve
public function resolve( $abstract, array $parameters = [] ) { // Get the true abstract name. $abstract = $this->getAbstract( $abstract ); // If this is being managed as an instance and we already have // the instance, return it now. if ( isset( $this->instances[ $abstract ] ) ) { return $this->instance...
php
public function resolve( $abstract, array $parameters = [] ) { // Get the true abstract name. $abstract = $this->getAbstract( $abstract ); // If this is being managed as an instance and we already have // the instance, return it now. if ( isset( $this->instances[ $abstract ] ) ) { return $this->instance...
[ "public", "function", "resolve", "(", "$", "abstract", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "// Get the true abstract name.", "$", "abstract", "=", "$", "this", "->", "getAbstract", "(", "$", "abstract", ")", ";", "// If this is being mana...
Resolve and return the binding. @since 5.0.0 @access public @param string $abstract @param array $parameters @return mixed
[ "Resolve", "and", "return", "the", "binding", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Container/Container.php#L150-L198
justintadlock/hybrid-core
src/Container/Container.php
Container.getConcrete
protected function getConcrete( $abstract ) { $concrete = false; $abstract = $this->getAbstract( $abstract ); if ( $this->has( $abstract ) ) { $concrete = $this->bindings[ $abstract ]['concrete']; } return $concrete ?: $abstract; }
php
protected function getConcrete( $abstract ) { $concrete = false; $abstract = $this->getAbstract( $abstract ); if ( $this->has( $abstract ) ) { $concrete = $this->bindings[ $abstract ]['concrete']; } return $concrete ?: $abstract; }
[ "protected", "function", "getConcrete", "(", "$", "abstract", ")", "{", "$", "concrete", "=", "false", ";", "$", "abstract", "=", "$", "this", "->", "getAbstract", "(", "$", "abstract", ")", ";", "if", "(", "$", "this", "->", "has", "(", "$", "abstra...
Gets the concrete of an abstract. @since 5.0.0 @access protected @param string $abstract @return mixed
[ "Gets", "the", "concrete", "of", "an", "abstract", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Container/Container.php#L315-L325
justintadlock/hybrid-core
src/Container/Container.php
Container.build
protected function build( $concrete, array $parameters = [] ) { if ( $concrete instanceof Closure ) { return $concrete( $this, $parameters ); } $reflect = new ReflectionClass( $concrete ); $constructor = $reflect->getConstructor(); if ( ! $constructor ) { return new $concrete(); } return $refle...
php
protected function build( $concrete, array $parameters = [] ) { if ( $concrete instanceof Closure ) { return $concrete( $this, $parameters ); } $reflect = new ReflectionClass( $concrete ); $constructor = $reflect->getConstructor(); if ( ! $constructor ) { return new $concrete(); } return $refle...
[ "protected", "function", "build", "(", "$", "concrete", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "if", "(", "$", "concrete", "instanceof", "Closure", ")", "{", "return", "$", "concrete", "(", "$", "this", ",", "$", "parameters", ")", ...
Builds the concrete implementation. If a closure, we'll simply return the closure and pass the included parameters. Otherwise, we'll resolve the dependencies for the class and return a new object. @since 5.0.0 @access protected @param mixed $concrete @param array $parameters @return object
[ "Builds", "the", "concrete", "implementation", ".", "If", "a", "closure", "we", "ll", "simply", "return", "the", "closure", "and", "pass", "the", "included", "parameters", ".", "Otherwise", "we", "ll", "resolve", "the", "dependencies", "for", "the", "class", ...
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Container/Container.php#L353-L370
justintadlock/hybrid-core
src/Container/Container.php
Container.resolveDependencies
protected function resolveDependencies( array $dependencies, array $parameters ) { $args = []; foreach ( $dependencies as $dependency ) { // If a dependency is set via the parameters passed in, use it. if ( isset( $parameters[ $dependency->getName() ] ) ) { $args[] = $parameters[ $dependency->getName(...
php
protected function resolveDependencies( array $dependencies, array $parameters ) { $args = []; foreach ( $dependencies as $dependency ) { // If a dependency is set via the parameters passed in, use it. if ( isset( $parameters[ $dependency->getName() ] ) ) { $args[] = $parameters[ $dependency->getName(...
[ "protected", "function", "resolveDependencies", "(", "array", "$", "dependencies", ",", "array", "$", "parameters", ")", "{", "$", "args", "=", "[", "]", ";", "foreach", "(", "$", "dependencies", "as", "$", "dependency", ")", "{", "// If a dependency is set vi...
Resolves the dependencies for a method's parameters. @todo Handle errors when we can't solve a dependency. @since 5.0.0 @access protected @param array $dependencies @param array $parameters @return array
[ "Resolves", "the", "dependencies", "for", "a", "method", "s", "parameters", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Container/Container.php#L383-L407
justintadlock/hybrid-core
src/Lang/LanguageServiceProvider.php
LanguageServiceProvider.register
public function register() { $this->app->singleton( LanguageContract::class, Language::class ); $this->app->alias( LanguageContract::class, 'language' ); }
php
public function register() { $this->app->singleton( LanguageContract::class, Language::class ); $this->app->alias( LanguageContract::class, 'language' ); }
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "LanguageContract", "::", "class", ",", "Language", "::", "class", ")", ";", "$", "this", "->", "app", "->", "alias", "(", "LanguageContract", "::", "class...
Registration callback that adds a single instance of the language system to the container. @since 5.0.0 @access public @return void
[ "Registration", "callback", "that", "adds", "a", "single", "instance", "of", "the", "language", "system", "to", "the", "container", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Lang/LanguageServiceProvider.php#L36-L41
justintadlock/hybrid-core
src/Template/Hierarchy.php
Hierarchy.boot
public function boot() { // Filter the front page template. add_filter( 'frontpage_template_hierarchy', [ $this, 'frontPage' ], 5 ); // Filter the single, page, and attachment templates. add_filter( 'single_template_hierarchy', [ $this, 'single' ], 5 ); add_filter( 'page_template_hierarchy', [ $t...
php
public function boot() { // Filter the front page template. add_filter( 'frontpage_template_hierarchy', [ $this, 'frontPage' ], 5 ); // Filter the single, page, and attachment templates. add_filter( 'single_template_hierarchy', [ $this, 'single' ], 5 ); add_filter( 'page_template_hierarchy', [ $t...
[ "public", "function", "boot", "(", ")", "{", "// Filter the front page template.", "add_filter", "(", "'frontpage_template_hierarchy'", ",", "[", "$", "this", ",", "'frontPage'", "]", ",", "5", ")", ";", "// Filter the single, page, and attachment templates.", "add_filter...
Sets up template hierarchy filters. @since 5.0.0 @access public @return void
[ "Sets", "up", "template", "hierarchy", "filters", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Template/Hierarchy.php#L86-L119
justintadlock/hybrid-core
src/Template/Hierarchy.php
Hierarchy.frontPage
public function frontPage( $templates ) { $templates = []; if ( ! is_home() ) { $custom = get_page_template_slug( get_queried_object_id() ); if ( $custom ) { $templates[] = $custom; } $templates[] = 'front-page.php'; } // Return the template hierarchy. return $templates; }
php
public function frontPage( $templates ) { $templates = []; if ( ! is_home() ) { $custom = get_page_template_slug( get_queried_object_id() ); if ( $custom ) { $templates[] = $custom; } $templates[] = 'front-page.php'; } // Return the template hierarchy. return $templates; }
[ "public", "function", "frontPage", "(", "$", "templates", ")", "{", "$", "templates", "=", "[", "]", ";", "if", "(", "!", "is_home", "(", ")", ")", "{", "$", "custom", "=", "get_page_template_slug", "(", "get_queried_object_id", "(", ")", ")", ";", "if...
Fix for the front page template handling in WordPress core. Its handling is not logical because it forces devs to account for both a page on the front page and posts on the front page. Theme devs must handle both scenarios if they've created a "front-page.php" template. This filter overwrites that and disables the `fr...
[ "Fix", "for", "the", "front", "page", "template", "handling", "in", "WordPress", "core", ".", "Its", "handling", "is", "not", "logical", "because", "it", "forces", "devs", "to", "account", "for", "both", "a", "page", "on", "the", "front", "page", "and", ...
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Template/Hierarchy.php#L152-L169
justintadlock/hybrid-core
src/Template/Hierarchy.php
Hierarchy.single
public function single( $templates ) { $templates = []; // Get the queried post. $post = get_queried_object(); // Decode the post name. $name = urldecode( $post->post_name ); // Check for a custom post template. $custom = get_page_template_slug( $post->ID ); if ( $custom ) { $templates[] = $cust...
php
public function single( $templates ) { $templates = []; // Get the queried post. $post = get_queried_object(); // Decode the post name. $name = urldecode( $post->post_name ); // Check for a custom post template. $custom = get_page_template_slug( $post->ID ); if ( $custom ) { $templates[] = $cust...
[ "public", "function", "single", "(", "$", "templates", ")", "{", "$", "templates", "=", "[", "]", ";", "// Get the queried post.", "$", "post", "=", "get_queried_object", "(", ")", ";", "// Decode the post name.", "$", "name", "=", "urldecode", "(", "$", "po...
Overrides the default single (singular post) template for all post types, including pages and attachments. @since 5.0.0 @access public @param array $templates @return array
[ "Overrides", "the", "default", "single", "(", "singular", "post", ")", "template", "for", "all", "post", "types", "including", "pages", "and", "attachments", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Template/Hierarchy.php#L180-L236
justintadlock/hybrid-core
src/Template/Hierarchy.php
Hierarchy.taxonomy
public function taxonomy( $template ) { $templates = []; // Get the queried term object. $term = get_queried_object(); $slug = urldecode( $term->slug ); // Remove 'post-format' from the slug. if ( 'post_format' === $term->taxonomy ) { $slug = str_replace( 'post-format-', '', $slug ); } // Slug-ba...
php
public function taxonomy( $template ) { $templates = []; // Get the queried term object. $term = get_queried_object(); $slug = urldecode( $term->slug ); // Remove 'post-format' from the slug. if ( 'post_format' === $term->taxonomy ) { $slug = str_replace( 'post-format-', '', $slug ); } // Slug-ba...
[ "public", "function", "taxonomy", "(", "$", "template", ")", "{", "$", "templates", "=", "[", "]", ";", "// Get the queried term object.", "$", "term", "=", "get_queried_object", "(", ")", ";", "$", "slug", "=", "urldecode", "(", "$", "term", "->", "slug",...
Overrides WP's default template for taxonomy-based archives. This allows better organization of taxonomy template files by making categories and post tags work the same way as other taxonomies. @since 5.0.0 @access public @param array $templates @return array
[ "Overrides", "WP", "s", "default", "template", "for", "taxonomy", "-", "based", "archives", ".", "This", "allows", "better", "organization", "of", "taxonomy", "template", "files", "by", "making", "categories", "and", "post", "tags", "work", "the", "same", "way...
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Template/Hierarchy.php#L248-L272
justintadlock/hybrid-core
src/Template/Hierarchy.php
Hierarchy.author
public function author( $templates ) { $templates = []; // Get the user nicename. $name = get_the_author_meta( 'user_nicename', get_query_var( 'author' ) ); // Get the user object. $user = new WP_User( absint( get_query_var( 'author' ) ) ); // Add the user nicename template. $templates[] = "user-{$nam...
php
public function author( $templates ) { $templates = []; // Get the user nicename. $name = get_the_author_meta( 'user_nicename', get_query_var( 'author' ) ); // Get the user object. $user = new WP_User( absint( get_query_var( 'author' ) ) ); // Add the user nicename template. $templates[] = "user-{$nam...
[ "public", "function", "author", "(", "$", "templates", ")", "{", "$", "templates", "=", "[", "]", ";", "// Get the user nicename.", "$", "name", "=", "get_the_author_meta", "(", "'user_nicename'", ",", "get_query_var", "(", "'author'", ")", ")", ";", "// Get t...
Overrides WP's default template for author-based archives. Better abstraction of templates than `is_author()` allows by allowing themes to specify templates for a specific author. @since 5.0.0 @access public @param array $templates @return array
[ "Overrides", "WP", "s", "default", "template", "for", "author", "-", "based", "archives", ".", "Better", "abstraction", "of", "templates", "than", "is_author", "()", "allows", "by", "allowing", "themes", "to", "specify", "templates", "for", "a", "specific", "a...
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Template/Hierarchy.php#L284-L311
justintadlock/hybrid-core
src/Template/Hierarchy.php
Hierarchy.date
public function date( $templates ) { $templates = []; // If viewing a time-based archive. if ( is_time() ) { // If viewing a minutely archive. if ( get_query_var( 'minute' ) ) { $templates[] = 'minute.php'; // If viewing an hourly archive. } elseif ( get_query_var( 'hour' ) ) { $templates[...
php
public function date( $templates ) { $templates = []; // If viewing a time-based archive. if ( is_time() ) { // If viewing a minutely archive. if ( get_query_var( 'minute' ) ) { $templates[] = 'minute.php'; // If viewing an hourly archive. } elseif ( get_query_var( 'hour' ) ) { $templates[...
[ "public", "function", "date", "(", "$", "templates", ")", "{", "$", "templates", "=", "[", "]", ";", "// If viewing a time-based archive.", "if", "(", "is_time", "(", ")", ")", "{", "// If viewing a minutely archive.", "if", "(", "get_query_var", "(", "'minute'"...
Overrides WP's default template for date-based archives. Better abstraction of templates than `is_date()` allows by checking for the year, month, week, day, hour, and minute. @since 5.0.0 @access public @param array $templates @return array
[ "Overrides", "WP", "s", "default", "template", "for", "date", "-", "based", "archives", ".", "Better", "abstraction", "of", "templates", "than", "is_date", "()", "allows", "by", "checking", "for", "the", "year", "month", "week", "day", "hour", "and", "minute...
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Template/Hierarchy.php#L323-L368
justintadlock/hybrid-core
src/Template/Hierarchy.php
Hierarchy.templateHierarchy
public function templateHierarchy( $templates ) { // WooCommerce kind of does its own thing on `template_include`. // It's top-level `woocommerce.php` template isn't added to the // hierarchy until then. So, we're going prepend it to the // hierarchy here to make the `woocommerce.php` template available. if ...
php
public function templateHierarchy( $templates ) { // WooCommerce kind of does its own thing on `template_include`. // It's top-level `woocommerce.php` template isn't added to the // hierarchy until then. So, we're going prepend it to the // hierarchy here to make the `woocommerce.php` template available. if ...
[ "public", "function", "templateHierarchy", "(", "$", "templates", ")", "{", "// WooCommerce kind of does its own thing on `template_include`.", "// It's top-level `woocommerce.php` template isn't added to the", "// hierarchy until then. So, we're going prepend it to the", "// hierarchy here to...
Filters a queried template hierarchy for each type of template and looks templates within `resources/views`. @since 5.0.0 @access public @return array
[ "Filters", "a", "queried", "template", "hierarchy", "for", "each", "type", "of", "template", "and", "looks", "templates", "within", "resources", "/", "views", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Template/Hierarchy.php#L378-L408
justintadlock/hybrid-core
src/Media/Meta.php
Meta.get
public function get( $key ) { // `filesize` is correct, but `file_size` matches up with the // other `file_*` meta names, so let's support both. if ( 'filesize' === $key ) { $key = 'file_size'; } // Create the method name based on the given key. $method = str_replace( '_', '', lcfirst( ucwords( $key, '...
php
public function get( $key ) { // `filesize` is correct, but `file_size` matches up with the // other `file_*` meta names, so let's support both. if ( 'filesize' === $key ) { $key = 'file_size'; } // Create the method name based on the given key. $method = str_replace( '_', '', lcfirst( ucwords( $key, '...
[ "public", "function", "get", "(", "$", "key", ")", "{", "// `filesize` is correct, but `file_size` matches up with the", "// other `file_*` meta names, so let's support both.", "if", "(", "'filesize'", "===", "$", "key", ")", "{", "$", "key", "=", "'file_size'", ";", "}...
Returns the escaped and formatted media meta. @since 5.0.0 @access public @param string $key @return string
[ "Returns", "the", "escaped", "and", "formatted", "media", "meta", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Media/Meta.php#L69-L85
justintadlock/hybrid-core
src/Media/Meta.php
Meta.raw
protected function raw( $key ) { $value = ''; // If the property exists in the meta array. if ( isset( $this->meta[ $key ] ) ) { $value = $this->meta[ $key ]; // If the property exists in the image meta array. } elseif ( isset( $this->meta['image_meta'] ) && isset( $this->meta['image_meta'][ $key ] ) )...
php
protected function raw( $key ) { $value = ''; // If the property exists in the meta array. if ( isset( $this->meta[ $key ] ) ) { $value = $this->meta[ $key ]; // If the property exists in the image meta array. } elseif ( isset( $this->meta['image_meta'] ) && isset( $this->meta['image_meta'][ $key ] ) )...
[ "protected", "function", "raw", "(", "$", "key", ")", "{", "$", "value", "=", "''", ";", "// If the property exists in the meta array.", "if", "(", "isset", "(", "$", "this", "->", "meta", "[", "$", "key", "]", ")", ")", "{", "$", "value", "=", "$", ...
Returns raw data from the media meta. @since 5.0.0 @access protected @param string $key @return mixed
[ "Returns", "raw", "data", "from", "the", "media", "meta", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Media/Meta.php#L95-L116
justintadlock/hybrid-core
src/Media/Meta.php
Meta.aperture
protected function aperture() { $aperture = $this->raw( 'aperture' ); if ( $aperture ) { $aperture = sprintf( '<sup>f</sup>&#8260;<sub>%s</sub>', absint( $aperture ) ); } return $aperture; }
php
protected function aperture() { $aperture = $this->raw( 'aperture' ); if ( $aperture ) { $aperture = sprintf( '<sup>f</sup>&#8260;<sub>%s</sub>', absint( $aperture ) ); } return $aperture; }
[ "protected", "function", "aperture", "(", ")", "{", "$", "aperture", "=", "$", "this", "->", "raw", "(", "'aperture'", ")", ";", "if", "(", "$", "aperture", ")", "{", "$", "aperture", "=", "sprintf", "(", "'<sup>f</sup>&#8260;<sub>%s</sub>'", ",", "absint"...
Returns the camera aperture for an image. @since 5.0.0 @access protected @return string
[ "Returns", "the", "camera", "aperture", "for", "an", "image", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Media/Meta.php#L125-L138
justintadlock/hybrid-core
src/Media/Meta.php
Meta.createdTimestamp
protected function createdTimestamp() { $timestamp = $this->raw( 'created_timestamp' ); if ( $timestamp ) { $timestamp = date_i18n( get_option( 'date_format' ), strip_tags( $timestamp ) ); } return $timestamp; }
php
protected function createdTimestamp() { $timestamp = $this->raw( 'created_timestamp' ); if ( $timestamp ) { $timestamp = date_i18n( get_option( 'date_format' ), strip_tags( $timestamp ) ); } return $timestamp; }
[ "protected", "function", "createdTimestamp", "(", ")", "{", "$", "timestamp", "=", "$", "this", "->", "raw", "(", "'created_timestamp'", ")", ";", "if", "(", "$", "timestamp", ")", "{", "$", "timestamp", "=", "date_i18n", "(", "get_option", "(", "'date_for...
Returns the created timestamp for an image. @since 5.0.0 @access protected @return string
[ "Returns", "the", "created", "timestamp", "for", "an", "image", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Media/Meta.php#L147-L160
justintadlock/hybrid-core
src/Media/Meta.php
Meta.dimensions
protected function dimensions() { $dimensions = ''; $width = $this->raw( 'width' ); $height = $this->raw( 'height' ); if ( ! empty( $width ) && ! empty( $height ) ) { $dimensions = sprintf( // Translators: Media dimensions - 1 is width and 2 is height. esc_html__( '%1$s &#215; %2$s', 'hy...
php
protected function dimensions() { $dimensions = ''; $width = $this->raw( 'width' ); $height = $this->raw( 'height' ); if ( ! empty( $width ) && ! empty( $height ) ) { $dimensions = sprintf( // Translators: Media dimensions - 1 is width and 2 is height. esc_html__( '%1$s &#215; %2$s', 'hy...
[ "protected", "function", "dimensions", "(", ")", "{", "$", "dimensions", "=", "''", ";", "$", "width", "=", "$", "this", "->", "raw", "(", "'width'", ")", ";", "$", "height", "=", "$", "this", "->", "raw", "(", "'height'", ")", ";", "if", "(", "!...
Returns the media dimensions (width/height). @since 5.0.0 @access protected @return string
[ "Returns", "the", "media", "dimensions", "(", "width", "/", "height", ")", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Media/Meta.php#L169-L186
justintadlock/hybrid-core
src/Media/Meta.php
Meta.fileName
protected function fileName() { $filename = basename( get_attached_file( $this->post->ID ) ); if ( $filename ) { $filename = sprintf( '<a href="%s">%s</a>', esc_url( wp_get_attachment_url( $this->post->ID ) ), $filename ); } return $filename; }
php
protected function fileName() { $filename = basename( get_attached_file( $this->post->ID ) ); if ( $filename ) { $filename = sprintf( '<a href="%s">%s</a>', esc_url( wp_get_attachment_url( $this->post->ID ) ), $filename ); } return $filename; }
[ "protected", "function", "fileName", "(", ")", "{", "$", "filename", "=", "basename", "(", "get_attached_file", "(", "$", "this", "->", "post", "->", "ID", ")", ")", ";", "if", "(", "$", "filename", ")", "{", "$", "filename", "=", "sprintf", "(", "'<...
Returns the media file name, linked to the original media file. @since 5.0.0 @access protected @return string
[ "Returns", "the", "media", "file", "name", "linked", "to", "the", "original", "media", "file", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Media/Meta.php#L195-L209
justintadlock/hybrid-core
src/Media/Meta.php
Meta.fileSize
protected function fileSize() { $filesize = isset( $this->meta['filesize'] ) ? $this->meta['filesize'] : ''; if ( ! $filesize ) { $file = get_attached_file( $this->post->ID ); if ( file_exists( $file ) ) { $filesize = filesize( $file ); } } if ( $filesize ) { $filesize = size_format( strip_...
php
protected function fileSize() { $filesize = isset( $this->meta['filesize'] ) ? $this->meta['filesize'] : ''; if ( ! $filesize ) { $file = get_attached_file( $this->post->ID ); if ( file_exists( $file ) ) { $filesize = filesize( $file ); } } if ( $filesize ) { $filesize = size_format( strip_...
[ "protected", "function", "fileSize", "(", ")", "{", "$", "filesize", "=", "isset", "(", "$", "this", "->", "meta", "[", "'filesize'", "]", ")", "?", "$", "this", "->", "meta", "[", "'filesize'", "]", ":", "''", ";", "if", "(", "!", "$", "filesize",...
Returns the media file size. @since 5.0.0 @access protected @return string
[ "Returns", "the", "media", "file", "size", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Media/Meta.php#L218-L236
justintadlock/hybrid-core
src/Media/Meta.php
Meta.fileType
protected function fileType() { $type = ''; if ( preg_match( '/^.*?\.(\w+)$/', get_attached_file( $this->post->ID ), $matches ) ) { $type = $matches[1]; } return $type ? esc_html( strtoupper( $type ) ) : ''; }
php
protected function fileType() { $type = ''; if ( preg_match( '/^.*?\.(\w+)$/', get_attached_file( $this->post->ID ), $matches ) ) { $type = $matches[1]; } return $type ? esc_html( strtoupper( $type ) ) : ''; }
[ "protected", "function", "fileType", "(", ")", "{", "$", "type", "=", "''", ";", "if", "(", "preg_match", "(", "'/^.*?\\.(\\w+)$/'", ",", "get_attached_file", "(", "$", "this", "->", "post", "->", "ID", ")", ",", "$", "matches", ")", ")", "{", "$", "...
Returns the media file type. @since 5.0.0 @access protected @return string
[ "Returns", "the", "media", "file", "type", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Media/Meta.php#L245-L255
justintadlock/hybrid-core
src/Media/Meta.php
Meta.focalLength
protected function focalLength() { $focal_length = $this->raw( 'focal_length' ); if ( $focal_length ) { // Translators: %s is the focal length of a camera. $focal_length = sprintf( __( '%s mm', 'hybrid-core' ), absint( $focal_length ) ); } return $focal_length; }
php
protected function focalLength() { $focal_length = $this->raw( 'focal_length' ); if ( $focal_length ) { // Translators: %s is the focal length of a camera. $focal_length = sprintf( __( '%s mm', 'hybrid-core' ), absint( $focal_length ) ); } return $focal_length; }
[ "protected", "function", "focalLength", "(", ")", "{", "$", "focal_length", "=", "$", "this", "->", "raw", "(", "'focal_length'", ")", ";", "if", "(", "$", "focal_length", ")", "{", "// Translators: %s is the focal length of a camera.", "$", "focal_length", "=", ...
Returns the camera focal length for an image. @since 5.0.0 @access protected @return string
[ "Returns", "the", "camera", "focal", "length", "for", "an", "image", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Media/Meta.php#L264-L278
justintadlock/hybrid-core
src/Media/Meta.php
Meta.lyrics
protected function lyrics() { $lyrics = ''; // Look for the 'unsynchronised_lyric' tag. if ( isset( $this->meta['unsynchronised_lyric'] ) ) { $lyrics = $this->meta['unsynchronised_lyric']; // Seen this misspelling of the id3 tag. } elseif ( isset( $this->meta['unsychronised_lyric'] ) ) { $lyrics = $t...
php
protected function lyrics() { $lyrics = ''; // Look for the 'unsynchronised_lyric' tag. if ( isset( $this->meta['unsynchronised_lyric'] ) ) { $lyrics = $this->meta['unsynchronised_lyric']; // Seen this misspelling of the id3 tag. } elseif ( isset( $this->meta['unsychronised_lyric'] ) ) { $lyrics = $t...
[ "protected", "function", "lyrics", "(", ")", "{", "$", "lyrics", "=", "''", ";", "// Look for the 'unsynchronised_lyric' tag.", "if", "(", "isset", "(", "$", "this", "->", "meta", "[", "'unsynchronised_lyric'", "]", ")", ")", "{", "$", "lyrics", "=", "$", ...
Returns the lyrics for an audio file. @since 5.0.0 @access protected @return string
[ "Returns", "the", "lyrics", "for", "an", "audio", "file", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Media/Meta.php#L287-L308
justintadlock/hybrid-core
src/Media/Meta.php
Meta.mimeType
protected function mimeType() { $mime_type = get_post_mime_type( $this->post ); if ( ! $mime_type ) { $mime_type = $this->raw( 'mime_type' ); } return $mime_type ? esc_html( $mime_type ) : ''; }
php
protected function mimeType() { $mime_type = get_post_mime_type( $this->post ); if ( ! $mime_type ) { $mime_type = $this->raw( 'mime_type' ); } return $mime_type ? esc_html( $mime_type ) : ''; }
[ "protected", "function", "mimeType", "(", ")", "{", "$", "mime_type", "=", "get_post_mime_type", "(", "$", "this", "->", "post", ")", ";", "if", "(", "!", "$", "mime_type", ")", "{", "$", "mime_type", "=", "$", "this", "->", "raw", "(", "'mime_type'", ...
Returns the media file mime type. @since 5.0.0 @access protected @return string
[ "Returns", "the", "media", "file", "mime", "type", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Media/Meta.php#L317-L326
justintadlock/hybrid-core
src/Media/Meta.php
Meta.shutterSpeed
protected function shutterSpeed() { $shutter = $this->raw( 'shutter_speed' ); // If a shutter speed is given, format the float into a fraction. if ( $shutter ) { $shutter = $speed = floatval( strip_tags( $shutter ) ); if ( ( 1 / $speed ) > 1 ) { $shutter = sprintf( '<sup>%s</sup>&#8260;', number_for...
php
protected function shutterSpeed() { $shutter = $this->raw( 'shutter_speed' ); // If a shutter speed is given, format the float into a fraction. if ( $shutter ) { $shutter = $speed = floatval( strip_tags( $shutter ) ); if ( ( 1 / $speed ) > 1 ) { $shutter = sprintf( '<sup>%s</sup>&#8260;', number_for...
[ "protected", "function", "shutterSpeed", "(", ")", "{", "$", "shutter", "=", "$", "this", "->", "raw", "(", "'shutter_speed'", ")", ";", "// If a shutter speed is given, format the float into a fraction.", "if", "(", "$", "shutter", ")", "{", "$", "shutter", "=", ...
Returns the camera shutter speed for an image. @since 5.0.0 @access protected @return string
[ "Returns", "the", "camera", "shutter", "speed", "for", "an", "image", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Media/Meta.php#L335-L368
justintadlock/hybrid-core
src/Template/Manager.php
Manager.postTemplates
public function postTemplates( $templates, $theme, $post, $post_type ) { foreach ( $this->templates->all() as $template ) { if ( $template->forPostType( $post_type ) ) { $templates[ $template->filename() ] = esc_html( $template->label() ); } } return $templates; }
php
public function postTemplates( $templates, $theme, $post, $post_type ) { foreach ( $this->templates->all() as $template ) { if ( $template->forPostType( $post_type ) ) { $templates[ $template->filename() ] = esc_html( $template->label() ); } } return $templates; }
[ "public", "function", "postTemplates", "(", "$", "templates", ",", "$", "theme", ",", "$", "post", ",", "$", "post_type", ")", "{", "foreach", "(", "$", "this", "->", "templates", "->", "all", "(", ")", "as", "$", "template", ")", "{", "if", "(", "...
Filter used on `theme_templates` to add custom templates to the template drop-down. Note that this method is `public` because of WP's hook callback system. See the implemented contract for publicly-available methods. @since 5.0.0 @access public @param array $templates @param object $theme @param object $post ...
[ "Filter", "used", "on", "theme_templates", "to", "add", "custom", "templates", "to", "the", "template", "drop", "-", "down", "." ]
train
https://github.com/justintadlock/hybrid-core/blob/20f15f3235505ed7d11f121f45b2ef226bc0c88f/src/Template/Manager.php#L96-L107
phptal/PHPTAL
classes/PHPTAL/Php/Attribute/TAL/Attributes.php
PHPTAL_Php_Attribute_TAL_Attributes.prepareAttributeUnconditional
private function prepareAttributeUnconditional(PHPTAL_Php_CodeWriter $codewriter, $qname, $code) { // regular attribute which value is the evaluation of $code $attkey = $this->getVarName($qname, $codewriter); if ($this->_echoType == PHPTAL_Php_Attribute::ECHO_STRUCTURE) { $value ...
php
private function prepareAttributeUnconditional(PHPTAL_Php_CodeWriter $codewriter, $qname, $code) { // regular attribute which value is the evaluation of $code $attkey = $this->getVarName($qname, $codewriter); if ($this->_echoType == PHPTAL_Php_Attribute::ECHO_STRUCTURE) { $value ...
[ "private", "function", "prepareAttributeUnconditional", "(", "PHPTAL_Php_CodeWriter", "$", "codewriter", ",", "$", "qname", ",", "$", "code", ")", "{", "// regular attribute which value is the evaluation of $code", "$", "attkey", "=", "$", "this", "->", "getVarName", "(...
attribute will be output regardless of its evaluated value. NULL behaves just like "".
[ "attribute", "will", "be", "output", "regardless", "of", "its", "evaluated", "value", ".", "NULL", "behaves", "just", "like", "." ]
train
https://github.com/phptal/PHPTAL/blob/40e0cdbebfa1c5bfca7b722037ea41fee7362946/classes/PHPTAL/Php/Attribute/TAL/Attributes.php#L95-L106
phptal/PHPTAL
classes/PHPTAL/Php/Attribute/TAL/Attributes.php
PHPTAL_Php_Attribute_TAL_Attributes.prepareAttributeConditional
private function prepareAttributeConditional(PHPTAL_Php_CodeWriter $codewriter, $qname, $code) { // regular attribute which value is the evaluation of $code $attkey = $this->getVarName($qname, $codewriter); $codewriter->doIf("null !== ($attkey = ($code))"); if ($this->_echoType !==...
php
private function prepareAttributeConditional(PHPTAL_Php_CodeWriter $codewriter, $qname, $code) { // regular attribute which value is the evaluation of $code $attkey = $this->getVarName($qname, $codewriter); $codewriter->doIf("null !== ($attkey = ($code))"); if ($this->_echoType !==...
[ "private", "function", "prepareAttributeConditional", "(", "PHPTAL_Php_CodeWriter", "$", "codewriter", ",", "$", "qname", ",", "$", "code", ")", "{", "// regular attribute which value is the evaluation of $code", "$", "attkey", "=", "$", "this", "->", "getVarName", "(",...
If evaluated value of attribute is NULL, it will not be output at all.
[ "If", "evaluated", "value", "of", "attribute", "is", "NULL", "it", "will", "not", "be", "output", "at", "all", "." ]
train
https://github.com/phptal/PHPTAL/blob/40e0cdbebfa1c5bfca7b722037ea41fee7362946/classes/PHPTAL/Php/Attribute/TAL/Attributes.php#L111-L128
phptal/PHPTAL
classes/PHPTAL/Dom/XmlnsState.php
PHPTAL_Dom_XmlnsState.newElement
public function newElement(array $nodeAttributes) { $prefix_to_uri = $this->prefix_to_uri; $current_default = $this->current_default; $changed = false; foreach ($nodeAttributes as $qname => $value) { if (preg_match('/^xmlns:(.+)$/', $qname, $m)) { $change...
php
public function newElement(array $nodeAttributes) { $prefix_to_uri = $this->prefix_to_uri; $current_default = $this->current_default; $changed = false; foreach ($nodeAttributes as $qname => $value) { if (preg_match('/^xmlns:(.+)$/', $qname, $m)) { $change...
[ "public", "function", "newElement", "(", "array", "$", "nodeAttributes", ")", "{", "$", "prefix_to_uri", "=", "$", "this", "->", "prefix_to_uri", ";", "$", "current_default", "=", "$", "this", "->", "current_default", ";", "$", "changed", "=", "false", ";", ...
Returns a new XmlnsState inheriting of $this if $nodeAttributes contains xmlns attributes, returns $this otherwise. This method is used by the PHPTAL parser to keep track of xmlns fluctuation for each encountered node.
[ "Returns", "a", "new", "XmlnsState", "inheriting", "of", "$this", "if", "$nodeAttributes", "contains", "xmlns", "attributes", "returns", "$this", "otherwise", "." ]
train
https://github.com/phptal/PHPTAL/blob/40e0cdbebfa1c5bfca7b722037ea41fee7362946/classes/PHPTAL/Dom/XmlnsState.php#L66-L87
phptal/PHPTAL
classes/PHPTAL/Dom/Element.php
PHPTAL_Dom_Element.replaceTextWithCDATA
private function replaceTextWithCDATA() { $isCDATAelement = PHPTAL_Dom_Defs::getInstance()->isCDATAElementInHTML($this->getNamespaceURI(), $this->getLocalName()); if (!$isCDATAelement) { return; } $valueEscaped = ''; // sometimes parser generates split text nodes. "norm...
php
private function replaceTextWithCDATA() { $isCDATAelement = PHPTAL_Dom_Defs::getInstance()->isCDATAElementInHTML($this->getNamespaceURI(), $this->getLocalName()); if (!$isCDATAelement) { return; } $valueEscaped = ''; // sometimes parser generates split text nodes. "norm...
[ "private", "function", "replaceTextWithCDATA", "(", ")", "{", "$", "isCDATAelement", "=", "PHPTAL_Dom_Defs", "::", "getInstance", "(", ")", "->", "isCDATAElementInHTML", "(", "$", "this", "->", "getNamespaceURI", "(", ")", ",", "$", "this", "->", "getLocalName",...
Replace <script> foo &gt; bar </script> with <script>/*<![CDATA[* / foo > bar /*]]>* /</script> This avoids gotcha in text/html. Note that PHPTAL_Dom_CDATASection::generate() does reverse operation, if needed! @return void
[ "Replace", "<script", ">", "foo", "&gt", ";", "bar", "<", "/", "script", ">", "with", "<script", ">", "/", "*", "<!", "[", "CDATA", "[", "*", "/", "foo", ">", "bar", "/", "*", "]]", ">", "*", "/", "<", "/", "script", ">", "This", "avoids", "g...
train
https://github.com/phptal/PHPTAL/blob/40e0cdbebfa1c5bfca7b722037ea41fee7362946/classes/PHPTAL/Dom/Element.php#L85-L117
phptal/PHPTAL
classes/PHPTAL/Dom/Element.php
PHPTAL_Dom_Element.hasAttribute
public function hasAttribute($qname) { foreach($this->attribute_nodes as $attr) if ($attr->getQualifiedName() == $qname) return true; return false; }
php
public function hasAttribute($qname) { foreach($this->attribute_nodes as $attr) if ($attr->getQualifiedName() == $qname) return true; return false; }
[ "public", "function", "hasAttribute", "(", "$", "qname", ")", "{", "foreach", "(", "$", "this", "->", "attribute_nodes", "as", "$", "attr", ")", "if", "(", "$", "attr", "->", "getQualifiedName", "(", ")", "==", "$", "qname", ")", "return", "true", ";",...
Returns true if the element contains specified PHPTAL attribute.
[ "Returns", "true", "if", "the", "element", "contains", "specified", "PHPTAL", "attribute", "." ]
train
https://github.com/phptal/PHPTAL/blob/40e0cdbebfa1c5bfca7b722037ea41fee7362946/classes/PHPTAL/Dom/Element.php#L213-L217
phptal/PHPTAL
classes/PHPTAL/Dom/Element.php
PHPTAL_Dom_Element.getOrCreateAttributeNode
public function getOrCreateAttributeNode($qname) { if ($attr = $this->getAttributeNode($qname)) return $attr; $attr = new PHPTAL_Dom_Attr($qname, "", null, 'UTF-8'); // FIXME: should find namespace and encoding $this->attribute_nodes[] = $attr; return $attr; }
php
public function getOrCreateAttributeNode($qname) { if ($attr = $this->getAttributeNode($qname)) return $attr; $attr = new PHPTAL_Dom_Attr($qname, "", null, 'UTF-8'); // FIXME: should find namespace and encoding $this->attribute_nodes[] = $attr; return $attr; }
[ "public", "function", "getOrCreateAttributeNode", "(", "$", "qname", ")", "{", "if", "(", "$", "attr", "=", "$", "this", "->", "getAttributeNode", "(", "$", "qname", ")", ")", "return", "$", "attr", ";", "$", "attr", "=", "new", "PHPTAL_Dom_Attr", "(", ...
If possible, use getAttributeNodeNS and setAttributeNS. NB: This method doesn't handle namespaces properly.
[ "If", "possible", "use", "getAttributeNodeNS", "and", "setAttributeNS", "." ]
train
https://github.com/phptal/PHPTAL/blob/40e0cdbebfa1c5bfca7b722037ea41fee7362946/classes/PHPTAL/Dom/Element.php#L253-L260
phptal/PHPTAL
classes/PHPTAL/Dom/Element.php
PHPTAL_Dom_Element.getAttributeNS
public function getAttributeNS($namespace_uri, $localname) { if ($n = $this->getAttributeNodeNS($namespace_uri, $localname)) { return $n->getValue(); } return ''; }
php
public function getAttributeNS($namespace_uri, $localname) { if ($n = $this->getAttributeNodeNS($namespace_uri, $localname)) { return $n->getValue(); } return ''; }
[ "public", "function", "getAttributeNS", "(", "$", "namespace_uri", ",", "$", "localname", ")", "{", "if", "(", "$", "n", "=", "$", "this", "->", "getAttributeNodeNS", "(", "$", "namespace_uri", ",", "$", "localname", ")", ")", "{", "return", "$", "n", ...
Returns textual (unescaped) value of specified element attribute.
[ "Returns", "textual", "(", "unescaped", ")", "value", "of", "specified", "element", "attribute", "." ]
train
https://github.com/phptal/PHPTAL/blob/40e0cdbebfa1c5bfca7b722037ea41fee7362946/classes/PHPTAL/Dom/Element.php#L263-L269