_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q258000 | Package_Command.browse | test | public function browse( $_, $assoc_args ) {
$this->set_composer_auth_env_var();
if ( empty( $assoc_args['format'] ) || 'table' === $assoc_args['format'] ) {
WP_CLI::line( WP_CLI::colorize( '%CAlthough the package index will remain in place for backward compatibility reasons, it has been deprecated and will not b... | php | {
"resource": ""
} |
q258001 | Package_Command.list_ | test | public function list_( $args, $assoc_args ) {
$this->set_composer_auth_env_var();
$this->show_packages( 'list', $this->get_installed_packages(), $assoc_args );
} | php | {
"resource": ""
} |
q258002 | Package_Command.path | test | public function path( $args ) {
$packages_dir = WP_CLI::get_runner()->get_packages_dir_path();
if ( ! empty( $args ) ) {
$packages_dir .= 'vendor/' . $args[0];
if ( ! is_dir( $packages_dir ) ) {
WP_CLI::error( 'Invalid package name.' );
}
}
WP_CLI::line( $packages_dir );
} | php | {
"resource": ""
} |
q258003 | Package_Command.update | test | public function update() {
$this->set_composer_auth_env_var();
$composer = $this->get_composer();
// Set up the EventSubscriber
$event_subscriber = new PackageManagerEventSubscriber();
$composer->getEventDispatcher()->addSubscriber( $event_subscriber );
// Set up the installer
$install = Installer::crea... | php | {
"resource": ""
} |
q258004 | Package_Command.uninstall | test | public function uninstall( $args ) {
list( $package_name ) = $args;
$this->set_composer_auth_env_var();
$package = $this->get_installed_package_by_name( $package_name );
if ( false === $package ) {
WP_CLI::error( 'Package not installed.' );
}
$package_name = $package->getPrettyName(); // Make sure packa... | php | {
"resource": ""
} |
q258005 | Package_Command.get_composer | test | private function get_composer() {
$this->avoid_composer_ca_bundle();
try {
$composer_path = $this->get_composer_json_path();
// Composer's auto-load generating code makes some assumptions about where
// the 'vendor-dir' is, and where Composer is running from.
// Best to just pretend we're installing a ... | php | {
"resource": ""
} |
q258006 | Package_Command.get_community_packages | test | private function get_community_packages() {
static $community_packages;
if ( null === $community_packages ) {
$this->avoid_composer_ca_bundle();
try {
$community_packages = $this->package_index()->getPackages();
} catch ( Exception $e ) {
WP_CLI::error( $e->getMessage() );
}
}
return $comm... | php | {
"resource": ""
} |
q258007 | Package_Command.package_index | test | private function package_index() {
static $package_index;
if ( ! $package_index ) {
$config_args = [
'config' => [
'secure-http' => true,
'home' => dirname( $this->get_composer_json_path() ),
],
];
$config = new Config();
$config->merge( $config_args );
$config->setConf... | php | {
"resource": ""
} |
q258008 | Package_Command.show_packages | test | private function show_packages( $context, $packages, $assoc_args ) {
if ( 'list' === $context ) {
$default_fields = [
'name',
'authors',
'version',
'update',
'update_version',
];
} elseif ( 'browse' === $context ) {
$default_fields = [
'name',
'description',
'authors',
'... | php | {
"resource": ""
} |
q258009 | Package_Command.get_package_by_shortened_identifier | test | private function get_package_by_shortened_identifier( $package_name ) {
// Check the package index first, so we don't break existing behavior.
$lc_package_name = strtolower( $package_name ); // For BC check.
foreach ( $this->get_community_packages() as $package ) {
if ( $package_name === $package->getPrettyNam... | php | {
"resource": ""
} |
q258010 | Package_Command.get_installed_packages | test | private function get_installed_packages() {
$composer = $this->get_composer();
$repo = $composer->getRepositoryManager()->getLocalRepository();
$existing = json_decode( file_get_contents( $this->get_composer_json_path() ), true );
$installed_package_keys = ! empty( $existing['re... | php | {
"resource": ""
} |
q258011 | Package_Command.get_installed_package_by_name | test | private function get_installed_package_by_name( $package_name ) {
foreach ( $this->get_installed_packages() as $package ) {
if ( $package_name === $package->getPrettyName() ) {
return $package;
}
// Also check non-pretty (lowercase) name in case of legacy incorrect name.
if ( $package_name === $packag... | php | {
"resource": ""
} |
q258012 | Package_Command.get_package_name_and_version_from_dir_package | test | private static function get_package_name_and_version_from_dir_package( $dir_package ) {
$composer_file = $dir_package . '/composer.json';
if ( ! file_exists( $composer_file ) ) {
WP_CLI::error( sprintf( "Invalid package: composer.json file '%s' not found.", $composer_file ) );
}
$composer_data = json_decode(... | php | {
"resource": ""
} |
q258013 | Package_Command.get_composer_json_path | test | private function get_composer_json_path() {
static $composer_path;
if ( null === $composer_path || getenv( 'WP_CLI_TEST_PACKAGE_GET_COMPOSER_JSON_PATH' ) ) {
if ( getenv( 'WP_CLI_PACKAGES_DIR' ) ) {
$composer_path = Utils\trailingslashit( getenv( 'WP_CLI_PACKAGES_DIR' ) ) . 'composer.json';
} else {
... | php | {
"resource": ""
} |
q258014 | Package_Command.create_default_composer_json | test | private function create_default_composer_json( $composer_path ) {
$composer_dir = pathinfo( $composer_path, PATHINFO_DIRNAME );
if ( ! is_dir( $composer_dir ) ) {
if ( ! @mkdir( $composer_dir, 0777, true ) ) { // @codingStandardsIgnoreLine
$error = error_get_last();
WP_CLI::error( sprintf( "Composer dir... | php | {
"resource": ""
} |
q258015 | Package_Command.get_raw_git_version | test | private function get_raw_git_version( $version ) {
if ( '' === $version ) {
return 'master';
}
// If Composer hash given then just use whatever's after it.
$hash_pos = strpos( $version, '#' );
if ( false !== $hash_pos ) {
return substr( $version, $hash_pos + 1 );
}
// Strip any Composer 'dev-' pre... | php | {
"resource": ""
} |
q258016 | Package_Command.guess_version_constraint_from_tag | test | private function guess_version_constraint_from_tag( $tag ) {
$matches = [];
if ( 1 !== preg_match( '/(?:version|v)\s*((?:[0-9]+\.?)+)(?:-.*)/i', $tag, $matches ) ) {
return $tag;
}
$constraint = "^{$matches[1]}";
WP_CLI::debug( "Guessing version constraint to use: {$constraint}", 'packages' );
return $... | php | {
"resource": ""
} |
q258017 | Package_Command.get_composer_json_path_backup_decoded | test | private function get_composer_json_path_backup_decoded() {
$composer_json_obj = $this->get_composer_json();
$json_path = $composer_json_obj->getPath();
$composer_backup = file_get_contents( $json_path );
if ( false === $composer_backup ) {
$error = error_get_last();
WP_CLI::error( sprintf( "Fail... | php | {
"resource": ""
} |
q258018 | AbstractQueuedJob.setObject | test | protected function setObject(DataObject $object, $name = 'Object')
{
$this->{$name . 'ID'} = $object->ID;
$this->{$name . 'Type'} = $object->ClassName;
} | php | {
"resource": ""
} |
q258019 | AbstractQueuedJob.loadCustomConfig | test | private function loadCustomConfig()
{
$custom = $this->getCustomConfig();
if (!is_array($custom)) {
return;
}
foreach ($custom as $class => $settings) {
foreach ($settings as $setting => $value) {
Config::modify()->set($class, $setting, $valu... | php | {
"resource": ""
} |
q258020 | DeleteAllJobsTask.run | test | public function run($request)
{
$confirm = $request->getVar('confirm');
$jobs = DataObject::get(QueuedJobDescriptor::class);
if (!$confirm) {
echo "Really delete " . $jobs->count() . " jobs? Please add ?confirm=1 to the URL to confirm.";
return;
}
e... | php | {
"resource": ""
} |
q258021 | CleanupJob.process | test | public function process()
{
// construct limit statement if query_limit is valid int value
$limit = '';
$query_limit = $this->config()->get('query_limit');
if (is_numeric($query_limit) && $query_limit >= 0) {
$limit = ' LIMIT ' . ((int)$query_limit);
}
$s... | php | {
"resource": ""
} |
q258022 | QueuedJobService.queueJob | test | public function queueJob(QueuedJob $job, $startAfter = null, $userId = null, $queueName = null)
{
$signature = $job->getSignature();
// see if we already have this job in a queue
$filter = [
'Signature' => $signature,
'JobStatus' => [
QueuedJob::STATU... | php | {
"resource": ""
} |
q258023 | QueuedJobService.copyJobToDescriptor | test | protected function copyJobToDescriptor($job, $jobDescriptor)
{
$data = $job->getJobData();
$jobDescriptor->TotalSteps = $data->totalSteps;
$jobDescriptor->StepsProcessed = $data->currentStep;
if ($data->isComplete) {
$jobDescriptor->JobStatus = QueuedJob::STATUS_COMPLETE... | php | {
"resource": ""
} |
q258024 | QueuedJobService.getNextPendingJob | test | public function getNextPendingJob($type = null)
{
// Filter jobs by type
$type = $type ?: QueuedJob::QUEUED;
$list = QueuedJobDescriptor::get()
->filter('JobType', $type)
->sort('ID', 'ASC');
// see if there's any blocked jobs that need to be resumed
... | php | {
"resource": ""
} |
q258025 | QueuedJobService.checkJobHealth | test | public function checkJobHealth($queue = null)
{
$queue = $queue ?: QueuedJob::QUEUED;
// Select all jobs currently marked as running
$runningJobs = QueuedJobDescriptor::get()
->filter([
'JobStatus' => [
QueuedJob::STATUS_RUN,
... | php | {
"resource": ""
} |
q258026 | QueuedJobService.checkDefaultJobs | test | public function checkDefaultJobs($queue = null)
{
$queue = $queue ?: QueuedJob::QUEUED;
if (count($this->defaultJobs)) {
$activeJobs = QueuedJobDescriptor::get()->filter(
'JobStatus',
[
QueuedJob::STATUS_NEW,
QueuedJ... | php | {
"resource": ""
} |
q258027 | QueuedJobService.restartStalledJob | test | protected function restartStalledJob($stalledJob)
{
if ($stalledJob->ResumeCounts < static::config()->get('stall_threshold')) {
$stalledJob->restart();
$logLevel = 'warning';
$message = _t(
__CLASS__ . '.STALLED_JOB_RESTART_MSG',
'A job nam... | php | {
"resource": ""
} |
q258028 | QueuedJobService.initialiseJob | test | protected function initialiseJob(QueuedJobDescriptor $jobDescriptor)
{
// create the job class
$impl = $jobDescriptor->Implementation;
/** @var QueuedJob $job */
$job = Injector::inst()->create($impl);
/* @var $job QueuedJob */
if (!$job) {
throw new Excep... | php | {
"resource": ""
} |
q258029 | QueuedJobService.hasPassedTimeLimit | test | protected function hasPassedTimeLimit()
{
// Ensure a limit exists
$limit = static::config()->get('time_limit');
if (!$limit) {
return false;
}
// Ensure started date is set
$this->markStarted();
// Check duration
$now = DBDatetime::now()... | php | {
"resource": ""
} |
q258030 | QueuedJobService.isMemoryTooHigh | test | protected function isMemoryTooHigh()
{
$used = $this->getMemoryUsage();
$limit = $this->getMemoryLimit();
return $limit && ($used > $limit);
} | php | {
"resource": ""
} |
q258031 | QueuedJobService.parseMemory | test | protected function parseMemory($memString)
{
switch (strtolower(substr($memString, -1))) {
case "b":
return round(substr($memString, 0, -1));
case "k":
return round(substr($memString, 0, -1) * 1024);
case "m":
return round(s... | php | {
"resource": ""
} |
q258032 | QueuedJobService.getJobListFilter | test | public function getJobListFilter($type = null, $includeUpUntil = 0)
{
$util = singleton(QJUtils::class);
$filter = ['JobStatus <>' => QueuedJob::STATUS_COMPLETE];
if ($includeUpUntil) {
$filter['JobFinished > '] = DBDatetime::create()->setValue(
DBDatetime::now()... | php | {
"resource": ""
} |
q258033 | QueuedJobService.runQueue | test | public function runQueue($queue)
{
if (!self::config()->get('disable_health_check')) {
$this->checkJobHealth($queue);
}
$this->checkdefaultJobs($queue);
$this->queueRunner->runQueue($queue);
} | php | {
"resource": ""
} |
q258034 | QueuedJobService.processJobQueue | test | public function processJobQueue($name)
{
// Start timer to measure lifetime
$this->markStarted();
// Begin main loop
do {
if (class_exists(Subsite::class)) {
// clear subsite back to default to prevent any subsite changes from leaking to
/... | php | {
"resource": ""
} |
q258035 | QueuedTaskRunner.queueTask | test | public function queueTask($request)
{
$name = $request->param('TaskName');
$tasks = $this->getTasks();
$variables = $request->getVars();
unset($variables['url']);
unset($variables['flush']);
unset($variables['flushtoken']);
unset($variables['isDev']);
... | php | {
"resource": ""
} |
q258036 | BaseRunner.logDescriptorStatus | test | protected function logDescriptorStatus($descriptor, $queue)
{
if (is_null($descriptor)) {
$this->writeLogLine('No new jobs on queue ' . $queue);
}
if ($descriptor === false) {
$this->writeLogLine('Job is still running on queue ' . $queue);
}
if ($des... | php | {
"resource": ""
} |
q258037 | BaseRunner.listJobs | test | public function listJobs()
{
$service = $this->getService();
for ($i = 1; $i <= 3; $i++) {
$jobs = $service->getJobList($i);
$num = $jobs ? $jobs->Count() : 0;
$this->writeLogLine('Found ' . $num . ' jobs for mode ' . $i . '.');
}
} | php | {
"resource": ""
} |
q258038 | DoormanQueuedJobTask.refreshDescriptor | test | protected function refreshDescriptor()
{
if ($this->descriptor) {
$this->descriptor = QueuedJobDescriptor::get()->byID($this->descriptor->ID);
}
} | php | {
"resource": ""
} |
q258039 | CheckJobHealthTask.run | test | public function run($request)
{
$queue = $request->requestVar('queue') ?: QueuedJob::QUEUED;
$stalledJobCount = $this->getService()->checkJobHealth($queue);
echo $stalledJobCount === 0 ? 'All jobs are healthy' : 'Detected and attempted restart on ' . $stalledJobCount .
' stalle... | php | {
"resource": ""
} |
q258040 | QueuedJobDescriptor.pause | test | public function pause($force = false)
{
if ($force || in_array(
$this->JobStatus,
[QueuedJob::STATUS_WAIT, QueuedJob::STATUS_RUN, QueuedJob::STATUS_INIT]
)) {
$this->JobStatus = QueuedJob::STATUS_PAUSED;
$this->write();
return true;
... | php | {
"resource": ""
} |
q258041 | QueuedJobDescriptor.resume | test | public function resume($force = false)
{
if ($force || in_array($this->JobStatus, [QueuedJob::STATUS_PAUSED, QueuedJob::STATUS_BROKEN])) {
$this->JobStatus = QueuedJob::STATUS_WAIT;
$this->ResumeCounts++;
$this->write();
QueuedJobService::singleton()->startJob... | php | {
"resource": ""
} |
q258042 | QueuedJobDescriptor.activateOnQueue | test | public function activateOnQueue()
{
// if it's an immediate job, lets cache it to disk to be picked up later
if ($this->JobType == QueuedJob::IMMEDIATE
&& !Config::inst()->get(QueuedJobService::class, 'use_shutdown_function')
) {
touch($this->getJobDir() . '/queuedjob... | php | {
"resource": ""
} |
q258043 | QueuedJobDescriptor.getJobDir | test | protected function getJobDir()
{
// make sure our temp dir is in place. This is what will be inotify watched
$jobDir = Config::inst()->get(QueuedJobService::class, 'cache_dir');
if ($jobDir{0} !== '/') {
$jobDir = TEMP_FOLDER . '/' . $jobDir;
}
if (!is_dir($jobDi... | php | {
"resource": ""
} |
q258044 | QueuedJobDescriptor.cleanupJob | test | public function cleanupJob()
{
// remove the job's temp file if it exists
$tmpFile = $this->getJobDir() . '/queuedjob-' . $this->ID;
if (file_exists($tmpFile)) {
unlink($tmpFile);
}
} | php | {
"resource": ""
} |
q258045 | QueuedJobDescriptor.getMessages | test | public function getMessages()
{
if (strlen($this->SavedJobMessages)) {
$messages = @unserialize($this->SavedJobMessages);
if (!empty($messages)) {
return DBField::create_field(
'HTMLText',
'<ul><li>' . nl2br(implode('</li><li>',... | php | {
"resource": ""
} |
q258046 | QueuedJobDescriptor.getLastMessage | test | public function getLastMessage()
{
if (strlen($this->SavedJobMessages)) {
$msgs = @unserialize($this->SavedJobMessages);
if (is_array($msgs) && sizeof($msgs)) {
return array_pop($msgs);
}
}
} | php | {
"resource": ""
} |
q258047 | QueuedJobDescriptor.getJobTypeString | test | public function getJobTypeString()
{
$map = $this->getJobTypeValues();
return isset($map[$this->JobType]) ? $map[$this->JobType] : '(Unknown)';
} | php | {
"resource": ""
} |
q258048 | QueuedJobDescriptor.getJobTypeValues | test | public function getJobTypeValues()
{
return [
QueuedJob::IMMEDIATE => _t(__CLASS__ . '.TYPE_IMMEDIATE', 'Immediate'),
QueuedJob::QUEUED => _t(__CLASS__ . '.TYPE_QUEUED', 'Queued'),
QueuedJob::LARGE => _t(__CLASS__ . '.TYPE_LARGE', 'Large'),
];
} | php | {
"resource": ""
} |
q258049 | GenerateGoogleSitemapJob.setup | test | public function setup()
{
parent::setup();
Environment::increaseTimeLimitTo();
$restart = $this->currentStep == 0;
if (!$this->tempFile || !file_exists($this->tempFile)) {
$tmpfile = tempnam(TempFolder::getTempFolder(BASE_PATH), 'sitemap');
if (file_exists($t... | php | {
"resource": ""
} |
q258050 | GenerateGoogleSitemapJob.prepareForRestart | test | public function prepareForRestart()
{
parent::prepareForRestart();
// if the file we've been building is missing, lets fix it up
if (!$this->tempFile || !file_exists($this->tempFile)) {
$tmpfile = tempnam(TempFolder::getTempFolder(BASE_PATH), 'sitemap');
if (file_exis... | php | {
"resource": ""
} |
q258051 | GenerateGoogleSitemapJob.completeJob | test | protected function completeJob()
{
$content = '<?xml version="1.0" encoding="UTF-8"?>' .
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
$content .= file_get_contents($this->tempFile);
$content .= '</urlset>';
$sitemap = Director::baseFolder() . '... | php | {
"resource": ""
} |
q258052 | DoormanRunner.runQueue | test | public function runQueue($queue)
{
// split jobs out into multiple tasks...
/** @var ProcessManager $manager */
$manager = Injector::inst()->create(ProcessManager::class);
$manager->setWorker(
BASE_PATH . "/vendor/silverstripe/framework/cli-script.php dev/tasks/ProcessJo... | php | {
"resource": ""
} |
q258053 | GridFieldQueuedJobExecute.handleAction | test | public function handleAction(GridField $gridField, $actionName, $arguments, $data)
{
$actions = $this->getActions(null);
if (in_array($actionName, $actions)) {
$item = $gridField->getList()->byID($arguments['RecordID']);
if (!$item) {
return;
}
... | php | {
"resource": ""
} |
q258054 | PublishItemsJob.getTitle | test | public function getTitle()
{
$title = 'Unknown';
if ($root = $this->getRoot()) {
$title = $root->Title;
}
return _t(
__CLASS__ . '.Title',
"Publish items beneath {title}",
['title' => $title]
);
} | php | {
"resource": ""
} |
q258055 | PublishItemsJob.setup | test | public function setup()
{
if (!$this->getRoot()) {
// we're missing for some reason!
$this->isComplete = true;
$this->remainingChildren = array();
return;
}
$remainingChildren = array();
$remainingChildren[] = $this->getRoot()->ID;
... | php | {
"resource": ""
} |
q258056 | PublishItemsJob.process | test | public function process()
{
$remainingChildren = $this->remainingChildren;
// if there's no more, we're done!
if (!count($remainingChildren)) {
$this->isComplete = true;
return;
}
// we need to always increment! This is important, because if we don't... | php | {
"resource": ""
} |
q258057 | ProcessJobQueueTask.getQueue | test | protected function getQueue($request)
{
$queue = $request->getVar('queue');
if (!$queue) {
$queue = 'Queued';
}
switch (strtolower($queue)) {
case 'immediate':
$queue = QueuedJob::IMMEDIATE;
break;
case 'queued':
... | php | {
"resource": ""
} |
q258058 | YiiCaster.castModel | test | public static function castModel(ActiveRecord $model)
{
$attributes = array_merge(
$model->getAttributes(), $model->getRelatedRecords()
);
$results = [];
foreach ($attributes as $key => $value) {
$results[Caster::PREFIX_VIRTUAL.$key] = $value;
}
... | php | {
"resource": ""
} |
q258059 | ShellController.actionIndex | test | public function actionIndex()
{
$config = new Configuration;
$config->getPresenter()->addCasters(
$this->getCasters()
);
$shell = new Shell($config);
$shell->setIncludes($this->include);
$shell->run();
} | php | {
"resource": ""
} |
q258060 | SourceMapGenerator.saveMap | test | public function saveMap($content)
{
$asset_handler = Requirements::backend()->getAssetHandler();
$css_file = $this->options['sourceMapWriteTo'];
$asset_handler->setContent($css_file, $content);
$url = $asset_handler->getContentURL($css_file);
$this->options['sourceMapURL'] ... | php | {
"resource": ""
} |
q258061 | Block.write | test | public function write($data)
{
$size = mb_strlen($data, 'UTF-8');
if($this->exists($this->id)) {
shmop_delete($this->shmid);
shmop_close($this->shmid);
$this->shmid = shmop_open($this->id, "c", $this->perms, $size);
shmop_write($this->shmid, $data, 0)... | php | {
"resource": ""
} |
q258062 | Block.read | test | public function read()
{
$size = shmop_size($this->shmid);
$data = shmop_read($this->shmid, 0, $size);
return $data;
} | php | {
"resource": ""
} |
q258063 | Sidebar_Command.list_ | test | public function list_( $args, $assoc_args ) {
global $wp_registered_sidebars;
Utils\wp_register_unused_sidebar();
if ( ! empty( $assoc_args['format'] ) && 'ids' === $assoc_args['format'] ) {
$sidebars = wp_list_pluck( $wp_registered_sidebars, 'id' );
} else {
$sidebars = $wp_registered_sidebars;
}
... | php | {
"resource": ""
} |
q258064 | Widget_Command.list_ | test | public function list_( $args, $assoc_args ) {
list( $sidebar_id ) = $args;
$this->validate_sidebar( $sidebar_id );
$output_widgets = $this->get_sidebar_widgets( $sidebar_id );
if ( ! empty( $assoc_args['format'] ) && 'ids' === $assoc_args['format'] ) {
$output_widgets = wp_list_pluck( $output_widgets, 'i... | php | {
"resource": ""
} |
q258065 | Widget_Command.add | test | public function add( $args, $assoc_args ) {
list( $name, $sidebar_id ) = $args;
$position = Utils\get_flag_value( $args, 2, 1 ) - 1;
$this->validate_sidebar( $sidebar_id );
$widget = $this->get_widget_obj( $name );
if ( false === $widget ) {
WP_CLI::error( 'Invalid widget type.' );
}
... | php | {
"resource": ""
} |
q258066 | Widget_Command.update | test | public function update( $args, $assoc_args ) {
list( $widget_id ) = $args;
if ( ! $this->validate_sidebar_widget( $widget_id ) ) {
WP_CLI::error( "Widget doesn't exist." );
}
if ( empty( $assoc_args ) ) {
WP_CLI::error( 'No options specified to update.' );
}
list( $name, $option_index ) = $this->ge... | php | {
"resource": ""
} |
q258067 | Widget_Command.move | test | public function move( $args, $assoc_args ) {
list( $widget_id ) = $args;
if ( ! $this->validate_sidebar_widget( $widget_id ) ) {
WP_CLI::error( "Widget doesn't exist." );
}
if ( empty( $assoc_args['position'] ) && empty( $assoc_args['sidebar-id'] ) ) {
WP_CLI::error( 'A new position or new sidebar must ... | php | {
"resource": ""
} |
q258068 | Widget_Command.deactivate | test | public function deactivate( $args, $assoc_args ) {
$count = 0;
$errors = 0;
foreach ( $args as $widget_id ) {
if ( ! $this->validate_sidebar_widget( $widget_id ) ) {
WP_CLI::warning( "Widget '{$widget_id}' doesn't exist." );
$errors++;
continue;
}
list( $name, $option_index, $sidebar_id, ... | php | {
"resource": ""
} |
q258069 | Widget_Command.delete | test | public function delete( $args, $assoc_args ) {
$count = 0;
$errors = 0;
foreach ( $args as $widget_id ) {
if ( ! $this->validate_sidebar_widget( $widget_id ) ) {
WP_CLI::warning( "Widget '{$widget_id}' doesn't exist." );
$errors++;
continue;
}
// Remove the widget's settings.
list( $na... | php | {
"resource": ""
} |
q258070 | Widget_Command.reset | test | public function reset( $args, $assoc_args ) {
global $wp_registered_sidebars;
$all = Utils\get_flag_value( $assoc_args, 'all', false );
// Bail if no arguments and no all flag.
if ( ! $all && empty( $args ) ) {
WP_CLI::error( 'Please specify one or more sidebars, or use --all.' );
}
// Fetch all side... | php | {
"resource": ""
} |
q258071 | Widget_Command.validate_sidebar | test | private function validate_sidebar( $sidebar_id ) {
global $wp_registered_sidebars;
Utils\wp_register_unused_sidebar();
if ( ! array_key_exists( $sidebar_id, $wp_registered_sidebars ) ) {
WP_CLI::error( 'Invalid sidebar.' );
}
} | php | {
"resource": ""
} |
q258072 | Widget_Command.validate_sidebar_widget | test | private function validate_sidebar_widget( $widget_id ) {
$sidebars_widgets = $this->wp_get_sidebars_widgets();
$widget_exists = false;
foreach ( $sidebars_widgets as $sidebar_id => $widgets ) {
if ( in_array( $widget_id, $widgets, true ) ) {
$widget_exists = true;
break;
}
}
return $widget_ex... | php | {
"resource": ""
} |
q258073 | Widget_Command.get_widget_data | test | private function get_widget_data( $widget_id ) {
$parts = explode( '-', $widget_id );
$option_index = array_pop( $parts );
$name = implode( '-', $parts );
$sidebar_id = false;
$sidebar_index = false;
$all_widgets = $this->wp_get_sidebars_widgets();
foreach ( $all_widgets as $s_id => ... | php | {
"resource": ""
} |
q258074 | Widget_Command.move_sidebar_widget | test | private function move_sidebar_widget( $widget_id, $current_sidebar_id, $new_sidebar_id, $current_index, $new_index ) {
$all_widgets = $this->wp_get_sidebars_widgets();
$needs_placement = true;
// Existing widget
if ( $current_sidebar_id && ! is_null( $current_index ) ) {
$widgets = $all_widgets[ $curre... | php | {
"resource": ""
} |
q258075 | Widget_Command.get_widget_obj | test | private function get_widget_obj( $id_base ) {
global $wp_widget_factory;
$widget = wp_filter_object_list( $wp_widget_factory->widgets, array( 'id_base' => $id_base ) );
if ( empty( $widget ) ) {
return false;
}
return array_pop( $widget );
} | php | {
"resource": ""
} |
q258076 | Widget_Command.sanitize_widget_options | test | private function sanitize_widget_options( $id_base, $dirty_options, $old_options ) {
$widget = $this->get_widget_obj( $id_base );
if ( empty( $widget ) ) {
return array();
}
// No easy way to determine expected array keys for $dirty_options
// because Widget API dependent on the form fields
// phpcs:ig... | php | {
"resource": ""
} |
q258077 | Random.getRandomInteger | test | public function getRandomInteger($min = 0, $max = PHP_INT_MAX)
{
$min = (int) $min;
$max = (int) $max;
$range = $max - $min;
$bits = $this->getBitsInInteger($range);
$bytes = $this->getBytesInBits($bits);
$mask = (int) ((1 << $bits) - 1);
do {
... | php | {
"resource": ""
} |
q258078 | Random.getRandomString | test | public function getRandomString($length, $charset = null)
{
$length = (int) $length;
if (!$charset) {
$charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./';
}
$charsetLength = strlen($charset);
$neededBytes = $this->getBytesInBits($length ... | php | {
"resource": ""
} |
q258079 | Base32Encoder.encode | test | public function encode($string)
{
$encoded = '';
if ($string) {
$binString = '';
// Build a binary string representation of the input string
foreach (str_split($string) as $char) {
$binString .= str_pad(decbin(ord($char)), 8, 0, STR_PAD_LEFT);
... | php | {
"resource": ""
} |
q258080 | Base32Encoder.decode | test | public function decode($string)
{
$decoded = '';
$string = preg_replace("/[^{$this->charset}]/", '', rtrim(strtoupper($string), $this->charset[32]));
if ($string) {
$binString = '';
foreach (str_split($string) as $char) {
$binString .= str_pad(decbin(... | php | {
"resource": ""
} |
q258081 | GeneratorFactory.addGeneratorPath | test | public function addGeneratorPath($prefix, $path)
{
$path = realpath($path);
$success = false;
if ($path && !array_key_exists($prefix, $this->generatorPaths)) {
$this->generatorPaths[$prefix] = $path;
$success = true;
}
return $success;
} | php | {
"resource": ""
} |
q258082 | GeneratorFactory.removeGeneratorPath | test | public function removeGeneratorPath($prefixOrPath)
{
if (array_key_exists($prefixOrPath, $this->generatorPaths)) {
$prefix = $prefixOrPath;
unset($this->generatorPaths[$prefix]);
} elseif (($prefixOrPath = realpath($prefixOrPath)) && in_array($prefixOrPath, $this->generatorPa... | php | {
"resource": ""
} |
q258083 | GeneratorFactory.getGenerator | test | public function getGenerator()
{
if (!$this->generators) {
$this->loadGenerators();
}
$generators = $this->generators;
usort($generators, function ($a, $b) {
return ($b::getPriority() - $a::getPriority());
});
$generator = null;
if (i... | php | {
"resource": ""
} |
q258084 | GeneratorFactory.loadGenerators | test | public function loadGenerators()
{
// Reset the list of loaded classes
$this->generators = array ();
// Loop through each registered path
foreach ($this->generatorPaths as $generatorPrefix => $generatorPath) {
// Build the iterators to search the path
$dirIte... | php | {
"resource": ""
} |
q258085 | FormGroup.showAsRow | test | public function showAsRow($rowConfig = 'default')
{
$rowConfig = app('config')->get("bs4.form_rows.$rowConfig", null);
if ($rowConfig === null)
{
throw new \InvalidArgumentException("Unknown configuration entry: bs4.form_rows.$rowConfig");
}
$element = clone $thi... | php | {
"resource": ""
} |
q258086 | Input.readOnly | test | public function readOnly($showAsPlainText = false)
{
$element = clone $this;
$element->plainText = $showAsPlainText;
return $element->attribute('readonly', 'readonly');
} | php | {
"resource": ""
} |
q258087 | BuildsForms.openForm | test | public function openForm($method, $action, array $options = []): Htmlable
{
// Initialize the form state
if ($this->formState !== null || $this->currentForm !== null)
{
throw new RuntimeException('You cannot open another form before closing the previous one');
}
$... | php | {
"resource": ""
} |
q258088 | InputGroup.prefix | test | public function prefix($prefix, $isPlainText = true)
{
if ($prefix === null)
{
return $this;
}
$element = clone $this;
$element->prefixes[] = [
'content' => $prefix,
'plaintext' => $isPlainText,
];
return $element;
} | php | {
"resource": ""
} |
q258089 | InputGroup.suffix | test | public function suffix($suffix, $isPlainText = true)
{
if ($suffix === null)
{
return $this;
}
$element = clone $this;
$element->suffixes[] = [
'content' => $suffix,
'plaintext' => $isPlainText,
];
return $element;
} | php | {
"resource": ""
} |
q258090 | InputGroup.assembleAddons | test | private function assembleAddons($addons, $addonContainerClass)
{
if (0 === \count($addons))
{
return $this;
}
$div = Div::create()
->addClass($addonContainerClass)
->addChildren($addons,
function ($token) {
... | php | {
"resource": ""
} |
q258091 | SizableComponent.size | test | public function size($size)
{
if (!property_exists($this, 'sizableClass'))
{
throw new RuntimeException('You must specify the sizable CSS class');
}
$size = strtolower($size);
if (!\in_array($size, ['lg', 'sm'], true))
{
throw new RuntimeExcep... | php | {
"resource": ""
} |
q258092 | Session.unscrub | test | private function unscrub($msg) {
$args = $msg->arguments;
$session = $this;
foreach ($msg->callbacks as $id => $path) {
if (!isset($this->wrapped[$id])) {
$this->wrapped[$id] = function() use ($session, $id) {
$session->request((int) $id, func_get_... | php | {
"resource": ""
} |
q258093 | Converter.clientTempF | test | public function clientTempF($cb)
{
$this->remote->temperature(function($degC) use ($cb) {
$degF = round($degC * 9 / 5 + 32);
$cb($degF);
});
} | php | {
"resource": ""
} |
q258094 | SimpleRemoteRepository.getNodes | test | public function getNodes($sessionName, $path, $cb)
{
if (!$this->validateSessionName($sessionName, $cb))
return false;
$exception = null;
$msg = null;
$names = array ();
try {
$parent = $this->sessions[$sessionName]->getNode($path);
$node... | php | {
"resource": ""
} |
q258095 | SimpleRemoteRepository.getProperties | test | public function getProperties($sessionName, $path, $cb)
{
if (!$this->validateSessionName($sessionName, $cb))
return false;
$exception = null;
$msg = null;
$names = array ();
try {
$parent = $this->sessions[$sessionName]->getNode($path);
... | php | {
"resource": ""
} |
q258096 | SmartyEngine.evaluatePath | test | protected function evaluatePath(string $path, array $data = [])
{
extract($data, EXTR_SKIP);
try {
if (!$this->smarty->isCached($path)) {
foreach ($data as $var => $val) {
$this->smarty->assign($var, $val);
}
}
/... | php | {
"resource": ""
} |
q258097 | Redis.write | test | protected function write(array $keys, $expire = 1)
{
foreach ($keys as $k => $v) {
$k = sha1($k);
$this->redis->setex($k, $expire, $v);
}
return true;
} | php | {
"resource": ""
} |
q258098 | Selenium.getWebdriver | test | public function getWebdriver()
{
$browser = $this->browser;
$config = parse_ini_file(__DIR__ . '/config.dist.ini', true);
if (file_exists(__DIR__ . '/config.ini'))
{
$config = parse_ini_file(__DIR__ . '/config.ini', true);
}
if ($browser == 'chrome')
{
$driver['type'] = 'webdriver.chrome.driver';... | php | {
"resource": ""
} |
q258099 | Exif.getAperture | test | public function getAperture()
{
if (!isset($this->data[self::APERTURE])) {
return false;
}
return $this->data[self::APERTURE];
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.