• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Yoast SEO a2z

Yoast SEO a2z

WordPress SEO a2z

  • Home
  • Plugins
  • Blocks
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / Files / admin/views/tool-file-editor.php


Lines:

1 to 100 of 246
<?php

/**
 * WPSEO plugin file.
 *
 * @package WPSEO\Admin
 */

if ( ! defined( 'WPSEO_VERSION' ) ) {
  header( 'Status: 403 Forbidden' );
  header( 'HTTP/1.1 403 Forbidden' );
  exit();
}

$yform     = Yoast_Form::get_instance();
$home_path = get_home_path();

if ( ! is_writable( $home_path ) && ! empty( $_SERVER['DOCUMENT_ROOT'] ) ) {
  $home_path = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR;
}

$robots_file    = $home_path . 'robots.txt';
$ht_access_file = $home_path . '.htaccess';

if ( isset( $_POST['create_robots'] ) ) {
  if ( ! current_user_can( 'edit_files' ) ) {
    $die_msg = sprintf(
      /* translators: %s expands to robots.txt. */
      __( 'You cannot create a %s file.', 'wordpress-seo' ),
      'robots.txt'
    );
    die( esc_html( $die_msg ) );
  }

  check_admin_referer( 'wpseo_create_robots' );

  ob_start();
  error_reporting( 0 );
  do_robots();
  $robots_content = ob_get_clean();

  $f = fopen( $robots_file, 'x' );
  fwrite( $f, $robots_content );
}

if ( isset( $_POST['submitrobots'] ) ) {
  if ( ! current_user_can( 'edit_files' ) ) {
    $die_msg = sprintf(
      /* translators: %s expands to robots.txt. */
      __( 'You cannot edit the %s file.', 'wordpress-seo' ),
      'robots.txt'
    );
    die( esc_html( $die_msg ) );
  }

  check_admin_referer( 'wpseo-robotstxt' );

  if ( isset( $_POST['robotsnew'] ) && file_exists( $robots_file ) ) {
    $robotsnew = sanitize_textarea_field( wp_unslash( $_POST['robotsnew'] ) );
    if ( is_writable( $robots_file ) ) {
      $f = fopen( $robots_file, 'w+' );
      fwrite( $f, $robotsnew );
      fclose( $f );
      $msg = sprintf(
        /* translators: %s expands to robots.txt. */
        __( 'Updated %s', 'wordpress-seo' ),
        'robots.txt'
      );
    }
  }
}

if ( isset( $_POST['submithtaccess'] ) ) {
  if ( ! current_user_can( 'edit_files' ) ) {
    $die_msg = sprintf(
      /* translators: %s expands to ".htaccess". */
      __( 'You cannot edit the %s file.', 'wordpress-seo' ),
      '.htaccess'
    );
    die( esc_html( $die_msg ) );
  }

  check_admin_referer( 'wpseo-htaccess' );

  if ( isset( $_POST['htaccessnew'] ) && file_exists( $ht_access_file ) ) {
    $ht_access_new = wp_unslash( $_POST['htaccessnew'] );
    if ( is_writable( $ht_access_file ) ) {
      $f = fopen( $ht_access_file, 'w+' );
      fwrite( $f, $ht_access_new );
      fclose( $f );
    }
  }
}

if ( is_multisite() ) {
  $action_url = network_admin_url( 'admin.php?page=wpseo_files' );
  $yform->admin_header( false, 'wpseo_ms' );
}
else {
  $action_url = admin_url( 'admin.php?page=wpseo_tools&tool=file-editor' );
[1] [2] [3] Next »

 View on GitHub View on Trac

Called by

    Invoked by

      Calls

      1 to 2 of 2
      • WPSEO_Utils::is_nginx() – Check if the web server is running on Nginx.
      • Yoast_Form::get_instance() – Get the singleton instance of this class.

      Call hooks

      File name: admin/views/tool-file-editor.php
      Plugin ref: Yoast SEO
      Version: 19.1
      Deprecated?: No
      API Letters: A,E,F,T,V

      Published: 27th November 2019 | Last updated: 10th December 2020

      Primary Sidebar

      Information

      File name: admin/views/tool-file-editor.php
      Plugin ref: Yoast SEO
      Version: 19.1
      Deprecated?: No
      API Letters: A,E,F,T,V

      admin/views

      Footer

      Yoast SEO a2z
      Yoast SEO a2z
      WordPress SEO a2z
      WordPress 6.0.1
      WordPress a2z
      WordPress core a2z
      Genesis Theme Framework a2z
      Jetpack a2z
      WordPress develop tests
      Easy Digital Downloads a2z
      WooCommerce a2z
      Yoast SEO a2z
      WordPress Blocks

      Site:  wordpress-seo.wp-a2z.org
      © Copyright Yoast SEO a2z 2017-2022. All rights reserved.


      Website designed and developed by Herb Miller
      Proudly powered by WordPress and oik plugins

      • Home
      • Blog
      • Sitemap
      • Sites