Redux callback action

时间:2016-01-21 作者:Trong Lam Phan

我是新来的Redux. 我不知道如何使用开关显示和隐藏文本区域(不保存)。当my switch(我的开关)打开时,文本输入将显示,当它关闭时,输入将隐藏自己。我试着用动作钩,但没用。

这是我的代码:

Redux::setSection( $opt_name, array(
    \'title\'     => __( \'Test\', \'redux-test\' ),
    \'id\'        => \'switch_buttonset\',
    \'desc\'      => __( \'\', \'redux-test\'),
    \'icon\'      => \'el el-cog\',
    \'fields\'    => array(
        array(
            \'id\'       => \'opt-text-email\',
            \'type\'     => \'text\',
            \'title\'    => __( \'Title\', \'redux-test\' ),
        ),
        array(
            \'id\'       => \'switch-on\',
            \'type\'     => \'switch\',
            \'title\'    => __( \'Switch On\', \'redux-framework-demo\' ),
            \'default\'  => true,
        ),
    )
) );

add_action( \'redux/field/\' . $opt_name . \'/switch/callback/after\', \'compiler_action\', 10, 3 );
function compiler_action( $data ) {
    global $opt_name;
    Redux::hideField( $opt_name, \'opt-text-email\' );
}

1 个回复
SO网友:Tofandel

这是一个老问题,但如果您仍在寻找,那么您需要的是依赖项选项。

您可以这样使用它:

Redux::setSection( $opt_name, array(
    \'title\'  => __( \'Test\', \'redux-test\' ),
    \'id\'     => \'switch_buttonset\',
    \'desc\'   => __( \'\', \'redux-test\' ),
    \'icon\'   => \'el el-cog\',
    \'fields\' => array(
        array(
            \'id\'      => \'switch-on\',
            \'type\'    => \'switch\',
            \'title\'   => __( \'Switch On\', \'redux-framework-demo\' ),
            \'default\' => true,
        ),
        array(
            \'id\'         => \'opt-text-email\',
            \'type\'       => \'textarea\',
            \'title\'      => __( \'Title\', \'redux-test\' ),
            \'dependency\' => array(
                \'element\' => \'switch-on\', //Name of the field that will hide or show this one
                \'value\'   => array( \'true\', 1 ) //The value it should have for it to be displayed
            ),
        )
    )
) );

相关推荐

Sucuri SiteCheck在使用iThemes Security Pro插件的域上失败

我在我的几个网站上安装了iThemes Security Pro插件。最近,我注意到我的Sucuri SiteCheck(自动和非自动)扫描都失败了,但我不知道为什么会这样。日志也不明确,告诉我:Unable to properly scan your site. Timeout reached.下面是插件给我的原始日志。如果有人能告诉我问题出在哪里,我将不胜感激。我没有在插件或Apache级别启用防火墙,尽管我启用了ModSecurity。但是,每当我尝试SiteCheck时,ModSecurity的日