You appear to be a bot. Output may be restricted
Description
Set the required values for the $args to register_post_type()- bw_register_post_type() requires "singular_label" in order to create "singular_name"
- Sometimes we need to cast stdObject to an array
- "on" is used as the checkbox representation of true.
- we only set args to false if the field is in the original array
Usage
$array = oikcpt_adjust_args( $data_args, $cast, $original_args );
Parameters
- $data_args
- ( array ) required –
- $cast
- ( bool ) optional default: 1 – true when we need to cast objects to arrays
- $original_args
- ( array ) optional –
Returns
array $argsTO DO
Determine when 'sometimes' is!Source
File name: oik-types/oik-types.phpLines:
1 to 29 of 29
function oikcpt_adjust_args( $data_args, $cast=true, $original_args=array() ) { $args = array(); foreach ( $data_args as $key => $data ) { if ( $cast && is_object( $data )) { $data = (array) $data; } if ( $data == "on" ) { $data = true; } if ( $key == "singular_name" ) { $key = "singular_label"; } if ( $key == "labels" && isset( $original_args[ $key ] ) ) { $labels = ( array ) $data; $data = array_merge( $labels, $original_args[ $key] ); } //bw_trace2( $data, "data", false ); if ( $data ) { $args[$key] = $data; } else { if ( isset( $original_args[$key] ) && is_bool( $original_args[$key ] ) ) { $args[$key] = false; } } } bw_trace2( $args, "args", true, BW_TRACE_VERBOSE ); return( $args ); }View on GitHub