page_title = __( 'Generator', 'insert-headers-and-footers' ); $this->header_title = $this->page_title; parent::__construct(); } /** * Page-specific hooks & logic. * * @return void */ public function page_hooks() { $this->generators = wpcode()->generator()->get_all_generators(); // phpcs:disable WordPress.Security.NonceVerification.Recommended // Let's see if we should display a generator. if ( isset( $_GET['generator'] ) ) { $generator = sanitize_text_field( wp_unslash( $_GET['generator'] ) ); if ( array_key_exists( $generator, $this->generators ) ) { $this->generator = $generator; } } $snippet_id = isset( $_GET['snippet'] ) ? absint( $_GET['snippet'] ) : false; if ( $snippet_id ) { $this->snippet = new WPCode_Snippet( $snippet_id ); if ( $this->snippet->get_post_data() ) { WPCode_Notice::add( sprintf( // Translators: gets replaced with the snippet title. __( 'You are now editing the generated snippet: "%s". Updating the snippet will override any edits you made to the code.', 'insert-headers-and-footers' ), $this->snippet->get_title() ), 'warning' ); } else { unset( $this->snippet ); } } // phpcs:enable WordPress.Security.NonceVerification.Recommended if ( $this->generator ) { // Translators: gets replaced with the generator name. $this->header_title = sprintf( __( '%s Generator', 'insert-headers-and-footers' ), $this->generators[ $this->generator ]->get_title() ); } } /** * Output the content of the page. * * @return void */ public function output_content() { if ( $this->generator ) { $this->show_generator(); } else { $this->show_generators_list(); } } /** * Show the list of generators with categories. * * @return void */ public function show_generators_list() { $categories = wpcode()->generator()->get_categories(); ?>
generators[ $this->generator ]; $tabs = $generator->get_tabs(); $snippet_data = array(); if ( isset( $this->snippet ) ) { $snippet_data = $this->snippet->get_generator_data(); } ?>