• Resolved Denis Pintilie

    (@denisflorin197)


    <?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 );
    }

    Is it possible to create a filter to override the homepath?

Viewing 3 replies - 1 through 3 (of 3 total)
  • @denisflorin197 We’re sorry but we aren’t able to provide this level of support in the forums. These forums are dedicated to offering support for the plugin, but this unfortunately doesn’t include development support so we aren’t able to offer support on custom code (needed to change core features of our plugin).

    Since we don’t want to take the risk that we break your website by suggesting incorrect or incomplete code, we cannot advise you on how to make such changes. Maybe someone watching these forums can assist you further, but if your topic is inactive, we’ll mark it as resolved to keep the overview.

    Thank you for your understanding.

    Thread Starter Denis Pintilie

    (@denisflorin197)

    Hi @devnihil,

    I’m not sure if I understood you.

    The code is from the official plugin, there is no custom code inside.

    I was curios if it’s possible somehow to change the homepath where robots.txt file gets saved

    The code from plugin:

    $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';

    I want to replace somehow that path with a filter or something.

    Plugin Support Maybellyne

    (@maybellyne)

    Hello @denisflorin197

    Though it’s the Yoast SEO plugin code, we can’t provide customization to offer features beyond what the plugin currently has. But you’re free to develop on top of the features the plugin has to suit your needs

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Create filter for home path’ is closed to new replies.