PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.16
VikBooking Hotel Booking Engine & PMS v1.8.16
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
← All changes | libraries/adapter/module/widget.php +46 -0 1.8.6 → 1.8.16 View file →
@@ -157,8 +157,24 @@
157 157 {
158 158 return;
159 159 }
160 160
161 + /**
162 + * If we are under a block preview, prefer a different layout.
163 + *
164 + * @since 10.1.71
165 + */
166 + if ($this->isBlockPreview()) {
167 + // check whether the block preview layout is supported by this widget
168 + $blockPreviewLayout = ABSPATH . '/wp-content/plugins/' . $this->_option . '/libraries/wordpress/fse/modules/' . $this->_id . '.php';
169 +
170 + if (JFile::exists($blockPreviewLayout))
171 + {
172 + // block preview layout supported, use it in place of the default one
173 + $layout = JPath::clean($blockPreviewLayout);
174 + }
175 + }
176 +
161 177 // include system.js file to support JoomlaCore
162 178 JHtml::fetch('system.js');
163 179
164 180 /**
@@ -1060,6 +1076,36 @@
1060 1076 {
1061 1077 $this->extractHtmlElements($node, $tag);
1062 1078 }
1063 1079 }
1080 + }
1081 +
1082 + /**
1083 + * Checks whether the block is displayed by a block preview.
1084 + *
1085 + * @return bool
1086 + *
1087 + * @since 1.10.71
1088 + */
1089 + protected function isBlockPreview()
1090 + {
1091 + $app = JFactory::getApplication();
1092 +
1093 + // check whether we are displaying the widget on the block preview
1094 + $restPrefix = trailingslashit(rest_get_url_prefix());
1095 + $isPreview = strpos($app->input->server->getString('REQUEST_URI', ''), $restPrefix) !== false
1096 + || JUri::getInstance($app->input->server->getString('REQUEST_URI', ''))->hasVar('rest_route')
1097 + || strpos($app->input->server->getString('REQUEST_URI', ''), '/wp-admin/') !== false;
1098 +
1099 + /**
1100 + * This hook can be used to determine at runtime whether we should display
1101 + * a preview of the widget for a block editor.
1102 + *
1103 + * @param bool $isPreview Whether the preview layout should be preferred.
1104 + *
1105 + * @since 1.10.71
1106 + */
1107 + $isPreview = apply_filters('vikwp_widget_block_preview', $isPreview);
1108 +
1109 + return $isPreview;
1064 1110 }
1065 1111 }