_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q22500 | ListPrinter.printScenariosList | train | public function printScenariosList(OutputPrinter $printer, $intro, $resultCode, array $scenarioStats)
{
if (!count($scenarioStats)) {
return;
}
$style = $this->resultConverter->convertResultCodeToString($resultCode);
$intro = $this->translator->trans($intro, array(), 'ou... | php | {
"resource": ""
} |
q22501 | ListPrinter.printStepList | train | public function printStepList(OutputPrinter $printer, $intro, $resultCode, array $stepStats)
{
if (!count($stepStats)) {
return;
}
$style = $this->resultConverter->convertResultCodeToString($resultCode);
$intro = $this->translator->trans($intro, array(), 'output');
... | php | {
"resource": ""
} |
q22502 | ListPrinter.printFailedHooksList | train | public function printFailedHooksList(OutputPrinter $printer, $intro, array $failedHookStats)
{
if (!count($failedHookStats)) {
return;
}
$style = $this->resultConverter->convertResultCodeToString(TestResult::FAILED);
$intro = $this->translator->trans($intro, array(), 'ou... | php | {
"resource": ""
} |
q22503 | StatisticsListener.printStatisticsOnAfterExerciseEvent | train | private function printStatisticsOnAfterExerciseEvent(Formatter $formatter, $eventName)
{
if (ExerciseCompleted::AFTER !== $eventName) {
return;
}
$this->statistics->stopTimer();
$this->printer->printStatistics($formatter, $this->statistics);
} | php | {
"resource": ""
} |
q22504 | PrettyScenarioPrinter.printKeyword | train | private function printKeyword(OutputPrinter $printer, $keyword)
{
$printer->write(sprintf('%s{+keyword}%s:{-keyword}', $this->indentText, $keyword));
} | php | {
"resource": ""
} |
q22505 | DefinitionArgumentsTransformer.transformArgument | train | private function transformArgument(DefinitionCall $definitionCall, $index, $value)
{
foreach ($this->argumentTransformers as $transformer) {
if (!$transformer->supportsDefinitionAndArgument($definitionCall, $index, $value)) {
continue;
}
return $transform... | php | {
"resource": ""
} |
q22506 | JUnitFeatureElementListener.captureScenarioEvent | train | private function captureScenarioEvent(ScenarioTested $event)
{
if ($event instanceof AfterScenarioTested) {
$this->afterScenarioTestedEvents[$event->getScenario()->getLine()] = array(
'event' => $event,
'step_events' => $this->afterStepTestedEven... | php | {
"resource": ""
} |
q22507 | JUnitFeatureElementListener.printFeatureOnAfterEvent | train | public function printFeatureOnAfterEvent(Formatter $formatter, Event $event)
{
if (!$event instanceof AfterFeatureTested) {
return;
}
$this->featurePrinter->printHeader($formatter, $this->beforeFeatureTestedEvent);
foreach ($this->afterScenarioTestedEvents as $afterScen... | php | {
"resource": ""
} |
q22508 | SuiteWithContextsSetup.getNormalizedContextClasses | train | private function getNormalizedContextClasses(Suite $suite)
{
return array_map(
function ($context) {
return is_array($context) ? current(array_keys($context)) : $context;
},
$this->getSuiteContexts($suite)
);
} | php | {
"resource": ""
} |
q22509 | SuiteWithContextsSetup.getSuiteContexts | train | private function getSuiteContexts(Suite $suite)
{
$contexts = $suite->getSetting('contexts');
if (!is_array($contexts)) {
throw new SuiteConfigurationException(
sprintf('`contexts` setting of the "%s" suite is expected to be an array, `%s` given.',
$s... | php | {
"resource": ""
} |
q22510 | SuiteWithContextsSetup.createContextDirectory | train | private function createContextDirectory($path)
{
mkdir($path, 0777, true);
if ($this->logger) {
$this->logger->directoryCreated($path, 'place your context classes here');
}
} | php | {
"resource": ""
} |
q22511 | SuiteWithContextsSetup.createContextFile | train | private function createContextFile($path, $content)
{
file_put_contents($path, $content);
if ($this->logger) {
$this->logger->fileCreated($path, 'place your definitions, transformations and hooks here');
}
} | php | {
"resource": ""
} |
q22512 | SuiteWithContextsSetup.findClassFile | train | private function findClassFile($class)
{
list($classpath, $classname) = $this->findClasspathAndClass($class);
$classpath .= str_replace('_', DIRECTORY_SEPARATOR, $classname) . '.php';
foreach ($this->autoloader->getPrefixes() as $prefix => $dirs) {
if (0 === strpos($class, $pref... | php | {
"resource": ""
} |
q22513 | SuiteWithContextsSetup.generateClass | train | private function generateClass(Suite $suite, $class)
{
$content = null;
foreach ($this->classGenerators as $generator) {
if ($generator->supportsSuiteAndClass($suite, $class)) {
$content = $generator->generateClass($suite, $class);
}
}
return ... | php | {
"resource": ""
} |
q22514 | SuiteWithContextsSetup.findClasspathAndClass | train | private function findClasspathAndClass($class)
{
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$classpath = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $pos)) . DIRECTORY_SEPARATOR;
$classname = substr($class, $pos + 1);
... | php | {
"resource": ""
} |
q22515 | ServicesResolver.resolveArgument | train | private function resolveArgument($value)
{
if (is_string($value) && 0 === mb_strpos($value, '@')) {
return $this->container->get(mb_substr($value, 1));
}
return $value;
} | php | {
"resource": ""
} |
q22516 | ConsoleFormatter.replaceStyle | train | private function replaceStyle($match)
{
if (!$this->isDecorated()) {
return $match[2];
}
if ($this->hasStyle($match[1])) {
$style = $this->getStyle($match[1]);
} else {
return $match[0];
}
return $style->apply($match[2]);
} | php | {
"resource": ""
} |
q22517 | SnippetWriter.printSnippets | train | public function printSnippets(SnippetPrinter $printer, array $snippets)
{
$printableSnippets = array();
foreach ($snippets as $snippet) {
foreach ($snippet->getTargets() as $target) {
$targetSnippets = array();
if (isset($printableSnippets[$target])) {
... | php | {
"resource": ""
} |
q22518 | SnippetWriter.printUndefinedSteps | train | public function printUndefinedSteps(SnippetPrinter $printer, array $undefinedSteps)
{
$printableSteps = array();
foreach ($undefinedSteps as $undefinedStep) {
$suiteName = $undefinedStep->getEnvironment()->getSuite()->getName();
$step = $undefinedStep->getStep();
... | php | {
"resource": ""
} |
q22519 | SnippetWriter.appendSnippet | train | private function appendSnippet(AggregateSnippet $snippet)
{
foreach ($this->appenders as $appender) {
if (!$appender->supportsSnippet($snippet)) {
continue;
}
$appender->appendSnippet($snippet);
}
} | php | {
"resource": ""
} |
q22520 | RepositoryArgumentTransformer.applySimpleTransformations | train | private function applySimpleTransformations(array $transformations, DefinitionCall $definitionCall, $index, $value)
{
usort($transformations, function (SimpleArgumentTransformation $t1, SimpleArgumentTransformation $t2) {
if ($t1->getPriority() == $t2->getPriority()) {
return 0;
... | php | {
"resource": ""
} |
q22521 | RepositoryArgumentTransformer.transform | train | private function transform(DefinitionCall $definitionCall, Transformation $transformation, $index, $value)
{
if (is_object($value) && !$value instanceof ArgumentInterface) {
return $value;
}
if ($transformation instanceof SimpleArgumentTransformation &&
$transformati... | php | {
"resource": ""
} |
q22522 | RepositoryArgumentTransformer.splitSimpleAndNormalTransformations | train | private function splitSimpleAndNormalTransformations(array $transformations)
{
return array_reduce($transformations, function ($acc, $t) {
return array(
$t instanceof SimpleArgumentTransformation ? array_merge($acc[0], array($t)) : $acc[0],
!$t instanceof SimpleAr... | php | {
"resource": ""
} |
q22523 | ProgressFormatterFactory.loadRootNodeListener | train | protected function loadRootNodeListener(ContainerBuilder $container)
{
$definition = new Definition('Behat\Behat\Output\Node\EventListener\AST\StepListener', array(
new Reference('output.node.printer.progress.step')
));
$container->setDefinition(self::ROOT_LISTENER_ID, $definitio... | php | {
"resource": ""
} |
q22524 | ProgressFormatterFactory.loadCorePrinters | train | protected function loadCorePrinters(ContainerBuilder $container)
{
$definition = new Definition('Behat\Behat\Output\Node\Printer\CounterPrinter', array(
new Reference(self::RESULT_TO_STRING_CONVERTER_ID),
new Reference(TranslatorExtension::TRANSLATOR_ID),
));
$contain... | php | {
"resource": ""
} |
q22525 | Invoker.call | train | public function call($closure, array $parameters = [], $buffer = false)
{
if ($buffer) {
\ob_start();
}
$rslt = \call_user_func_array($closure, $parameters);
if ($buffer) {
return \ob_get_clean();
}
return $rslt;
} | php | {
"resource": ""
} |
q22526 | Event.start | train | public function start()
{
$command = $this->buildCommand();
$process = Process::fromStringCommand($command);
$this->setProcess($process);
$this->getProcess()->start(
function ($type, $content): void {
$this->wholeOutput[] = $content;
}
... | php | {
"resource": ""
} |
q22527 | Event.cron | train | public function cron(string $expression): self
{
/** @var array $parts */
$parts = \preg_split(
'/\s/',
$expression,
-1,
PREG_SPLIT_NO_EMPTY
);
if (\count($parts) > 5) {
throw new TaskException("Expression '{$expression}' h... | php | {
"resource": ""
} |
q22528 | Event.on | train | public function on($date)
{
$parsedDate = \date_parse($date);
$segments = \array_intersect_key($parsedDate, $this->fieldsPosition);
if ($parsedDate['year']) {
$this->skip(static function () use ($parsedDate) {
return (int) \date('Y') !== $parsedDate['year'];
... | php | {
"resource": ""
} |
q22529 | Event.weeklyOn | train | public function weeklyOn($day, $time = '0:0'): self
{
$this->dailyAt($time);
return $this->spliceIntoPosition(5, (string) $day);
} | php | {
"resource": ""
} |
q22530 | Event.days | train | public function days($days): self
{
$days = \is_array($days) ? $days : \func_get_args();
return $this->spliceIntoPosition(5, \implode(',', $days));
} | php | {
"resource": ""
} |
q22531 | Event.minute | train | public function minute($value): self
{
$value = \is_array($value) ? $value : \func_get_args();
return $this->spliceIntoPosition(1, \implode(',', $value));
} | php | {
"resource": ""
} |
q22532 | Event.every | train | public function every($unit = null, $value = null): self
{
if (null === $unit || !isset($this->fieldsPosition[$unit])) {
return $this;
}
$value = (1 === (int) $value) ? '*' : '*/' . $value;
return $this->spliceIntoPosition($this->fieldsPosition[$unit], $value)
... | php | {
"resource": ""
} |
q22533 | Event.refreshLock | train | public function refreshLock(): void
{
if (!$this->preventOverlapping) {
return;
}
$lock = $this->createLockObject();
$remainingLifetime = $lock->getRemainingLifetime();
// Lock will never expire
if (null === $remainingLifetime) {
return;
... | php | {
"resource": ""
} |
q22534 | Event.createLockObject | train | protected function createLockObject()
{
$this->checkLockFactory();
if (null === $this->lock && null !== $this->lockFactory) {
$ttl = 30;
$this->lock = $this->lockFactory
->createLock($this->lockKey(), $ttl);
}
return $this->lock;
} | php | {
"resource": ""
} |
q22535 | Event.serializeClosure | train | protected function serializeClosure(Closure $closure)
{
$closure = (new Serializer())->serialize($closure);
$serializedClosure = \http_build_query([$closure]);
$crunzRoot = CRUNZ_BIN;
return PHP_BINARY . " {$crunzRoot} closure:run {$serializedClosure}";
} | php | {
"resource": ""
} |
q22536 | Event.applyMask | train | protected function applyMask($unit)
{
$cron = \explode(' ', $this->expression);
$mask = ['0', '0', '1', '1', '*', '*'];
$fpos = $this->fieldsPosition[$unit] - 1;
\array_splice($cron, 0, $fpos, \array_slice($mask, 0, $fpos));
return $this->cron(\implode(' ', $cron));
} | php | {
"resource": ""
} |
q22537 | TaskGeneratorCommand.save | train | protected function save()
{
$filename = Path::create([$this->outputPath(), $this->outputFile()]);
return (bool) \file_put_contents($filename->toString(), $this->stub);
} | php | {
"resource": ""
} |
q22538 | TaskGeneratorCommand.outputPath | train | protected function outputPath()
{
$source = $this->config
->getSourcePath()
;
$destination = $this->ask('Where do you want to save the file? (Press enter for the current directory)');
$outputPath = null !== $destination ? $destination : $source;
if (!\file_exists... | php | {
"resource": ""
} |
q22539 | TaskGeneratorCommand.getStub | train | protected function getStub()
{
$projectRootDirectory = $this->filesystem
->projectRootDirectory();
$path = Path::fromStrings(
$projectRootDirectory,
'src',
'Stubs',
\ucfirst($this->type() . 'Task.php')
);
return $this->file... | php | {
"resource": ""
} |
q22540 | TaskGeneratorCommand.replaceFrequency | train | protected function replaceFrequency()
{
$this->stub = \str_replace('DummyFrequency', \rtrim($this->options['frequency'], '()'), $this->stub);
return $this;
} | php | {
"resource": ""
} |
q22541 | TaskGeneratorCommand.replaceConstraint | train | protected function replaceConstraint()
{
$this->stub = \str_replace('DummyConstraint', \rtrim($this->options['constraint'], '()'), $this->stub);
return $this;
} | php | {
"resource": ""
} |
q22542 | Schedule.run | train | public function run($command, array $parameters = [])
{
if (\is_string($command) && \count($parameters)) {
$command .= ' ' . $this->compileParameters($parameters);
}
$this->events[] = $event = new Event($this->id(), $command);
return $event;
} | php | {
"resource": ""
} |
q22543 | Schedule.events | train | public function events(array $events = null)
{
if (null !== $events) {
return $this->events = $events;
}
return $this->events;
} | php | {
"resource": ""
} |
q22544 | Schedule.id | train | protected function id()
{
while (true) {
$id = \uniqid('crunz', true);
if (!\array_key_exists($id, $this->events)) {
return $id;
}
}
} | php | {
"resource": ""
} |
q22545 | ProcessUtils.validateInput | train | public static function validateInput($caller, $input)
{
if (null !== $input) {
if (\is_resource($input)) {
return $input;
}
if (\is_string($input)) {
return $input;
}
if (\is_scalar($input)) {
return ... | php | {
"resource": ""
} |
q22546 | Logger.addStream | train | public function addStream($path, $level, $bubble = true)
{
$handler = new StreamHandler(
$path,
$this->parseLevel($level),
$bubble
);
$handler->setFormatter($this->getDefaultFormatter());
$this->logger
->pushHandler($handler)
;... | php | {
"resource": ""
} |
q22547 | Logger.getDefaultFormatter | train | protected function getDefaultFormatter()
{
$allowLinebreaks = $this->configuration
->get('log_allow_line_breaks')
;
return new LineFormatter(
null,
null,
$allowLinebreaks,
false
);
} | php | {
"resource": ""
} |
q22548 | EventRunner.handle | train | public function handle(OutputInterface $output, array $schedules = []): void
{
$this->schedules = $schedules;
$this->output = $output;
foreach ($this->schedules as $schedule) {
$this->consoleLogger
->debug("Invoke Schedule's ping before");
$this->pin... | php | {
"resource": ""
} |
q22549 | EventRunner.start | train | protected function start(Event $event): void
{
// if sendOutputTo or appendOutputTo have been specified
if (!$event->nullOutput()) {
// if sendOutputTo then truncate the log file if it exists
if (!$event->shouldAppendOutput) {
$f = @\fopen($event->output, 'r+'... | php | {
"resource": ""
} |
q22550 | EventRunner.manageStartedEvents | train | protected function manageStartedEvents(): void
{
while ($this->schedules) {
foreach ($this->schedules as $scheduleKey => $schedule) {
$events = $schedule->events();
// 10% chance that refresh will be called
$refreshLocks = (\mt_rand(1, 100) <= 10);... | php | {
"resource": ""
} |
q22551 | EventRunner.invoke | train | protected function invoke(array $callbacks = [], array $parameters = [])
{
$output = '';
foreach ($callbacks as $callback) {
// Invoke the callback with buffering enabled
$output .= $this->invoker->call($callback, $parameters, true);
}
return $output;
} | php | {
"resource": ""
} |
q22552 | EventRunner.formatEventError | train | protected function formatEventError(Event $event)
{
return $event->description
. '('
. $event->getCommandForDisplay()
. ') '
. PHP_EOL
. $event->wholeOutput()
. PHP_EOL;
} | php | {
"resource": ""
} |
q22553 | Mailer.getMailer | train | private function getMailer(): \Swift_Mailer
{
// If the mailer has already been defined via the constructor, return it.
if ($this->mailer) {
return $this->mailer;
}
// Get the proper transporter
switch ($this->config('mailer.transport')) {
case 'smtp'... | php | {
"resource": ""
} |
q22554 | Mailer.getSmtpTransport | train | private function getSmtpTransport(): \Swift_SmtpTransport
{
$object = new \Swift_SmtpTransport(
$this->config('smtp.host'),
$this->config('smtp.port'),
$this->config('smtp.encryption')
);
return $object
->setUsername($this->config('smtp.userna... | php | {
"resource": ""
} |
q22555 | Mailer.getMessage | train | private function getMessage(string $subject, string $message): \Swift_Message
{
$messageObject = new \Swift_Message($subject, $message);
$messageObject
->setFrom([$this->config('mailer.sender_email') => $this->config('mailer.sender_name')])
->setTo($this->config('mailer.recip... | php | {
"resource": ""
} |
q22556 | Configuration.get | train | public function get(string $key, $default = null)
{
if (null === $this->config) {
$this->config = $this->configurationParser
->parseConfig();
}
if (\array_key_exists($key, $this->config)) {
return $this->config[$key];
}
$parts = \expl... | php | {
"resource": ""
} |
q22557 | Sections.outer_sections_css | train | public function outer_sections_css() {
echo '<style>';
$css = '';
if ( ! empty( Kirki::$sections ) ) {
foreach ( Kirki::$sections as $section_args ) {
if ( isset( $section_args['id'] ) && isset( $section_args['type'] ) && 'outer' === $section_args['type'] || 'kirki-outer' === $section_args['type'] ) {
... | php | {
"resource": ""
} |
q22558 | User_Meta.get_root_value | train | protected function get_root_value( $default = null ) {
$id_base = $this->id_data['base'];
// Get all user-meta.
// We'll use this to check if the value is set or not,
// in order to figure out if we need to return the default value.
$user_meta = get_user_meta( get_current_user_id() );
// Get the single me... | php | {
"resource": ""
} |
q22559 | User_Meta.set_root_value | train | protected function set_root_value( $value ) {
$id_base = $this->id_data['base'];
// First delete the current user-meta.
// We're doing this to avoid duplicate entries.
delete_user_meta( get_current_user_id(), $id_base );
// Update the user-meta.
return update_user_meta( get_current_user_id(), $id_base, $v... | php | {
"resource": ""
} |
q22560 | Module.field_add_setting_args | train | public function field_add_setting_args( $args ) {
if ( ! isset( $args['transport'] ) ) {
return $args;
}
if ( 'postMessage' === $args['transport'] && isset( $args['js_vars'] ) && ! empty( $args['js_vars'] ) ) {
$this->fields[] = $args;
return $args;
}
if ( 'auto' === $args['transport'] ) {
$arg... | php | {
"resource": ""
} |
q22561 | Module.postmessage | train | public function postmessage() {
wp_enqueue_script( 'kirki_auto_postmessage', URL::get_from_path( __DIR__ . '/assets/scripts/script.js' ), [ 'jquery', 'customize-preview' ], KIRKI_VERSION, true );
$fields = array_merge( Kirki::$fields, $this->fields );
$data = [];
foreach ( $fields as $field ) {
if ( isset(... | php | {
"resource": ""
} |
q22562 | Output.apply_sanitize_callback | train | protected function apply_sanitize_callback( $output, $value ) {
if ( isset( $output['sanitize_callback'] ) && null !== $output['sanitize_callback'] ) {
// If the sanitize_callback is invalid, return the value.
if ( ! is_callable( $output['sanitize_callback'] ) ) {
return $value;
}
return call_user_fu... | php | {
"resource": ""
} |
q22563 | Output.parse_output | train | protected function parse_output() {
foreach ( $this->output as $output ) {
$skip = false;
// Apply any sanitization callbacks defined.
$value = $this->apply_sanitize_callback( $output, $this->value );
// Skip if value is empty.
if ( '' === $this->value ) {
$skip = true;
}
// No need to pro... | php | {
"resource": ""
} |
q22564 | Output.process_output | train | protected function process_output( $output, $value ) {
if ( ! isset( $output['element'] ) || ! isset( $output['property'] ) ) {
return;
}
$output['media_query'] = ( isset( $output['media_query'] ) ) ? $output['media_query'] : 'global';
$output['prefix'] = ( isset( $output['prefix'] ) ) ? $output['prefix... | php | {
"resource": ""
} |
q22565 | Output.process_property_value | train | protected function process_property_value( $property, $value ) {
$properties = apply_filters(
'kirki_output_property_classnames',
[
'font-family' => '\Kirki\Modules\CSS\Property\Font_Family',
'background-image' => '\Kirki\Modules\CSS\Property\Background_Image',
'background-position' => '\... | php | {
"resource": ""
} |
q22566 | Output.process_value | train | protected function process_value( $value, $output ) {
if ( isset( $output['property'] ) ) {
return $this->process_property_value( $output['property'], $value );
}
return $value;
} | php | {
"resource": ""
} |
q22567 | URL.get_instance | train | public static function get_instance( $path ) {
$path = \wp_normalize_path( $path );
if ( ! isset( self::$instances[ $path ] ) ) {
self::$instances[ $path ] = new self( $path );
}
return self::$instances[ $path ];
} | php | {
"resource": ""
} |
q22568 | URL.get_url | train | public function get_url() {
/**
* Start by replacing ABSPATH with site_url.
* This is not accurate at all and only serves as a fallback in case everything else fails.
*/
$this->url = \str_replace( ABSPATH, \trailingslashit( \site_url() ), $this->path );
/**
* If the file-path is inside wp-content re... | php | {
"resource": ""
} |
q22569 | Color_Palette.sanitize | train | public static function sanitize( $value ) {
if ( class_exists( '\Kirki\Field\Color' ) ) {
return \Kirki\Field\Color::sanitize( $value );
}
return esc_attr( $value );
} | php | {
"resource": ""
} |
q22570 | Modules.add_module | train | public static function add_module( $module ) {
if ( ! in_array( $module, self::$modules, true ) ) {
self::$modules[] = $module;
}
} | php | {
"resource": ""
} |
q22571 | Modules.remove_module | train | public static function remove_module( $module ) {
$key = array_search( $module, self::$modules, true );
if ( false !== $key ) {
unset( self::$modules[ $key ] );
}
} | php | {
"resource": ""
} |
q22572 | Preset.set_preset | train | protected function set_preset() {
// Set preset from the choices.
$this->preset = $this->choices;
// We're using a flat select.
foreach ( $this->choices as $key => $args ) {
$this->choices[ $key ] = $args['label'];
}
} | php | {
"resource": ""
} |
q22573 | Repeater.row_label | train | protected function row_label( $args ) {
// Validating args for row labels.
if ( isset( $args['row_label'] ) && is_array( $args['row_label'] ) && ! empty( $args['row_label'] ) ) {
// Validating row label type.
if ( isset( $args['row_label']['type'] ) && ( 'text' === $args['row_label']['type'] || 'field' === ... | php | {
"resource": ""
} |
q22574 | Generator.css | train | public static function css( $field ) {
// Set class vars.
self::$settings = $field['settings'];
self::$callback = isset( $field['sanitize_callback'] ) ? $field['sanitize_callback'] : '';
self::$field_type = $field['type'];
self::$field_type = ( isset( $field['choices'] ) && isset( $field['choices']['pare... | php | {
"resource": ""
} |
q22575 | Generator.styles_parse | train | public static function styles_parse( $css = [] ) {
// Pass our styles from the kirki_styles_array filter.
$css = apply_filters( 'kirki_styles_array', $css );
// Process the array of CSS properties and produce the final CSS.
$final_css = '';
if ( ! is_array( $css ) || empty( $css ) ) {
return '';
}
fo... | php | {
"resource": ""
} |
q22576 | Generator.add_prefixes | train | public static function add_prefixes( $css ) {
if ( is_array( $css ) ) {
foreach ( $css as $media_query => $elements ) {
foreach ( $elements as $element => $style_array ) {
foreach ( $style_array as $property => $value ) {
// Add -webkit-* and -moz-*.
if ( is_string( $property ) && in_array(
... | php | {
"resource": ""
} |
q22577 | Checkbox_Switch.set_choices | train | protected function set_choices() {
if ( ! is_array( $this->choices ) ) {
$this->choices = [];
}
$this->choices = wp_parse_args(
$this->choices,
[
'on' => esc_html__( 'On', 'kirki' ),
'off' => esc_html__( 'Off', 'kirki' ),
'round' => false,
]
);
} | php | {
"resource": ""
} |
q22578 | Kirki.add_panel | train | public static function add_panel( $id = '', $args = [] ) {
$args['id'] = $id;
if ( ! isset( $args['description'] ) ) {
$args['description'] = '';
}
if ( ! isset( $args['priority'] ) ) {
$args['priority'] = 10;
}
if ( ! isset( $args['type'] ) ) {
$args['type'] = 'default';
}
if ( false === strpo... | php | {
"resource": ""
} |
q22579 | Kirki.remove_panel | train | public static function remove_panel( $id = '' ) {
if ( ! in_array( $id, self::$panels_to_remove, true ) ) {
self::$panels_to_remove[] = $id;
}
} | php | {
"resource": ""
} |
q22580 | Kirki.remove_section | train | public static function remove_section( $id = '' ) {
if ( ! in_array( $id, self::$sections_to_remove, true ) ) {
self::$sections_to_remove[] = $id;
}
} | php | {
"resource": ""
} |
q22581 | Kirki.add_field | train | public static function add_field( $config_id, $args = [] ) {
if ( doing_action( 'customize_register' ) ) {
_doing_it_wrong( __METHOD__, esc_html__( 'Kirki fields should not be added on customize_register. Please add them directly, or on init.', 'kirki' ), '3.0.10' );
}
// Early exit if 'type' is not defined.
... | php | {
"resource": ""
} |
q22582 | Kirki.remove_control | train | public static function remove_control( $id ) {
if ( ! in_array( $id, self::$controls_to_remove, true ) ) {
self::$controls_to_remove[] = $id;
}
} | php | {
"resource": ""
} |
q22583 | Kirki.get_config_param | train | public static function get_config_param( $id, $param ) {
if ( ! isset( self::$config[ $id ] ) || ! isset( self::$config[ $id ][ $param ] ) ) {
return '';
}
return self::$config[ $id ][ $param ];
} | php | {
"resource": ""
} |
q22584 | Multicolor.sanitize | train | public static function sanitize( $value ) {
if ( ! is_array( $value ) ) {
return [];
}
foreach ( $value as $key => $val ) {
$value[ $key ] = Color::sanitize( $val );
}
return $value;
} | php | {
"resource": ""
} |
q22585 | Section.add_section | train | public function add_section( $args ) {
global $wp_customize;
// The default class to be used when creating a section.
$section_classname = 'WP_Customize_Section';
if ( isset( $args['type'] ) && array_key_exists( $args['type'], $this->section_types ) ) {
$section_classname = $this->section_types[ $args['typ... | php | {
"resource": ""
} |
q22586 | Embed.resource_hints | train | public function resource_hints( $urls, $relation_type ) {
$fonts_to_load = $this->googlefonts->fonts;
if ( ! empty( $fonts_to_load ) && 'preconnect' === $relation_type ) {
$urls[] = [
'href' => 'https://fonts.gstatic.com',
'crossorigin',
];
}
return $urls;
} | php | {
"resource": ""
} |
q22587 | Embed.the_css | train | public function the_css() {
foreach ( $this->fonts_to_load as $font ) {
$family = str_replace( ' ', '+', trim( $font['family'] ) );
$weights = join( ',', $font['weights'] );
$url = "https://fonts.googleapis.com/css?family={$family}:{$weights}&subset=cyrillic,cyrillic-ext,devanagari,greek,greek-ext,khmer... | php | {
"resource": ""
} |
q22588 | Embed.use_local_files | train | private function use_local_files( $css ) {
preg_match_all( '/https\:.*?\.woff/', $css, $matches );
$matches = array_shift( $matches );
foreach ( $matches as $match ) {
if ( 0 === strpos( $match, 'https://fonts.gstatic.com' ) ) {
$new_url = Helper::download_font_file( $match );
if ( $new_url ) {
... | php | {
"resource": ""
} |
q22589 | L10n.load_textdomain | train | public function load_textdomain() {
if ( null !== $this->get_path() ) {
load_textdomain( $this->textdomain, $this->get_path() );
}
load_plugin_textdomain( $this->textdomain, false, dirname( KIRKI_PLUGIN_FILE ) . '/languages' );
} | php | {
"resource": ""
} |
q22590 | L10n.get_path | train | protected function get_path() {
$path_found = false;
$found_path = null;
foreach ( $this->get_paths() as $path ) {
if ( $path_found ) {
continue;
}
$path = wp_normalize_path( $path );
if ( file_exists( $path ) ) {
$path_found = true;
$found_path = $path;
}
}
return $found_path;
} | php | {
"resource": ""
} |
q22591 | L10n.get_paths | train | protected function get_paths() {
return [
WP_LANG_DIR . '/' . $this->textdomain . '-' . get_locale() . '.mo',
dirname( KIRKI_PLUGIN_FILE ) . '/languages/' . $this->textdomain . '-' . get_locale() . '.mo',
];
} | php | {
"resource": ""
} |
q22592 | L10n.override_load_textdomain | train | public function override_load_textdomain( $override, $domain, $mofile ) {
global $l10n;
if ( isset( $l10n[ $this->get_theme_textdomain() ] ) ) {
$l10n['kirki'] = $l10n[ $this->get_theme_textdomain() ]; // phpcs:ignore WordPress.WP.GlobalVariablesOverride
}
// Check if the domain is "kirki".
if ( 'kirki' =... | php | {
"resource": ""
} |
q22593 | L10n.get_theme_textdomain | train | private function get_theme_textdomain() {
if ( '' === $this->theme_textdomain ) {
// Get the textdomain.
$theme = wp_get_theme();
$this->theme_textdomain = $theme->get( 'TextDomain' );
// If no texdomain was found, use the template folder name.
if ( ! $this->theme_textdomain ) {
... | php | {
"resource": ""
} |
q22594 | Kirki_Color.sanitize_hex | train | public static function sanitize_hex( $color = '#FFFFFF', $hash = true ) {
if ( ! $hash ) {
return ltrim( self::sanitize_color( $color, 'hex' ), '#' );
}
return self::sanitize_color( $color, 'hex' );
} | php | {
"resource": ""
} |
q22595 | Kirki_Color.sanitize_color | train | public static function sanitize_color( $color = '', $mode = 'auto' ) {
if ( is_string( $color ) && 'transparent' == trim( $color ) ) {
return 'transparent';
}
$obj = ariColor::newColor( $color );
if ( 'auto' == $mode ) {
$mode = $obj->mode;
}
return $obj->toCSS( $mode );
} | php | {
"resource": ""
} |
q22596 | Kirki_Color.get_rgb | train | public static function get_rgb( $color, $implode = false ) {
$obj = ariColor::newColor( $color );
if ( $implode ) {
return $obj->toCSS( 'rgb' );
}
return array( $obj->red, $obj->green, $obj->blue );
} | php | {
"resource": ""
} |
q22597 | Kirki_Color.color_difference | train | public static function color_difference( $color_1 = '#ffffff', $color_2 = '#000000' ) {
$color_1 = self::sanitize_hex( $color_1, false );
$color_2 = self::sanitize_hex( $color_2, false );
$color_1_rgb = self::get_rgb( $color_1 );
$color_2_rgb = self::get_rgb( $color_2 );
$r_diff = max( $color_1_rgb[0], $color... | php | {
"resource": ""
} |
q22598 | Kirki_Color.brightness_difference | train | public static function brightness_difference( $color_1 = '#ffffff', $color_2 = '#000000' ) {
$color_1 = self::sanitize_hex( $color_1, false );
$color_2 = self::sanitize_hex( $color_2, false );
$color_1_rgb = self::get_rgb( $color_1 );
$color_2_rgb = self::get_rgb( $color_2 );
$br_1 = ( 299 * $color_1_rgb[0] +... | php | {
"resource": ""
} |
q22599 | Kirki_Color.lumosity_difference | train | public static function lumosity_difference( $color_1 = '#ffffff', $color_2 = '#000000' ) {
$color_1 = self::sanitize_hex( $color_1, false );
$color_2 = self::sanitize_hex( $color_2, false );
$color_1_rgb = self::get_rgb( $color_1 );
$color_2_rgb = self::get_rgb( $color_2 );
$l1 = 0.2126 * pow( $color_1_rgb[0]... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.