public function init() {

		if ( ! Book::isBook() ) {
			// Not a book, disable
			return;
		}
		if ( class_exists( '\Pressbooks\CustomCss' ) && CustomCss::isCustomCss() ) {
			// Uses old Custom CSS Editor, disable
			return;
		}

		// Code Mirror
		if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] === $this::PAGE ) {
			add_action(
				'admin_enqueue_scripts', function () {
					wp_enqueue_script( 'wp-codemirror' );
					wp_enqueue_script( 'csslint' );
					wp_enqueue_style( 'wp-codemirror' );
				}
			);
		}

		add_action(
			'init', function () {
				// Admin Menu
				add_action(
					'admin_menu', function () {
						add_theme_page( __( 'Custom Styles', 'pressbooks' ), __( 'Custom Styles', 'pressbooks' ), 'edit_others_posts', $this::PAGE, [ $this, 'editor' ] );
					}, 11
				);
				// Register Post Types
				$this->registerPosts();
			}
		);

		// Catch form submission
		add_action( 'init', [ $this, 'formSubmit' ], 50 );
	}
public function init() {

		if ( ! Book::isBook() ) {
			// Not a book, disable
			return;
		}
		if ( class_exists( '\Pressbooks\CustomCss' ) && CustomCss::isCustomCss() ) {
			// Uses old Custom CSS Editor, disable
			return;
		}

		// Code Mirror
		if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] === $this::PAGE ) {
			add_action(
				'admin_enqueue_scripts', function () {
					wp_enqueue_script( 'wp-codemirror' );
					wp_enqueue_script( 'csslint' );
					wp_enqueue_style( 'wp-codemirror' );
				}
			);
		}

		add_action(
			'init', function () {
				// Admin Menu
				add_action(
					'admin_menu', function () {
						add_theme_page( __( 'Custom Styles', 'pressbooks' ), __( 'Custom Styles', 'pressbooks' ), 'edit_others_posts', $this::PAGE, [ $this, 'editor' ] );
					}, 11
				);
				// Register Post Types
				$this->registerPosts();
			}
		);

		// Catch form submission
		add_action( 'init', [ $this, 'formSubmit' ], 50 );
	}
public function init ( ) { if ( ! Book :: isBook ( ) ) { // Not a book, disable return ; } if ( class_exists ( '\Pressbooks\CustomCss' ) && CustomCss :: isCustomCss ( ) ) { // Uses old Custom CSS Editor, disable return ; } // Code Mirror if ( isset ( $ _REQUEST [ 'page' ] ) && $ _REQUEST [ 'page' ] === $ this :: PAGE ) { add_action ( 'admin_enqueue_scripts' , function ( ) { wp_enqueue_script ( 'wp-codemirror' ) ; wp_enqueue_script ( 'csslint' ) ; wp_enqueue_style ( 'wp-codemirror' ) ; } ) ; } add_action ( 'init' , function ( ) { // Admin Menu add_action ( 'admin_menu' , function ( ) { add_theme_page ( __ ( 'Custom Styles' , 'pressbooks' ) , __ ( 'Custom Styles' , 'pressbooks' ) , 'edit_others_posts' , $ this :: PAGE , [ $ this , 'editor' ] ) ; } , 11 ) ; // Register Post Types $ this -> registerPosts ( ) ; } ) ; // Catch form submission add_action ( 'init' , [ $ this , 'formSubmit' ] , 50 ) ; }
Set filters & hooks
Set filters & hooks