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 +49 -28 0.5.0 → 1.5.5.1 View file →
@@ -10,20 +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 23 $obj = get_queried_object();
21 24
22 25 if ( is_admin() ) {
23 26
24 - $intro = __( 'Currently Viewing Admin Page', 'fl-assistant' );
25 - $type = __( 'Admin Page', 'fl-assistant' );
27 + $intro = __( 'Currently Viewing Admin Page', 'assistant' );
28 + $type = __( 'Admin Page', 'assistant' );
26 29 $screen = get_current_screen();
27 30 $name = $screen->id;
28 31
29 32 } else {
@@ -28,29 +31,30 @@
28 31
29 32 } else {
30 33
31 34 if ( is_404() ) {
32 - $name = __( 'Page Not Found', 'fl-assistant' );
33 - $type = __( '404', 'fl-assistant' );
35 + $name = __( 'Page Not Found', 'assistant' );
36 + $type = __( '404', 'assistant' );
34 37
35 38 } elseif ( is_search() ) {
36 39
37 - $intro = __( 'Currently Viewing Search Results For', 'fl-assistant' );
38 - $type = __( 'Search Results For:', 'fl-assistant' );
40 + $intro = __( 'Currently Viewing Search Results For', 'assistant' );
41 + $type = __( 'Search Results For:', 'assistant' );
39 42 $name = get_search_query();
40 43
41 44 } elseif ( is_date() ) {
42 45
43 - $intro = __( 'Currently Viewing Date Archive', 'fl-assistant' );
44 - $type = __( 'Date Archive', 'fl-assistant' );
46 + $intro = __( 'Currently Viewing Date Archive', 'assistant' );
47 + $type = __( 'Date Archive', 'assistant' );
45 48 $name = get_the_date();
46 49
47 50 } elseif ( is_post_type_archive() ) {
48 51
49 52 $post_type = get_post_type_object( 'post' );
50 - $intro = __( 'Currently Viewing Post Type Archive', 'fl-assistant' );
51 - $type = __( 'Post Type Archive', 'fl-assistant' );
53 + $intro = __( 'Currently Viewing Post Type Archive', 'assistant' );
54 + $type = __( 'Post Type Archive', 'assistant' );
52 55 $name = $post_type->labels->singular_name;
56 + $type_name = $post_type->name;
53 57
54 58 } elseif ( is_tax() || is_category() || is_tag() ) {
55 59
56 60 $tax = get_taxonomy( $obj->taxonomy );
@@ -55,13 +59,14 @@
55 59
56 60 $tax = get_taxonomy( $obj->taxonomy );
57 61 $labels = $tax->labels;
58 62
59 - $intro = sprintf( esc_html__( 'Currently Viewing %s', 'fl-assistant' ), $labels->singular_name );
63 + $intro = sprintf( esc_html__( 'Currently Viewing %s', 'assistant' ), $labels->singular_name );
60 64 $type = $labels->singular_name;
61 65 $name = $obj->name;
62 66
63 67 $actions[] = [
68 + 'handle' => 'edit',
64 69 'label' => $labels->edit_item,
65 70 'href' => get_edit_term_link( $obj->term_id, $obj->taxonomy, null ),
66 71 'capability' => 'manage_categories',
67 72 ];
@@ -68,27 +73,25 @@
68 73
69 74 } elseif ( is_singular() || is_attachment() ) {
70 75
71 76 $post_type = get_post_type_object( get_post_type() );
77 + $type_name = $post_type->name;
72 78 $labels = $post_type->labels;
73 79 $post_type = $labels->singular_name;
74 - $intro = sprintf( esc_html__( 'Currently Viewing %s', 'fl-assistant' ), $post_type );
80 + $intro = sprintf( esc_html__( 'Currently Viewing %s', 'assistant' ), $post_type );
75 81 $type = $post_type;
76 82 $name = $obj->post_title;
77 83
78 - if ( is_attachment() ) {
79 - $meta = wp_get_attachment_metadata( $obj->ID );
80 - $name = basename( $meta['file'] );
81 - }
82 -
83 84 $actions[] = [
85 + 'handle' => 'edit',
84 86 'label' => $labels->edit_item,
85 87 'href' => get_edit_post_link( $obj->ID, '' ),
88 + 'target' => '_blank',
89 + 'rel' => 'noopener',
86 90 'capability' => 'edit_pages',
87 91 ];
88 92
89 93 // Add Beaver Builder edit link
90 - global $wp_the_query;
91 94 if ( class_exists( '\FLBuilderModel' ) ) {
92 95 if ( \FLBuilderModel::is_post_editable() && is_object( $wp_the_query->post ) ) {
93 96
94 97 $enabled = get_post_meta( $wp_the_query->post->ID, '_fl_builder_enabled', true );
@@ -93,8 +96,9 @@
93 96
94 97 $enabled = get_post_meta( $wp_the_query->post->ID, '_fl_builder_enabled', true );
95 98
96 99 $actions[] = [
100 + 'handle' => 'fl-builder',
97 101 'label' => \FLBuilderModel::get_branding(),
98 102 'href' => \FLBuilderModel::get_edit_url( $wp_the_query->post->ID ),
99 103 'capability' => 'edit_pages',
100 104 'isEnabled' => $enabled,
@@ -102,16 +106,16 @@
102 106 }
103 107 }
104 108 } elseif ( is_author() ) {
105 109
106 - $intro = __( 'Currently Viewing Author', 'fl-assistant' );
107 - $type = __( 'Author Archive', 'fl-assistant' );
110 + $intro = __( 'Currently Viewing Author', 'assistant' );
111 + $type = __( 'Author Archive', 'assistant' );
108 112 $name = wp_get_current_user()->display_name;
109 113
110 114 } elseif ( is_front_page() ) {
111 - $intro = __( 'Currently Viewing Post Archive', 'fl-assistant' );
112 - $type = __( 'Post Archive', 'fl-assistant' );
113 - $name = __( 'Latest Posts', 'fl-assistant' );
115 + $intro = __( 'Currently Viewing Post Archive', 'assistant' );
116 + $type = __( 'Post Archive', 'assistant' );
117 + $name = __( 'Latest Posts', 'assistant' );
114 118 }
115 119 }
116 120
117 121 $data['intro'] = $intro;
@@ -116,9 +120,10 @@
116 120
117 121 $data['intro'] = $intro;
118 122 $data['name'] = $name;
119 123 $data['type'] = $type;
120 -
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'] = [
@@ -129,9 +134,9 @@
129 134 ];
130 135
131 136 $default_icon = plugins_url( 'img/icon-128x128.jpg', FL_ASSISTANT_FILE );
132 137 $data['site'] = [
133 - 'defaultIcon' => $default_icon,
138 + 'defaultIcon' => $default_icon,
134 139 'icon' => get_site_icon_url( 120, $default_icon ),
135 140 'title' => get_bloginfo( 'name' ),
136 141 'description' => get_bloginfo( 'description' ),
137 142 'homeURL' => home_url(),
@@ -142,8 +147,10 @@
142 147 $data['isSearch'] = is_search();
143 148 $data['isDate'] = is_date();
144 149 $data['isPostTypeArchive'] = is_post_type_archive();
145 150 $data['isSingular'] = is_singular();
151 + $data['isSingle'] = is_single();
152 + $data['isPage'] = is_page();
146 153 $data['isAttachment'] = is_attachment();
147 154 $data['isCategory'] = is_tax();
148 155 $data['isCategory'] = is_category();
149 156 $data['isTag'] = is_tag();
@@ -200,8 +207,10 @@
200 207
201 208 $urls['dashboard'] = admin_url();
202 209
203 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' );
204 213
205 214 $url = static::get_customize_url();
206 215 if ( $url ) {
207 216 $urls['customize'] = $url;
@@ -207,9 +216,9 @@
207 216 $urls['customize'] = $url;
208 217 }
209 218
210 219 if ( current_user_can( 'switch_themes' ) ) {
211 - $urls['switchThemes'] = '';
220 + $urls['switchThemes'] = admin_url( 'themes.php' );
212 221 }
213 222
214 223 // Your User Profile
215 224 $user_id = get_current_user_id();
@@ -250,6 +259,18 @@
250 259 $customize_url = add_query_arg( [ 'changeset_uuid' => $wp_customize->changeset_uuid() ], $customize_url );
251 260 }
252 261
253 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;
254 275 }
255 276 }