page_title = __( 'File Editor', 'insert-headers-and-footers' ); parent::__construct(); } /** * Add codemirror settings specific to the needs for this page. * * @return void */ public function page_hooks() { // Add the codemirror settings. add_filter( 'wpcode_editor_config', array( $this, 'editor_config' ) ); } /** * Output the page content. * * @return void */ public function output_content() { $this->can_edit = true; echo '
'; $this->file_editor_area(); echo '
'; echo $this->get_pixel_overlay(); } /** * File editor area. * * @return void */ public function file_editor_area() { $value = $this->get_value(); ?>

get_checkbox_toggle( $value['enabled'], 'wpcode_file_' . $this->view . '[enabled]' ) ?>

views[ $this->view ] ) ); ?>

', '' ); ?>

view, 'wpcode-edit-' . $this->view . '-nonce' ); // If we need to add page-specific content we can do this here. if ( method_exists( $this, 'output_view_' . $this->view ) ) { call_user_func( array( $this, 'output_view_' . $this->view ) ); } ?> register_editor( 'wpcode_file_' . $this->view ); $editor->init_editor(); } /** * Disable all the codemirror settings for this page as we need a basic editor. * * @param array $config The WPCode editor config. * * @return array */ public function editor_config( $config ) { if ( 'serviceworkerjs' === $this->view ) { $config['type'] = 'text/javascript'; } else { $config['type'] = 'shell'; $config['codemirror'] = array(); $config['showHint'] = 'false'; } return $config; } /** * Output content specific to the robots.txt file. * * @return void */ public function output_view_robotstxt() { ?>

views = array( 'adstxt' => 'ads.txt', 'appadstxt' => 'app-ads.txt', 'serviceworkerjs' => 'service-worker.js', 'robotstxt' => 'robots.txt', ); } /** * Nothing to return by default. * * @return array */ public function get_value() { return array( 'enabled' => true, 'content' => '', ); } /** * Get the overlay for the file editor page. * * @return string */ public function get_pixel_overlay() { $text = '

' . esc_html__( 'Simplify your website management with the WPCode File Editor! Say goodbye to the hassle of manually editing files on your server.', 'insert-headers-and-footers' ) . '

'; $text .= sprintf( // translators: %1$s and %2$s are tags. '

' . esc_html__( 'With this powerful tool, you can easily customize crucial files like %1$sads.txt%2$s, %1$sapp-ads.txt%2$s, %1$srobots.txt%2$s, and %1$sservice-worker.js%2$s right from your WordPress admin.', 'insert-headers-and-footers' ) . '

', '', '' ); return self::get_upsell_box( __( 'File Editor is a PRO Feature', 'insert-headers-and-footers' ), $text, array( 'text' => esc_html__( 'Upgrade to WPCode PRO', 'insert-headers-and-footers' ), 'url' => esc_url( wpcode_utm_url( 'https://wpcode.com/lite/', 'file-editor', 'tab-' . $this->view, 'upgrade-to-pro' ) ), ), array( 'text' => esc_html__( 'Learn More about the File Editor', 'insert-headers-and-footers' ), 'url' => esc_url( wpcode_utm_url( 'https://wpcode.com/docs/file-editor/', 'file-editor', 'tab-' . $this->view, 'learn-more' ) ), ), array( esc_html__( 'No manual coding, no FTP', 'insert-headers-and-footers' ), esc_html__( 'Effortless integrations setup', 'insert-headers-and-footers' ), esc_html__( 'Reduce the number of plugins', 'insert-headers-and-footers' ), esc_html__( 'Prevent advertising fraud', 'insert-headers-and-footers' ), ) ); } }