好的,我有这个代码,我一直用来向我的应用程序吐出新闻.它一直工作到今天.我已经删除了以下代码中的所有逻辑,使其变得简单.但它应该"工作"有人可以帮助我修复这个代码到它工作的地方,并做得对吗?我知道它被黑了,但直到今天它似乎没有任何问题.我没有更新任何东西,不知道这笔交易是什么.
Plugin Name: MyPlugin Example
Version: 1.0.1
If ( ! class_exists("MyPlugin") )
{
class MyPlugin
{
var $db_version = "1.0"; //not used yet
function init()
{
//Nothing as of now.
}
function activate()
{
global $wp_rewrite;
$this->flush_rewrite_rules();
}
function pushoutput( $id )
{
$output->out =' The output worked!';
$this->output( $output );
}
function output( $output )
{
ob_start();
ob_end_clean();
header( 'Cache-Control: no-cache, must-revalidate' );
header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' );
header( 'Content-type: application/json' ); …Run Code Online (Sandbox Code Playgroud) 我对WordPress的永久链接如何工作有点困惑,特别是超出了Wordpress自己的用法.我的永久链接就像:
%post_id%-%post_name%
Run Code Online (Sandbox Code Playgroud)
但是single.php我希望将另一个链接放到页面本身但是使用不同的查询字符串.单击它时,永久链接结构可能如下所示:
%mystring%-%post_id%-%post_name%
Run Code Online (Sandbox Code Playgroud)
我想从中得到价值$_GET['action'],所以:
$_GET['action'] = %mystring%
Run Code Online (Sandbox Code Playgroud)
我的计划是将它解释为:
if('xx' == $_GET['action']){
//do xx stuff
} else if ('yy'==$_GET['action']){
//do yy stuff
} else {
//show the single post as a single.php always shows
}
Run Code Online (Sandbox Code Playgroud)
这意味着,我想解析$_GET['action']可选的.如果我不解析它,即使它在查询字符串中可用,我希望页面正确呈现.
为了完成这项工作,我应该在哪里工作?另外我如何形成<a>标签的链接?通常我们这样做链接:
<a href="'.the_permalink().'">TEXT</a>
Run Code Online (Sandbox Code Playgroud)
但你已经知道了,我需要在帖子的原始永久链接之前添加一些文字.
提前致谢.