在@toscho的提示下,我目前正在扩展分页插件。因此,该插件现在将使用与本机wordpress分页函数相同的过滤器、挂钩和参数。
我的问题是,不同的wp函数命名它们的参数。。。不同的
示例:
这是如何更改“下一个”链接的文本- wp_link_page()=- \'nextpagelink\'
- paginate_links()=- \'next_text\'
在类中检索输入后,I
wp_parse_args( $args, $this->defaults ); 我的论点,然后
extract 他们
问题:
当我现在同时允许
\'nextpagelink\' &;
\'next_text\' 作为有效的论据,我将如何处理它们?我应该先检查哪个?我是否需要设置一些优先级,以便其中一个优先于另一个(如果两者都设置了)?
示例:
此示例显示了我的困境:
哪个优先级较高?我如何避免做出决定这是一段很长的代码,只用于决定如何处理2个变量代码:
if ( $nextpagelink && $next_text ) 
{
    // CASE 1: both are set
    // which one should I take now?
}
elseif ( $nextpagelink )
{
    // CASE 2: only one is set - should this one override the next one?
    // set something
}
elseif ( $next_text )
{
    // CASE 3: only one is set - should this be overridden by the previous one?
    // set
}
else
{
    // CASE 4: none is set - apply default
    // set default
}