static function PostsSearch($sql) { global $wp_query, $wpdb; if (empty($sql)) { return $sql; } wpfb_loadclass('File'); $is_wp_search = !empty($_GET['s']) && empty($_GET['wpfb_s']); $search_id3 = WPFB_Core::$settings->search_id3; $no_matches = false; $where = self::SearchWhereSql($search_id3); $where = "({$where} AND (" . WPFB_File::GetReadPermsWhere() . "))"; // check if there are matching files, if there are, include the filebrowser page/post in the resulst! // if we have file pages, only include the file browser if file search widget was used! $file_browser_id = intval(WPFB_Core::$settings->file_browser_post_id); if ($file_browser_id > 0 && WPFB_File::GetNumFiles2($where, true) > 0) { $where = "({$where} OR ({$wpdb->posts}.ID = {$file_browser_id}))"; // TODO! wpfb_loadclass('Output'); WPFB_Core::$file_browser_search = true; } // OR' the $where to existing search conditions $p = strpos($sql, "("); $sql = substr($sql, 0, $p) . "( " . substr($sql, $p); $p = strrpos($sql, ")))"); $sql = substr($sql, 0, $p + 3) . " OR {$where})" . substr($sql, $p + 3); //echo "<br>".$sql; return $sql; }