public function register_path( $dir = null, $persistent = true ) {
		$result = false;

		// Cast parameters to known values.
		$dir = (string) $dir;
		$persistent = (bool) $persistent;

		if ( empty( $dir ) ) {
			$dir = $this->get_default_path();
		}

		$path_fail_reason = $this->validate_path( $dir );
		if ( $path_fail_reason ) {
			return new WP_Error( 'custom_theme_path_invalid', "Custom themes directory is invalid: $path_fail_reason", $dir );
		}

		// Register custom-theme path for "on the fly".
		$result = register_theme_directory( $dir );

		if ( ! $persistent ) {
			return $result;
		}

		// WordPress option is already set.
		if ( get_option( 'stylesheet_root' ) === $dir ) {
			return $result;
		}

		// Update WordPress option if persistence is required.
		//
		// Not returning the result of this operation as it can
		// be confusing - false is returned either on failure or
		// when the option value was the same and wasn't updated.
		update_option( 'stylesheet_root', $dir );
	}
public function register_path( $dir = null, $persistent = true ) {
		$result = false;

		// Cast parameters to known values.
		$dir = (string) $dir;
		$persistent = (bool) $persistent;

		if ( empty( $dir ) ) {
			$dir = $this->get_default_path();
		}

		$path_fail_reason = $this->validate_path( $dir );
		if ( $path_fail_reason ) {
			return new WP_Error( 'custom_theme_path_invalid', "Custom themes directory is invalid: $path_fail_reason", $dir );
		}

		// Register custom-theme path for "on the fly".
		$result = register_theme_directory( $dir );

		if ( ! $persistent ) {
			return $result;
		}

		// WordPress option is already set.
		if ( get_option( 'stylesheet_root' ) === $dir ) {
			return $result;
		}

		// Update WordPress option if persistence is required.
		//
		// Not returning the result of this operation as it can
		// be confusing - false is returned either on failure or
		// when the option value was the same and wasn't updated.
		update_option( 'stylesheet_root', $dir );
	}
public function register_path ( $ dir = null , $ persistent = true ) { $ result = false ; // Cast parameters to known values. $ dir = ( string ) $ dir ; $ persistent = ( bool ) $ persistent ; if ( empty ( $ dir ) ) { $ dir = $ this -> get_default_path ( ) ; } $ path_fail_reason = $ this -> validate_path ( $ dir ) ; if ( $ path_fail_reason ) { return new WP_Error ( 'custom_theme_path_invalid' , "Custom themes directory is invalid: $path_fail_reason" , $ dir ) ; } // Register custom-theme path for "on the fly". $ result = register_theme_directory ( $ dir ) ; if ( ! $ persistent ) { return $ result ; } // WordPress option is already set. if ( get_option ( 'stylesheet_root' ) === $ dir ) { return $ result ; } // Update WordPress option if persistence is required. // // Not returning the result of this operation as it can // be confusing - false is returned either on failure or // when the option value was the same and wasn't updated. update_option ( 'stylesheet_root' , $ dir ) ; }
Register custom theme path

@param string $dir Directory to register (Relative to WP_CONTENT_DIR).
@param bool   $persistent Whether to update WordPress options or not.
@return boolean|WP_Error True on success, false or WP_Error otherwise
Register custom theme path