Raja Petra had posted three articles on his popular blog Malaysia Today implying that Shafee was behind the sodomy allegations against Anwar Ibrahim, an adviser to the opposition Keadilan (justice) party and a former deputy prime minister.
Shafee said the court also ordered Raja Petra, who writes for his No Holds Barred column, to remove the contentious postings and to refrain from publishing similar allegations.
Raja Petra is already facing charges of sedition and criminal defamation over an article and a sworn statement he made alleging links between the country's deputy prime minister and a murdered Mongolian woman.
But Raja Petra said on Thursday he will not reveal his sources and denied knowing the identity of people who post comments on his blog.
"Of course, I won't. I never reveal my sources," he said.
Raja Petra said he had expected "some sort of backlash" from his articles which is expected "in my line of business".
"I'm always prepared and never surprised," he said.
Anwar, the country's de facto opposition leader, was charged last week with sodomising a male aide, allegations he has denied, claiming a government conspiracy to derail his political comeback.
He is also preparing to contest a by-election later this month in his former constituency of Permatang Pauh.
Anwar is expected to easily win the by-election despite the sodomy charge.