Skip to content

Commit bf92bc8

Browse files
authored
Merge pull request elementor#887 from WP2Static/feature/STR-9650_add-strattic-link-in-sidebar
add Strattic link in sidebar
2 parents fb97bd0 + af34191 commit bf92bc8

File tree

6 files changed

+88
-0
lines changed

6 files changed

+88
-0
lines changed

css/admin/style.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
a[href*="wp2static-try-1-click-publish"], .try-1-click-publish-menu-item {
2+
color: white;
3+
background-color: #FB4247;
4+
font-weight: bold;
5+
}
6+

js/admin/override-menu-style.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
document.addEventListener("DOMContentLoaded", function(event) {
2+
3+
// locate the submenu item by partial match of its href value
4+
const try1ClickPublish = document.querySelector('a[href*="wp2static-try-1-click-publish"]');
5+
6+
// add a class, for easier style application
7+
try1ClickPublish.classList.add('try-1-click-publish-menu-item');
8+
9+
// set to open the link in new window
10+
try1ClickPublish.target = "_blank";
11+
12+
// set a custom external href for the submenu item
13+
try1ClickPublish.href = 'https://www.strattic.com/pricing/?utm_campaign=start-trial&utm_source=wp2static&utm_medium=wp-dash&utm_content=sidebar';
14+
15+
});

src/Controller.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,15 @@ public static function registerOptionsPage() : void {
209209
);
210210
}
211211

212+
add_submenu_page(
213+
'wp2static',
214+
'WP2Static - Try 1-Click Publish',
215+
'Try 1-Click Publish',
216+
'manage_options',
217+
'wp2static-try-1-click-publish',
218+
[ ViewRenderer::class, 'renderTry1ClickPublish' ]
219+
);
220+
212221
add_submenu_page(
213222
'',
214223
'WP2Static Crawl Queue',

src/ViewRenderer.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ public static function renderAddonsPage() : void {
5858
require_once WP2STATIC_PATH . 'views/addons-page.php';
5959
}
6060

61+
public static function renderTry1ClickPublish() : void {
62+
if ( ! is_admin() ) {
63+
http_response_code( 403 );
64+
die( 'Forbidden' );
65+
}
66+
67+
require_once WP2STATIC_PATH . 'views/try-1-click-publishing.php';
68+
}
69+
6170
public static function renderCrawlQueue() : void {
6271
if ( ! is_admin() ) {
6372
http_response_code( 403 );

src/WordPressAdmin.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,18 @@ public static function registerHooks( string $bootstrap_file ) : void {
293293
0
294294
);
295295

296+
add_action(
297+
'admin_enqueue_scripts',
298+
[ self::class, 'wp2staticAdminStyles' ],
299+
0
300+
);
301+
302+
add_action(
303+
'admin_enqueue_scripts',
304+
[ self::class, 'wp2staticAdminScripts' ],
305+
0
306+
);
307+
296308
/*
297309
* Register actions for when we should invalidate cache for
298310
* a URL(s) or whole site
@@ -355,5 +367,26 @@ public static function adminPostProcessQueue() : void {
355367

356368
Controller::wp2staticProcessQueue();
357369
}
370+
371+
public function wp2staticAdminStyles() : void {
372+
wp_register_style(
373+
'wp2static_admin_styles',
374+
plugins_url( '../css/admin/style.css', __FILE__ ),
375+
[],
376+
WP2STATIC_VERSION
377+
);
378+
wp_enqueue_style( 'wp2static_admin_styles' );
379+
}
380+
381+
public function wp2staticAdminScripts() : void {
382+
wp_register_script(
383+
'wp2static_admin_scripts',
384+
plugins_url( '../js/admin/override-menu-style.js', __FILE__ ),
385+
[],
386+
WP2STATIC_VERSION,
387+
false
388+
);
389+
wp_enqueue_script( 'wp2static_admin_scripts' );
390+
}
358391
}
359392

views/try-1-click-publishing.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
// phpcs:disable Generic.Files.LineLength.MaxExceeded
3+
// phpcs:disable Generic.Files.LineLength.TooLong
4+
5+
// Fallback template, in case JS fails to override the WP2Static submenu item
6+
7+
?>
8+
9+
<div class="wrap">
10+
<h1>Try 1-Click static site publishing!</h1>
11+
12+
<p>Loving WP2Static but want to try 1-Click Publish on Strattic?</p>
13+
14+
<p><a href="https://www.strattic.com/pricing/?utm_campaign=start-trial&utm_source=wp2static&utm_medium=wp-dash&utm_content=sidebar">Click here</a> to try Strattic for free today!</p>
15+
16+
</div>

0 commit comments

Comments
 (0)