• Hello,

    I managed to have a working Admin Page with a checkbox (result is correcty stored in database) but I can’t figure how to execute some piece of code only if is checked… Found nothing related to checkbox in tutorials.

    Tried this with no succes:

     if (AdminPageFramework::getOption( 'MyPluginName', 'my_checkbox_2', '1' )) {
        remove_action( 'wp_head', 'feed_links', 2 );
        remove_action( 'wp_head', 'feed_links_extra', 3 );
      } else {}

    In fact, the code is always executed. Not only when the option is checked…

    Somebody has an idea?

    Here is a gist with my full plugin code
    https://gist.github.com/bugsysop/5b81d62ae49415df4e9c3cc657964118

    • This topic was modified 1 year, 6 months ago by Aris.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author miunosoft

    (@miunosoft)

    Hi,

    Try

    
    $value = AdminPageFramework::getOption( 'MyPluginName', array( 'my_second_section', 'my_checkbox_3' ) );
    

    To retrieve a value in a nested array of a multidimensional array, you want to pass an array representing the dimensional key path to the second parameter.

    For example, to get the value THIS in the below array,

    
    array(
        'a' => array( 
            'b' => array(
                'c' => 'THIS'
            ) 
        )
    )
    

    You need to pass array( 'a', 'b', 'c' ).

    You can use AdminPageFramework_Debug::log() to check the structure of your options array. The log file will be created in the wp-content directory. You need to enable WP_Debug to use it.

    
    AdminPageFramework_Debug::log( AdminPageFramework::getOption( 'MyPluginName' ) );
    
    Thread Starter Aris

    (@bugsysop)

    Thanks a lot, I will try this.
    Have a nice day

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Checkbox Problem’ is closed to new replies.