WPIntell

Source evidence

Warning: Undefined array key 0 in

Coming soon Page · support · 2024-08-28T13:58:00+00:00

mixedsentiment
mediumseverity
0.84relevance
2replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

5 / 34 rows with source links

14.7% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

29 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
janosklak resolved
I think your plugin is great and uncomplicated because I can use an existing page as a coming soon page. Could I ask you to eliminate this error? Warning: Undefined array key 0 in /home/httpd/vhosts/badundraum.ch/boffi-sg.ch/wp-content/plugins/bw-coming-soon-page/includes/plugin-settings.php on line 11 Please update your Plugin “Coming soon Page”. 😉 The page I need help with: [ log in to see the link] if ( ! function_exists('bwcs_redirection_process') ) { function bwcs_redirection_process() { // get options $is_enabled = ( ! empty( get_option( 'bwcs_enable_plugin' ) ) ) ? get_option( 'bwcs_enable_plugin' ) : 'enabled'; $roles = ( ! empty( get_option( 'bwcs_roles' ) ) ) ? get_option( 'bwcs_roles' ) : array(); $pages = ( ! empty( get_option( 'bwcs_other_pages' ) ) ) ? get_option( 'bwcs_other_pages' ) : array(); $current_user = wp_get_current_user(); $current_user_role = isset($current_user->roles[0]) ? $current_user->roles[0] : ''; $current_page_id = get_queried_object_id(); $coming_soon_page_id = get_option( 'bwcs_coming_soon_page' ); $shop_page_id = get_option( 'woocommerce_shop_page_id' ); // If options are not updated yet if ( empty( $coming_soon_page_id ) ) { $coming_soon_page_id = get_page_by_path( 'coming-soon' )->ID; } // Condition for shop page if ( empty( $shop_page_id ) ){ $shop_page = false; }else{ if ( ! function_exists('is_shop') ) { // nothing to do }elseif (is_shop() && in_array( $shop_page_id, $pages ) ) { $shop_page = true; } } if ( $is_enabled != 'disabled' ) { if ( in_array( $current_page_id, $pages ) ) { // no redirection }elseif ( in_array( $current_user_role, $roles ) || current_user_can( 'manage_options' ) ) { // no redirection }elseif ( $shop_page ) { // no redirection if shop page is selected }elseif( $current_page_id != $coming_soon_page_id ) { wp_redirect( get_permalink( $coming_soon_page_id ) ); exit; } } } add_action( 'template_redirect', 'bwcs_redirection_process', 1 ); } To fix this bug, you should make sure that the array is not empty before accessing its elements. You can do this as follows: $current_user = wp_get_current_user(); $current_user_role = isset($current_user->roles[0]) ? $current_user->roles[0] : ''; This change first checks whether the array roles even has an element at position 0 before it is accessed. If the array is empty, an empty character string (”) is assigned.

Comments

2 shown
janosklak 2024-09-03T10:02:00+00:00

if ( ! function_exists('bwcs_redirection_process') ) { function bwcs_redirection_process() { // get options $is_enabled = ( ! empty( get_option( 'bwcs_enable_plugin' ) ) ) ? get_option( 'bwcs_enable_plugin' ) : 'enabled'; $roles = ( ! empty( get_option( 'bwcs_roles' ) ) ) ? get_option( 'bwcs_roles' ) : array(); $pages = ( ! empty( get_option( 'bwcs_other_pages' ) ) ) ? get_option( 'bwcs_other_pages' ) : array(); $current_user = wp_get_current_user(); $current_user_role = isset($current_user->roles[0]) ? $current_user->roles[0] : ''; $current_page_id = get_queried_object_id(); $coming_soon_page_id = get_option( 'bwcs_coming_soon_page' ); $shop_page_id = get_option( 'woocommerce_shop_page_id' ); // If options are not updated yet if ( empty( $coming_soon_page_id ) ) { $coming_soon_page_id = get_page_by_path( 'coming-soon' )->ID; } // Condition for shop page if ( empty( $shop_page_id ) ){ $shop_page = false; }else{ if ( ! function_exists('is_shop') ) { // nothing to do }elseif (is_shop() && in_array( $shop_page_id, $pages ) ) { $shop_page = true; } } if ( $is_enabled != 'disabled' ) { if ( in_array( $current_page_id, $pages ) ) { // no redirection }elseif ( in_array( $current_user_role, $roles ) || current_user_can( 'manage_options' ) ) { // no redirection }elseif ( $shop_page ) { // no redirection if shop page is selected }elseif( $current_page_id != $coming_soon_page_id ) { wp_redirect( get_permalink( $coming_soon_page_id ) ); exit; } } } add_action( 'template_redirect', 'bwcs_redirection_process', 1 ); }

janosklak 2024-09-03T10:06:00+00:00

To fix this bug, you should make sure that the array is not empty before accessing its elements. You can do this as follows: $current_user = wp_get_current_user(); $current_user_role = isset($current_user->roles[0]) ? $current_user->roles[0] : ''; This change first checks whether the array roles even has an element at position 0 before it is accessed. If the array is empty, an empty character string (”) is assigned.