_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q256700
Service.setEndpoints
test
public function setEndpoints($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Api\Endpoint::class); $this->endpoints = $arr; return $this; }
php
{ "resource": "" }
q256701
Service.setLogs
test
public function setLogs($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Api\LogDescriptor::class); $this->logs = $arr; return $this; }
php
{ "resource": "" }
q256702
Service.setMetrics
test
public function setMetrics($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Api\MetricDescriptor::class); $this->metrics = $arr; return $this; }
php
{ "resource": "" }
q256703
BadRequest.setFieldViolations
test
public function setFieldViolations($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Rpc\BadRequest\FieldViolation::class); $this->field_violations = $arr; return $this; }
php
{ "resource": "" }
q256704
ListOperationsResponse.setOperations
test
public function setOperations($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\LongRunning\Operation::class); $this->operations = $arr; return $this; }
php
{ "resource": "" }
q256705
ListRolesRequest.setView
test
public function setView($var) { GPBUtil::checkEnum($var, \Google\Iam\Admin\V1\RoleView::class); $this->view = $var; return $this; }
php
{ "resource": "" }
q256706
Role.setIncludedPermissions
test
public function setIncludedPermissions($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $this->included_permissions = $arr; return $this; }
php
{ "resource": "" }
q256707
Role.setStage
test
public function setStage($var) { GPBUtil::checkEnum($var, \Google\Iam\Admin\V1\Role_RoleLaunchStage::class); $this->stage = $var; return $this; }
php
{ "resource": "" }
q256708
Billing.setConsumerDestinations
test
public function setConsumerDestinations($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Api\Billing\BillingDestination::class); $this->consumer_destinations = $arr; return $this; }
php
{ "resource": "" }
q256709
HttpBody.setExtensions
test
public function setExtensions($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Any::class); $this->extensions = $arr; return $this; }
php
{ "resource": "" }
q256710
Authentication.setProviders
test
public function setProviders($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Api\AuthProvider::class); $this->providers = $arr; return $this; }
php
{ "resource": "" }
q256711
ContextRule.setRequested
test
public function setRequested($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $this->requested = $arr; return $this; }
php
{ "resource": "" }
q256712
ContextRule.setProvided
test
public function setProvided($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $this->provided = $arr; return $this; }
php
{ "resource": "" }
q256713
Explicit.setBounds
test
public function setBounds($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::DOUBLE); $this->bounds = $arr; return $this; }
php
{ "resource": "" }
q256714
UpdateRoleRequest.setRole
test
public function setRole($var) { GPBUtil::checkMessage($var, \Google\Iam\Admin\V1\Role::class); $this->role = $var; return $this; }
php
{ "resource": "" }
q256715
Page.setSubpages
test
public function setSubpages($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Api\Page::class); $this->subpages = $arr; return $this; }
php
{ "resource": "" }
q256716
ListServiceAccountKeysRequest.setKeyTypes
test
public function setKeyTypes($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::ENUM, \Google\Iam\Admin\V1\ListServiceAccountKeysRequest\KeyType::class); $this->key_types = $arr; return $this; }
php
{ "resource": "" }
q256717
PostalAddress.setRecipients
test
public function setRecipients($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $this->recipients = $arr; return $this; }
php
{ "resource": "" }
q256718
DebugInfo.setStackEntries
test
public function setStackEntries($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $this->stack_entries = $arr; return $this; }
php
{ "resource": "" }
q256719
Monitoring.setProducerDestinations
test
public function setProducerDestinations($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Api\Monitoring\MonitoringDestination::class); $this->producer_destinations = $arr; return $this; }
php
{ "resource": "" }
q256720
Monitoring.setConsumerDestinations
test
public function setConsumerDestinations($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Api\Monitoring\MonitoringDestination::class); $this->consumer_destinations = $arr; return $this; }
php
{ "resource": "" }
q256721
AuthenticationRule.setRequirements
test
public function setRequirements($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Api\AuthRequirement::class); $this->requirements = $arr; return $this; }
php
{ "resource": "" }
q256722
Policy.setBindings
test
public function setBindings($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Iam\V1\Binding::class); $this->bindings = $arr; return $this; }
php
{ "resource": "" }
q256723
MetricRule.setMetricCosts
test
public function setMetricCosts($var) { $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::INT64); $this->metric_costs = $arr; return $this; }
php
{ "resource": "" }
q256724
Documentation.setPages
test
public function setPages($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Api\Page::class); $this->pages = $arr; return $this; }
php
{ "resource": "" }
q256725
BindingDelta.setAction
test
public function setAction($var) { GPBUtil::checkEnum($var, \Google\Cloud\Iam\V1\BindingDelta_Action::class); $this->action = $var; return $this; }
php
{ "resource": "" }
q256726
SourceInfo.setSourceFiles
test
public function setSourceFiles($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Any::class); $this->source_files = $arr; return $this; }
php
{ "resource": "" }
q256727
ListServiceAccountKeysResponse.setKeys
test
public function setKeys($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Iam\Admin\V1\ServiceAccountKey::class); $this->keys = $arr; return $this; }
php
{ "resource": "" }
q256728
ListServiceAccountsResponse.setAccounts
test
public function setAccounts($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Iam\Admin\V1\ServiceAccount::class); $this->accounts = $arr; return $this; }
php
{ "resource": "" }
q256729
Permission.setCustomRolesSupportLevel
test
public function setCustomRolesSupportLevel($var) { GPBUtil::checkEnum($var, \Google\Iam\Admin\V1\Permission_CustomRolesSupportLevel::class); $this->custom_roles_support_level = $var; return $this; }
php
{ "resource": "" }
q256730
AuditData.setPolicyDelta
test
public function setPolicyDelta($var) { GPBUtil::checkMessage($var, \Google\Cloud\Iam\V1\PolicyDelta::class); $this->policy_delta = $var; return $this; }
php
{ "resource": "" }
q256731
Distribution.setExemplars
test
public function setExemplars($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Api\Distribution\Exemplar::class); $this->exemplars = $arr; return $this; }
php
{ "resource": "" }
q256732
Endpoint.setFeatures
test
public function setFeatures($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $this->features = $arr; return $this; }
php
{ "resource": "" }
q256733
ProjectProperties.setProperties
test
public function setProperties($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Api\Property::class); $this->properties = $arr; return $this; }
php
{ "resource": "" }
q256734
QuotaFailure.setViolations
test
public function setViolations($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Rpc\QuotaFailure\Violation::class); $this->violations = $arr; return $this; }
php
{ "resource": "" }
q256735
CreateServiceAccountKeyRequest.setPrivateKeyType
test
public function setPrivateKeyType($var) { GPBUtil::checkEnum($var, \Google\Iam\Admin\V1\ServiceAccountPrivateKeyType::class); $this->private_key_type = $var; return $this; }
php
{ "resource": "" }
q256736
CreateServiceAccountKeyRequest.setKeyAlgorithm
test
public function setKeyAlgorithm($var) { GPBUtil::checkEnum($var, \Google\Iam\Admin\V1\ServiceAccountKeyAlgorithm::class); $this->key_algorithm = $var; return $this; }
php
{ "resource": "" }
q256737
Status.setDetails
test
public function setDetails($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Any::class); $this->details = $arr; return $this; }
php
{ "resource": "" }
q256738
PolicyDelta.setBindingDeltas
test
public function setBindingDeltas($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Iam\V1\BindingDelta::class); $this->binding_deltas = $arr; return $this; }
php
{ "resource": "" }
q256739
GetServiceAccountKeyRequest.setPublicKeyType
test
public function setPublicKeyType($var) { GPBUtil::checkEnum($var, \Google\Iam\Admin\V1\ServiceAccountPublicKeyType::class); $this->public_key_type = $var; return $this; }
php
{ "resource": "" }
q256740
QueryGrantableRolesResponse.setRoles
test
public function setRoles($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Iam\Admin\V1\Role::class); $this->roles = $arr; return $this; }
php
{ "resource": "" }
q256741
SystemParameterRule.setParameters
test
public function setParameters($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Api\SystemParameter::class); $this->parameters = $arr; return $this; }
php
{ "resource": "" }
q256742
Cache.getCacheFile
test
public function getCacheFile($filename, $actual = false, $mkdir = false) { $path = array(); // Getting the length of the filename before the extension $parts = explode('.', $filename); $len = strlen($parts[0]); for ($i=0; $i<min($len, $this->prefixSize); $i++) { $path[] = $filename[$i]; } $path = implode('/', $path); if ($mkdir) { $actualDir = $this->getActualCacheDirectory() . '/' . $path; $this->mkdir($actualDir); } $path .= '/' . $filename; if ($actual) { return $this->getActualCacheDirectory() . '/' . $path; } else { return $this->getCacheDirectory() . '/' . $path; } }
php
{ "resource": "" }
q256743
Cache.checkConditions
test
protected function checkConditions($cacheFile, array $conditions = array()) { // Implicit condition: the cache file should exist if (!file_exists($cacheFile)) { return false; } foreach ($conditions as $type => $value) { switch ($type) { case 'maxage': case 'max-age': // Return false if the file is older than $value $age = time() - filemtime($cacheFile); if ($age > $value) { return false; } break; case 'younger-than': case 'youngerthan': // Return false if the file is older than the file $value, or the files $value $check = function($filename) use ($cacheFile) { return !file_exists($filename) || filemtime($cacheFile) < filemtime($filename); }; if (!is_array($value)) { if (!$this->isRemote($value) && $check($value)) { return false; } } else { foreach ($value as $file) { if (!$this->isRemote($file) && $check($file)) { return false; } } } break; default: throw new \Exception('Cache condition '.$type.' not supported'); } } return true; }
php
{ "resource": "" }
q256744
Cache.exists
test
public function exists($filename, array $conditions = array()) { $cacheFile = $this->getCacheFile($filename, true); return $this->checkConditions($cacheFile, $conditions); }
php
{ "resource": "" }
q256745
Cache.set
test
public function set($filename, $contents = '') { $cacheFile = $this->getCacheFile($filename, true, true); file_put_contents($cacheFile, $contents, \LOCK_EX); return $this; }
php
{ "resource": "" }
q256746
Cache.get
test
public function get($filename, array $conditions = array()) { if ($this->exists($filename, $conditions)) { return file_get_contents($this->getCacheFile($filename, true)); } else { return null; } }
php
{ "resource": "" }
q256747
Cache.getOrCreate
test
public function getOrCreate($filename, array $conditions = array(), $function, $file = false, $actual = false) { if (!is_callable($function)) { throw new \InvalidArgumentException('The argument $function should be callable'); } $cacheFile = $this->getCacheFile($filename, true, true); $data = null; if (!$this->check($filename, $conditions)) { if(file_exists($cacheFile)) { unlink($cacheFile); } $data = call_user_func($function, $cacheFile); // Test if the closure wrote the file or if it returned the data if (!file_exists($cacheFile)) { $this->set($filename, $data); } else { $data = file_get_contents($cacheFile); } } return $file ? $this->getCacheFile($filename, $actual) : file_get_contents($cacheFile); }
php
{ "resource": "" }
q256748
Core_Command.is_installed
test
public function is_installed( $args, $assoc_args ) { if ( is_blog_installed() && ( ! Utils\get_flag_value( $assoc_args, 'network' ) || is_multisite() ) ) { WP_CLI::halt( 0 ); } WP_CLI::halt( 1 ); }
php
{ "resource": "" }
q256749
Core_Command.install
test
public function install( $args, $assoc_args ) { if ( $this->do_install( $assoc_args ) ) { WP_CLI::success( 'WordPress installed successfully.' ); } else { WP_CLI::log( 'WordPress is already installed.' ); } }
php
{ "resource": "" }
q256750
Core_Command.multisite_convert
test
public function multisite_convert( $args, $assoc_args ) { if ( is_multisite() ) { WP_CLI::error( 'This already is a multisite install.' ); } $assoc_args = self::set_multisite_defaults( $assoc_args ); if ( ! isset( $assoc_args['title'] ) ) { // translators: placeholder is blog name $assoc_args['title'] = sprintf( _x( '%s Sites', 'Default network name' ), get_option( 'blogname' ) ); } if ( $this->multisite_convert_( $assoc_args ) ) { WP_CLI::success( "Network installed. Don't forget to set up rewrite rules (and a .htaccess file, if using Apache)." ); } }
php
{ "resource": "" }
q256751
Core_Command.multisite_install
test
public function multisite_install( $args, $assoc_args ) { if ( $this->do_install( $assoc_args ) ) { WP_CLI::log( 'Created single site database tables.' ); } else { WP_CLI::log( 'Single site database tables already present.' ); } $assoc_args = self::set_multisite_defaults( $assoc_args ); // translators: placeholder is user supplied title $assoc_args['title'] = sprintf( _x( '%s Sites', 'Default network name' ), $assoc_args['title'] ); // Overwrite runtime args, to avoid mismatches. $consts_to_args = [ 'SUBDOMAIN_INSTALL' => 'subdomains', 'PATH_CURRENT_SITE' => 'base', 'SITE_ID_CURRENT_SITE' => 'site_id', 'BLOG_ID_CURRENT_SITE' => 'blog_id', ]; foreach ( $consts_to_args as $const => $arg ) { if ( defined( $const ) ) { $assoc_args[ $arg ] = constant( $const ); } } if ( ! $this->multisite_convert_( $assoc_args ) ) { return; } // Do the steps that were skipped by populate_network(), // which checks is_multisite(). if ( is_multisite() ) { $site_user = get_user_by( 'email', $assoc_args['admin_email'] ); self::add_site_admins( $site_user ); $domain = self::get_clean_basedomain(); self::create_initial_blog( $assoc_args['site_id'], $assoc_args['blog_id'], $domain, $assoc_args['base'], $assoc_args['subdomains'], $site_user ); } WP_CLI::success( "Network installed. Don't forget to set up rewrite rules (and a .htaccess file, if using Apache)." ); }
php
{ "resource": "" }
q256752
Core_Command.version
test
public function version( $args = [], $assoc_args = [] ) { $details = self::get_wp_details(); if ( ! Utils\get_flag_value( $assoc_args, 'extra' ) ) { WP_CLI::line( $details['wp_version'] ); return; } $match = []; $found_version = preg_match( '/(\d)(\d+)-/', $details['tinymce_version'], $match ); $human_readable_tiny_mce = $found_version ? "{$match[1]}.{$match[2]}" : ''; echo Utils\mustache_render( self::get_template_path( 'versions.mustache' ), [ 'wp-version' => $details['wp_version'], 'db-version' => $details['wp_db_version'], 'local-package' => empty( $details['wp_local_package'] ) ? 'en_US' : $details['wp_local_package'], 'mce-version' => $human_readable_tiny_mce ? "{$human_readable_tiny_mce} ({$details['tinymce_version']})" : $details['tinymce_version'], ] ); }
php
{ "resource": "" }
q256753
Core_Command.get_core_checksums
test
private static function get_core_checksums( $version, $locale ) { $query = http_build_query( compact( 'version', 'locale' ), null, '&' ); $url = "https://api.wordpress.org/core/checksums/1.0/?{$query}"; $options = [ 'timeout' => 30 ]; $headers = [ 'Accept' => 'application/json' ]; $response = Utils\http_request( 'GET', $url, null, $headers, $options ); if ( ! $response->success || 200 !== (int) $response->status_code ) { return "Checksum request '{$url}' failed (HTTP {$response->status_code})."; } $body = trim( $response->body ); $body = json_decode( $body, true ); if ( ! is_array( $body ) || ! isset( $body['checksums'] ) || ! is_array( $body['checksums'] ) ) { return "Checksums not available for WordPress {$version}/{$locale}."; } return $body['checksums']; }
php
{ "resource": "" }
q256754
Core_Command.update_db
test
public function update_db( $args, $assoc_args ) { global $wpdb, $wp_db_version, $wp_current_db_version; $network = Utils\get_flag_value( $assoc_args, 'network' ); if ( $network && ! is_multisite() ) { WP_CLI::error( 'This is not a multisite installation.' ); } $dry_run = Utils\get_flag_value( $assoc_args, 'dry-run' ); if ( $dry_run ) { WP_CLI::log( 'Performing a dry run, with no database modification.' ); } if ( $network ) { $iterator_args = [ 'table' => $wpdb->blogs, 'where' => [ 'spam' => 0, 'deleted' => 0, 'archived' => 0, ], ]; $it = new TableIterator( $iterator_args ); $success = 0; $total = 0; $site_ids = []; foreach ( $it as $blog ) { $total++; $site_ids[] = $blog->site_id; $url = $blog->domain . $blog->path; $cmd = "--url={$url} core update-db"; if ( $dry_run ) { $cmd .= ' --dry-run'; } $process = WP_CLI::runcommand( $cmd, [ 'return' => 'all' ] ); if ( 0 === (int) $process->return_code ) { // See if we can parse the stdout if ( preg_match( '#Success: (.+)#', $process->stdout, $matches ) ) { $message = rtrim( $matches[1], '.' ); $message = "{$message} on {$url}"; } else { $message = "Database upgraded successfully on {$url}"; } WP_CLI::log( $message ); $success++; } else { WP_CLI::warning( "Database failed to upgrade on {$url}" ); } } if ( ! $dry_run && $total && $success === $total ) { foreach ( array_unique( $site_ids ) as $site_id ) { update_metadata( 'site', $site_id, 'wpmu_upgrade_site', $wp_db_version ); } } WP_CLI::success( "WordPress database upgraded on {$success}/{$total} sites." ); } else { require_once ABSPATH . 'wp-admin/includes/upgrade.php'; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Replacing WP Core behavior is the goal here. $wp_current_db_version = (int) __get_option( 'db_version' ); if ( $wp_db_version !== $wp_current_db_version ) { if ( $dry_run ) { WP_CLI::success( "WordPress database will be upgraded from db version {$wp_current_db_version} to {$wp_db_version}." ); } else { // WP upgrade isn't too fussy about generating MySQL warnings such as "Duplicate key name" during an upgrade so suppress. $wpdb->suppress_errors(); // WP upgrade expects `$_SERVER['HTTP_HOST']` to be set in `wp_guess_url()`, otherwise get PHP notice. if ( ! isset( $_SERVER['HTTP_HOST'] ) ) { $_SERVER['HTTP_HOST'] = 'http://example.com'; } wp_upgrade(); WP_CLI::success( "WordPress database upgraded successfully from db version {$wp_current_db_version} to {$wp_db_version}." ); } } else { WP_CLI::success( "WordPress database already at latest db version {$wp_db_version}." ); } } }
php
{ "resource": "" }
q256755
Core_Command.get_download_url
test
private function get_download_url( $version, $locale = 'en_US', $file_type = 'zip' ) { if ( 'nightly' === $version ) { if ( 'zip' === $file_type ) { return 'https://wordpress.org/nightly-builds/wordpress-latest.zip'; } else { WP_CLI::error( 'Nightly builds are only available in .zip format.' ); } } $locale_subdomain = 'en_US' === $locale ? '' : substr( $locale, 0, 2 ) . '.'; $locale_suffix = 'en_US' === $locale ? '' : "-{$locale}"; return "https://{$locale_subdomain}wordpress.org/wordpress-{$version}{$locale_suffix}.{$file_type}"; }
php
{ "resource": "" }
q256756
Core_Command.get_updates
test
private function get_updates( $assoc_args ) { wp_version_check(); $from_api = get_site_transient( 'update_core' ); if ( ! $from_api ) { return []; } $compare_version = str_replace( '-src', '', $GLOBALS['wp_version'] ); $updates = [ 'major' => false, 'minor' => false, ]; foreach ( $from_api->updates as $offer ) { $update_type = Utils\get_named_sem_ver( $offer->version, $compare_version ); if ( ! $update_type ) { continue; } // WordPress follow its own versioning which is roughly equivalent to semver if ( 'minor' === $update_type ) { $update_type = 'major'; } elseif ( 'patch' === $update_type ) { $update_type = 'minor'; } if ( ! empty( $updates[ $update_type ] ) && ! Comparator::greaterThan( $offer->version, $updates[ $update_type ]['version'] ) ) { continue; } $updates[ $update_type ] = [ 'version' => $offer->version, 'update_type' => $update_type, 'package_url' => ! empty( $offer->packages->partial ) ? $offer->packages->partial : $offer->packages->full, ]; } foreach ( $updates as $type => $value ) { if ( empty( $value ) ) { unset( $updates[ $type ] ); } } foreach ( [ 'major', 'minor' ] as $type ) { if ( true === Utils\get_flag_value( $assoc_args, $type ) ) { return ! empty( $updates[ $type ] ) ? [ $updates[ $type ] ] : false; } } return array_values( $updates ); }
php
{ "resource": "" }
q256757
CoreUpgrader.download_package
test
public function download_package( $package, $check_signatures = true ) { /** * Filter whether to return the package. * * @since 3.7.0 * * @param bool $reply Whether to bail without returning the package. Default is false. * @param string $package The package file name. * @param object $this The WP_Upgrader instance. */ $reply = apply_filters( // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Override existing hook from Core. 'upgrader_pre_download', false, $package, $this ); if ( false !== $reply ) { return $reply; } // Check if package is a local or remote file. Bail if it's local. if ( ! preg_match( '!^(http|https|ftp)://!i', $package ) && file_exists( $package ) ) { return $package; } if ( empty( $package ) ) { return new WP_Error( 'no_package', $this->strings['no_package'] ); } $filename = pathinfo( $package, PATHINFO_FILENAME ); $extension = pathinfo( $package, PATHINFO_EXTENSION ); $temp = Utils\get_temp_dir() . uniqid( 'wp_' ) . ".{$extension}"; register_shutdown_function( function () use ( $temp ) { if ( file_exists( $temp ) ) { unlink( $temp ); } } ); $cache = WP_CLI::get_cache(); $update = $GLOBALS['wpcli_core_update_obj']; $cache_key = "core/{$filename}-{$update->locale}.{$extension}"; $cache_file = $cache->has( $cache_key ); if ( $cache_file && false === stripos( $package, 'https://wordpress.org/nightly-builds/' ) && false === stripos( $package, 'http://wordpress.org/nightly-builds/' ) ) { WP_CLI::log( "Using cached file '{$cache_file}'..." ); copy( $cache_file, $temp ); return $temp; } /* * Download to a temporary file because piping from cURL to tar is flaky * on MinGW (and probably in other environments too). */ $headers = [ 'Accept' => 'application/json' ]; $options = [ 'timeout' => 600, // 10 minutes ought to be enough for everybody. 'filename' => $temp, 'halt_on_error' => false, ]; $this->skin->feedback( 'downloading_package', $package ); /** @var Requests_Response|null $req */ try { $response = Utils\http_request( 'GET', $package, null, $headers, $options ); } catch ( Exception $e ) { return new WP_Error( 'download_failed', $e->getMessage() ); } if ( ! is_null( $response ) && 200 !== (int) $response->status_code ) { return new WP_Error( 'download_failed', $this->strings['download_failed'] ); } if ( false === stripos( $package, 'https://wordpress.org/nightly-builds/' ) ) { $cache->import( $cache_key, $temp ); } return $temp; }
php
{ "resource": "" }
q256758
CoreUpgrader.upgrade
test
public function upgrade( $current, $args = [] ) { set_error_handler( [ __CLASS__, 'error_handler' ], E_USER_WARNING | E_USER_NOTICE ); $result = parent::upgrade( $current, $args ); restore_error_handler(); return $result; }
php
{ "resource": "" }
q256759
Papi_Property_Table.build_table
test
protected function build_table( array $arr, $child = false ) { $html = '<div class="papi-property-table"><table class="papi-table">'; $allow_html = $this->get_setting( 'allow_html' ); if ( $child ) { $html .= '<thead>'; foreach ( $arr[0] as $key => $value ) { if ( $allow_html ) { $key = html_entity_decode( $key ); } $html .= sprintf( '<th>%s</th>', $key ); } $html .= '</thead>'; } foreach ( $arr as $key => $value ) { $html .= '<tr>'; foreach ( $value as $key2 => $value2 ) { if ( is_array( $value2 ) ) { $value2 = $this->build_table( $value2, true ); } $value2 = papi_convert_to_string( $value2 ); if ( $allow_html ) { $value2 = html_entity_decode( $value2 ); } $html .= sprintf( '<td>%s</td>', $value2 ); } $html .= '</tr>'; } return $html . '</table></div>'; }
php
{ "resource": "" }
q256760
Papi_Admin_Meta_Box.admin_head
test
public function admin_head() { if ( ! $this->box->frame ) { echo sprintf( '<style type="text/css">label[for="%s-hide"],#%s>h2,#%s>button{display:none !important}</style>', esc_attr( $this->box->id ), esc_attr( $this->box->id ), esc_attr( $this->box->id ) ); } }
php
{ "resource": "" }
q256761
Papi_Admin_Meta_Box.move_meta_box_after_title
test
public function move_meta_box_after_title() { global $post, $wp_meta_boxes; do_meta_boxes( get_current_screen(), $this->box->context, $post ); unset( $wp_meta_boxes[get_post_type( $post )][$this->box->context] ); }
php
{ "resource": "" }
q256762
Papi_Admin_Meta_Box.get_post_type
test
protected function get_post_type() { if ( papi_get_meta_type() === 'post' ) { if ( $post_id = papi_get_post_id() ) { return get_post_type( $post_id ); } if ( $post_type = papi_get_post_type() ) { return $post_type; } } return $this->box->id; }
php
{ "resource": "" }
q256763
Papi_Admin_Meta_Box.get_title
test
protected function get_title() { $title = $this->box->title; if ( $this->box->get_option( 'required' ) ) { $title .= papi_property_required_html( $this->box->properties[0], true ); } return $title; }
php
{ "resource": "" }
q256764
Papi_Admin_Meta_Box.render_meta_box
test
public function render_meta_box( $post, array $args ) { if ( ! isset( $args['args'] ) ) { return; } // Do a last check before all properties is rendered. $args['args'] = array_filter( $args['args'], 'papi_is_property' ); // Inherit options from the box. foreach ( $args['args'] as $index => $property ) { if ( $property->layout === 'horizontal' ) { $args['args'][$index]->layout = $this->box->layout; } } // Render the properties. papi_render_properties( papi_sort_order( array_reverse( $args['args'] ) ) ); }
php
{ "resource": "" }
q256765
Papi_Admin_Meta_Box.setup_meta_box
test
public function setup_meta_box() { $properties = $this->box->properties; // Check all properties and remove them that can't be rendered. foreach ( $properties as $index => $property ) { if ( $property instanceof Papi_Property && ! $property->can_render() ) { unset( $properties[$index] ); } } // Bail if properties array is empty, // no need to render a empty meta box. if ( empty( $properties ) ) { return; } add_meta_box( $this->box->id, $this->get_title(), [$this, 'render_meta_box'], $this->get_post_type(), $this->box->context, $this->box->priority, $properties ); }
php
{ "resource": "" }
q256766
Papi_Core_Type.get_meta
test
protected function get_meta() { $method = 'meta'; if ( ! method_exists( $this, $method ) ) { return []; } $child_meta = call_user_func( [$this, $method] ); $child_meta = is_array( $child_meta ) ? $child_meta : []; $parent_class = get_parent_class( $this ); $parent_exists = method_exists( $parent_class, $method ); $parent_meta = []; while ( $parent_exists ) { $rc = new ReflectionClass( $parent_class ); // Bail if not instantiable. if ( ! $rc->isInstantiable() ) { break; } $parent = $rc->newInstance(); $output = call_user_func( [$parent, $method] ); $output = is_array( $output ) ? $output : []; $parent_meta = array_merge( $parent_meta, $output ); $parent_class = get_parent_class( $parent_class ); $parent_exists = method_exists( $parent_class, $method ); } return array_merge( $parent_meta, $child_meta ); }
php
{ "resource": "" }
q256767
Papi_Core_Type.setup_file
test
protected function setup_file( $file_path ) { $this->_file_path = $file_path; $this->_class_name = papi_get_class_name( $this->_file_path ); }
php
{ "resource": "" }
q256768
Papi_Core_Type.setup_meta_data
test
protected function setup_meta_data() { foreach ( $this->get_meta() as $key => $value ) { if ( substr( $key, 0, 1 ) === '_' ) { continue; } $this->$key = papi_esc_html( $value ); } if ( $this->sort_order === 1000 ) { $this->sort_order = papi_filter_settings_sort_order(); } }
php
{ "resource": "" }
q256769
Papi_Core_Property.disabled
test
public function disabled() { // Return true if site id isn't zero and don't match the current site id. if ( $this->site_id !== 0 && $this->site_id !== get_current_blog_id() ) { return true; } // If the post type don't match the current one // the property should not be rendered. if ( papi_get_meta_type() === 'post' && ! empty( $this->post_type ) && $this->post_type !== papi_get_post_type() ) { return true; } return $this->disabled; }
php
{ "resource": "" }
q256770
Papi_Core_Property.factory
test
public static function factory() { if ( count( func_get_args() ) === 0 ) { return new static; } else { $type = func_get_arg( 0 ); } if ( is_array( $type ) ) { $type = (object) $type; } if ( ! is_string( $type ) && ! is_object( $type ) ) { return; } if ( is_object( $type ) && ! isset( $type->type ) ) { $property = new static; $property->set_options( $type ); return $property; } if ( is_subclass_of( $type, __CLASS__ ) ) { return $type; } $options = null; if ( is_object( $type ) ) { if ( ! isset( $type->type ) || ! is_string( $type->type ) ) { return; } $options = $type; $type = $type->type; } // Old types, 'PropertyString' => 'String'. $type = preg_replace( '/^Property/', '', $type ); if ( empty( $type ) ) { return; } $class_name = papi_get_property_class_name( $type ); if ( ! class_exists( $class_name ) || ! is_subclass_of( $class_name, __CLASS__ ) ) { return; } if ( ! papi()->exists( $class_name ) ) { papi()->bind( $class_name, new $class_name() ); } $class = papi()->make( $class_name ); // @codeCoverageIgnoreStart if ( ! is_object( $class ) || $class instanceof Papi_Core_Property === false ) { $class = new $class_name(); papi()->bind( $class_name, $class ); } // @codeCoverageIgnoreEnd $property = clone $class; if ( is_object( $options ) ) { $property->set_options( (array) $options ); } return $property; }
php
{ "resource": "" }
q256771
Papi_Core_Property.get_child_property
test
public function get_child_property( $slug, array $items = [] ) { $items = empty( $items ) ? $this->get_child_properties() : $items; foreach ( $items as $property ) { if ( is_array( $property ) && isset( $property['items'] ) ) { $property = $this->get_child_property( $slug, $property['items'] ); } $property = papi_get_property_type( $property ); if ( papi_is_property( $property ) && $property->match_slug( $slug ) ) { return $property; } } }
php
{ "resource": "" }
q256772
Papi_Core_Property.get_option
test
public function get_option( $key, $default = null ) { $value = $default; if ( isset( $this->options->$key ) ) { $value = $this->options->$key; } if ( papi_is_empty( $value ) && isset( $this->default_options[$key] ) ) { $value = $this->default_options[$key]; } if ( $key === 'settings' && is_array( $value ) ) { $value = (object) $value; } return $value; }
php
{ "resource": "" }
q256773
Papi_Core_Property.get_post_id
test
public function get_post_id() { if ( ! papi_is_empty( $this->post_id ) ) { return $this->post_id; } if ( $this->store instanceof Papi_Core_Meta_Store ) { return $this->store->id; } return papi_get_post_id(); }
php
{ "resource": "" }
q256774
Papi_Core_Property.html_id
test
public function html_id( $suffix = '', $row = null ) { if ( is_array( $suffix ) || is_object( $suffix ) ) { return papi_f( $this->html_name( $suffix, $row ) ); } else { $suffix = empty( $suffix ) || ! is_string( $suffix ) ? '' : '_' . $suffix; $suffix = papi_underscorify( papi_slugify( $suffix ) ); } $name = $this->html_name(); $len = strlen( $name ); if ( isset( $name[$len - 1] ) && $name[$len - 1] === ']' ) { return papi_f( sprintf( '%s%s]', substr( $name, 0, $len - 1 ), $suffix ) ); } return papi_f( sprintf( '%s%s', $this->html_name(), $suffix ) ); }
php
{ "resource": "" }
q256775
Papi_Core_Property.html_name
test
public function html_name( $sub_property = null, $row = null ) { $base_slug = $this->slug; if ( is_null( $sub_property ) ) { return $base_slug; } if ( is_numeric( $row ) ) { $base_slug = sprintf( '%s[%d]', $base_slug, intval( $row ) ); } if ( ! papi_is_property( $sub_property ) ) { if ( is_array( $sub_property ) || is_object( $sub_property ) ) { $sub_property = self::factory( $sub_property ); } else { return $base_slug; } } return sprintf( '%s[%s]', $base_slug, unpapify( $sub_property->get_slug() ) ); }
php
{ "resource": "" }
q256776
Papi_Core_Property.match_slug
test
public function match_slug( $slug ) { if ( ! is_string( $slug ) ) { return false; } return $this->get_slug( ! preg_match( '/^papi\_/', $slug ) ) === $slug; }
php
{ "resource": "" }
q256777
Papi_Core_Property.prepare_value
test
protected function prepare_value( $value ) { if ( papi_is_empty( $value ) ) { return; } $value = papi_santize_data( $value ); if ( is_array( $value ) ) { $value = array_filter( $value, function ( $val ) { return ! papi_is_empty( $val ); } ); if ( ! count( array_filter( array_keys( $value ), 'is_string' ) ) ) { $value = array_values( $value ); } } return $value; }
php
{ "resource": "" }
q256778
Papi_Core_Property.render_is_allowed_by_rules
test
public function render_is_allowed_by_rules( array $rules = [] ) { if ( empty( $rules ) ) { $rules = $this->get_rules(); } return $this->conditional->display( $rules, $this ); }
php
{ "resource": "" }
q256779
Papi_Core_Property.set_option
test
public function set_option( $key, $value ) { if ( ! is_object( $this->options ) ) { $this->options = (object) $this->default_options; } $this->options->$key = $value; }
php
{ "resource": "" }
q256780
Papi_Core_Property.set_setting
test
public function set_setting( $key, $value ) { if ( isset( $this->options->settings, $this->options->settings->$key ) ) { $this->options->settings->$key = $value; } }
php
{ "resource": "" }
q256781
Papi_Core_Property.setup_properties
test
protected function setup_properties() { $this->conditional = new Papi_Core_Conditional(); if ( $this->default_options['sort_order'] === -1 ) { $this->default_options['sort_order'] = papi_filter_settings_sort_order(); } if ( papi_is_empty( $this->default_options['post_type'] ) ) { $this->default_options['post_type'] = papi_get_post_type(); } }
php
{ "resource": "" }
q256782
Papi_Core_Property.setup_options
test
protected function setup_options( $options = [] ) { // When a object is sent in, just return it. if ( is_object( $options ) ) { return $options; } // Only arrays can be handled. if ( ! is_array( $options ) ) { $options = []; } // Merge default options with the given options array. $options = array_merge( $this->default_options, $options ); $options = (object) $options; // Setup aliases. $option_aliases = apply_filters( 'papi/option_aliases', $this->option_aliases ); $option_aliases = is_array( $option_aliases ) ? $option_aliases : []; $option_aliases = array_merge( $this->option_aliases, $option_aliases ); foreach ( $option_aliases as $alias => $option ) { if ( isset( $options->$alias ) && ! papi_is_empty( $options->$alias ) ) { $options->$option = $options->$alias; unset( $options->$alias ); } } // Capabilities should be a array. $options->capabilities = papi_to_array( $options->capabilities ); // Setup property slug. $options->slug = strtolower( $this->setup_options_slug( $options ) ); // Setup property settings. $options->settings = $this->setup_options_settings( $options ); // Type should always be lowercase. $options->type = strtolower( $options->type ); // Escape all options except those that are send it as second argument. return papi_esc_html( $options, ['before_html', 'html', 'after_html'] ); }
php
{ "resource": "" }
q256783
Papi_Core_Property.setup_options_slug
test
protected function setup_options_slug( $options ) { $slug = $options->slug; // When `slug` is false or not required a unique slug should be generated. if ( $slug === false || ( empty( $slug ) && $this->slug_required === false ) ) { return '_' . papi_html_name( md5( uniqid( rand(), true ) ) ); } // If `slug` is empty, check if `title` is not empty // and generate a slug from the `title` or if empty // use the `type`. if ( empty( $slug ) ) { if ( empty( $options->title ) ) { $slug = papi_slugify( $options->type ); } else { $slug = papi_slugify( $options->title ); } } // Create a html friendly name from the `slug`. return papi_html_name( $slug ); }
php
{ "resource": "" }
q256784
Papi_Core_Property.setup_options_settings
test
protected function setup_options_settings( $options ) { $property_class = self::factory( $options->type ); if ( papi_is_property( $property_class ) ) { $options->settings = array_merge( (array) $property_class->get_default_settings(), (array) $options->settings ); } return (object) $options->settings; }
php
{ "resource": "" }
q256785
Papi_Attachment_Type.edit_attachment
test
public function edit_attachment( $form_fields, $post ) { foreach ( $this->get_boxes() as $box ) { if ( ! empty( $box->title ) ) { $form_fields['papi-media-title-' . uniqid()] = [ 'label' => '', 'input' => 'html', 'html' => '<h4 class="papi-media-title">' . $box->title . '</h4>' ]; } foreach ( $box->properties as $prop ) { // Raw output is required. $prop->raw = true; // Set post id to the property. $prop->set_post_id( $post->ID ); // Add property to form fields. $form_fields[$prop->get_slug()] = [ 'label' => $prop->title, 'input' => 'html', 'helps' => $prop->description, 'html' => papi_maybe_get_callable_value( 'papi_render_property', $prop ) ]; } } // Add nonce field. $form_fields['papi_meta_nonce'] = [ 'label' => '', 'input' => 'html', 'html' => sprintf( '<input name="papi_meta_nonce" type="hidden" value="%s" />', wp_create_nonce( 'papi_save_data' ) ) ]; return $form_fields; }
php
{ "resource": "" }
q256786
Papi_Attachment_Type.save_attachment
test
public function save_attachment( $post ) { update_post_meta( $post['ID'], papi_get_page_type_key(), $this->get_id() ); $handler = new Papi_Admin_Meta_Handler(); $handler->save_meta_boxes( $post['ID'], $post ); return $post; }
php
{ "resource": "" }
q256787
Papi_Attachment_Type.singleton
test
public function singleton() { $key = sprintf( 'entry_type_id.post_type.%s', $this->get_post_type() ); if ( papi()->exists( $key ) ) { return true; } papi()->singleton( $key, $this->get_id() ); return false; }
php
{ "resource": "" }
q256788
Papi_Core_Meta_Store.get_property_meta_value
test
public function get_property_meta_value( $slug ) { $slug = strtolower( $slug ); if ( isset( $this->meta_values[$slug] ) ) { return $this->meta_values[$slug]; } return papi_data_get( $this->id, $slug, $this->get_type() ); }
php
{ "resource": "" }
q256789
Papi_Core_Meta_Store.format_value
test
public function format_value( $slug, $value ) { $slug = strtolower( unpapify( $slug ) ); $property = $this->property( $slug ); // If no property type is found, just return null. if ( ! papi_is_property( $property ) ) { return; } // Format the value from the property class. $value = $property->format_value( $value, $slug, $this->id ); // Only fired when not in admin. if ( ! papi_is_admin() ) { $value = papi_filter_format_value( $property->type, $value, $slug, $this->id, papi_get_meta_type() ); } // Modify value before it's return to the theme via a defined format callback on the property. if ( ! papi_is_admin() && is_callable( $property->format_cb ) ) { $value = call_user_func( $property->format_cb, $value ); } // Remove empty values from arrays. if ( is_array( $value ) ) { foreach ( $value as $index => $val ) { if ( papi_is_empty( $val ) ) { unset( $value[$index] ); } } } return $value; }
php
{ "resource": "" }
q256790
Papi_Core_Meta_Store.property
test
protected function property( $slug = '' ) { if ( isset( $this->properties[$slug] ) && papi_is_property( $this->properties[$slug] ) ) { $property = $this->properties[$slug]; } else { $property = $this->properties[$slug] = $this->get_property( $slug ); } /** * Modify property. * * @param Papi_Core_Property $property */ return apply_filters( 'papi/get_property', $property ); }
php
{ "resource": "" }
q256791
Papi_Core_Meta_Store.load_value
test
public function load_value( $slug ) { $slug = strtolower( unpapify( $slug ) ); $property = $this->property( $slug ); // If no property type is found, just return null. if ( ! papi_is_property( $property ) ) { return; } // Get raw property meta value. $value = $this->get_property_meta_value( $slug ); // Prepare load value, when you have `overwrite => true` // this value will not exist in the database and that's // why we need to prepare (change) the value. $value = $this->prepare_load_value( $property, $value ); // Bail if value is empty and option value is empty. if ( papi_is_empty( $value ) ) { if ( ! papi_is_empty( $property->get_option( 'value' ) ) ) { return $property->get_option( 'value' ); } return; } // A property need to know about the store. $this->property( $slug )->set_store( $this ); // Run load value method right after the value has been loaded from the database. $value = $property->load_value( $value, $slug, $this->id ); $value = papi_filter_load_value( $property->type, $value, $slug, $this->id, papi_get_meta_type() ); // Remove empty values from arrays. if ( is_array( $value ) ) { foreach ( $value as $index => $val ) { if ( papi_is_empty( $val ) ) { unset( $value[$index] ); } } } return $value; }
php
{ "resource": "" }
q256792
Papi_Core_Meta_Store.factory
test
public static function factory( $post_id, $type = 'post' ) { $type = papi_get_meta_type( $type ); $class_suffix = '_' . ucfirst( $type ) . '_Store'; $class_name = 'Papi' . $class_suffix; if ( ! class_exists( $class_name ) ) { return; } $post_id = papi_get_post_id( $post_id ); $page = new $class_name( $post_id ); if ( ! $page->valid() ) { return; } return $page; }
php
{ "resource": "" }
q256793
Papi_Core_Meta_Store.get_property_option
test
public function get_property_option( $slug, $option, $default = null ) { $slug = unpapify( $slug ); $property = $this->property( $slug ); // If no property type is found, return default // value since we don't have a property. if ( ! papi_is_property( $property ) ) { return $default; } $value = $property->get_option( $option ); if ( papi_is_empty( $value ) ) { return $default; } return $value; }
php
{ "resource": "" }
q256794
Papi_Property.can_render
test
public function can_render() { // Check if current user can view the property. if ( ! $this->current_user_can() ) { return false; } // A disabled property should not be rendered. if ( $this->disabled() ) { return false; } // Check language option, so we don't render properties on a different language. if ( $lang = $this->get_option( 'lang' ) ) { return in_array( papi_get_lang(), papi_to_array( $lang ), true ); } // If no valid lang query string exists we have to override the display property. return $this->get_option( 'lang' ) === false; }
php
{ "resource": "" }
q256795
Papi_Property.render
test
public function render() { // Bail if we can't render the property. if ( ! $this->can_render() ) { return; } // Override display with rules check. if ( $this->display() ) { $this->display = $this->render_is_allowed_by_rules(); } // Render property. $this->render_row_html(); }
php
{ "resource": "" }
q256796
Papi_Property.render_hidden_html
test
protected function render_hidden_html() { $slug = $this->get_option( 'slug' ); if ( substr( $slug, - 1 ) === ']' ) { $slug = substr( $slug, 0, - 1 ); $slug = papi_get_property_type_key( $slug ); $slug .= ']'; } else { $slug = papi_get_property_type_key( $slug ); } $slug = papify( $slug ); $options = $this->get_options(); $property_json = base64_encode( papi_maybe_json_encode( $options ) ); papi_render_html_tag( 'input', [ 'data-property' => strtolower( $this->get_option( 'type' ) ), 'name' => $slug, 'type' => 'hidden', 'value' => $property_json ] ); }
php
{ "resource": "" }
q256797
Papi_Property.render_label_html
test
protected function render_label_html() { $title = $this->get_option( 'title' ); papi_render_html_tag( 'label', [ 'for' => $this->html_id(), 'title' => trim( $title . ' ' . papi_property_require_text( $this->get_options() ) ), $title, papi_property_required_html( $this ) ] ); }
php
{ "resource": "" }
q256798
Papi_Property.render_row_html
test
protected function render_row_html() { $display_class = $this->display() ? '' : ' papi-hide'; $rules_class = papi_is_empty( $this->get_rules() ) ? '' : ' papi-rules-exists'; $css_class = trim( $display_class . $rules_class ); $css_class .= sprintf( ' papi-layout-%s', $this->get_option( 'layout' ) ); if ( $this->get_option( 'raw' ) ) { echo sprintf( '<div class="%s">', esc_attr( $css_class ) ); $this->render_property_html(); $this->render_hidden_html(); $this->render_rules_json(); echo '</div>'; } else { ?> <tr class="<?php echo esc_attr( $css_class ); ?>"> <?php if ( $this->get_option( 'sidebar' ) && $this->get_option( 'layout' ) === 'horizontal' ): ?> <td class="papi-table-sidebar"> <?php $this->render_label_html(); $this->render_description_html(); ?> </td> <?php endif; ?> <td <?php echo $this->get_option( 'sidebar' ) && $this->get_option( 'layout' ) === 'horizontal' ? '' : 'colspan="2"'; ?>> <?php // Render vertical layout where title and description is above the property. if ( $this->get_option( 'layout' ) === 'vertical' && $this->get_option( 'sidebar' ) ) { $this->render_label_html(); $this->render_description_html(); } $this->render_property_html(); $this->render_hidden_html(); $this->render_rules_json(); ?> </td> </tr> <?php } }
php
{ "resource": "" }
q256799
Papi_Property.render_rules_json
test
protected function render_rules_json() { $rules = $this->get_rules(); if ( empty( $rules ) ) { return; } $rules = $this->conditional->prepare_rules( $rules, $this ); papi_render_html_tag( 'script', [ 'data-papi-rule-source-slug' => $this->html_name(), 'data-papi-rules' => 'true', 'type' => 'application/json', papi_maybe_json_encode( $rules ) ] ); }
php
{ "resource": "" }