function news_date_weights($match) { $post_type = relevanssi_get_post_type($match->doc); if ($post_type == 'post') { $post_date = strtotime(get_the_time("Y-m-d", $match->doc)); $nine_months_ago = time() - 60 * 60 * 24 * 7 * 38; $eighteen_months_ago = time() - 60 * 60 * 24 * 7 * 78; // Older than a year and a half, remove weight if ($post_date < $eighteen_months_ago) { $match->weight = $match->weight * 0; } else { if ($post_date < $nine_months_ago) { $match->weight = $match->weight * 0.5; } } } return $match; }
/** * Do note that while this function takes $post_ok as a parameter, it actually doesn't care much * about the previous value, and will instead overwrite it. If you want to make sure your value * is preserved, either disable this default function, or run your function on a later priority * (this defaults to 10). */ function relevanssi_default_post_ok($post_ok, $doc) { $status = relevanssi_get_post_status($doc); // if it's not public, don't show if ('publish' != $status) { $post_ok = false; } // ...unless if ('private' == $status) { $post_ok = false; if (function_exists('awp_user_can')) { // Role-Scoper, though Role-Scoper actually uses a different function to do this // So whatever is in here doesn't actually run. $current_user = wp_get_current_user(); $post_ok = awp_user_can('read_post', $doc, $current_user->ID); } else { // Basic WordPress version $type = relevanssi_get_post_type($doc); $cap = 'read_private_' . $type . 's'; if (current_user_can($cap)) { $post_ok = true; } } } // only show drafts, pending and future posts in admin search if (in_array($status, array('draft', 'pending', 'future')) && is_admin()) { $post_ok = true; } if (relevanssi_s2member_level($doc) == 0) { $post_ok = false; } // not ok with s2member return $post_ok; }
function relevanssi_default_post_ok($doc) { $post_ok = true; $status = relevanssi_get_post_status($doc); if ('publish' != $status) { $post_ok = false; } if ('private' == $status) { $post_ok = false; if (function_exists('awp_user_can')) { // Role-Scoper $current_user = wp_get_current_user(); $post_ok = awp_user_can('read_post', $doc, $current_user->ID); } else { // Basic WordPress version $type = relevanssi_get_post_type($doc); $cap = 'read_private_' . $type . 's'; if (current_user_can($cap)) { $post_ok = true; } } } // only show drafts in admin search if (in_array($status, array('draft', 'pending', 'future')) && is_admin()) { $post_ok = true; } if (relevanssi_s2member_level($doc) == 0) { $post_ok = false; } // not ok with s2member return $post_ok; }