当前位置: 首页>>代码示例>>PHP>>正文


PHP map_deep函数代码示例

本文整理汇总了PHP中map_deep函数的典型用法代码示例。如果您正苦于以下问题:PHP map_deep函数的具体用法?PHP map_deep怎么用?PHP map_deep使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了map_deep函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_map_deep_should_map_each_object_property_of_an_object

	function test_map_deep_should_map_each_object_property_of_an_object() {
		$this->assertEquals( (object)array( 'var0' => 'ababa', 'var1' => (object)array( 'xbaba' ) ),
			map_deep( array( $this, 'append_baba' ), (object)array( 'var0' => 'a', 'var1' => (object)array( 'x' ) ) ) );
	}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:4,代码来源:MapDeep.php

示例2: wp_kses_post_deep

/**
 * Navigates through an array, object, or scalar, and sanitizes content for
 * allowed HTML tags for post content.
 *
 * @since 4.4.2
 *
 * @param mixed $value The array or string to filter.
 * @return mixed $value The filtered content.
 */
function wp_kses_post_deep($data)
{
    return map_deep($data, 'wp_kses_post');
}
开发者ID:zoran180,项目名称:wp_szf,代码行数:13,代码来源:kses.php

示例3: map_deep

/**
 * Maps a function to all non-iterable elements of an array or an object.
 *
 * This is similar to `array_walk_recursive()` but acts upon objects too.
 *
 * @since 4.4.0
 *
 * @param mixed    $value    The array, object, or scalar.
 * @param callable $callback The function to map onto $value.
 * @return The value with the callback applied to all non-arrays and non-objects inside it.
 */
function map_deep($value, $callback)
{
    if (is_array($value) || is_object($value)) {
        foreach ($value as &$item) {
            $item = map_deep($item, $callback);
        }
        return $value;
    } else {
        return call_user_func($callback, $value);
    }
}
开发者ID:zhoujiangyou,项目名称:WordPress,代码行数:22,代码来源:formatting.php

示例4: map_deep

/**
 * Maps a function to all non-iterable elements of an array or an object.
 *
 * This is similar to `array_walk_recursive()` but acts upon objects too.
 *
 * @since 4.4.0
 *
 * @param mixed    $value    The array, object, or scalar.
 * @param callable $callback The function to map onto $value.
 * @return The value with the callback applied to all non-arrays and non-objects inside it.
 */
function map_deep( $value, $callback ) {
	if ( is_array( $value ) ) {
		foreach ( $value as $index => $item ) {
			$value[ $index ] = map_deep( $item, $callback );
		}
	} elseif ( is_object( $value ) ) {
		$object_vars = get_object_vars( $value );
		foreach ( $object_vars as $property_name => $property_value ) {
			$value->$property_name = map_deep( $property_value, $callback );
		}
	} else {
		$value = call_user_func( $callback, $value );
	}

	return $value;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:27,代码来源:formatting.php

示例5: test_map_deep_should_map_array_elements_passed_by_reference

 /**
  * @ticket 35058
  */
 public function test_map_deep_should_map_array_elements_passed_by_reference()
 {
     $array_a = array('var0' => 'a');
     $array_b = array('var0' => &$array_a['var0'], 'var1' => 'x');
     $this->assertEquals(array('var0' => 'ababa', 'var1' => 'xbaba'), map_deep($array_b, array($this, 'append_baba')));
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:9,代码来源:MapDeep.php

示例6: gv_map_deep

/**
 * Maps a function to all non-iterable elements of an array or an object.
 *
 * @see map_deep() This is an alias of the WP core function `map_deep()`, added in 4.4. Here for legacy purposes.
 * @since 1.16.3
 *
 * @param mixed    $value    The array, object, or scalar.
 * @param callable $callback The function to map onto $value.
 *
 * @return mixed The value with the callback applied to all non-arrays and non-objects inside it.
 */
function gv_map_deep($value, $callback)
{
    // Use the original function, if exists.
    // Requires WP 4.4+
    if (function_exists('map_deep')) {
        return map_deep($value, $callback);
    }
    // Exact copy of map_deep() code below:
    if (is_array($value)) {
        foreach ($value as $index => $item) {
            $value[$index] = gv_map_deep($item, $callback);
        }
    } elseif (is_object($value)) {
        $object_vars = get_object_vars($value);
        foreach ($object_vars as $property_name => $property_value) {
            $value->{$property_name} = gv_map_deep($property_value, $callback);
        }
    } else {
        $value = call_user_func($callback, $value);
    }
    return $value;
}
开发者ID:mgratch,项目名称:GravityView,代码行数:33,代码来源:helper-functions.php

示例7: update_term_meta

 /**
  * Sanitizes and saves term meta data when a term is altered.
  *
  * @since 2.7.0
  *
  * @param int $term_id     Term ID.
  * @param int $tt_id       Term Taxonomy ID.
  * @param string $taxonomy Taxonomy Slug
  * @return void Early on AJAX call.
  */
 public function update_term_meta($term_id, $tt_id, $taxonomy = '')
 {
     if (defined('DOING_AJAX') && DOING_AJAX) {
         return;
     }
     //* Check again against ambiguous injection.
     if (isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'update-tag_' . $term_id)) {
         $data = isset($_POST['autodescription-meta']) ? (array) map_deep($_POST['autodescription-meta'], 'esc_attr') : array();
         $data = wp_parse_args($data, $this->get_term_meta_defaults());
         update_term_meta($term_id, THE_SEO_FRAMEWORK_TERM_OPTIONS, $data);
     }
 }
开发者ID:sybrew,项目名称:the-seo-framework,代码行数:22,代码来源:term-data.class.php


注:本文中的map_deep函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。