开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (49)
标签 (747)
master
trunk
6.5
6.6
5.8
5.9
6.0
6.1
6.2
6.3
5.3
5.4
5.5
5.6
5.7
6.4
4.1
4.2
4.3
4.4
6.6.1
6.6.0
4.1.41
4.2.38
4.3.34
4.4.33
4.5.32
4.6.29
4.7.29
4.8.25
4.9.26
5.0.22
5.1.19
5.2.21
5.3.18
5.4.16
5.5.15
5.6.14
5.7.12
5.8.10
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
项目仓库所选许可证以仓库主分支所使用许可证为准
master
分支 (49)
标签 (747)
master
trunk
6.5
6.6
5.8
5.9
6.0
6.1
6.2
6.3
5.3
5.4
5.5
5.6
5.7
6.4
4.1
4.2
4.3
4.4
6.6.1
6.6.0
4.1.41
4.2.38
4.3.34
4.4.33
4.5.32
4.6.29
4.7.29
4.8.25
4.9.26
5.0.22
5.1.19
5.2.21
5.3.18
5.4.16
5.5.15
5.6.14
5.7.12
5.8.10
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (49)
标签 (747)
master
trunk
6.5
6.6
5.8
5.9
6.0
6.1
6.2
6.3
5.3
5.4
5.5
5.6
5.7
6.4
4.1
4.2
4.3
4.4
6.6.1
6.6.0
4.1.41
4.2.38
4.3.34
4.4.33
4.5.32
4.6.29
4.7.29
4.8.25
4.9.26
5.0.22
5.1.19
5.2.21
5.3.18
5.4.16
5.5.15
5.6.14
5.7.12
5.8.10
utils.php 13.47 KB
一键复制 编辑 原始数据 按行查看 历史
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562
<?php
// Misc help functions and utilities.
/**
* Returns a string of the required length containing random characters. Note that
* the maximum possible string length is 32.
*
* @param int $len Optional. The required length. Default 32.
* @return string The string.
*/
function rand_str( $len = 32 ) {
return substr( md5( uniqid( rand() ) ), 0, $len );
}
/**
* Returns a string of the required length containing random characters.
*
* @param int $len The required length.
* @return string The string.
*/
function rand_long_str( $length ) {
$chars = 'abcdefghijklmnopqrstuvwxyz';
$string = '';
for ( $i = 0; $i < $length; $i++ ) {
$rand = rand( 0, strlen( $chars ) - 1 );
$string .= substr( $chars, $rand, 1 );
}
return $string;
}
/**
* Strips leading and trailing whitespace from each line in the string.
*
* @param string $txt The text.
* @return string Text with line-leading and line-trailing whitespace stripped.
*/
function strip_ws( $txt ) {
$lines = explode( "\n", $txt );
$result = array();
foreach ( $lines as $line ) {
if ( trim( $line ) ) {
$result[] = trim( $line );
}
}
return trim( implode( "\n", $result ) );
}
/*
* Helper class for testing code that involves actions and filters.
*
* Typical use:
*
* $ma = new MockAction();
* add_action( 'foo', array( &$ma, 'action' ) );
*/
class MockAction {
public $events;
public $debug;
/**
* PHP5 constructor.
*/
public function __construct( $debug = 0 ) {
$this->reset();
$this->debug = $debug;
}
public function reset() {
$this->events = array();
}
public function current_filter() {
if ( is_callable( 'current_filter' ) ) {
return current_filter();
}
global $wp_actions;
return end( $wp_actions );
}
public function action( $arg ) {
if ( $this->debug ) {
dmp( __FUNCTION__, $this->current_filter() );
}
$args = func_get_args();
$this->events[] = array(
'action' => __FUNCTION__,
'tag' => $this->current_filter(),
'args' => $args,
);
return $arg;
}
public function action2( $arg ) {
if ( $this->debug ) {
dmp( __FUNCTION__, $this->current_filter() );
}
$args = func_get_args();
$this->events[] = array(
'action' => __FUNCTION__,
'tag' => $this->current_filter(),
'args' => $args,
);
return $arg;
}
public function filter( $arg ) {
if ( $this->debug ) {
dmp( __FUNCTION__, $this->current_filter() );
}
$args = func_get_args();
$this->events[] = array(
'filter' => __FUNCTION__,
'tag' => $this->current_filter(),
'args' => $args,
);
return $arg;
}
public function filter2( $arg ) {
if ( $this->debug ) {
dmp( __FUNCTION__, $this->current_filter() );
}
$args = func_get_args();
$this->events[] = array(
'filter' => __FUNCTION__,
'tag' => $this->current_filter(),
'args' => $args,
);
return $arg;
}
public function filter_append( $arg ) {
if ( $this->debug ) {
dmp( __FUNCTION__, $this->current_filter() );
}
$args = func_get_args();
$this->events[] = array(
'filter' => __FUNCTION__,
'tag' => $this->current_filter(),
'args' => $args,
);
return $arg . '_append';
}
public function filterall( $tag, ...$args ) {
// This one doesn't return the result, so it's safe to use with the new 'all' filter.
if ( $this->debug ) {
dmp( __FUNCTION__, $this->current_filter() );
}
$this->events[] = array(
'filter' => __FUNCTION__,
'tag' => $tag,
'args' => $args,
);
}
// Return a list of all the actions, tags and args.
public function get_events() {
return $this->events;
}
// Return a count of the number of times the action was called since the last reset.
public function get_call_count( $tag = '' ) {
if ( $tag ) {
$count = 0;
foreach ( $this->events as $e ) {
if ( $e['action'] === $tag ) {
++$count;
}
}
return $count;
}
return count( $this->events );
}
// Return an array of the tags that triggered calls to this action.
public function get_tags() {
$out = array();
foreach ( $this->events as $e ) {
$out[] = $e['tag'];
}
return $out;
}
// Return an array of args passed in calls to this action.
public function get_args() {
$out = array();
foreach ( $this->events as $e ) {
$out[] = $e['args'];
}
return $out;
}
}
// Convert valid XML to an array tree structure.
// Kinda lame, but it works with a default PHP 4 installation.
class TestXMLParser {
public $xml;
public $data = array();
/**
* PHP5 constructor.
*/
public function __construct( $in ) {
$this->xml = xml_parser_create();
xml_set_object( $this->xml, $this );
xml_parser_set_option( $this->xml, XML_OPTION_CASE_FOLDING, 0 );
xml_set_element_handler( $this->xml, array( $this, 'start_handler' ), array( $this, 'end_handler' ) );
xml_set_character_data_handler( $this->xml, array( $this, 'data_handler' ) );
$this->parse( $in );
}
public function parse( $in ) {
$parse = xml_parse( $this->xml, $in, true );
if ( ! $parse ) {
trigger_error(
sprintf(
'XML error: %s at line %d',
xml_error_string( xml_get_error_code( $this->xml ) ),
xml_get_current_line_number( $this->xml )
),
E_USER_ERROR
);
xml_parser_free( $this->xml );
}
return true;
}
public function start_handler( $parser, $name, $attributes ) {
$data['name'] = $name;
if ( $attributes ) {
$data['attributes'] = $attributes; }
$this->data[] = $data;
}
public function data_handler( $parser, $data ) {
$index = count( $this->data ) - 1;
if ( ! isset( $this->data[ $index ]['content'] ) ) {
$this->data[ $index ]['content'] = '';
}
$this->data[ $index ]['content'] .= $data;
}
public function end_handler( $parser, $name ) {
if ( count( $this->data ) > 1 ) {
$data = array_pop( $this->data );
$index = count( $this->data ) - 1;
$this->data[ $index ]['child'][] = $data;
}
}
}
/**
* Converts an XML string into an array tree structure.
*
* The output of this function can be passed to xml_find() to find nodes by their path.
*
* @param string $in The XML string.
* @return array XML as an array.
*/
function xml_to_array( $in ) {
$p = new TestXMLParser( $in );
return $p->data;
}
/**
* Finds XML nodes by a given "path".
*
* Example usage:
*
* $tree = xml_to_array( $rss );
* $items = xml_find( $tree, 'rss', 'channel', 'item' );
*
* @param array $tree An array tree structure of XML, typically from xml_to_array().
* @param string ...$elements Names of XML nodes to create a "path" to find within the XML.
* @return array Array of matching XML node information.
*/
function xml_find( $tree, ...$elements ) {
$n = count( $elements );
$out = array();
if ( $n < 1 ) {
return $out;
}
for ( $i = 0; $i < count( $tree ); $i++ ) {
# echo "checking '{$tree[$i][name]}' == '{$elements[0]}'\n";
# var_dump( $tree[$i]['name'], $elements[0] );
if ( $tree[ $i ]['name'] === $elements[0] ) {
# echo "n == {$n}\n";
if ( 1 === $n ) {
$out[] = $tree[ $i ];
} else {
$subtree =& $tree[ $i ]['child'];
$out = array_merge( $out, xml_find( $subtree, ...array_slice( $elements, 1 ) ) );
}
}
}
return $out;
}
function xml_join_atts( $atts ) {
$a = array();
foreach ( $atts as $k => $v ) {
$a[] = $k . '="' . $v . '"';
}
return implode( ' ', $a );
}
function xml_array_dumbdown( &$data ) {
$out = array();
foreach ( array_keys( $data ) as $i ) {
$name = $data[ $i ]['name'];
if ( ! empty( $data[ $i ]['attributes'] ) ) {
$name .= ' ' . xml_join_atts( $data[ $i ]['attributes'] );
}
if ( ! empty( $data[ $i ]['child'] ) ) {
$out[ $name ][] = xml_array_dumbdown( $data[ $i ]['child'] );
} else {
$out[ $name ] = $data[ $i ]['content'];
}
}
return $out;
}
function dmp( ...$args ) {
foreach ( $args as $thing ) {
echo ( is_scalar( $thing ) ? (string) $thing : var_export( $thing, true ) ), "\n";
}
}
function dmp_filter( $a ) {
dmp( $a );
return $a;
}
function get_echo( $callable, $args = array() ) {
ob_start();
call_user_func_array( $callable, $args );
return ob_get_clean();
}
// Recursively generate some quick assertEquals() tests based on an array.
function gen_tests_array( $name, $array ) {
$out = array();
foreach ( $array as $k => $v ) {
if ( is_numeric( $k ) ) {
$index = (string) $k;
} else {
$index = "'" . addcslashes( $k, "\n\r\t'\\" ) . "'";
}
if ( is_string( $v ) ) {
$out[] = '$this->assertEquals( \'' . addcslashes( $v, "\n\r\t'\\" ) . '\', $' . $name . '[' . $index . '] );';
} elseif ( is_numeric( $v ) ) {
$out[] = '$this->assertEquals( ' . $v . ', $' . $name . '[' . $index . '] );';
} elseif ( is_array( $v ) ) {
$out[] = gen_tests_array( "{$name}[{$index}]", $v );
}
}
return implode( "\n", $out ) . "\n";
}
/**
* Use to create objects by yourself
*/
class MockClass {}
/**
* Drops all tables from the WordPress database
*/
function drop_tables() {
global $wpdb;
$tables = $wpdb->get_col( 'SHOW TABLES;' );
foreach ( $tables as $table ) {
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
$wpdb->query( "DROP TABLE IF EXISTS {$table}" );
}
}
function print_backtrace() {
$bt = debug_backtrace();
echo "Backtrace:\n";
$i = 0;
foreach ( $bt as $stack ) {
echo ++$i, ': ';
if ( isset( $stack['class'] ) ) {
echo $stack['class'] . '::';
}
if ( isset( $stack['function'] ) ) {
echo $stack['function'] . '() ';
}
echo "line {$stack[line]} in {$stack[file]}\n";
}
echo "\n";
}
// Mask out any input fields matching the given name.
function mask_input_value( $in, $name = '_wpnonce' ) {
return preg_replace( '@<input([^>]*) name="' . preg_quote( $name ) . '"([^>]*) value="[^>]*" />@', '<input1ドル name="' . preg_quote( $name ) . '"2ドル value="***" />', $in );
}
/**
* Removes the post type and its taxonomy associations.
*/
function _unregister_post_type( $cpt_name ) {
unregister_post_type( $cpt_name );
}
function _unregister_taxonomy( $taxonomy_name ) {
unregister_taxonomy( $taxonomy_name );
}
/**
* Unregister a post status.
*
* @since 4.2.0
*
* @param string $status
*/
function _unregister_post_status( $status ) {
unset( $GLOBALS['wp_post_statuses'][ $status ] );
}
function _cleanup_query_vars() {
// Clean out globals to stop them polluting wp and wp_query.
foreach ( $GLOBALS['wp']->public_query_vars as $v ) {
unset( $GLOBALS[ $v ] );
}
foreach ( $GLOBALS['wp']->private_query_vars as $v ) {
unset( $GLOBALS[ $v ] );
}
foreach ( get_taxonomies( array(), 'objects' ) as $t ) {
if ( $t->publicly_queryable && ! empty( $t->query_var ) ) {
$GLOBALS['wp']->add_query_var( $t->query_var );
}
}
foreach ( get_post_types( array(), 'objects' ) as $t ) {
if ( is_post_type_viewable( $t ) && ! empty( $t->query_var ) ) {
$GLOBALS['wp']->add_query_var( $t->query_var );
}
}
}
function _clean_term_filters() {
remove_filter( 'get_terms', array( 'Featured_Content', 'hide_featured_term' ), 10, 2 );
remove_filter( 'get_the_terms', array( 'Featured_Content', 'hide_the_featured_term' ), 10, 3 );
}
/**
* Special class for exposing protected wpdb methods we need to access
*/
class WpdbExposedMethodsForTesting extends wpdb {
public function __construct() {
global $wpdb;
$this->dbh = $wpdb->dbh;
$this->use_mysqli = $wpdb->use_mysqli;
$this->is_mysql = $wpdb->is_mysql;
$this->ready = true;
$this->field_types = $wpdb->field_types;
$this->charset = $wpdb->charset;
$this->dbuser = $wpdb->dbuser;
$this->dbpassword = $wpdb->dbpassword;
$this->dbname = $wpdb->dbname;
$this->dbhost = $wpdb->dbhost;
}
public function __call( $name, $arguments ) {
return call_user_func_array( array( $this, $name ), $arguments );
}
}
/**
* Determine approximate backtrack count when running PCRE.
*
* @return int The backtrack count.
*/
function benchmark_pcre_backtracking( $pattern, $subject, $strategy ) {
$saved_config = ini_get( 'pcre.backtrack_limit' );
// Attempt to prevent PHP crashes. Adjust lower when needed.
$limit = 1000000;
// Start with small numbers, so if a crash is encountered at higher numbers we can still debug the problem.
for ( $i = 4; $i <= $limit; $i *= 2 ) {
ini_set( 'pcre.backtrack_limit', $i );
switch ( $strategy ) {
case 'split':
preg_split( $pattern, $subject );
break;
case 'match':
preg_match( $pattern, $subject );
break;
case 'match_all':
$matches = array();
preg_match_all( $pattern, $subject, $matches );
break;
}
ini_set( 'pcre.backtrack_limit', $saved_config );
switch ( preg_last_error() ) {
case PREG_NO_ERROR:
return $i;
case PREG_BACKTRACK_LIMIT_ERROR:
break;
case PREG_RECURSION_LIMIT_ERROR:
trigger_error( 'PCRE recursion limit encountered before backtrack limit.' );
return;
case PREG_BAD_UTF8_ERROR:
trigger_error( 'UTF-8 error during PCRE benchmark.' );
return;
case PREG_INTERNAL_ERROR:
trigger_error( 'Internal error during PCRE benchmark.' );
return;
default:
trigger_error( 'Unexpected error during PCRE benchmark.' );
return;
}
}
return $i;
}
function test_rest_expand_compact_links( $links ) {
if ( empty( $links['curies'] ) ) {
return $links;
}
foreach ( $links as $rel => $links_array ) {
if ( ! strpos( $rel, ':' ) ) {
continue;
}
$name = explode( ':', $rel );
$curie = wp_list_filter( $links['curies'], array( 'name' => $name[0] ) );
$full_uri = str_replace( '{rel}', $name[1], $curie[0]['href'] );
$links[ $full_uri ] = $links_array;
unset( $links[ $rel ] );
}
return $links;
}
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/github7972/wordpress-develop.git
git@gitee.com:github7972/wordpress-develop.git
github7972
wordpress-develop
wordpress-develop
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /