Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kharissulistiyo/1da55791646b7287fb72e6ee9ba1ebd0 to your computer and use it in GitHub Desktop.
Save kharissulistiyo/1da55791646b7287fb72e6ee9ba1ebd0 to your computer and use it in GitHub Desktop.
Patch code sample: Cross Site Request Forgery (CSRF) vulnerability
<?php
public static function render_settings_page() {
if ( isset( $_POST['save_settings'] ) ) {
self::save_settings( $_POST );
}
if ( ! isset( $_POST['cew_settings_nonce'] ) || ! wp_verify_nonce( $_POST['cew_settings_nonce'], CEW_BASENAME . '-settings' ) ) {
return;
}
wp_enqueue_style( 'cew-settings', CEW_URL . 'assets/css/settings.css', array(), CEW_VERSION );
wp_enqueue_script( 'cew-settings', CEW_URL . 'assets/js/scripts.js', array( 'jquery', 'jquery-ui' ), CEW_VERSION, true );
wp_localize_script(
'cew-settings',
'cew',
array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
)
);
include_once CEW_PATH . '/templates/settings.php';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment