Skip to content

Commit

Permalink
Merge branch 'develop' into enhance/#8230-follow-up.
Browse files Browse the repository at this point in the history
  • Loading branch information
hussain-t committed Apr 29, 2024
2 parents 2243821 + bfc841c commit e20923d
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,35 @@
padding: 4px 9px;
}
}

.googlesitekit-authorize-application__footer {
display: none;

@media (min-width: $bp-wpAdminBarTablet) {
bottom: 0;
display: block;
left: 0;
line-height: $lh-authorize-application-headline-sm;
margin-left: 36px;
padding: 0 47px;
position: absolute;

p {
color: $c-authorize-application-sys-light-on-surface;
font-family: $f-primary;
font-size: $fs-authorize-application-footer-lg;
font-weight: $fw-medium;
}
}

@media (min-width: $width-desktop + 1 + px) {
margin-left: 160px;
}
}
}

#wpbody-content {
padding-bottom: 100px;
}

#wpcontent,
Expand All @@ -105,11 +134,15 @@
font-family: $f-primary;
padding: 0 10px;

@media (min-width: $width-wpAdminBarTablet + 1 + px) {
@media (min-width: $bp-wpAdminBarTablet) {
padding: 0 47px;
}
}

#wpfooter {
bottom: 45px;
}

#approve,
#reject {
border-radius: $br-lg;
Expand Down
1 change: 1 addition & 0 deletions assets/sass/config/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ $fs-authorize-application-title-lg: 18px;
$fs-authorize-application-label-lg: 14px;
$fs-authorize-application-label-md: 12px;
$fs-authorize-application-body-md: 14px;
$fs-authorize-application-footer-lg: 16px;

$lh-authorize-application-headline-sm: 32px;
$lh-authorize-application-title-lg: 24px;
Expand Down
12 changes: 12 additions & 0 deletions includes/Core/Admin/Authorize_Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public function __construct(
*/
public function register() {
add_action( 'admin_enqueue_scripts', $this->get_method_proxy( 'enqueue_assets' ) );
add_action( 'admin_footer', $this->get_method_proxy( 'render_custom_footer' ) );
}

/**
Expand Down Expand Up @@ -114,4 +115,15 @@ private function enqueue_assets() {
$this->assets->enqueue_asset( 'googlesitekit-authorize-application-css' );
}
}

/**
* Renders custom footer for the Authorize Application screen if the service is a Google service.
*
* @since n.e.x.t
*/
private function render_custom_footer() {
if ( $this->is_authorize_application_screen() && $this->is_google_service() ) {
echo '<div class="googlesitekit-authorize-application__footer"><p>Powered by Site Kit</p></div>';
}
}
}
22 changes: 22 additions & 0 deletions tests/phpunit/integration/Core/Admin/Authorize_ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ public function test_register() {

// Check that the expected assets are enqueued.
$this->assertTrue( wp_style_is( 'googlesitekit-authorize-application-css', 'enqueued' ) );

ob_start();
do_action( 'admin_footer' );
$output = ob_get_clean();

// Check that the custom footer content is rendered.
$this->assertStringContainsString( '<div class="googlesitekit-authorize-application__footer"><p>Powered by Site Kit</p></div>', $output );
}

public function test_register_with_incorrect_success_url() {
Expand All @@ -61,6 +68,13 @@ public function test_register_with_incorrect_success_url() {

// Check that the assets aren't enqueued due to incorrect success URL.
$this->assertFalse( wp_style_is( 'googlesitekit-authorize-application-css', 'enqueued' ) );

ob_start();
do_action( 'admin_footer' );
$output = ob_get_clean();

// Check that the custom footer content isn't rendered.
$this->assertStringNotContainsString( '<div class="googlesitekit-authorize-application__footer"><p>Powered by Site Kit</p></div>', $output );
}

public function test_register_with_incorrect_screen() {
Expand All @@ -83,6 +97,14 @@ public function test_register_with_incorrect_screen() {

// Check that expected assets aren't enqueued due to incorrect screen.
$this->assertFalse( wp_style_is( 'googlesitekit-authorize-application-css', 'enqueued' ) );

ob_start();
do_action( 'admin_footer' );
$output = ob_get_clean();

// Check that the custom footer content isn't rendered.
$this->assertStringNotContainsString( '<div class="googlesitekit-authorize-application__footer"><p>Powered by Site Kit</p></div>', $output );

}

public function set_global_get_params( $success_url ) {
Expand Down

0 comments on commit e20923d

Please sign in to comment.