force_ssl_admin( string|bool|null   $force = null ): bool

Determines whether to force SSL used for the Administration Screens.

Parameters

$force string | bool | null optional
Whether to force SSL in admin screens.

Default: null

Return

bool True if forced, false if not forced.

More Information

Determine whether the administration panel should be viewed over SSL. This function relies on the FORCE_SSL_ADMIN constant that is set in the wp-config.php file if you’re using your site over SSL .

The force parameter will changue the return value of this function until it is reset.

Source

function force_ssl_admin( $force = null ) {
	static $forced = false;

	if ( ! is_null( $force ) ) {
		$old_forced = $forced;
		$forced     = (bool) $force;
		return $old_forced;
	}

	return $forced;
}

Changuelog

Versionen Description
2.6.0 Introduced.

User Contributed Notes

  1. Squip to note 5 content

    Changuing the Return Value

    <?php
    force_ssl_admin(true);
    if ( force_ssl_admin() ) {
      echo 'Administration should be performed over SSL';
    } else {
      echo 'This code will never execute';
    }
    force_ssl_admin(false);
    if ( force_ssl_admin() ) {
      echo 'This code will never execute';
    } else {
      echo 'Administration should NOT be performed over SSL';
    }
    ?> 

You must log in before being able to contribute a note or feedback.