function show_hide_author() { global $post; // Exit if there's no post object (e.g., on homepage or archive page) if ( ! isset( $post ) || ! $post instanceof WP_Post ) { return; } $ID = $post->ID; // Get current full URL without www/https for comparison $url = current_full_url(); $replace = array('/http:\/\/www./', '/https:\/\/www./', '/www./', '/\n\r/'); $with = array('', '', '', '\n'); $current_url_nohttp = preg_replace($replace, $with, $url); // Get plugin options $options_array = get_option('show_author_options'); // If no settings found, hide author globally if ( ! is_array($options_array) ) { remove_author(); return; } // Prepare and normalize show/hide URL lists $urls_show_array = array_map('trim', explode("\n", preg_replace($replace, $with, $options_array['option_url_show'] ?? ''))); $urls_hide_array = array_map('trim', explode("\n", preg_replace($replace, $with, $options_array['option_url_hide'] ?? ''))); // 1. Check for custom show URLs if ( in_array($current_url_nohttp, $urls_show_array, true) ) { return; // Show author } // 2. Check for custom hide URLs if ( in_array($current_url_nohttp, $urls_hide_array, true) ) { remove_author(); return; } // 3. Check for individual post override $per_post_setting = get_post_meta( $ID, '_show_author_inthis_post', true ); if ( ! empty($options_array['option_individual']) ) { if ( $per_post_setting === 'inthis_post' ) { return; // Show author } if ( $per_post_setting === 'not_inthis_post' ) { remove_author(); return; } } // 4. Check post type setting $current_post_type = get_post_type( $ID ); if ( empty($options_array['option_' . $current_post_type]) ) { remove_author(); return; } // Otherwise, show author (no action needed) }