| 1 |
<?php |
| 2 |
/** |
| 3 |
* Admin Welcome page. |
| 4 |
*/ |
| 5 |
|
| 6 |
namespace Extendify\Library; |
| 7 |
|
| 8 |
use Extendify\Config; |
| 9 |
|
| 10 |
/** |
| 11 |
* This class handles the Welcome page on the admin panel. |
| 12 |
*/ |
| 13 |
class Welcome |
| 14 |
{ |
| 15 |
|
| 16 |
/** |
| 17 |
* Adds various actions to set up the page |
| 18 |
* |
| 19 |
* @return void |
| 20 |
*/ |
| 21 |
public function __construct() |
| 22 |
{ |
| 23 |
if (Config::$standalone || Config::$showOnboarding) { |
| 24 |
\add_action('admin_menu', [ $this, 'addAdminMenu' ]); |
| 25 |
|
| 26 |
$this->loadScripts(); |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* Adds Extendify menu to admin panel. |
| 32 |
* |
| 33 |
* @return void |
| 34 |
*/ |
| 35 |
public function addAdminMenu() |
| 36 |
{ |
| 37 |
add_menu_page( |
| 38 |
'Extendify', |
| 39 |
'Extendify', |
| 40 |
Config::$requiredCapability, |
| 41 |
'extendify', |
| 42 |
[ |
| 43 |
$this, |
| 44 |
'createAdminPage', |
| 45 |
], |
| 46 |
// phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode |
| 47 |
'data:image/svg+xml;base64,' . base64_encode('<svg width="20" height="20" viewBox="0 0 60 62" fill="black" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M36.0201 0H49.2377C52.9815 0 54.3365 0.391104 55.7061 1.12116C57.0756 1.85412 58.1469 2.92893 58.8795 4.29635C59.612 5.66666 60 7.02248 60 10.7684V23.9935C60 27.7394 59.6091 29.0952 58.8795 30.4655C58.1469 31.8358 57.0727 32.9078 55.7061 33.6407C55.0938 33.9684 54.4831 34.2381 53.661 34.4312V44.9564C53.661 50.7417 53.0573 52.8356 51.9305 54.952C50.7991 57.0683 49.1401 58.7238 47.0294 59.8558C44.9143 60.9878 42.8215 61.5873 37.0395 61.5873H16.626C10.844 61.5873 8.75122 60.9833 6.63608 59.8558C4.52094 58.7238 2.86639 57.0638 1.73504 54.952C0.603687 52.8401 0 50.7417 0 44.9564V24.5358C0 18.7506 0.603687 16.6566 1.73057 14.5403C2.86192 12.424 4.52094 10.764 6.63608 9.63201C8.74675 8.5045 10.844 7.90047 16.626 7.90047H25.3664C25.5303 6.18172 25.8724 5.24393 26.3754 4.29924C27.1079 2.92893 28.1821 1.85412 29.5517 1.12116C30.9183 0.391104 32.2763 0 36.0201 0ZM29.2266 8.41812C29.2266 5.96352 31.2155 3.97368 33.6689 3.97368H51.5859C54.0393 3.97368 56.0282 5.96352 56.0282 8.41812V26.3438C56.0282 28.7984 54.0393 30.7882 51.5859 30.7882H33.6689C31.2155 30.7882 29.2266 28.7984 29.2266 26.3438V8.41812Z" fill="black"/></svg>') |
| 48 |
); |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* Settings page output |
| 53 |
* |
| 54 |
* @since 1.0.0 |
| 55 |
* |
| 56 |
* @return void |
| 57 |
*/ |
| 58 |
public function createAdminPage() |
| 59 |
{ |
| 60 |
?> |
| 61 |
<div class="extendify-outer-container"> |
| 62 |
<div class="wrap welcome-container"> |
| 63 |
<div class="welcome-header"> |
| 64 |
<img alt="<?php \esc_html_e('Extendify Banner', 'extendify'); ?>" src="<?php echo \esc_url(EXTENDIFY_URL . 'public/assets/welcome-banner.jpg'); ?>"> |
| 65 |
</div> |
| 66 |
<hr class="is-small"/> |
| 67 |
<div class="welcome-section"> |
| 68 |
<h2 class="aligncenter"> |
| 69 |
<?php \esc_html_e('Welcome to Extendify', 'extendify'); ?> |
| 70 |
</h2> |
| 71 |
<p class="aligncenter is-subheading"> |
| 72 |
<?php \esc_html_e('Extendify is a massive library of drop-in black patterns easily customized to your liking. Each pattern is meticulously designed to work with your existing WordPress theme.', 'extendify'); ?> |
| 73 |
</p> |
| 74 |
</div> |
| 75 |
<hr/> |
| 76 |
<div class="welcome-section has-2-columns has-gutters is-wider-right"> |
| 77 |
<div class="column is-edge-to-edge"> |
| 78 |
<h3> |
| 79 |
<?php |
| 80 |
echo sprintf( |
| 81 |
/* translators: %s: Extendify Library term */ |
| 82 |
\esc_html__('1. Open the %s', 'extendify'), |
| 83 |
'Extendify Library' |
| 84 |
); |
| 85 |
?> |
| 86 |
</h3> |
| 87 |
<p> |
| 88 |
<?php \esc_html_e("When editing a page or post within the block editor, you'll see the Extendify library button within the editor's header", 'extendify'); ?> |
| 89 |
</p> |
| 90 |
<p> |
| 91 |
<?php |
| 92 |
// translators: %1$s = URL. |
| 93 |
echo \wp_sprintf(\esc_html__('You may also add a new page with the library opened for you by %1$s.', 'extendify'), '<a href="' . \esc_url(\admin_url('post-new.php?post_type=page&ext-open')) . '">' . \esc_html__('clicking here', 'extendify') . '</a>'); ?> |
| 94 |
</p> |
| 95 |
</div> |
| 96 |
<div class="column welcome-image is-vertically-aligned-center is-edge-to-edge"> |
| 97 |
<img src="<?php echo \esc_url(EXTENDIFY_URL . 'public/assets/welcome-block-1.jpg'); ?>" alt=""/> |
| 98 |
</div> |
| 99 |
</div> |
| 100 |
<div class="welcome-section has-2-columns has-gutters is-wider-left"> |
| 101 |
<div class="column welcome-image is-vertically-aligned-center is-edge-to-edge"> |
| 102 |
<img src="<?php echo \esc_url(EXTENDIFY_URL . 'public/assets/welcome-block-2.jpg'); ?>" alt=""/> |
| 103 |
</div> |
| 104 |
<div class="column is-edge-to-edge"> |
| 105 |
<h3> |
| 106 |
<?php \esc_html_e('2. Choose a site industry', 'extendify'); ?> |
| 107 |
</h3> |
| 108 |
<p> |
| 109 |
<?php \esc_html_e('With the library open, you can set your site industry - or type - which will surface the perfect industry-specific patterns and full page layouts to drop onto your website.', 'extendify'); ?> |
| 110 |
</p> |
| 111 |
<p> |
| 112 |
<?php \esc_html_e('Extendify supports over sixty types with new industries added regularly.', 'extendify'); ?> |
| 113 |
</p> |
| 114 |
</div> |
| 115 |
</div> |
| 116 |
<div class="welcome-section has-2-columns has-gutters is-wider-right"> |
| 117 |
<div class="column is-edge-to-edge"> |
| 118 |
<h3> |
| 119 |
<?php \esc_html_e('3. Browse Patterns & Layouts.', 'extendify'); ?> |
| 120 |
</h3> |
| 121 |
<p> |
| 122 |
<?php \esc_html_e('Search by industry, contents, and design attributes. Extendify has thousands of best-in-class block patterns. Find what you love and add it to the page - done!', 'extendify'); ?> |
| 123 |
</p> |
| 124 |
<p> |
| 125 |
<?php \esc_html_e("You'll find beautiful high fidelity Gutenberg content to add to your pages in no time!", 'extendify'); ?> |
| 126 |
</p> |
| 127 |
</div> |
| 128 |
<div class="column welcome-image is-vertically-aligned-center is-edge-to-edge"> |
| 129 |
<img src="<?php echo \esc_url(EXTENDIFY_URL . 'public/assets/welcome-block-3.jpg'); ?>" alt=""/> |
| 130 |
</div> |
| 131 |
</div> |
| 132 |
<hr class="is-small"/> |
| 133 |
<?php if (!defined('EXTENDIFY_SITE_LICENSE')) : ?> |
| 134 |
<div class="welcome-section"> |
| 135 |
<h2 class="aligncenter"> |
| 136 |
<?php \esc_html_e('Upgrade to Extendify Pro', 'extendify'); ?> |
| 137 |
</h2> |
| 138 |
<p class="aligncenter is-subheading"> |
| 139 |
<?php \esc_html_e('Do you want more patterns and layouts - without limits? Choose one of our plans and receive unlimited access to our complete library.', 'extendify'); ?> |
| 140 |
</p> |
| 141 |
</div> |
| 142 |
<a href="https://extendify.com/pricing/?utm_source=welcome&utm_medium=settings&utm_campaign=get_started&utm_campaign=get_started" class="button button-primary components-button"> |
| 143 |
<?php echo \esc_html__('View Pricing', 'extendify'); ?></a> |
| 144 |
<hr/> |
| 145 |
<?php endif; ?> |
| 146 |
</div> |
| 147 |
</div> |
| 148 |
<?php |
| 149 |
} |
| 150 |
|
| 151 |
/** |
| 152 |
* Adds scripts and styles to every page is enabled |
| 153 |
* |
| 154 |
* @return void |
| 155 |
*/ |
| 156 |
public function loadScripts() |
| 157 |
{ |
| 158 |
// No nonce for _GET. |
| 159 |
// phpcs:ignore WordPress.Security.NonceVerification |
| 160 |
if (isset($_GET['page']) && $_GET['page'] === 'extendify') { |
| 161 |
\add_action( |
| 162 |
'in_admin_header', |
| 163 |
function () { |
| 164 |
\remove_all_actions('admin_notices'); |
| 165 |
\remove_all_actions('all_admin_notices'); |
| 166 |
}, |
| 167 |
1000 |
| 168 |
); |
| 169 |
|
| 170 |
\add_action( |
| 171 |
'admin_enqueue_scripts', |
| 172 |
function () { |
| 173 |
\wp_enqueue_style( |
| 174 |
'extendify-welcome', |
| 175 |
EXTENDIFY_URL . 'public/admin-page/welcome.css', |
| 176 |
[], |
| 177 |
Config::$version |
| 178 |
); |
| 179 |
} |
| 180 |
); |
| 181 |
}//end if |
| 182 |
} |
| 183 |
} |
| 184 |
|