|
6 | 6 | namespace Extendify\Library;
|
7 | 7 |
|
8 | 8 | use function add_action;
|
| 9 | +use function wp_sprintf; |
| 10 | +use Extendify\Library\App; |
9 | 11 | use function add_menu_page;
|
10 | 12 | use function wp_enqueue_style;
|
11 |
| -use function wp_sprintf; |
12 | 13 |
|
13 | 14 | /**
|
14 | 15 | * This class handles the Welcome page on the admin panel.
|
15 | 16 | */
|
16 | 17 | class Welcome
|
17 | 18 | {
|
18 | 19 |
|
19 |
| - /** |
20 |
| - * Adds various actions to set up the page |
21 |
| - * |
22 |
| - * @return void |
23 |
| - */ |
24 |
| - public function __construct() |
25 |
| - { |
26 |
| - if (isset($GLOBALS['extendify_sdk_partner']) && 'standalone' === $GLOBALS['extendify_sdk_partner']) { |
27 |
| - add_action( 'admin_menu', [ $this, 'addAdminMenu' ] ); |
| 20 | + /** |
| 21 | + * Adds various actions to set up the page |
| 22 | + * |
| 23 | + * @return void |
| 24 | + */ |
| 25 | + public function __construct() |
| 26 | + { |
| 27 | + if (App::$standalone) { |
| 28 | + add_action('admin_menu', [ $this, 'addAdminMenu' ]); |
28 | 29 |
|
29 | 30 | $this->loadScripts();
|
30 | 31 | }
|
31 |
| - } |
| 32 | + } |
32 | 33 |
|
33 |
| - /** |
34 |
| - * Adds Extendify menu to admin panel. |
35 |
| - * |
36 |
| - * @return void |
37 |
| - */ |
38 |
| - public function addAdminMenu() |
39 |
| - { |
40 |
| - $raw = wp_remote_get( EXTENDIFY_URL . 'public/assets/extendify-logo.svg' ); |
41 |
| - if (is_wp_error($raw)) { |
42 |
| - $svg = ''; |
43 |
| - } else { |
44 |
| - $svg = wp_remote_retrieve_body($raw); |
45 |
| - } |
| 34 | + /** |
| 35 | + * Adds Extendify menu to admin panel. |
| 36 | + * |
| 37 | + * @return void |
| 38 | + */ |
| 39 | + public function addAdminMenu() |
| 40 | + { |
| 41 | + $raw = wp_remote_get(EXTENDIFY_URL . 'public/assets/extendify-logo.svg'); |
| 42 | + if (is_wp_error($raw)) { |
| 43 | + $svg = ''; |
| 44 | + } else { |
| 45 | + $svg = wp_remote_retrieve_body($raw); |
| 46 | + } |
46 | 47 |
|
47 |
| - add_menu_page( |
48 |
| - 'Extendify', |
49 |
| - 'Extendify', |
50 |
| - App::$requiredCapability, |
51 |
| - 'extendify', |
52 |
| - [ |
53 |
| - $this, |
54 |
| - 'createAdminPage', |
55 |
| - ], |
56 |
| - // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode |
57 |
| - 'data:image/svg+xml;base64,' . base64_encode( $svg ) |
58 |
| - ); |
59 |
| - } |
| 48 | + add_menu_page( |
| 49 | + 'Extendify', |
| 50 | + 'Extendify', |
| 51 | + App::$requiredCapability, |
| 52 | + 'extendify', |
| 53 | + [ |
| 54 | + $this, |
| 55 | + 'createAdminPage', |
| 56 | + ], |
| 57 | + // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode |
| 58 | + 'data:image/svg+xml;base64,' . base64_encode($svg) |
| 59 | + ); |
| 60 | + } |
60 | 61 |
|
61 |
| - /** |
62 |
| - * Settings page output |
63 |
| - * |
64 |
| - * @since 1.0.0 |
65 |
| - * |
66 |
| - * @return void |
67 |
| - */ |
68 |
| - public function createAdminPage() |
69 |
| - { |
70 |
| - ?> |
71 |
| - <div class="extendify-outer-container"> |
72 |
| - <div class="wrap welcome-container"> |
73 |
| - <div class="welcome-header"> |
74 |
| - <img alt="<?php esc_html_e( 'Extendify Banner', 'extendify' ); ?>" src="<?php echo esc_url( EXTENDIFY_URL . 'public/assets/welcome-banner.jpg' ); ?>"> |
75 |
| - </div> |
76 |
| - <hr class="is-small"/> |
77 |
| - <div class="welcome-section"> |
78 |
| - <h2 class="aligncenter"> |
79 |
| - <?php esc_html_e( 'Welcome to Extendify', 'extendify' ); ?> |
80 |
| - </h2> |
81 |
| - <p class="aligncenter is-subheading"> |
82 |
| - <?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' ); ?> |
83 |
| - </p> |
84 |
| - </div> |
85 |
| - <hr/> |
86 |
| - <div class="welcome-section has-2-columns has-gutters is-wider-right"> |
87 |
| - <div class="column is-edge-to-edge"> |
88 |
| - <h3> |
89 |
| - <?php esc_html_e( '1. Open the Extendify Library', 'extendify' ); ?> |
90 |
| - </h3> |
91 |
| - <p> |
92 |
| - <?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' ); ?> |
93 |
| - </p> |
94 |
| - <p> |
95 |
| - <?php |
96 |
| - // translators: %1$s = URL. |
97 |
| - 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>' ); |
98 |
| - ?> |
99 |
| - </p> |
100 |
| - </div> |
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-1.jpg' ); ?>" alt=""/> |
103 |
| - </div> |
104 |
| - </div> |
105 |
| - <div class="welcome-section has-2-columns has-gutters is-wider-left"> |
106 |
| - <div class="column welcome-image is-vertically-aligned-center is-edge-to-edge"> |
107 |
| - <img src="<?php echo esc_url( EXTENDIFY_URL . 'public/assets/welcome-block-2.jpg' ); ?>" alt=""/> |
108 |
| - </div> |
109 |
| - <div class="column is-edge-to-edge"> |
110 |
| - <h3> |
111 |
| - <?php esc_html_e( '2. Choose a site industry', 'extendify' ); ?> |
112 |
| - </h3> |
113 |
| - <p> |
114 |
| - <?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' ); ?> |
115 |
| - </p> |
116 |
| - <p> |
117 |
| - <?php esc_html_e( 'Extendify supports over sixty types with new industries added regularly.', 'extendify' ); ?> |
118 |
| - </p> |
119 |
| - </div> |
120 |
| - </div> |
121 |
| - <div class="welcome-section has-2-columns has-gutters is-wider-right"> |
122 |
| - <div class="column is-edge-to-edge"> |
123 |
| - <h3> |
124 |
| - <?php esc_html_e( '3. Browse Patterns & Layouts.', 'extendify' ); ?> |
125 |
| - </h3> |
126 |
| - <p> |
127 |
| - <?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' ); ?> |
128 |
| - </p> |
129 |
| - <p> |
130 |
| - <?php esc_html_e( "You'll find beautiful high fidelity Gutenberg content to add to your pages in no time!", 'extendify' ); ?> |
131 |
| - </p> |
132 |
| - </div> |
133 |
| - <div class="column welcome-image is-vertically-aligned-center is-edge-to-edge"> |
134 |
| - <img src="<?php echo esc_url( EXTENDIFY_URL . 'public/assets/welcome-block-3.jpg' ); ?>" alt=""/> |
135 |
| - </div> |
136 |
| - </div> |
137 |
| - <hr class="is-small"/> |
138 |
| - <div class="welcome-section"> |
139 |
| - <h2 class="aligncenter"> |
140 |
| - <?php esc_html_e( 'Upgrade to Extendify Pro', 'extendify' ); ?> |
141 |
| - </h2> |
142 |
| - <p class="aligncenter is-subheading"> |
143 |
| - <?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' ); ?> |
144 |
| - </p> |
145 |
| - </div> |
146 |
| - <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"> |
147 |
| - <?php echo esc_html__( 'View Pricing', 'extendify' ); ?></a> |
148 |
| - <hr/> |
149 |
| - </div> |
150 |
| - </div> |
151 |
| - <?php |
152 |
| - } |
| 62 | + /** |
| 63 | + * Settings page output |
| 64 | + * |
| 65 | + * @since 1.0.0 |
| 66 | + * |
| 67 | + * @return void |
| 68 | + */ |
| 69 | + public function createAdminPage() |
| 70 | + { |
| 71 | + ?> |
| 72 | + <div class="extendify-outer-container"> |
| 73 | + <div class="wrap welcome-container"> |
| 74 | + <div class="welcome-header"> |
| 75 | + <img alt="<?php esc_html_e('Extendify Banner', 'extendify'); ?>" src="<?php echo esc_url(EXTENDIFY_URL . 'public/assets/welcome-banner.jpg'); ?>"> |
| 76 | + </div> |
| 77 | + <hr class="is-small"/> |
| 78 | + <div class="welcome-section"> |
| 79 | + <h2 class="aligncenter"> |
| 80 | + <?php esc_html_e('Welcome to Extendify', 'extendify'); ?> |
| 81 | + </h2> |
| 82 | + <p class="aligncenter is-subheading"> |
| 83 | + <?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'); ?> |
| 84 | + </p> |
| 85 | + </div> |
| 86 | + <hr/> |
| 87 | + <div class="welcome-section has-2-columns has-gutters is-wider-right"> |
| 88 | + <div class="column is-edge-to-edge"> |
| 89 | + <h3> |
| 90 | + <?php esc_html_e('1. Open the Extendify Library', 'extendify'); ?> |
| 91 | + </h3> |
| 92 | + <p> |
| 93 | + <?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'); ?> |
| 94 | + </p> |
| 95 | + <p> |
| 96 | + <?php |
| 97 | + // translators: %1$s = URL. |
| 98 | + 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>'); ?> |
| 99 | + </p> |
| 100 | + </div> |
| 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-1.jpg'); ?>" alt=""/> |
| 103 | + </div> |
| 104 | + </div> |
| 105 | + <div class="welcome-section has-2-columns has-gutters is-wider-left"> |
| 106 | + <div class="column welcome-image is-vertically-aligned-center is-edge-to-edge"> |
| 107 | + <img src="<?php echo esc_url(EXTENDIFY_URL . 'public/assets/welcome-block-2.jpg'); ?>" alt=""/> |
| 108 | + </div> |
| 109 | + <div class="column is-edge-to-edge"> |
| 110 | + <h3> |
| 111 | + <?php esc_html_e('2. Choose a site industry', 'extendify'); ?> |
| 112 | + </h3> |
| 113 | + <p> |
| 114 | + <?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'); ?> |
| 115 | + </p> |
| 116 | + <p> |
| 117 | + <?php esc_html_e('Extendify supports over sixty types with new industries added regularly.', 'extendify'); ?> |
| 118 | + </p> |
| 119 | + </div> |
| 120 | + </div> |
| 121 | + <div class="welcome-section has-2-columns has-gutters is-wider-right"> |
| 122 | + <div class="column is-edge-to-edge"> |
| 123 | + <h3> |
| 124 | + <?php esc_html_e('3. Browse Patterns & Layouts.', 'extendify'); ?> |
| 125 | + </h3> |
| 126 | + <p> |
| 127 | + <?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'); ?> |
| 128 | + </p> |
| 129 | + <p> |
| 130 | + <?php esc_html_e("You'll find beautiful high fidelity Gutenberg content to add to your pages in no time!", 'extendify'); ?> |
| 131 | + </p> |
| 132 | + </div> |
| 133 | + <div class="column welcome-image is-vertically-aligned-center is-edge-to-edge"> |
| 134 | + <img src="<?php echo esc_url(EXTENDIFY_URL . 'public/assets/welcome-block-3.jpg'); ?>" alt=""/> |
| 135 | + </div> |
| 136 | + </div> |
| 137 | + <hr class="is-small"/> |
| 138 | + <div class="welcome-section"> |
| 139 | + <h2 class="aligncenter"> |
| 140 | + <?php esc_html_e('Upgrade to Extendify Pro', 'extendify'); ?> |
| 141 | + </h2> |
| 142 | + <p class="aligncenter is-subheading"> |
| 143 | + <?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'); ?> |
| 144 | + </p> |
| 145 | + </div> |
| 146 | + <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"> |
| 147 | + <?php echo esc_html__('View Pricing', 'extendify'); ?></a> |
| 148 | + <hr/> |
| 149 | + </div> |
| 150 | + </div> |
| 151 | + <?php |
| 152 | + } |
153 | 153 |
|
154 |
| - /** |
155 |
| - * Adds scripts and styles to every page is enabled |
156 |
| - * |
157 |
| - * @return void |
158 |
| - */ |
159 |
| - public function loadScripts() |
160 |
| - { |
161 |
| - // No nonce for _GET. |
162 |
| - // phpcs:ignore WordPress.Security.NonceVerification |
163 |
| - if (isset($_GET['page'] ) && $_GET['page'] === 'extendify') { |
164 |
| - add_action( |
165 |
| - 'admin_enqueue_scripts', |
166 |
| - function () { |
167 |
| - wp_enqueue_style( |
168 |
| - 'extendify-welcome', |
169 |
| - EXTENDIFY_URL . 'public/admin-page/welcome.css', |
170 |
| - [], |
171 |
| - App::$version |
172 |
| - ); |
173 |
| - } |
174 |
| - ); |
175 |
| - } |
176 |
| - } |
| 154 | + /** |
| 155 | + * Adds scripts and styles to every page is enabled |
| 156 | + * |
| 157 | + * @return void |
| 158 | + */ |
| 159 | + public function loadScripts() |
| 160 | + { |
| 161 | + // No nonce for _GET. |
| 162 | + // phpcs:ignore WordPress.Security.NonceVerification |
| 163 | + if (isset($_GET['page']) && $_GET['page'] === 'extendify') { |
| 164 | + add_action( |
| 165 | + 'admin_enqueue_scripts', |
| 166 | + function () { |
| 167 | + wp_enqueue_style( |
| 168 | + 'extendify-welcome', |
| 169 | + EXTENDIFY_URL . 'public/admin-page/welcome.css', |
| 170 | + [], |
| 171 | + App::$version |
| 172 | + ); |
| 173 | + } |
| 174 | + ); |
| 175 | + } |
| 176 | + } |
177 | 177 | }
|
0 commit comments