diff --git a/README.md b/README.md deleted file mode 100644 index 6f8e6c8..0000000 --- a/README.md +++ /dev/null @@ -1 +0,0 @@ -# uc-js diff --git a/uc-js.js b/uc-js.js new file mode 100644 index 0000000..9b4eeae --- /dev/null +++ b/uc-js.js @@ -0,0 +1,9 @@ +jQuery(document).ready(function($){ + $('#revertucjs').click(function(){ + $('.ucjs-content').val($('.ucjs-content-back').val()); + $('input[name=submit]').attr('disabled', false); + }); + $('.ucjs-content').keyup(function(){ + $('input[name=submit]').attr('disabled', false); + }); +}); \ No newline at end of file diff --git a/uc-js.php b/uc-js.php new file mode 100644 index 0000000..b92b799 --- /dev/null +++ b/uc-js.php @@ -0,0 +1,154 @@ + character. + * + * @since 1.1 + */ +function ucjs_trigger_check() { + if ( intval( get_query_var( 'ucjs' ) ) == 1 ) { + ob_start(); + header( 'Content-type: text/javascript' ); + $options = get_option( 'ucjs_settings' ); + $raw_content = isset( $options['ucjs-content'] ) ? $options['ucjs-content'] : ''; + $content = str_replace( '>', '>', $raw_content ); + echo $content; //xss okay + exit; + ob_clean(); + } +} +add_action( 'template_redirect', 'ucjs_trigger_check' ); + + +/** + * Register "Custom JS" submenu in "Appearance" Admin Menu + * + * @since 1.0 + */ +function ucjs_register_submenu_page() { + add_theme_page( __( 'JavaScript', 'ucjs' ), __( 'JavaScript', 'ucjs' ), 'manage_network', basename( __FILE__ ), 'ucjs_render_submenu_page' ); +} +add_action( 'admin_menu', 'ucjs_register_submenu_page' ); + + +/** + * Register settings + * + * @since 1.0 + */ +function ucjs_register_settings() { + register_setting( 'ucjs_settings_group', 'ucjs_settings' ); +} +add_action( 'admin_init', 'ucjs_register_settings' ); + +/** + * Render Admin Menu page + * + * @since 1.0 + */ +function ucjs_render_submenu_page() { + + $options = get_option( 'ucjs_settings' ); + $content = isset( $options['ucjs-content'] ) && ! empty( $options['ucjs-content'] ) ? $options['ucjs-content'] : '/* Enter Your Custom JS Here */'; + $content_back = isset( $options['ucjs-content-back'] ) && ! empty( $options['ucjs-content-back'] ) ? $options['ucjs-content-back'] : $options['ucjs-content']; + + if ( isset( $_GET['settings-updated'] ) ) : ?> +

+ +
+

+
+ +
+ +
+ + + +
+ +
+
+ Revert to previous version +
+ true) ); ?> +
+ +
+
+
+