コード例 #1
0
function tool_acf_get_fields($p = array())
{
    /** ABOUT
    
    					USE {
    
    						$result = tool_acf_get_fields( array(
    							'keys' => false, // simple array( 'one', 'two' )
    							'post_id' => tool_may_get_the_id(),
    							'print_keys' => false,
    							'print' => false,
    							'permalink' => true,
    						) );
    
    					}
    
    				**/
    $p += array('keys' => false, 'post_id' => tool_get_an_id(), 'print_keys' => false, 'print' => false, 'permalink' => true);
    $ret = false;
    if ($p['keys'] === false) {
        $p['keys'] = tool_acf_get_post_custom_keys($p);
    }
    if ($p['keys']) {
        foreach ($p['keys'] as $key => $value) {
            if ($p['post_id']) {
                $ret[$value] = get_field($value, $p['post_id']);
            }
            if (!$p['post_id']) {
                $ret[$value] = get_field($value);
            }
        }
        if ($p['permalink'] === true) {
            $ret['permalink'] = get_permalink($p['post_id']);
        }
        if ($p['print_keys']) {
            $temp = false;
            $keys = tool_acf_get_post_custom_keys($p);
            foreach ($keys as $key => $value) {
                $temp .= $value . "\n";
            }
            print_o(trim($temp));
        }
        if ($p['print']) {
            print_o($ret);
        }
    }
    return $ret;
}
コード例 #2
0
function tool_has_menu_ancestors($p = array())
{
    /** ABOUT
    
    				USE {
    
    					$result = tool_has_menu_ancestors( array(
    						'menu_id' => false,
    						'post_id' => tool_get_an_id()
    					) );
    
    				}
    				REQUIRE {
    					tool_get_menu_ancestors()
    				}
    				RETURN {
    					the number of anchestors from 0 on
    				}
    			**/
    $p += array('menu_id' => false, 'post_id' => tool_get_an_id());
    $return = tool_get_menu_ancestors(array('menu_id' => $p['menu_id'], 'post_id' => $p['post_id']));
    $count = count($return);
    if ($count) {
        $return = $count - 1;
    }
    return $return;
}