0; $i-- ) { $current = strtolower( $file_parts[ $i ] ); $current = str_ireplace( '_', '-', $current ); $current = str_ireplace( 'ddwcaf-', '', $current ); if ( count( $file_parts ) - 1 === $i ) { if ( strpos( strtolower( $file_parts[ count( $file_parts ) - 1 ] ), 'interface' ) ) { $interface_name = explode( '_', $file_parts[ count( $file_parts ) - 1 ] ); array_pop( $interface_name ); $interface_name = strtolower( implode( '-', $interface_name ) ); $file_name = "interface-{$interface_name}.php"; } else { $file_name = "{$current}.php"; } } else { $namespace = '/' . $current . $namespace; } $filepath = trailingslashit( dirname( dirname( __FILE__ ) ) . $namespace ); $filepath .= $file_name; } // If the file exists in the specified path, then include it. if ( file_exists( $filepath ) ) { include_once( $filepath ); } else { wp_die( /* translators: %s for the filepath */ sprintf( esc_html__( 'The file attempting to be loaded at %s does not exist.', 'affiliates-for-woocommerce' ), $filepath ) ); } }