PluginProbe
Assistant – Every Day Productivity Apps / 1.5.5.1
Assistant – Every Day Productivity Apps v1.5.5.1
1.5.5.1 1.5.5 trunk 0.1.0 0.2.0 0.2.1 0.2.2 0.3.0 0.3.1 0.4 0.4.1 0.4.2 0.5.0 0.5.1 0.6.0 0.7.0 0.7.0.2 0.7.0.3 0.7.0.4 0.7.0.5 0.7.0.6 0.7.0.7 0.7.0.8 0.7.0.9 0.7.1 All 72 releases
← All changes | backend/src/Data/Site.php +72 -34 0.3.1 → 1.5.5.1 View file →
@@ -10,21 +10,23 @@
10 10 /**
11 11 * Get info about the current page view.
12 12 */
13 13 public function get_current_view() {
14 + global $wp_the_query;
15 +
14 16 $data = [];
15 17 $actions = [];
16 - $intro = __( 'Currently Viewing', 'fl-assistant' );
18 + $intro = __( 'Currently Viewing', 'assistant' );
17 19 $type = '';
18 - $name = __( 'Untitled', 'fl-assistant' );
20 + $type_name = '';
21 + $name = __( 'Untitled', 'assistant' );
19 22
20 - $obj = get_queried_object();
21 - $data['queried_object'] = $obj;
23 + $obj = get_queried_object();
22 24
23 25 if ( is_admin() ) {
24 26
25 - $intro = __( 'Currently Viewing Admin Page', 'fl-assistant' );
26 - $type = __( 'Admin Page', 'fl-assistant' );
27 + $intro = __( 'Currently Viewing Admin Page', 'assistant' );
28 + $type = __( 'Admin Page', 'assistant' );
27 29 $screen = get_current_screen();
28 30 $name = $screen->id;
29 31
30 32 } else {
@@ -29,29 +31,30 @@
29 31
30 32 } else {
31 33
32 34 if ( is_404() ) {
33 - $name = __( 'Page Not Found', 'fl-assistant' );
34 - $type = __( '404', 'fl-assistant' );
35 + $name = __( 'Page Not Found', 'assistant' );
36 + $type = __( '404', 'assistant' );
35 37
36 38 } elseif ( is_search() ) {
37 39
38 - $intro = __( 'Currently Viewing Search Results For', 'fl-assistant' );
39 - $type = __( 'Search Results For:', 'fl-assistant' );
40 + $intro = __( 'Currently Viewing Search Results For', 'assistant' );
41 + $type = __( 'Search Results For:', 'assistant' );
40 42 $name = get_search_query();
41 43
42 44 } elseif ( is_date() ) {
43 45
44 - $intro = __( 'Currently Viewing Date Archive', 'fl-assistant' );
45 - $type = __( 'Date Archive', 'fl-assistant' );
46 + $intro = __( 'Currently Viewing Date Archive', 'assistant' );
47 + $type = __( 'Date Archive', 'assistant' );
46 48 $name = get_the_date();
47 49
48 50 } elseif ( is_post_type_archive() ) {
49 51
50 52 $post_type = get_post_type_object( 'post' );
51 - $intro = __( 'Currently Viewing Post Type Archive', 'fl-assistant' );
52 - $type = __( 'Post Type Archive', 'fl-assistant' );
53 + $intro = __( 'Currently Viewing Post Type Archive', 'assistant' );
54 + $type = __( 'Post Type Archive', 'assistant' );
53 55 $name = $post_type->labels->singular_name;
56 + $type_name = $post_type->name;
54 57
55 58 } elseif ( is_tax() || is_category() || is_tag() ) {
56 59
57 60 $tax = get_taxonomy( $obj->taxonomy );
@@ -56,13 +59,14 @@
56 59
57 60 $tax = get_taxonomy( $obj->taxonomy );
58 61 $labels = $tax->labels;
59 62
60 - $intro = sprintf( esc_html__( 'Currently Viewing %s', 'fl-assistant' ), $labels->singular_name );
63 + $intro = sprintf( esc_html__( 'Currently Viewing %s', 'assistant' ), $labels->singular_name );
61 64 $type = $labels->singular_name;
62 65 $name = $obj->name;
63 66
64 67 $actions[] = [
68 + 'handle' => 'edit',
65 69 'label' => $labels->edit_item,
66 70 'href' => get_edit_term_link( $obj->term_id, $obj->taxonomy, null ),
67 71 'capability' => 'manage_categories',
68 72 ];
@@ -69,27 +73,25 @@
69 73
70 74 } elseif ( is_singular() || is_attachment() ) {
71 75
72 76 $post_type = get_post_type_object( get_post_type() );
77 + $type_name = $post_type->name;
73 78 $labels = $post_type->labels;
74 79 $post_type = $labels->singular_name;
75 - $intro = sprintf( esc_html__( 'Currently Viewing %s', 'fl-assistant' ), $post_type );
80 + $intro = sprintf( esc_html__( 'Currently Viewing %s', 'assistant' ), $post_type );
76 81 $type = $post_type;
77 82 $name = $obj->post_title;
78 83
79 - if ( is_attachment() ) {
80 - $meta = wp_get_attachment_metadata( $obj->ID );
81 - $name = basename( $meta['file'] );
82 - }
83 -
84 84 $actions[] = [
85 + 'handle' => 'edit',
85 86 'label' => $labels->edit_item,
86 87 'href' => get_edit_post_link( $obj->ID, '' ),
88 + 'target' => '_blank',
89 + 'rel' => 'noopener',
87 90 'capability' => 'edit_pages',
88 91 ];
89 92
90 93 // Add Beaver Builder edit link
91 - global $wp_the_query;
92 94 if ( class_exists( '\FLBuilderModel' ) ) {
93 95 if ( \FLBuilderModel::is_post_editable() && is_object( $wp_the_query->post ) ) {
94 96
95 97 $enabled = get_post_meta( $wp_the_query->post->ID, '_fl_builder_enabled', true );
@@ -94,8 +96,9 @@
94 96
95 97 $enabled = get_post_meta( $wp_the_query->post->ID, '_fl_builder_enabled', true );
96 98
97 99 $actions[] = [
100 + 'handle' => 'fl-builder',
98 101 'label' => \FLBuilderModel::get_branding(),
99 102 'href' => \FLBuilderModel::get_edit_url( $wp_the_query->post->ID ),
100 103 'capability' => 'edit_pages',
101 104 'isEnabled' => $enabled,
@@ -103,16 +106,16 @@
103 106 }
104 107 }
105 108 } elseif ( is_author() ) {
106 109
107 - $intro = __( 'Currently Viewing Author', 'fl-assistant' );
108 - $type = __( 'Author Archive', 'fl-assistant' );
110 + $intro = __( 'Currently Viewing Author', 'assistant' );
111 + $type = __( 'Author Archive', 'assistant' );
109 112 $name = wp_get_current_user()->display_name;
110 113
111 114 } elseif ( is_front_page() ) {
112 - $intro = __( 'Currently Viewing Post Archive', 'fl-assistant' );
113 - $type = __( 'Post Archive', 'fl-assistant' );
114 - $name = __( 'Latest Posts', 'fl-assistant' );
115 + $intro = __( 'Currently Viewing Post Archive', 'assistant' );
116 + $type = __( 'Post Archive', 'assistant' );
117 + $name = __( 'Latest Posts', 'assistant' );
115 118 }
116 119 }
117 120
118 121 $data['intro'] = $intro;
@@ -117,8 +120,10 @@
117 120
118 121 $data['intro'] = $intro;
119 122 $data['name'] = $name;
120 123 $data['type'] = $type;
124 + $data['type_name'] = $type_name;
125 +
121 126 $data['actions'] = $this->filter_actions_by_capability( $actions );
122 127
123 128 $theme = wp_get_theme();
124 129 $data['theme'] = [
@@ -127,17 +132,36 @@
127 132 'screenshot' => $theme->get_screenshot(),
128 133 'version' => $theme->get( 'Version' ),
129 134 ];
130 135
131 - $default_icon = plugins_url('img/icon-128x128.jpg', FL_ASSISTANT_FILE );
136 + $default_icon = plugins_url( 'img/icon-128x128.jpg', FL_ASSISTANT_FILE );
132 137 $data['site'] = [
133 - 'test' => $default_icon,
134 - 'icon' => get_site_icon_url( 120, $default_icon ),
135 - 'title' => get_bloginfo('name'),
136 - 'description' => get_bloginfo('description'),
137 - 'homeURL' => home_url(),
138 + 'defaultIcon' => $default_icon,
139 + 'icon' => get_site_icon_url( 120, $default_icon ),
140 + 'title' => get_bloginfo( 'name' ),
141 + 'description' => get_bloginfo( 'description' ),
142 + 'homeURL' => home_url(),
138 143 ];
139 144
145 + $data['isAdmin'] = is_admin();
146 + $data['is404'] = is_404();
147 + $data['isSearch'] = is_search();
148 + $data['isDate'] = is_date();
149 + $data['isPostTypeArchive'] = is_post_type_archive();
150 + $data['isSingular'] = is_singular();
151 + $data['isSingle'] = is_single();
152 + $data['isPage'] = is_page();
153 + $data['isAttachment'] = is_attachment();
154 + $data['isCategory'] = is_tax();
155 + $data['isCategory'] = is_category();
156 + $data['isTag'] = is_tag();
157 + $data['isAuthor'] = is_author();
158 + $data['isFrontPage'] = is_front_page();
159 +
160 + if ( is_singular() ) {
161 + $data['id'] = $obj->ID;
162 + }
163 +
140 164 return $data;
141 165 }
142 166
143 167 /**
@@ -183,8 +207,10 @@
183 207
184 208 $urls['dashboard'] = admin_url();
185 209
186 210 $urls['createPost'] = admin_url( 'post-new.php' );
211 + $urls['editPost'] = admin_url( 'post.php?action=edit&post=' );
212 + $urls['customizeBase'] = admin_url( 'customize.php' );
187 213
188 214 $url = static::get_customize_url();
189 215 if ( $url ) {
190 216 $urls['customize'] = $url;
@@ -190,9 +216,9 @@
190 216 $urls['customize'] = $url;
191 217 }
192 218
193 219 if ( current_user_can( 'switch_themes' ) ) {
194 - $urls['switchThemes'] = '';
220 + $urls['switchThemes'] = admin_url( 'themes.php' );
195 221 }
196 222
197 223 // Your User Profile
198 224 $user_id = get_current_user_id();
@@ -233,6 +259,18 @@
233 259 $customize_url = add_query_arg( [ 'changeset_uuid' => $wp_customize->changeset_uuid() ], $customize_url );
234 260 }
235 261
236 262 return $customize_url;
263 + }
264 +
265 + /**
266 + * Check if the site is on localhost or not.
267 + */
268 + public function is_local() {
269 + $ips = [ '127.0.0.1', '::1' ];
270 + $domain = '.local';
271 + if ( isset( $_SERVER['REMOTE_ADDR'] ) && ! in_array( $_SERVER['REMOTE_ADDR'], $ips, true ) ) {
272 + return substr_compare( $_SERVER['SERVER_NAME'], $domain, -strlen( $domain ) ) === 0;
273 + }
274 + return true;
237 275 }
238 276 }