PluginProbe
Elementor Website Builder – more than just a page builder / 4.1.0-dev3
Elementor Website Builder – more than just a page builder v4.1.0-dev3
4.3.2 4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 All 455 releases
← All changes | core/experiments/manager.php +15 -78 4.3.2 → 4.1.0-dev3 View file →
@@ -249,11 +249,9 @@
249 249 *
250 250 * @since 3.1.0
251 251 * @access public
252 252 *
253 - * @param string $feature_name Experiment feature name.
254 - * @param bool $check_dependencies When true, also require dependency experiments to be active.
255 - * Missing or hidden dependencies are treated as active for compatibility.
253 + * @param string $feature_name
256 254 *
257 255 * @return bool
258 256 */
259 257 public function is_feature_active( $feature_name, $check_dependencies = false ) {
@@ -264,18 +262,9 @@
264 262 }
265 263
266 264 if ( $check_dependencies && isset( $feature['dependencies'] ) && is_array( $feature['dependencies'] ) ) {
267 265 foreach ( $feature['dependencies'] as $dependency ) {
268 - if ( $dependency instanceof Non_Existing_Dependency ) {
269 - continue;
270 - }
271 -
272 266 $dependent_feature = $this->get_features( $dependency->get_name() );
273 -
274 - if ( $this->is_removed_or_hidden_dependency( $dependent_feature ) ) {
275 - continue;
276 - }
277 -
278 267 $feature_state = self::STATE_ACTIVE === $this->get_feature_actual_state( $dependent_feature );
279 268
280 269 if ( ! $feature_state ) {
281 270 return false;
@@ -353,13 +342,15 @@
353 342 $this->add_feature( [
354 343 'name' => 'container',
355 344 'title' => esc_html__( 'Container', 'elementor' ),
356 345 'description' => sprintf(
357 - /* translators: 1: Link opening tag, 2: Link closing tag, 3: Link opening tag, 4: Link closing tag */
358 - esc_html__( 'Create advanced layouts and responsive designs with %1$sFlexbox%2$s and %3$sGrid%4$s container elements.', 'elementor' ),
346 + /* translators: 1: Link opening tag, 2: Link closing tag, 3: Link opening tag, 4: Link closing tag, 5: Link opening tag, 6: Link closing tag */
347 + esc_html__( 'Create advanced layouts and responsive designs with %1$sFlexbox%2$s and %3$sGrid%4$s container elements. Give it a try using the %5$sContainer playground%6$s.', 'elementor' ),
359 348 '<a target="_blank" href="https://go.elementor.com/wp-dash-flex-container/">',
360 349 '</a>',
361 350 '<a target="_blank" href="https://go.elementor.com/wp-dash-grid-container/">',
351 + '</a>',
352 + '<a target="_blank" href="https://go.elementor.com/wp-dash-flex-container-playground/">',
362 353 '</a>'
363 354 ),
364 355 'release_status' => self::RELEASE_STATUS_STABLE,
365 356 'default' => self::STATE_INACTIVE,
@@ -387,18 +378,8 @@
387 378 'default_active' => true,
388 379 'minimum_installation_version' => '3.30.0',
389 380 ],
390 381 ] );
391 -
392 - $this->add_feature( [
393 - 'name' => 'e_optimized_css_files',
394 - 'title' => esc_html__( 'Optimized CSS Files', 'elementor' ),
395 - 'tag' => esc_html__( 'Performance', 'elementor' ),
396 - 'description' => esc_html__( 'Keeps external CSS files available and consistent for sites behind page caching or a CDN.', 'elementor' ),
397 - 'release_status' => self::RELEASE_STATUS_ALPHA,
398 - 'default' => self::STATE_INACTIVE,
399 - 'generator_tag' => true,
400 - ] );
401 382 }
402 383
403 384 /**
404 385 * Init States
@@ -790,43 +771,22 @@
790 771 }
791 772
792 773 // Validate if the current feature dependency is available.
793 774 foreach ( $feature['dependencies'] as $dependency ) {
794 - if ( $dependency instanceof Non_Existing_Dependency ) {
795 - $this->warn_removed_or_hidden_dependency(
796 - sprintf(
797 - 'The feature `%s` has a dependency `%s` that is not available in Core.',
798 - esc_html( $feature['name'] ),
799 - esc_html( $dependency->get_name() )
800 - )
801 - );
802 - continue;
803 - }
804 -
805 775 $dependency_feature = $this->get_features( $dependency->get_name() );
806 776
807 777 if ( ! $dependency_feature ) {
808 - $this->warn_removed_or_hidden_dependency(
778 + $rollback( $feature_option_key, self::STATE_INACTIVE );
779 +
780 + throw new Exceptions\Dependency_Exception(
809 781 sprintf(
810 - 'The feature `%s` has a dependency `%s` that is not available in Core.',
782 + 'The feature `%s` has a dependency `%s` that is not available.',
811 783 esc_html( $feature['name'] ),
812 784 esc_html( $dependency->get_name() )
813 785 )
814 786 );
815 - continue;
816 787 }
817 788
818 - if ( $this->is_removed_or_hidden_dependency( $dependency_feature ) ) {
819 - $this->warn_removed_or_hidden_dependency(
820 - sprintf(
821 - 'The feature `%1$s` depends on hidden experiment `%2$s`.',
822 - esc_html( $feature['name'] ),
823 - esc_html( $dependency_feature['name'] )
824 - )
825 - );
826 - continue;
827 - }
828 -
829 789 $dependency_state = $this->get_feature_actual_state( $dependency_feature );
830 790
831 791 // If dependency is not active.
832 792 if ( self::STATE_INACTIVE === $dependency_state ) {
@@ -977,8 +937,10 @@
977 937
978 938 /**
979 939 * @param array $experimental_data
980 940 * @return array
941 + *
942 + * @throws Exceptions\Dependency_Exception If the feature dependency is not initialized or depends on a hidden experiment.
981 943 */
982 944 private function initialize_feature_dependencies( array $experimental_data ): array {
983 945 foreach ( $experimental_data['dependencies'] as $key => $dependency ) {
984 946 $feature = $this->get_features( $dependency );
@@ -983,28 +945,20 @@
983 945 foreach ( $experimental_data['dependencies'] as $key => $dependency ) {
984 946 $feature = $this->get_features( $dependency );
985 947
986 948 if ( ! isset( $feature ) ) {
987 - $this->warn_removed_or_hidden_dependency(
949 + // since we must validate the state of each dependency, we have to make sure that dependencies are initialized in the correct order, otherwise, error.
950 + throw new Exceptions\Dependency_Exception(
988 951 sprintf(
989 - 'Feature %1$s depends on experiment %2$s that is not registered in Core.',
952 + 'Feature %s cannot be initialized before dependency feature: %s.',
990 953 esc_html( $experimental_data['name'] ),
991 954 esc_html( $dependency )
992 955 )
993 956 );
994 -
995 - $experimental_data['dependencies'][ $key ] = $this->create_dependency_class( $dependency, null );
996 - continue;
997 957 }
998 958
999 959 if ( ! empty( $feature[ static::TYPE_HIDDEN ] ) ) {
1000 - $this->warn_removed_or_hidden_dependency(
1001 - sprintf(
1002 - 'Feature %1$s depends on hidden experiment %2$s.',
1003 - esc_html( $experimental_data['name'] ),
1004 - esc_html( $dependency )
1005 - )
1006 - );
960 + throw new Exceptions\Dependency_Exception( 'Depending on a hidden experiment is not allowed.' );
1007 961 }
1008 962
1009 963 $experimental_data['dependencies'][ $key ] = $this->create_dependency_class( $dependency, $feature );
1010 964 $experimental_data = $this->set_feature_default_state_to_match_dependencies( $feature, $experimental_data );
@@ -1010,25 +964,8 @@
1010 964 $experimental_data = $this->set_feature_default_state_to_match_dependencies( $feature, $experimental_data );
1011 965 }
1012 966
1013 967 return $experimental_data;
1014 - }
1015 -
1016 - private function is_removed_or_hidden_dependency( $dependency_feature ): bool {
1017 - if ( ! $dependency_feature ) {
1018 - return true;
1019 - }
1020 -
1021 - return ! empty( $dependency_feature[ static::TYPE_HIDDEN ] );
1022 - }
1023 -
1024 - private function warn_removed_or_hidden_dependency( string $message ): void {
1025 - if ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) {
1026 - return;
1027 - }
1028 -
1029 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Developer notice; message is escaped.
1030 - _doing_it_wrong( __METHOD__, esc_html( $message ), ELEMENTOR_VERSION );
1031 968 }
1032 969
1033 970 /**
1034 971 * @param array $feature