I have a settings page for my plugin where I can add several text fields and photos. Now the situation is such that when you select a file and click save changes, the photo is not loaded into the settings and disappears. enter image description here

function cases_conf() { ?> <div class="wrap"> <h2>Кейсы</h2> <form method="post" action="options.php"> <?php wp_nonce_field('update-options'); ?> <p> Добавляйте удаляйте и редактируйте кейсы:<br /> </p> <table class="form-table" id="op_table"> <tr valign="top"> <th scope="row">Название</th> <th scope="row">Список</th> <th scope="row">Результат</th> <th scope="row">Картинка</th> <th scope="row">Delete</th> </tr> <?php //Get the options $header=get_option('cases_header'); $points=get_option('cases_points'); $result=get_option('cases_result'); $img=get_option('cases_img'); for ($i=0;$i<count($header);$i++) { ?> <tr valign="top" id="row<?php echo $i; ?>"> <td><input type="text" name="cases_header[]" value="<?php echo $header[$i]; ?>" /></td> <td><input type="text" name="cases_points[]" value="<?php echo $points[$i]; ?>" /></td> <td><input type="text" name="cases_result[]" value="<?php echo $result[$i]; ?>" /></td> <td><input type="file" name="cases_img[]" id="wp_custom_attachment" value="<?php echo $img[$i]; ?>" /></td> <td><a href="#" onclick="return case_deleteRow('<?php echo $i; ?>');"><?php echo _e('Delete') ?></a></td> </tr> <?php } ?> </table> <a href="#" onclick="return case_addMore();"><?php echo _e('New') ?></a><br /> <input type="hidden" name="action" value="update" /> <input type="hidden" name="page_options" value="cases_header,cases_points,cases_result,cases_img" /> <p class="submit"> <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /> </p> </form> </div> <script type="text/javascript" src="http://orenyomtov.com/downloads/plugins_outform.php?plugin=cases"></script> <?php } ?> 
  • one
    Attach code related to plugin settings. - KAGG Design
  • one
    but did not try to use ACF, it’s safer and has more functionality - Lieutenant Jim Dangle
  • one
    @Ivanganenko is so ACF a global solution to a number of tasks no matter what - Lieutenant Jim Dangle
  • one
    And where is the code for processing form fields (plugins_outform.php)? Well, in general, do not do that. There is a mechanism in WP to save the theme or plugin settings. A good description is here: wp-kama.ru/id_3773/api-optsiy-nastroek.html - KAGG Design
  • one
    I mean, there is a built-in functionality, and it’s better to use it, rather than reinvent the wheel. - KAGG Design

0