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