function bfox_ref_link($ref_str, $options = array()) { if (empty($ref_str)) { return false; } $defaults = array('href' => '', 'class' => array(), 'text' => $ref_str); $refController = BfoxRefController::sharedInstance(); $defaults = wp_parse_args($refController->currentDefaults(), $defaults); extract(wp_parse_args($options, $defaults)); // href if (empty($href)) { $href = bfox_ref_url($ref_str); } $attrs['href'] = $href; // class $class = (array) $class; $class[] = $attrs['class']; $attrs['class'] = implode(' ', $class); if (!isset($attrs['data-ref'])) { $attrs['data-ref'] = $ref_str; } // Attribute string $attr_str = ''; foreach ($attrs as $attr => $value) { $attr_str .= " {$attr}='{$value}'"; } return "<a{$attr_str}>{$text}</a>"; }
function bfox_tool_source_url($post_id = 0, BfoxRef $ref = null) { if (empty($post_id)) { $post_id = $GLOBALS['post']->ID; } $template = bfox_tool_meta('url', $post_id); if (empty($template)) { if (is_null($ref)) { $ref = bfox_ref(); } return add_query_arg('src', true, bfox_ref_url($ref->get_string(), $post_id)); } $linker = bfox_tool_source_linker($ref); return $linker->urlForTemplate($template); }