小编Fea*_*ode的帖子

确定函数是否有输出的最佳方法?

我有一个函数列表,它们运行一个相当深的例程来确定从哪个post_id获取其内容并将其输出到站点的前端.

当这个函数返回它的内容时,我希望它包装在一个html包装器中.我希望这个html包装器只在函数有返回的输出时才加载.

在示例中,我有以下...

public static function output_*() {
  //  my routines that check for content to output precede here
  //  if there IS content to output the output will end in echo $output;
  //  if there is NO content to output the output will end in return;
}
Run Code Online (Sandbox Code Playgroud)

完整的解释,我有以下......

如果其中一个函数返回一个输出,我希望它包装在一个html包装器中,所以理论上这样的东西就是我想要完成的...

public static function begin_header_wrapper() {
  // This only returns true if an output function below returns content, 
  // which for me is other than an empty return;
  include(self::$begin_header_wrapper); …
Run Code Online (Sandbox Code Playgroud)

php wordpress wordpress-theming output

7
推荐指数
1
解决办法
320
查看次数

我可以在诸如admin.php之类的查询页面上执行$ pagenow吗?page = example?

我正在与...

global $pagenow;
    if(in_array($pagenow, array('example1.php','example2.php'))) {}
Run Code Online (Sandbox Code Playgroud)

在Wordpress中,此方法适用于仅在所需的管理页面上排队管理脚本。

有没有办法将相同的概念应用于查询页面?

例:

global $pagenow;
        if(in_array($pagenow, array('example1.php?page=example1','example2.php?page=example1'))) {}
Run Code Online (Sandbox Code Playgroud)

有一些插件我正在尝试使设置更有效地进行加载,但是有些插件对其页面使用页面查询,因此上述代码不起作用。

我没有在网上找到任何东西。

php wordpress

3
推荐指数
1
解决办法
2959
查看次数

标签 统计

php ×2

wordpress ×2

output ×1

wordpress-theming ×1