Sure. The complete snippet is really long, so I’ll just include a bit of it and describe the scenario that triggers the error. The snippet creates meta boxes (using CMB2) which is something I’ve been doing with Code Snippets for a long time, and here is a bit of it, creating a dropdown of options to set some post meta data …
add_action( 'cmb2_admin_init', 'register_metabox' );
function register_metabox() {
$meta_boxes_1->add_field( array(
'name' => esc_html__( 'Languages', 'admin-cmb' ),
'desc' => esc_html__( '(tick all that apply)', 'admin-cmb' ),
'id' => 'agent_languages',
'type' => 'multicheck',
'options' => array(
'cn' => esc_html__('Chinese','admin-cmb'),
'de' => esc_html__('German','admin-cmb'),
'en' => esc_html__('English','admin-cmb'),
'es' => esc_html__('Spanish','admin-cmb'),
),
) );
}
To add another option (ie. in this case another language choice), I copy one that exists, hit the return key to create an empty line, paste it in, change it as necessary, and click save. This is what started throwing 501 errors on me today, as soon as I tried to save. If I copy the whole snippet, paste it into a stand-alone code editor, edit it, then copy and paste the whole snippet back into Code Snippets, 501 again. If instead I paste it straight to the Snippets field in the database, it accepts it and everything’s normal.
At one stage I had the order of two of the options wrong, and wanted to swap them around. It wouldn’t save it, whether I copied just the bit of code and made a new line to paste it into, or copy/pasted the whole line.
I kept an eye on the browser console, but nothing was evident.
-
This reply was modified 3 years, 7 months ago by
aljuk.