PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 2.2.13
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v2.2.13
3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 All 111 releases
← All changes | includes/Core/Admin.php +20 -118 3.0.52.2.13 View file →
@@ -1,5 +1,6 @@
1 1 <?php
2 +
2 3 namespace Templately\Core;
3 4
4 5 use Exception;
5 6 use PriyoMukul\WPNotice\Notices;
@@ -5,13 +6,13 @@
5 6 use PriyoMukul\WPNotice\Notices;
6 7 use PriyoMukul\WPNotice\Utils\CacheBank;
7 8 use PriyoMukul\WPNotice\Utils\NoticeRemover;
8 9 use Templately\API\Login;
10 +use Templately\Core\Platform\Elementor;
11 +use Templately\Core\Platform\Gutenberg;
9 12 use Templately\Utils\Base;
10 13 use Templately\Utils\Helper;
11 14 use Templately\Utils\Options;
12 -use Templately\Core\Platform\Elementor;
13 -use Templately\Core\Platform\Gutenberg;
14 15
15 16 class Admin extends Base {
16 17
17 18 /**
@@ -38,92 +39,20 @@
38 39 // Remove OLD notice from 1.0.0 (if other WPDeveloper plugin has notice)
39 40 NoticeRemover::get_instance( '1.0.0' );
40 41 }
41 42
42 - public function register_post_type() {
43 - $labels = [
44 - 'name' => _x( 'Theme Builders', 'Post type general name', 'templately' ),
45 - 'singular_name' => _x( 'Theme Builder', 'Post type singular name', 'templately' ),
46 - 'menu_name' => _x( 'Theme Builder', 'Admin Menu text', 'templately' ),
47 - 'name_admin_bar' => _x( 'Book', 'Add New on Toolbar', 'templately' ),
48 - 'add_new' => __( 'Add New', 'templately' ),
49 - 'add_new_item' => __( 'Add New Template', 'templately' ),
50 - 'new_item' => __( 'New Template', 'templately' ),
51 - 'edit_item' => __( 'Edit Template', 'templately' ),
52 - 'view_item' => __( 'View Template', 'templately' ),
53 - 'all_items' => __( 'All Templates', 'templately' ),
54 - 'search_items' => __( 'Search Templates', 'templately' ),
55 - 'parent_item_colon' => __( 'Parent Templates:', 'templately' ),
56 - 'not_found' => __( 'No templates found.', 'templately' ),
57 - 'not_found_in_trash' => __( 'No templates found in Trash.', 'templately' ),
58 - 'featured_image' => _x( 'Template Cover Image', 'Overrides the “Featured Image” phrase for this post type. Added in 4.3', 'templately' ),
59 - 'set_featured_image' => _x( 'Set cover image', 'Overrides the “Set featured image” phrase for this post type. Added in 4.3', 'templately' ),
60 - 'remove_featured_image' => _x( 'Remove cover image', 'Overrides the “Remove featured image” phrase for this post type. Added in 4.3', 'templately' ),
61 - 'use_featured_image' => _x( 'Use as cover image', 'Overrides the “Use as featured image” phrase for this post type. Added in 4.3', 'templately' ),
62 - 'archives' => _x( 'Template archives', 'The post type archive label used in nav menus. Default “Post Archives”. Added in 4.4', 'templately' ),
63 - 'insert_into_item' => _x( /** @lang text */ "Insert Into Theme Builder", 'Overrides the “Insert into post”/”Insert into page” phrase (used when inserting media into a post). Added in 4.4', 'templately' ),
64 - 'uploaded_to_this_item' => _x( 'Uploaded to this template', 'Overrides the “Uploaded to this post”/”Uploaded to this page” phrase (used when viewing media attached to a post). Added in 4.4', 'templately' ),
65 - 'filter_items_list' => _x( 'Filter templates list', 'Screen reader text for the filter links heading on the post type listing screen. Default “Filter posts list”/”Filter pages list”. Added in 4.4', 'templately' ),
66 - 'items_list_navigation' => _x( 'Templates list navigation', 'Screen reader text for the pagination heading on the post type listing screen. Default “Posts list navigation”/”Pages list navigation”. Added in 4.4', 'templately' ),
67 - 'items_list' => _x( 'Templates list', 'Screen reader text for the items list heading on the post type listing screen. Default “Posts list”/”Pages list”. Added in 4.4', 'templately' ),
68 - ];
69 -
70 - $args = [
71 - 'labels' => $labels,
72 - 'public' => true,
73 - 'publicly_queryable' => true,
74 - 'show_ui' => true,
75 - 'show_in_menu' => false,
76 - 'query_var' => true,
77 - 'rewrite' => [ 'slug' => 'templately-library' ],
78 - 'capability_type' => 'post',
79 - 'has_archive' => true,
80 - 'hierarchical' => false,
81 - 'menu_position' => 10,
82 - 'supports' => [ 'title', 'editor', 'author', 'thumbnail', 'custom-field' ],
83 - ];
84 -
85 - register_post_type( 'templately_library', $args );
86 - }
87 -
88 43 /**
89 44 * Enqueuing Assets
90 45 *
91 - * @param string $hook
46 + * @param string $hook
47 + *
92 48 * @return void
93 49 */
94 - public function scripts( string $hook ) {
95 - if ( ! in_array( $hook, [ 'edit.php', 'toplevel_page_templately', 'elementor', 'gutenberg' ], true ) ) {
50 + public function scripts( $hook ) {
51 + if ( ! in_array( $hook, [ 'toplevel_page_templately', 'elementor', 'gutenberg' ], true ) ) {
96 52 return;
97 53 }
98 54
99 - $templately = [];
100 -
101 - if ( 'edit.php' === $hook ) {
102 - global $current_screen;
103 - if ( $current_screen->post_type !== 'templately_library' ) {
104 - return;
105 - }
106 -
107 - $types = templately()->theme_builder::$templates_manager->get_template_types();
108 - $types = array_filter( $types, function ( $item ) {
109 - return $item::get_property( 'builder' ) || $item::get_property( 'builder' ) === null;
110 - } );
111 -
112 - $types = array_reduce( $types, function ( $carry, $item ) {
113 - return array_merge( $carry, [
114 - [
115 - 'value' => call_user_func( [ $item, 'get_type' ] ),
116 - 'label' => call_user_func( [ $item, 'get_title' ] )
117 - ]
118 - ] );
119 - }, [] );
120 -
121 - $templately = [
122 - 'types' => $types
123 - ];
124 - }
125 -
126 55 $script_dependencies = [];
127 56 $_localize_handle = 'templately';
128 57 $_current_screen = 'templately';
129 58
@@ -129,23 +58,20 @@
129 58
130 59 if ( $hook === 'elementor' || $hook === 'gutenberg' ) {
131 60 $_current_screen = $hook;
132 61 $_localize_handle = 'templately-' . $hook;
133 - $script_dependencies = [$_localize_handle];
62 + $script_dependencies = [ $_localize_handle ];
134 63 }
135 64
136 - if ( $hook === 'toplevel_page_templately' || $hook == 'edit.php' ) {
65 + if ( $hook === 'toplevel_page_templately' ) {
137 66 templately()->assets->enqueue( 'templately-admin', 'css/admin.css', [ 'templately' ] );
138 67 }
139 68
140 69 // Google Font Enqueueing
141 - templately()->assets->enqueue(
142 - 'templately-dmsans',
143 - set_url_scheme( '//fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&display=swap' )
144 - );
70 + templately()->assets->enqueue( 'templately-dmsans', set_url_scheme( '//fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&display=swap' ) );
145 71
146 72 templately()->assets->enqueue( 'templately', 'js/templately.js', $script_dependencies, true );
147 - templately()->assets->enqueue( 'templately', 'css/templately.css', ['templately-dmsans'] );
73 + templately()->assets->enqueue( 'templately', 'css/templately.css', [ 'templately-dmsans' ] );
148 74
149 75 /**
150 76 * @var Elementor|Gutenberg $platform
151 77 */
@@ -150,9 +76,9 @@
150 76 * @var Elementor|Gutenberg $platform
151 77 */
152 78 $platform = $this->platform( $_current_screen );
153 79
154 - $templately = array_merge( [
80 + templately()->assets->localize( $_localize_handle, 'templately', [
155 81 'url' => home_url(),
156 82 'site_url' => site_url(),
157 83 'nonce' => wp_create_nonce( 'templately_nonce' ),
158 84 'rest_args' => [
@@ -161,11 +87,10 @@
161 87 ],
162 88 'log' => defined( 'TEMPLATELY_DEBUG_LOG' ) && TEMPLATELY_DEBUG_LOG,
163 89 'dev_mode' => defined( 'TEMPLATELY_DEV' ) && TEMPLATELY_DEV,
164 90 "icons" => [
165 - 'construction' => templately()->assets->icon( 'icons/construction.gif' ),
166 - 'profile' => templately()->assets->icon( 'icons/profile.svg' ),
167 - 'warning' => templately()->assets->icon( 'icons/warning.png' )
91 + 'profile' => templately()->assets->icon( 'icons/profile.svg' ),
92 + 'warning' => templately()->assets->icon( 'icons/warning.png' )
168 93 ],
169 94 'promo_image' => templately()->assets->icon( 'single-page-promo.png' ),
170 95 'default_image' => templately()->assets->icon( 'clouds/cloud-item.svg' ),
171 96 'not_found' => templately()->assets->icon( 'no-item-found.png' ),
@@ -175,21 +100,16 @@
175 100 'is_signed' => Login::is_signed(),
176 101 'is_globally_signed' => Login::is_globally_signed(),
177 102 'signed_as_global' => Login::signed_as_global(),
178 103 'current_screen' => $_current_screen,
179 - 'post_type' => get_post_type(),
180 104 'has_elementor_pro' => rest_sanitize_boolean( is_plugin_active( 'elementor-pro/elementor-pro.php' ) ),
181 - 'theme' => $_current_screen == 'templately' ? 'light' : $platform->ui_theme(),
182 - 'is_wp_support_gutenberg' => version_compare( get_bloginfo( 'version' ), '5.0.0', '>=' ),
183 - ], $templately );
184 -
185 - templately()->assets->localize( $_localize_handle, 'templately', $templately );
105 + 'theme' => $_current_screen == 'templately' ? 'light' : $platform->ui_theme()
106 + ] );
186 107 }
187 108
188 109 /**
189 110 * Admin notices for Review and others.
190 111 *
191 - * @since 2.0.0
192 112 * @return void
193 113 * @throws Exception
194 114 * @since 2.0.0
195 115 */
@@ -293,9 +213,9 @@
293 213 ]
294 214 ] );
295 215
296 216 $notice_text = '<p style="margin-top: 0; margin-bottom: 10px;">Black Friday Sale: Save up to 70% and <strong>get access to 5000+ ready templates</strong> to design amazing websites ✨</p>
297 - <a class="button button-primary" href="https://wpdeveloper.com/upgrade/templately-bfcm" target="_blank">Upgrade to pro</a> <button data-dismiss="true" class="dismiss-btn button button-link">I don’t want to save money</button>';
217 + <a class="button button-primary" href="https://wpdeveloper.com/upgrade/templately-bfcm" target="_blank">Upgrade to pro</a> <button data-dismiss="true" class="dismiss-btn button button-link">I don’t want to save money</button>';
298 218
299 219 $_black_friday = [
300 220 'thumbnail' => templately()->assets->icon( 'logos/logo-full.svg' ),
301 221 'html' => $notice_text,
@@ -320,22 +240,12 @@
320 240 * @return void
321 241 */
322 242 public function admin_menu() {
323 243 // TODO: Role Management
324 -
325 - add_menu_page( 'Templately', 'Templately', 'delete_posts', 'templately', '', templately()->assets->icon( 'logos/logo-icon.svg' ), '58.7' );
326 -
327 - add_submenu_page( 'templately', 'Templately', 'Template Library', 'delete_posts', 'templately', [
244 + add_menu_page( 'Templately', 'Templately', 'delete_posts', 'templately', [
328 245 $this,
329 246 'display'
330 - ], '58.7' );
331 -
332 - add_submenu_page( 'templately', 'Theme Builder', 'Theme Builder', 'delete_posts', 'edit.php?post_type=templately_library', '', '58.7' );
333 -
334 - // add_submenu_page( 'templately', 'Settings', 'Settings', 'administrator', 'templately-settings', [
335 - // Settings::get_instance(),
336 - // 'display'
337 - // ], '58.7' );
247 + ], templately()->assets->icon( 'logos/logo-icon.svg' ), '58.7' );
338 248 }
339 249
340 250 public function display() {
341 251 Helper::views( 'settings' );
@@ -353,17 +263,9 @@
353 263 $plugin_url = \wp_nonce_url( 'plugins.php?action=activate&amp;plugin=elementor/elementor.php', 'activate-plugin_elementor/elementor.php' );
354 264 $button_text = 'Activate Elementor';
355 265 }
356 266 $output = '<div class="notice notice-error">';
357 - $output .= sprintf(
358 - "<p><strong>%s</strong> %s <strong>%s</strong> %s &nbsp;&nbsp;<a class='button-primary' href='%s'>%s</a></p>",
359 - __( 'Templately', 'templately' ),
360 - __( 'requires', 'templately' ),
361 - __( 'Elementor', 'templately' ),
362 - __( 'plugin to be installed and activated. Please install Elementor to continue.', 'templately' ),
363 - esc_url( $plugin_url ),
364 - __( $button_text, 'templately' )
365 - );
267 + $output .= sprintf( "<p><strong>%s</strong> %s <strong>%s</strong> %s &nbsp;&nbsp;<a class='button-primary' href='%s'>%s</a></p>", __( 'Templately', 'templately' ), __( 'requires', 'templately' ), __( 'Elementor', 'templately' ), __( 'plugin to be installed and activated. Please install Elementor to continue.', 'templately' ), esc_url( $plugin_url ), __( $button_text, 'templately' ) );
366 268 $output .= '</div>';
367 269 echo $output;
368 270 }
369 271