Description
Determine the component name given the post IDBy following noderefs, recursively if necessary, we should be able to reach the component name, from which we may determine the version. The pre_mapping_keys array shows which field to access to determine the next ID to process.
Usage
oik_query_component_by_ID( $ID );Parameters
- $ID
- ( mixed ) required –
Returns
voidTO DO
The pre_mapping_types array should actually be a simple associative array. It tells us whether or not we can find a route to the component. We could also use the field APIs to see if the virtual field is associated with the post type.Source
File name: oik-shortcodes/shortcodes/oik-component-version.phpLines:
1 to 44 of 44
function oik_query_component_by_ID( $ID ) { $post_type = get_post_type( $ID ); $pre_mapping_types = array( "oik_pluginversion" => "oik-plugins" , "oik_premiumversion" => "oik-plugins" , "oik_themeversion" => "oik-themes" , "oik_themiumversion" => "oik-themes" , "oik_shortcodes" => "oik_shortcodes" , "shortcode_example" => "oik_shortcodes" , "oik_api" => "oik_api" , "oik_class" => "oik_class" , "oik_file" => "oik_file" ); $pre_map_type = bw_array_get( $pre_mapping_types, $post_type, null ); $mapping = array( "oik-plugins" => "_oikp_name" , "oik-themes" => "_oikth_slug" ); $meta_key = bw_array_get( $mapping, $post_type, null ); if ( $meta_key ) { oik_component_version_type( $post_type ); $meta_value = get_post_meta( $ID, $meta_key, true ); } else { $pre_mapping_keys = array( "oik_pluginversion" => "_oikpv_plugin" , "oik_premiumversion" => "_oikpv_plugin" , "oik_themeversion" => "_oiktv_theme" , "oik_themiumversion" => "_oiktv_theme" , "oik_shortcodes" => "_oik_sc_plugin" , "shortcode_example" => "_sc_param_code" , "oik_api" => "_oik_api_plugin" , "oik_class" => "_oik_api_plugin" , "oik_file" => "_oik_api_plugin" ); $pre_map_type = bw_array_get( $pre_mapping_types, $post_type, null ); $meta_value = null; if ( $pre_map_type ) { $pre_map_key = bw_array_get( $pre_mapping_keys, $post_type, null ); $component_ID = get_post_meta( $ID, $pre_map_key, true ); if ( $component_ID ) { $meta_value = oik_query_component_by_ID( $component_ID); } } } return( $meta_value ); }View on GitHub
Invoked by
Calls
1 to 3 of 3
