static function replace($value, $post) { if (is_array($value) || is_object($value)) { return $value; } global $wp_query, $wp_locale; $replace_with = ''; // We can only replace inline post tags when given a post if (is_object($post)) { $userData = get_userdata($post->post_author); $tags = ''; if (function_exists('the_tags')) { if (is_tag()) { $tags = single_tag_title(false, ''); } else { $items = get_the_tags($post->ID); if ($items) { foreach ($items as $tag) { $tags[] = $tag->name; } $tags = implode(', ', $tags); } } } if (is_day()) { $date = get_the_time('F jS, Y'); } else { if (is_month()) { $date = get_the_time('F, Y'); } else { if (is_year()) { $date = get_the_time('Y'); } else { $date = $post->post_date; } } } $replace_with = array($date, $post->post_title, $post->post_modified, $post->ID, $userData->display_name, $post->post_author, $tags, $_SERVER['REQUEST_URI']); } else { if (is_author()) { global $posts; $userData = get_userdata($posts[0]->post_author); $replace_with = array('', '', '', '', $userData->display_name, $posts[0]->post_author); } else { if (is_archive()) { $m = get_query_var('m'); $year = get_query_var('year'); $monthnum = get_query_var('monthnum'); $day = get_query_var('day'); $date = ''; // If there's a month if (!empty($m)) { $my_year = substr($m, 0, 4); $my_month = $wp_locale->get_month(substr($m, 4, 2)); $my_day = intval(substr($m, 6, 2)); $date = "{$my_year}" . ($my_month ? "{$sep} {$my_month}" : "") . ($my_day ? "{$sep} {$my_day}" : ""); } if (!empty($year)) { if (!empty($monthnum)) { $date .= " {$sep} " . $wp_locale->get_month($monthnum); } if (!empty($day)) { $date .= " {$sep} " . zeroise($day, 2); } $date .= ' ' . $year; } $replace_with = array($date, '', '', '', '', '', '', $_SERVER['REQUEST_URI']); } else { if (function_exists('is_tag') && is_tag()) { $replace_with = array('', '', '', '', '', '', single_tag_title('', false)); } } } } $search_for = array("%%date%%", "%%title%%", "%%modified%%", "%%id%%", "%%name%%", "%%userid%%", '%%tag%%', '%%url%%'); // Replace post values $value = str_replace($search_for, $replace_with, $value); // Replace static values $value = str_replace('%%searchphrase%%', isset($wp_query->query_vars['s']) ? strip_tags($wp_query->query_vars['s']) : '', $value); $value = str_replace('%%currentdate%%', date(get_option('date_format')), $value); $value = str_replace('%%currenttime%%', date(get_option('time_format')), $value); $value = str_replace('%%currentyear%%', date('Y'), $value); global $headspace2; $headspace2->ugly_hack = true; $value = str_replace('%%sitename%%', get_bloginfo('blogname'), $value); $headspace2->ugly_hack = false; if (is_object($wp_locale)) { $value = str_replace('%%currentmonth%%', $wp_locale->get_month(date('n')), $value); } else { $value = str_replace('%%currentmonth%%', date('F'), $value); } // These need extra work so we only do it if necessary if (strpos($value, '%%excerpt%%') !== false) { $value = str_replace('%%excerpt%%', HS_InlineTags::get_excerpt($post, true), $value); } if (strpos($value, '%%excerpt_only%%') !== false) { $value = str_replace('%%excerpt_only%%', HS_InlineTags::get_excerpt($post, false), $value); } if (strpos($value, '%%category%%') !== false) { $value = str_replace('%%category%%', HS_InlineTags::get_category($post), $value); } if (strpos($value, '%%category_description%%') !== false) { $value = str_replace('%%category_description%%', HS_InlineTags::get_category_description($post), $value); } if (strpos($value, '%%tag_description%%') !== false) { $value = str_replace('%%tag_description%%', HS_InlineTags::get_tag_description($post), $value); } if (strpos($value, '%%term_description%%') !== false) { $value = str_replace('%%term_description%%', HS_InlineTags::get_term_description(), $value); } if (strpos($value, '%%term_title%%') !== false) { $value = str_replace('%%term_title%%', HS_InlineTags::get_term_title(), $value); } if (strpos($value, '%%page%%') !== false) { $value = str_replace('%%page%%', HS_InlineTags::get_page($post), $value); } if (strpos($value, '%%pagenumber%%') !== false) { $value = str_replace('%%pagenumber%%', HS_InlineTags::get_page($post, 'number'), $value); } if (strpos($value, '%%pagetotal%%') !== false) { $value = str_replace('%%pagetotal%%', HS_InlineTags::get_page($post, 'total'), $value); } if (strpos($value, '%%caption%%') !== false) { $value = str_replace('%%caption%%', $post->post_excerpt, $value); } return $value; }