function get_option($option_name) { global $avia; $option = false; if (isset($avia->options['templates']) && isset($avia->options['templates'][$this->template_name . $option_name])) { $option = avia_deep_decode($avia->options['templates'][$this->template_name . $option_name]); } return $option; }
/** * This function retrieves the custom field values for a given post and saves it to the global avia config array * If a subkey was set the subkey is returned, otherwise the array is saved to the global config array * The function also hooks into the post loop and is automatically called for each post */ function avia_post_meta($post_id = '', $subkey = false) { $avia_post_id = $post_id; //if the user only passed a string and no id the string will be used as subkey if (!$subkey && $avia_post_id != "" && !is_numeric($avia_post_id) && !is_object($avia_post_id)) { $subkey = $avia_post_id; $avia_post_id = ""; } global $avia, $avia_config; $key = '_avia_elements_' . $avia->option_prefix; if (current_theme_supports('avia_post_meta_compat')) { $key = '_avia_elements_theme_compatibility_mode'; //actiavates a compatibility mode for easier theme switching and keeping post options } $values = ""; //if post id is on object the function was called via hook. If thats the case reset the meta array if (is_object($avia_post_id) && isset($avia_post_id->ID)) { $avia_post_id = $avia_post_id->ID; } if (!$avia_post_id) { $avia_post_id = @get_the_ID(); } if (!is_numeric($avia_post_id)) { return; } $avia_config['meta'] = avia_deep_decode(get_post_meta($avia_post_id, $key, true)); $avia_config['meta'] = apply_filters('avia_post_meta_filter', $avia_config['meta'], $avia_post_id); if ($subkey && isset($avia_config['meta'][$subkey])) { $meta = $avia_config['meta'][$subkey]; } else { if ($subkey) { $meta = false; } else { $meta = $avia_config['meta']; } } return $meta; }
/** * This function performs deep decoding on an array of elements */ function avia_deep_decode($elements) { if (is_array($elements) || is_object($elements)) { foreach ($elements as $key => $element) { $elements[$key] = avia_deep_decode($element); } } else { $elements = html_entity_decode($elements, ENT_QUOTES, get_bloginfo('charset')); } return $elements; }