Skip to content

Instantly share code, notes, and snippets.

@shawnhooper
Created September 3, 2020 23:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shawnhooper/2e800d719916c47c7976deedf4d91c48 to your computer and use it in GitHub Desktop.
Save shawnhooper/2e800d719916c47c7976deedf4d91c48 to your computer and use it in GitHub Desktop.
WordPress - Disable saving in the customizer
<?php
/** Add this to the bottom of your functions.php file in your theme **/
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
remove_action('wp_ajax_customize_save', array($GLOBALS['wp_customize'], 'save'));
add_action('wp_ajax_customize_save', 'return_403_on_customizer_save');
function return_403_on_customizer_save() {
wp_send_json(array('message' => 'Theme Editor in Read Only Mode'), 403);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment