| @@ -115,14 +115,8 @@ | ||
| 115 | 115 | if ( ! in_array( $screen, [ 'dashboard', 'settings' ], true ) ) { |
| 116 | 116 | return false; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { | |
| 120 | - $url = admin_url( 'network/admin.php?page=elasticpress&do_sync' ); | |
| 121 | - } else { | |
| 122 | - $url = admin_url( 'admin.php?page=elasticpress&do_sync' ); | |
| 123 | - } | |
| 124 | - | |
| 125 | 119 | return [ |
| 126 | 120 | 'html' => sprintf( esc_html__( 'Autosuggest feature is enabled. If documents feature is enabled, your media will also become searchable in the frontend.', 'elasticpress' ) ), |
| 127 | 121 | 'type' => 'info', |
| 128 | 122 | 'dismiss' => true, |
| @@ -176,17 +170,13 @@ | ||
| 176 | 170 | if ( $dismiss && ! in_array( $screen, [ 'dashboard', 'settings' ], true ) ) { |
| 177 | 171 | return false; |
| 178 | 172 | } |
| 179 | 173 | |
| 180 | - if ( isset( $_GET['do_sync'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification | |
| 174 | + if ( Utils\isset_do_sync_parameter() ) { | |
| 181 | 175 | return false; |
| 182 | 176 | } |
| 183 | 177 | |
| 184 | - if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { | |
| 185 | - $url = admin_url( 'network/admin.php?page=elasticpress-sync&do_sync' ); | |
| 186 | - } else { | |
| 187 | - $url = admin_url( 'admin.php?page=elasticpress-sync&do_sync' ); | |
| 188 | - } | |
| 178 | + $url = Utils\get_sync_url( 'features' ); | |
| 189 | 179 | |
| 190 | 180 | $feature = Features::factory()->get_registered_feature( $auto_activate_sync ); |
| 191 | 181 | |
| 192 | 182 | if ( defined( 'EP_DASHBOARD_SYNC' ) && ! EP_DASHBOARD_SYNC ) { |
| @@ -251,17 +241,13 @@ | ||
| 251 | 241 | if ( $dismiss && ! in_array( $screen, [ 'dashboard', 'settings' ], true ) ) { |
| 252 | 242 | return false; |
| 253 | 243 | } |
| 254 | 244 | |
| 255 | - if ( isset( $_GET['do_sync'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification | |
| 245 | + if ( Utils\isset_do_sync_parameter() ) { | |
| 256 | 246 | return false; |
| 257 | 247 | } |
| 258 | 248 | |
| 259 | - if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { | |
| 260 | - $url = admin_url( 'network/admin.php?page=elasticpress-sync&do_sync' ); | |
| 261 | - } else { | |
| 262 | - $url = admin_url( 'admin.php?page=elasticpress-sync&do_sync' ); | |
| 263 | - } | |
| 249 | + $url = Utils\get_sync_url( 'upgrade' ); | |
| 264 | 250 | |
| 265 | 251 | if ( defined( 'EP_DASHBOARD_SYNC' ) && ! EP_DASHBOARD_SYNC ) { |
| 266 | 252 | $html = esc_html__( 'Dashboard sync is disabled. The new version of ElasticPress requires that you delete all data and start a fresh sync using WP-CLI.', 'elasticpress' ); |
| 267 | 253 | } else { |
| @@ -315,9 +301,9 @@ | ||
| 315 | 301 | if ( $dismiss && ! in_array( $screen, [ 'dashboard', 'settings' ], true ) ) { |
| 316 | 302 | return false; |
| 317 | 303 | } |
| 318 | 304 | |
| 319 | - if ( isset( $_GET['do_sync'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification | |
| 305 | + if ( Utils\isset_do_sync_parameter() ) { | |
| 320 | 306 | return false; |
| 321 | 307 | } |
| 322 | 308 | |
| 323 | 309 | if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { |
| @@ -532,9 +518,9 @@ | ||
| 532 | 518 | if ( $dismiss ) { |
| 533 | 519 | return false; |
| 534 | 520 | } |
| 535 | 521 | |
| 536 | - $doc_url = 'https://10up.github.io/ElasticPress/tutorial-compatibility.html'; | |
| 522 | + $doc_url = 'https://www.elasticpress.io/resources/articles/compatibility/'; | |
| 537 | 523 | $html = sprintf( |
| 538 | 524 | /* translators: Document page URL */ |
| 539 | 525 | __( 'Your server software is not supported. To learn more about server compatibility please <a href="%s">visit our documentation</a>.', 'elasticpress' ), |
| 540 | 526 | esc_url( $doc_url ) |
| @@ -594,12 +580,19 @@ | ||
| 594 | 580 | $response_code = get_transient( 'ep_es_info_response_code' ); |
| 595 | 581 | $response_error = get_transient( 'ep_es_info_response_error' ); |
| 596 | 582 | } |
| 597 | 583 | |
| 584 | + $retry_url = add_query_arg( | |
| 585 | + [ | |
| 586 | + 'ep-retry' => 1, | |
| 587 | + 'ep_retry_nonce' => wp_create_nonce( 'ep_retry_nonce' ), | |
| 588 | + ] | |
| 589 | + ); | |
| 590 | + | |
| 598 | 591 | $html = sprintf( |
| 599 | 592 | /* translators: 1. Current URL with retry parameter; 2. Settings Page URL */ |
| 600 | 593 | __( 'There is a problem with connecting to your Elasticsearch host. ElasticPress can <a href="%1$s">try your host again</a>, or you may need to <a href="%2$s">change your settings</a>.', 'elasticpress' ), |
| 601 | - esc_url( add_query_arg( 'ep-retry', 1 ) ), | |
| 594 | + esc_url( $retry_url ), | |
| 602 | 595 | esc_url( $url ) |
| 603 | 596 | ); |
| 604 | 597 | |
| 605 | 598 | if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
| @@ -688,9 +681,8 @@ | ||
| 688 | 681 | 'dismiss' => true, |
| 689 | 682 | ]; |
| 690 | 683 | |
| 691 | 684 | } |
| 692 | - | |
| 693 | 685 | } |
| 694 | 686 | |
| 695 | 687 | /** |
| 696 | 688 | * Single node notification. Shows when index health is yellow. |
| @@ -772,14 +764,10 @@ | ||
| 772 | 764 | $has_error = false; |
| 773 | 765 | $has_warning = false; |
| 774 | 766 | |
| 775 | 767 | if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { |
| 776 | - $sites = Utils\get_sites(); | |
| 768 | + $sites = Utils\get_sites( 0, true ); | |
| 777 | 769 | foreach ( $sites as $site ) { |
| 778 | - if ( ! Utils\is_site_indexable( $site['blog_id'] ) ) { | |
| 779 | - continue; | |
| 780 | - } | |
| 781 | - | |
| 782 | 770 | switch_to_blog( $site['blog_id'] ); |
| 783 | 771 | |
| 784 | 772 | list( $has_error, $site_has_warning ) = $this->check_field_count(); |
| 785 | 773 | |
| @@ -798,10 +786,10 @@ | ||
| 798 | 786 | $message = sprintf( |
| 799 | 787 | /* translators: Elasticsearch or ElasticPress.io; 2. Link to article; 3. Link to article */ |
| 800 | 788 | __( 'Your website content has more public custom fields than %1$s is able to store. Check our articles about <a href="%2$s">Elasticsearch field limitations</a> and <a href="%3$s">how to index just the custom fields you need</a> before trying to sync.', 'elasticpress' ), |
| 801 | 789 | Utils\is_epio() ? __( 'ElasticPress.io', 'elasticpress' ) : __( 'Elasticsearch', 'elasticpress' ), |
| 802 | - 'https://elasticpress.zendesk.com/hc/en-us/articles/360051401212-I-get-the-error-Limit-of-total-fields-in-index-has-been-exceeded-', | |
| 803 | - 'https://elasticpress.zendesk.com/hc/en-us/articles/360052019111' | |
| 790 | + 'https://www.elasticpress.io/resources/articles/i-get-the-error-limit-of-total-fields-in-index-has-been-exceeded/', | |
| 791 | + 'https://www.elasticpress.io/resources/articles/how-to-exclude-metadata-from-indexing/' | |
| 804 | 792 | ); |
| 805 | 793 | |
| 806 | 794 | return [ |
| 807 | 795 | 'type' => 'error', |
| @@ -814,10 +802,10 @@ | ||
| 814 | 802 | $message = sprintf( |
| 815 | 803 | /* translators: Elasticsearch or ElasticPress.io; 2. Link to article; 3. Link to article */ |
| 816 | 804 | __( 'Your website content seems to have more public custom fields than %1$s is able to store. Check our articles about <a href="%2$s">Elasticsearch field limitations</a> and <a href="%3$s">how to index just the custom fields you need</a> if you receive any errors while syncing.', 'elasticpress' ), |
| 817 | 805 | Utils\is_epio() ? __( 'ElasticPress.io', 'elasticpress' ) : __( 'Elasticsearch', 'elasticpress' ), |
| 818 | - 'https://elasticpress.zendesk.com/hc/en-us/articles/360051401212-I-get-the-error-Limit-of-total-fields-in-index-has-been-exceeded-', | |
| 819 | - 'https://elasticpress.zendesk.com/hc/en-us/articles/360052019111' | |
| 806 | + 'https://www.elasticpress.io/resources/articles/i-get-the-error-limit-of-total-fields-in-index-has-been-exceeded/', | |
| 807 | + 'https://www.elasticpress.io/resources/articles/how-to-exclude-metadata-from-indexing/' | |
| 820 | 808 | ); |
| 821 | 809 | |
| 822 | 810 | return [ |
| 823 | 811 | 'type' => 'warning', |
| @@ -842,9 +830,35 @@ | ||
| 842 | 830 | * @hook ep_admin_notices |
| 843 | 831 | * @param {array} $notices Admin notices |
| 844 | 832 | * @return {array} New notices |
| 845 | 833 | */ |
| 846 | - return apply_filters( 'ep_admin_notices', $this->notices ); | |
| 834 | + $notices = apply_filters( 'ep_admin_notices', $this->notices ); | |
| 835 | + | |
| 836 | + if ( ! is_array( $notices ) ) { | |
| 837 | + _doing_it_wrong( | |
| 838 | + __METHOD__, | |
| 839 | + sprintf( | |
| 840 | + /* translators: %s: Detected variable type. */ | |
| 841 | + esc_html__( 'Callbacks of filter hook `ep_admin_notices` must return a value of type array, %s detected.', 'elasticpress' ), | |
| 842 | + esc_html( gettype( $notices ) ) | |
| 843 | + ), | |
| 844 | + 'ElasticPress 5.3.3' | |
| 845 | + ); | |
| 846 | + | |
| 847 | + $notices = []; | |
| 848 | + } | |
| 849 | + | |
| 850 | + // If the plugin is network-activated and not in the network admin, return the notices whose scope is site. | |
| 851 | + if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK && ! is_network_admin() ) { | |
| 852 | + $notices = array_filter( | |
| 853 | + $notices, | |
| 854 | + function ( $notice ) { | |
| 855 | + return isset( $notice['scope'] ) && 'site' === $notice['scope']; | |
| 856 | + } | |
| 857 | + ); | |
| 858 | + } | |
| 859 | + | |
| 860 | + return $notices; | |
| 847 | 861 | } |
| 848 | 862 | |
| 849 | 863 | /** |
| 850 | 864 | * Dismiss a notice given a notice key. |
| @@ -886,14 +900,21 @@ | ||
| 886 | 900 | */ |
| 887 | 901 | protected function check_field_count() { |
| 888 | 902 | $post_indexable = Indexables::factory()->get( 'post' ); |
| 889 | 903 | |
| 890 | - $indexable_fields = $post_indexable->get_predicted_indexable_meta_keys(); | |
| 891 | - $count_fields_db = count( $indexable_fields ); | |
| 904 | + $search = Features::factory()->get_registered_feature( 'search' ); | |
| 905 | + if ( $search && ! empty( $search->weighting ) && 'manual' === $search->weighting->get_meta_mode() ) { | |
| 906 | + $indexable_fields = $post_indexable->get_all_allowed_metas_manual(); | |
| 907 | + $count_fields_db = count( $indexable_fields ); | |
| 908 | + } else { | |
| 909 | + $indexable_fields = $post_indexable->get_predicted_indexable_meta_keys(); | |
| 910 | + $count_fields_db = count( $indexable_fields ); | |
| 911 | + } | |
| 892 | 912 | |
| 893 | 913 | $index_name = $post_indexable->get_index_name(); |
| 894 | 914 | $es_field_limit = Elasticsearch::factory()->get_index_total_fields_limit( $index_name ); |
| 895 | - $es_field_limit = $es_field_limit ?? apply_filters( 'ep_total_field_limit', 5000 ); | |
| 915 | + $es_field_limit = $es_field_limit ? $es_field_limit : 5000; | |
| 916 | + $es_field_limit = apply_filters( 'ep_total_field_limit', $es_field_limit ); | |
| 896 | 917 | |
| 897 | 918 | $predicted_es_field_count = $count_fields_db * 8; |
| 898 | 919 | |
| 899 | 920 | return [ |